Hi,
I would like to add custom command for generating a source file, and added the following to main/CMakeLists.txt
add_custom_command(OUTPUT version.c
COMMAND ../tools/get_version.py > version.c
DEPENDS ../.git/HEAD ../.git/index
COMMENT Generates version.c from Git version
)
But I get the error:
xtensa-esp32-elf-gcc: error: ../main/version.c: No such file or directory
Tool:
ESP-IDF: release-4.0
Buildsystem: "New" idf.py based
Br,
Benny
Buildsystem (idf.py) - add custom command
-
- Posts: 74
- Joined: Wed Oct 23, 2019 1:49 am
Re: Buildsystem (idf.py) - add custom command
The path you give for version.c is probably not correct.
add_custom_command by default creates a file relative to the current binary directory, but ../main/version.c seems to expect to find it in your main folder.
add_custom_command by default creates a file relative to the current binary directory, but ../main/version.c seems to expect to find it in your main folder.
Re: Buildsystem (idf.py) - add custom command
The path is wrong, but get_version.py is not even called, (nothing from get_version.py printed on STDOUT or fails if contains errors)
Extra:
CMake has some PROJECT_VERSION (https://cmake.org/cmake/help/v3.0/command/project.html).
It prints Project version first time after committing, but does not detect when a project goes dirty:
-- Detecting CXX compile features - done
-- Project version: v4.0.1-197-g94d97499a
-- Building ESP-IDF components for target esp32
But I can't access PROJECT_VERSION in c-code even after
add_definitions( -DPROJECT_VERSION=${PROJECT_VERSION} )
or
set(PROJECT_VERSION ${PROJECT_VERSION})
Extra:
CMake has some PROJECT_VERSION (https://cmake.org/cmake/help/v3.0/command/project.html).
It prints Project version first time after committing, but does not detect when a project goes dirty:
-- Detecting CXX compile features - done
-- Project version: v4.0.1-197-g94d97499a
-- Building ESP-IDF components for target esp32
But I can't access PROJECT_VERSION in c-code even after
add_definitions( -DPROJECT_VERSION=${PROJECT_VERSION} )
or
set(PROJECT_VERSION ${PROJECT_VERSION})
Re: Buildsystem (idf.py) - add custom command
This does not answer how to generate version.c, but is better solution
Variable PROJECT_VER (https://docs.espressif.com/projects/esp ... properties)
The version of firmware is stored in the firmware and can be extracted for both running and new (OTA) firmware, see
https://github.com/espressif/esp-idf/bl ... _example.c.
Variable PROJECT_VER (https://docs.espressif.com/projects/esp ... properties)
The version of firmware is stored in the firmware and can be extracted for both running and new (OTA) firmware, see
https://github.com/espressif/esp-idf/bl ... _example.c.
-
- Posts: 74
- Joined: Wed Oct 23, 2019 1:49 am
Re: Buildsystem (idf.py) - add custom command
You are telling CMake "if you need ${CMAKE_CURRENT_BINARY_DIR}/version.c then this is how you generate it". It will only actually call the command if ${CMAKE_CURRENT_BINARY_DIR}/version.c is required by a target. So if you give the wrong path, e.g. main/version.c it won't understand that you are talking about the same file, and therefor not generate it.
Happy you found a way to solve this though!
Who is online
Users browsing this forum: CyborgZA and 68 guests