Convert IDE project to scriptable build
We have added an STM32CubeIDE project to our monorepo. The monorepo is mostly C++ software built for linux x86_64, using CMake as the build tooling. This software is built inside of docker containers in our CI environment. We would like to be able to build this STM32 project as part of CI.
We need to be able to script the configuration and build of an IDE project without any human interaction. This includes scripting the installation of any tools needed for the build. Ideally we would like to have a "single source of truth" build (meaning not a separate `.project` system from what runs in CI, where they could get out of sync). Furthermore, we'd like to avoid committing generated code to the repo. We can copy down the "Drivers" and other software packages, but we'd like to generate code from the .ioc file rather than commit the generated code.
I'll sketch out our current workflow, things I've tried, and problems I've encountered. This has to be a thing others are doing, so I don't know if I'm missing documentation somewhere or what.
Development workflow:
- CMake build project - We have generated code (protobuf) that will need to exist for the STM32 project
- Copy in relevant Driver files to project area
- Open CubeIDE to an `stm32` directory in the project as the workspace, then add the project (subdir from there) to the workspace
- In CubeIDE, run configure from `.ioc` file
- build project
CMake/Makefile approach:
It seems to me like the IDE supports Makefiles and CMake. Ideally, we could just convert our project to a CMakeLists.txt and with a little bit of tweaking get it to either run as part of our overall build or as a standalone build. Either way would be fine. I can't figure out how to convert an existing project to CMake. There are instructions for starting new projects that way, but it's not clear to me how to convert them, if that's even possible. (edit: I have tried CLion to automatically generate the CMakeLists.txt, but the resulting file takes a bit of guesswork to get into working shape, and even then it wasn't getting dependencies resolved correctly)
Alternatively, I'd be okay with a Makefile based approach, but, again, I can't figure out how to get the IDE to actually generate a Makefile that I could run.
Headless build approach:
I can get the IDE "headless build" mode to build the code, but only if I've already run the generator against the `.ioc` file. It isn't clear to me how to actually run the generator in this headless mode. Additionally, I believe it's not best practices to commit generated code, so I would prefer a solution that can generate as a part of the build process.
Additionally, this is a bit of a frustrating approach because I shouldn't need to have an IDE installed in my CI environment. I should be able to just build the code (the CMake/Makefile approach above). I haven't yet tried to install the IDE into a docker container automatically (i.e. without an install "wizard"), but I had a lot of difficulty with the STM32CubeCLT before I realized that wasn't the right toolkit for me.
