-
Notifications
You must be signed in to change notification settings - Fork 3k
Add extra_targets.json support to build tools #4103
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
tools/targets/__init__.py
Outdated
# If extra_targets.json exists in working directory load it over the top | ||
extra = os.path.join('.', 'extra_targets.json') | ||
if os.path.exists(extra): | ||
targets.update(json_file_to_dict(extra)) |
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.
This will wipe out any old target in targets.json
if they are re-defined in an extra_targets.json
file.
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.
Yeah that was my intention, so that you can replace/change/fix existing ones if desired.
Obviously if this is likely to confuse people it could be merged in a more intelligent way (I've got a good recursive merge function if needed from another project)
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 think that most people will expect it to merge a bit more intelligently, or for merging to be disallowed completely. Something like overwriting only the keys that are in the extra_targets.json
is what I would expect to happen.
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 added a dict merge function for reference, it's not tested yet though.
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 like adding this as a separate file, because it makes it clear that it's not an application configuration.
Could you please explain why you need extra targets? |
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.
In general this is much more of what I'd expect use to do. I'd be happy to also see how this should be applied to MCU -> board -> custom boards if a single targets.json was broken up into more manageable chunks
@sg- would you expect to have a single targets structure built from relative paths in the target files or something. For example: {
"Target": ...,
"child_target_files" : ["TARGET_NXP/targets.json", ...]
} |
@theotherjimmy our specific need for something like this is commercial project development. We might have a small team, each with a dev board and some common peripherals. We'd like to have a new named target with definitions for this exact configuration of dev board+custom extras which we'll each have a copy of. Similar story in the next phase of the project where we'll have a custom board based heavily on the devboard+custom extras. It would be best to have a new named target inheriting from dev board details but specific to this project, not merged into a fork of mbed-os. |
Sounds like this is more a personal preference than a pressing "we cannot develop without this" style need. |
I urge you to use the |
by mbed CLI configuration, I mean the They live in the |
Is there any way to create multiple new build targets this way? Very soon we'll need to be able to target the raw devboard, the devboard+extras and the custom board from the same codebase. It would be by far the most ideal if these can be different target names that can be compiled for. Currently, I guess we need multiple mbed_app.json files with the different definitions and use Otherwise it's maintaining a private fork of the entire mbed-os repo, and manually merging in upstream updates etc.... ? |
on a slightly related note, it'd be great if config system had a key for artifact name ( |
Ah, now you need custom targets. I'm glad we had this discussion, because we got to the bottom of the requirement here. I think custom targets in an |
PR or issue works. Having it implemented probably gets it in sooner. FYI, the code you would be looking at changing is the |
You can do |
Actually, I like the config for |
@andrewleech Check out #4107 |
yes, custom targets was the removed feature I was suggesting a replacement for, multiple targets is definitely my key requirement! The |
Is there any future work planned here for this patch? Or we can close it? |
Well, it should pass CI... |
I'm very keen for the functionality to be able to add multiple targets without forking mbed-os. If this method is likely to be accepted if I clean it up I'd like to proceed, it'll clean it up but it'll take some days to find the time around work. |
There are a few changes that need to happen in this PR for it to be accepted. I know exactly what they are and they are difficult to explain. May I add a few commits to your branch? |
Yeah absolutely, very happy for any guidance! |
Thanks for the invite, but if you checked the maintainers can modify box, then I already have access. 😈 |
I just wanted to make sure that the parsing was done correctly, and that it would be possible to put |
I see where you're going with that, just needs a couple of little fixes still |
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 have to do one more thing. Excellent job picking up where I left off.
|
||
TARGET_NAMES = TARGET_MAP.keys() | ||
update_target_data() |
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.
Solid + 💯
Yeah it would be quite straightforward to not override existing targets. |
@andrewleech @pi-anl Could you rebase to resolve conflicts? |
If the file extra_targets.json exists in the working directory load it over the top of the built in targets.json for defining new and overriding built in mbed target definitions.
Recursively merge any target configs in extra_targets.json rather than completely replacing keys at the top level
Avoid duplication of update_target_data() code Keep "custom_targets.json" filename definition in Targets()
A warning will be printed if it is attempted.
17baf19
to
4491d2e
Compare
@theotherjimmy what is the best way to test this ? |
Travis runs the unit tests included in this PR. |
@theotherjimmy Please review after the rebase. Travis green, then we shall be good to have this ready for integration? |
The file the CLI is looking is extra_targets.json, not custom_targets.json ( I think an older version of mbed CLI used custom_targets.json ) I just tried this at the command line and confirmed this. Also, this PR talks about extra_targets ARMmbed/mbed-os#4103
Description
Enhancement to provide simple method of adding or overriding target definitions without modifying mbed-os library.
If the file extra_targets.json exists in the working directory load it over the top of the built in targets.json for defining new and overriding built in mbed target definitions.
This is currently just a suggestion for replacing functionality removed in PR #2691 below.
Status
IN DEVELOPMENT
Not ready for merging, open for discussion of direction before considering writing docs/tests
Related PRs
Todos