cancel
Showing results for 
Search instead for 
Did you mean: 

Project converter fails to make valid json from my pre-build step command

Robert-Helps
Associate

My STM32cube IDE project has a pre-build command:

${ProjDirPath}\Middlewares\Third_Party\nanopb\generator\protoc --nanopb_out=${ProjDirPath}\Application\cm4_interface --proto_path=${ProjDirPath}\Application\cm4_interface ${ProjDirPath}\Application\cm4_interface\cm4-interface.proto

The json that's generated doesn't correctly escape the '\' characters, which results in an error...

 

 

 

2 REPLIES 2
Nawres GHARBI
ST Employee

Hi @Robert-Helps 

could you please attach the original project or an example to reproduce the issue

Julien D
ST Employee

Hi @Robert-Helps,

Regardless of the JSON format issue, which will be fixed in a future bundle release, pre-build commands are not natively supported by CMake - only post-build commands are.

However, some tips exist; you can define a custom target that runs the command and add this custom target as a build dependency of the main target:

 

# 1. Custom target that runs your script/command
add_custom_target(prebuild_step
    COMMAND ${CMAKE_COMMAND} -E echo "Running prebuild_step"
    # You can add more commands here
    BYPRODUCTS ${CMAKE_BINARY_DIR}/generated_file.h
    COMMENT "Executing pre-build custom step"
)

# 2. Your main target
add_executable(MyApp main.cpp)

# 3. Ensure prebuild_step runs before MyApp is built
add_dependencies(MyApp prebuild_step)

 

As stated here, waiting for a release, you can fix your JSON file, and call the converter manually:

cube ide-project-convert --bypass-converter <path_to_stm32cubeide-export.json> --source-format stm32cubeide --destination <cmake_project_location> --format cmake

HTH. 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.