-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix usage of custom targets in applications and tests #2196
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
Conversation
Commit 43e036d removed the ability to use custom targets (defined in mbed_app.json) by restricting the type of the "target" argument to the list of the known targets. The problem with this is that the configuration system can dynamically add new custom targets to the list of known targets. In order to do this, however, it needs the list of top level source directories, so that it can look for a mbed_app.json file in them. This commit fixes this problem by splitting argument parsing in two steps: 1. in step 1, only '--source' is parsed. 2. the config object is created after this. 3. the rest of the command line options are parsed. 4. the config object created in step 2 is passed around to the various build functions (build_project, build_tests and so on) when needed.
Cc @screamerbg |
@bogdanm I can confirm that this is fixed both for apps and tests. Thanks for the fix! @screamerbg @0xc0170 @theotherjimmy Please note that this issue is now a blocker for the public release of the uVisor example ARMmbed/mbed-os-example-uvisor, which uses a custom target. |
This creates a spaghetti dependencies:
Why not simply remove the target verification from options and leave that to the toolchain object?? |
Because you need to know the full list of targets when you parse the arguments, so that you can display it to the user if he specifies a wrong target (or simply because he needs to know all available targets). |
@bogdanm I'm aware of the reasoning of the implementation. The question is "Why not simply remove the target verification from options and leave that to the toolchain object??" |
You could probably do that, but I don't really see the advantages, especially since I believe the implementation effort is actually larger than the one presented in this PR. |
@bogdanm What implementation effort? We can simply stop validating the target argument and let the toolchain and config handle it. |
The implementation effort that comes from re-implementing something that's already implemented in this PR, without real benefits from what I can tell. |
Usage information is broken by this PR.
was:
|
'-h' was broken because it was showing help for the first (--source only) argument parser. Fixed by creating the first argument parser without `-h` and re-adding the `--source` argument to the second one to get a full help text. Tested with `python tools make.py -h` and `python tools/test.py -h`.
@theotherjimmy, thanks, I didn't notice that. Fix with the latest commit. Let me know if that looks OK to you; if so, I'll rebase against master and merge. |
Trying to use custom targets as documented, and I believe Im being bitten by this.
|
@theotherjimmy: please let me know if the current solution looks OK, so that I can rebase and merge it. |
I'm still opposed to making two argument parsers for each entry point, and maintaining two copies of the |
I don't think custom targets is something we should to support until the inheritance and structure of targets is better defined. |
Agreed, they seem to be causing quit a bit of issues. Maybe we should deprecate them? |
Please do and we can come back to this later |
Commit 43e036d removed the ability to use custom targets (defined in
mbed_app.json) by restricting the type of the "target" argument to the
list of the known targets. The problem with this is that the
configuration system can dynamically add new custom targets to the list
of known targets. In order to do this, however, it needs the list of top
level source directories, so that it can look for a mbed_app.json file
in them. This commit fixes this problem by splitting argument parsing in
two steps:
build functions (build_project, build_tests and so on) when needed.