-
Notifications
You must be signed in to change notification settings - Fork 179
per profile build dirs #712
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
per profile build dirs #712
Conversation
@bmcdonnell-ionx using default as the "default profile" is correct, and may cause unneeded rebuilds. |
mbed/mbed.py
Outdated
@@ -2497,10 +2497,24 @@ def compile_(toolchain=None, target=None, profile=False, compile_library=False, | |||
|
|||
build_path = build | |||
|
|||
def safe_append_profile_to_build_path(bp): |
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.
Please avoid functions within functions. This makes it much more difficult to track what state is used by/shared with this function.
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.
I nested it because it's a helper function with limited scope, and likely not useful elsewhere.
Is your issue the fact that it's using a variable (profile
) from its outer scope? Would adding that as a parameter be sufficient?
Or is there some other issue I'm missing? Or is it just a rule that you want to be strictly followed, because of the potential for abuse, i.e. using variables from outer scope?
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.
Yes, my preference is to avoid using closures. Not because of their potential for abuse, but because it increases the amount of code I have to read to understand what state affects a single function. A function on it's own can change behavior based on global variable and inputs. A closure, a function within the body of another function, adds that function's scope and variable into the pool of variables that may impact it's state.
Helper functions may be prefixed with an _
to mark them private, by python convention.
TL;DR: I find self-contained functions easier to read and understand.
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.
It also might be useful to make the same change to the mbed test
sub-command.
Further, be aware that this will affect linker script command line length, but that's not a limitation at this time. |
I don't follow. Please clarify/elaborate. |
the default profile is always "develop". The use of "DEFAULT" for the default profile's name will force the user to recompile mbed-os when they explicitly specify the develop profile. |
@bmcdonnell-ionx Firstly, thanks for the contribution. Unfortunately in it's current state, this will break any CI or script that someone made which expects that the binary/output files for the default profile to be the Therefore my proposal to workaround this and keep it backwards compatible, is to change the pattern to |
Yes, I thought I had read that somewhere. But I couldn't figure out how that was happening in the code.
Admittedly, yes. I didn't want to hard code |
@screamerbg, I don't understand how your proposal doesn't have the same issue that you described as mine does, unless the testing tools only use the default build profile. Is that the case? |
@bmcdonnell-ionx Correct. The testing tools only use the default build profile. |
@screamerbg, shall I implement your suggestion then, or wait for more feedback? |
I agree with @screamerbg's suggestion of build paths. I think that's a good path forward. |
Not that I'm aware of. |
@screamerbg, et al,
Some toolchains already have underscores in their names, e.g.
I weakly favor two. |
Unpopular opinion of the day: Use |
2 |
e7923e0
to
113213f
Compare
OK, I've made the requested changes. This is working fine for me on project builds, and I tried it a couple times on library builds. I don't know how to test it on the Is the CI py3 test failure my fault? |
@bmcdonnell-ionx It looks like the py3 CI failure may be your fault:
|
How can I reproduce this error on my local system, or at least get a line number to know where to look? I tried installing Python 3.7.0 (notably not 3.6, which the CI is using), and in |
@bmcdonnell-ionx You may have to install it with |
you could also try |
How would I install from source with (Note, Python3 is not in my path.) I tried
|
That's odd. |
|
Actually, I don't think it is, because I get the same error when using Install Mbed CLI
Run the failing test:
|
@bmcdonnell-ionx Touche |
@cmonr How did this get onto master? |
@theotherjimmy No idea. Will look at root causing today. |
Nothing is wrong with it, except that there is the potential for it to be ambiguous: I thought that |
As @theotherjimmy pointed out, using something different from a single underscore separator (e.g. I think using Personally, I don't find a double underscore That said, if your team reaches consensus here on the |
Here is the I'm not a fan of Also it has the "shorter" issue (mistaking it to mean That said, again, I will defer to consensus. |
I'm out of symbol keys on my keyboard that normally work as separators (and are not |
OR I'm not |
|
Yeah, those ( |
While we're at it: I think that |
One underscore is ambiguous, and so is 2 but may be less, shall we make them 3? :) Are we really thinking that someone will use |
One example that comes to mind is library preprocessor macros. https://stackoverflow.com/a/224420 Apparently they're used in Python, too. https://stackoverflow.com/a/1301369
Whether or not it's used, it's still ambiguous to read. (I still will defer to consensus - that just doesn't appear to have occurred yet.) |
Not sure how this is relevant. Can you elaborate? |
@screamerbg, you said double underscores are not common usage. It may not be "common" per se, but I had said that that I thought it was a "common enough" usage. Those are examples of double underscores used by programmers. Mbed OS users are programmers - and using C/C++, so I figure they're likely to have seen double underscores used at least in preprocessor macros. |
@bmcdonnell-ionx Not sure what's the point you're trying to make. Programmers would mix preprocessing macros with output build folders?? |
I'm just saying that double underscore is a thing that most Mbed OS users have probably seen, and so should not be confused by, IMO, contrary to your initial statement. (I don't understand the "confusion", either.) |
This is about output folders naming, not code variables. I don't see the relevance. Also following your argument, developers are familiar with dot in coding as well. Why not GCC_ARM.DEBUG then? |
@screamerbg The important part is that python uses |
Aside, as for bike shedding we could not have made a better example if we tried. |
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.
Code looks great, BTW.
@screamerbg, the relevance is I didn't think anyone was going to say "what's that thing?" about the double underscore. You did? A weak recommendation against
|
https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file |
Yep, so |
Good example.
If @screamerbg still wants that, then yes. |
…stead of `__`) as a delimiter between compiler name and build profile name.
I frequently use
With That said, I take @screamerbg's 👍 on the previous 2 comments to mean he favors |
Looks great! Thank you! |
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.
LGTM. Merge at will @theotherjimmy
I will, when testing finishes. |
Summary
Attempt to address #615.
When a build dir is not specified,
mbed compile
creates a new per-build-profile subdirectory. This prevents full rebuilds when switching build profiles.mbed compile
BUILD/<target>/<toolchain>/DEFAULT/
mbed compile --profile debug
BUILD/<target>/<toolchain>/DEBUG/
mbed compile --profile=myprofiles/superoptimized-cpp11.json
BUILD/<target>/<toolchain>/SUPEROPTIMIZED-CPP11/
mbed compile --library --profile debug
BUILD/libraries/<project-name>/<target>/<toolchain>/DEBUG/
Notes
Questions