-
-
Notifications
You must be signed in to change notification settings - Fork 654
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
base: main
Are you sure you want to change the base?
Conversation
…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
core/SConscript.unix
Outdated
@@ -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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in force-push
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...
[no changelog]
9e9ea7c
to
f765e11
Compare
cherry-picked your quiet mode as f765e11 |
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 |
$(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 oneCPPDEFINES
in Sconscripts no longer need to be shell-quoted ... (but it's still a hack, read the commit description to learn more about limitations)