Stop CMake before linking MicroPython

Good evening. I am using MicroPython on a Raspberry Pi Pico. As my .py script grew too big (+3000 lines) and I still need to add features, I find myself in trouble since I can’t use the MicroPython interpreter anymore; it keeps throwing many errors.

I found that freezing my routine into the firmware by compiling it with the rest of the MicroPython modules allows me to keep going. So, I setup a Docker container that builds all the neccesary tools, and I can generate the .UF2 firmware with the required modifications, including the single module “” on /ports/rp2/modules that gets compiled and can be imported and run, so far so good.

Thing is, as expected, every single modification to “” involves generating ALL the modules that make up MicroPython, even though none of them have changed, except for my single file. This takes a very long amount of time to process; I was able to reduce it somehow by using a multi-stage container; in which the first stage generates up to mpy-cross; and the second stage takes from there and generates the .UF2. But even this is rather time consuming.

Is there any way of configuring CMake to stop right when it finished generating all the .obj files pertinent to MicroPython, ideally on the first stage; then compile my single file, and finally linking all together to generate the .UF2? I am confused as there are literally HUNDREDS of CMake scripts, and I don’t know which to customize, and how to do it. Any help will be much appreciated. Sincerely,


List item

Not reliably as the build system doesn’t know how to “stop” only when your command isn’t completed without knowing how to do it on its own anyways (basically as part of the proper build graph).

To me, it sounds like something to ask for proper support from MicroPython for the ability to embed your own scripts into the runtime as well.

Hello Ben, thanks for answering! Turned out I didn’t need to, as CMake is clever enough (clever than me!) to compile and link only the parts that changed. I didn’t realize this because I was rebuilding the filesystem over and over again. More details here:

Once again, thanks for your interest in solving my issue. Sincerely,