8000 py/mkrules.mk: Add $(MPY_CROSS) as a dependency by osresearch · Pull Request #5760 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

py/mkrules.mk: Add $(MPY_CROSS) as a dependency #5760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

osresearch
Copy link
Contributor

By making $(MPY_CROSS) an order-only prerequisite of the various frozen files, it removes the need to remember to build ../../mpy-cross/mpy-cross by hand on a clean checkout.

More info on order-only prerequisites.

By making $(MPY_CROSS) an order-only prerequisite of the
various frozen files, this removes the need to remember to
build ../../mpy-cross/mpy-cross by hand on a clean checkout.

Signed-off-by: Trammell hudson <hudson@trmm.net>
@dpgeorge
Copy link
Member

Thanks for the PR. This was actually the original behaviour but it was removed because it had a few difficulties. See 4173950 and #3255 and #4825 (and issues linked from that one). The main problem calling make recursively to build mpy-cross is that setting/env variables for the port being built then apply to mpy-cross.

@osresearch
Copy link
Contributor Author

The order-only prereq prevents the slow build issue in #3255: it only builds mpy-cross if it doesn't exist, but doesn't rebuild it ever after that. The env variables are an issue, for sure. Hacks like unsetting a bunch of env variables seem pretty messy and also potentially an issue if the builder wanted those variables set.

However, if mpy-cross needs to be build separately to avoid the env pollution, it can still be built on its own with whatever environment and the order-only prereq in py/mkrules.mk won't rebuild it. So having this patch might make the experience better for the new user -- they can just run make in their port and it will probably work, similar to the way stm32lib is automatically checked out if they forgot to do a submodule clone. More experienced devs who need to customize mpy-cross can still do so.

@dpgeorge
Copy link
Member

I agree with the above reasoning, that the change here is a nice convenience for users (and building mpy-cross is often a stumbling block for newcomers, so making it smoother is good).

But I think there a problem: currently tools/makemanifest.py allows the user to specify a custom mpy-cross executable via the MICROPY_MPYCROSS env variable. If they do that with this PR applied then make will now always try to build mpy-cross in this repo, which may not be possible for the user (eg they had to specify extra CFLAGS to get it to build, or they needed to add a .exe extension on Windows). And they won't be able to prevent it from being built (or an attempt to be built and then failure).

dpgeorge added a commit to dpgeorge/micropython that referenced this pull request Aug 3, 2021
Commit 4173950 removed automatic building
of mpy-cross, which rebuilt it whenever any of its dependent source files
changed.

But needing to build mpy-cross, and not knowing how, is a frequent issue.
This commit aims to help by automatically building mpy-cross only if it
doesn't exist.  For Makefiles it uses an order-only prerequisite, while
for CMake it uses a custom command.

If MICROPY_MPYCROSS (which is what makemanifest.py uses to locate the
mpy-cross executable) is defined in the environment then automatic build
will not be attempted, allowing a way to prevent this auto-build if needed.

Thanks to Trammell Hudson aka osresearch for the original idea; see micropython#5760.

Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge
Copy link
Member
dpgeorge commented Aug 3, 2021

See #7610 for an alternative which also supports CMake.

dpgeorge added a commit to dpgeorge/micropython that referenced this pull request Aug 7, 2021
Commit 4173950 removed automatic building
of mpy-cross, which rebuilt it whenever any of its dependent source files
changed.

But needing to build mpy-cross, and not knowing how, is a frequent issue.
This commit aims to help by automatically building mpy-cross only if it
doesn't exist.  For Makefiles it uses an order-only prerequisite, while
for CMake it uses a custom command.

If MICROPY_MPYCROSS (which is what makemanifest.py uses to locate the
mpy-cross executable) is defined in the environment then automatic build
will not be attempted, allowing a way to prevent this auto-build if needed.

Thanks to Trammell Hudson aka @osresearch for the original idea; see micropython#5760.

Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge
Copy link
Member

Done in 78718ff

@dpgeorge dpgeorge closed this Nov 30, 2021
tannewt added a commit to tannewt/circuitpython that referenced this pull request Dec 29, 2021
circuitpython_stubs: Use `circuitpython_typing` for cp-specific typing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0