How to configure CMAKE to detect source code changes?

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
ChrisO
Posts: 48
Joined: Mon Apr 06, 2020 6:16 pm

How to configure CMAKE to detect source code changes?

Post by ChrisO » Wed Jun 29, 2022 9:13 am

Hi,

I have a project which, in terms of directory structure looks like this:

- main project (git repo)
- subfolder: esp-idf (created with the help of `ci_esp32_setup_helper v4.4.1`)
- submodule: micropython v1.18

in micropython/ports/esp32/boards/manifest.py I have the following contents:

Code: Select all

# manifest and modules folder moved to root of parent project (fridge-smart-controller-2) because its easier for newcomers to see all code that will be frozen.
include("$(MPY_DIR)/../application/manifest.py")
so basically: I moved the manifest to a different location so that new developers, coming into our project don't have to search for the manifest in specific ports. It's pretty much a convenience thing... However, I run into the follow issue:

When I change a line in my source code, (located in the top level directory) calling `make all` does not pick up the changes.
It seems like CMAKE is not aware of the fact that something has changed.
How do I make sure CMAKE checks for my src directory as well?
I figured it has something to do with `micropython/ports/esp32/CMakeLists.txt` but I'm not sure as this is my first time using (C)make


regards,
Chris
Chris

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: How to configure CMAKE to detect source code changes?

Post by jimmo » Wed Jun 29, 2022 11:57 pm

ChrisO wrote:
Wed Jun 29, 2022 9:13 am
When I change a line in my source code, (located in the top level directory) calling `make all` does not pick up the changes.
This looks like a bug in our CMake config... CMake makes this very difficult. It looks ninja only understands the final step in the chain (firmware->frozen_content.c) but not the steps to make frozen_content.c.

As a temporary workaround, if you do

Code: Select all

rm -rf build-GENERIC/frozen_content.c build-GENERIC/frozen_mpy/
and then "make all", it will only rebuild the Python code and re-link the final binary.

FYI, rather than modifying esp32/boards/manifest.py (which means you need to have modificatons to the microptyhon tree), the recommended approach is to define your own board, which lives in your own repo.

See https://github.com/micropython/micropyt ... ain/boards

So you'd maintain your board definition (which lets you also control micropython build settings and feature flags etc), alongside your tree of python code.

ChrisO
Posts: 48
Joined: Mon Apr 06, 2020 6:16 pm

Re: How to configure CMAKE to detect source code changes?

Post by ChrisO » Fri Jul 01, 2022 9:07 am

jimmo wrote:
Wed Jun 29, 2022 11:57 pm
ChrisO wrote:
Wed Jun 29, 2022 9:13 am
When I change a line in my source code, (located in the top level directory) calling `make all` does not pick up the changes.
This looks like a bug in our CMake config... CMake makes this very difficult. It looks ninja only understands the final step in the chain (firmware->frozen_content.c) but not the steps to make frozen_content.c.

As a temporary workaround, if you do

Code: Select all

rm -rf build-GENERIC/frozen_content.c build-GENERIC/frozen_mpy/
and then "make all", it will only rebuild the Python code and re-link the final binary.

FYI, rather than modifying esp32/boards/manifest.py (which means you need to have modificatons to the microptyhon tree), the recommended approach is to define your own board, which lives in your own repo.

See https://github.com/micropython/micropyt ... ain/boards

So you'd maintain your board definition (which lets you also control micropython build settings and feature flags etc), alongside your tree of python code.
Thanks for the workaround Jim.
I was already using a custom board definition but somehow missed the manifest file in that directory, so I guess that's why my project was using the default manifest. I will move it to the custom board directory :)
Chris

Post Reply