Skip to content
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

Scons quality-of-life improvements #4234

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

matejcik
Copy link
Contributor

@matejcik matejcik commented Oct 1, 2024

  • $(SCONS) in makefile now includes all the TREZOR_FOO_BAR=1 specifiers so you don't have to copy them to 20 places when adding a new one
  • CPPDEFINES in Sconscripts no longer need to be shell-quoted ... (but it's still a hack, read the commit description to learn more about limitations)

…t passed as scons vars

so that we don't have to write "USE_FOO=$(USE_FOO)" 20 times every time
we add such flag
@matejcik matejcik requested a review from cepetr October 1, 2024 11:20
@@ -835,7 +841,9 @@ def cargo_build():
bindgen_macros = tools.get_bindgen_defines(env.get("CPPDEFINES"), ALLPATHS)
build_dir = str(Dir('.').abspath)

return f'export BINDGEN_MACROS=\'{bindgen_macros}\'; export BUILD_DIR=\'{build_dir}\'; cd embed/rust; cargo build --profile {RUST_PROFILE} --target-dir=../../build/unix/rust --no-default-features --features "{" ".join(features)}" --target {TARGET}'
print(bindgen_macros)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to leave these print() statements here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in force-push

matejcik and others added 2 commits October 3, 2024 09:40
Here we change all FOO=VALUE defines to be tuples ("FOO", "VALUE").
Also, VALUE is always the raw string you want to end up in the C file,
instead of attempting to shell-escape it while specifying.

By all rights scons _should_ be using shlex.quote() on the CPPDEFINES,
but it doesn't, so we hack it by specifying the define prefix as `-D'`
and suffix as `'`. That way the arguments in shell are '-escaped, and
we're (currently) not using ' in any argument value so this should work
fine.

At the same time, when passing the flags to cargo, we can shlex.quote
the whole thing and get the right strings passed all the way into
build.rs -- as long as no argument contains a comma, which is the split
character...
@matejcik
Copy link
Contributor Author

matejcik commented Oct 3, 2024

cherry-picked your quiet mode as f765e11

@matejcik
Copy link
Contributor Author

blocked by #4253 that causes build failures in CI

we could work around it here by not passing PYOPT to kernel, or force-setting it to 1, but i'd prefer a real solution

@matejcik matejcik added the blocked Blocked by external force. Third party inputs required. label Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Blocked by external force. Third party inputs required.
Projects
Status: 🔎 Needs review
Development

Successfully merging this pull request may close these issues.

2 participants