Skip to content

[tools] Modified config to aggregate cumulative overrides against targets #2215

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

Merged
merged 4 commits into from
Jul 22, 2016

Conversation

geky
Copy link
Contributor

@geky geky commented Jul 21, 2016

Modified '_process_config_and_overrides' to update cumulative attributes based on cumulative overrides found during walking config files.

This should remove most of the disparity between the config target cumulative overrides and cumulative attributes set in targets.json. These cumulative overrides are updated after the global target
instantiation though, which may cause internal build tool state dependent on cumulative attributes to not correctly reflect all cumulative overrides.

Example:

{
  "target_overrides": {
    "K64F": {
      "target.features_add": ["COOL_THING"],
      "target.extra_labels_add": ["COOL_THING_SUPPORTED"],
      "target.macros_add": ["COOL_THING_IS_HERE"],
      "target.device_has_add": ["COOL_THING_YES"]
    }
  }
}

cc @sg-, @screamerbg, @theotherjimmy
related #2209

@AlessandroA
Copy link
Contributor

@geky I tested it with uVisor and the label does not appear in the macros list, nor in the mbed_config.h file.

My sample config file:

{
    "target_overrides": {
        "K64F": {
            "target.features_add": ["UVISOR"],
            "target.extra_labels_add": ["UVISOR_SUPPORTED"]
        }
    }
}

@geky
Copy link
Contributor Author

geky commented Jul 22, 2016

Oh, looking into this there are complicated dependencies between the config system and the target system. This will require a bit of extra work to sort out the labels correctly.

geky added 4 commits July 22, 2016 00:35
In tools/config.py, Config now aggregates all cumulative attributes in
target overrides.

{
  "target_overrides": {
    "K64F": {
      "target.features_add": ["UVISOR"],
      "target.extra_labels_add": ["UVISOR_SUPPORTED"],
      "target.macros_add": ["UVISOR_MACRO"],
      "target.device_has_add": ["UVISOR_HAS"]
    }
  }
}

Note: no action is performed on overrides yet
Modified '_process_config_and_overrides' to update cumulative
attributes based on cumulative overrides found during walking config
files.

This should remove most of the disparity between the config target
cumulative overrides and cumulative attributes set in targets.json.
These cumulative overrides are updated after the global target
instantiation though, which may cause internal build tool state
dependent on cumulative attributes to not correctly reflect all
cumulative overrides.
Due to dependencies between the config/target systems, the config
has been modified to preparse the mbed_app.json for overrides.
This means that attributes with dependencies in the targets are
only valid at the application level. A hard error has been
added for these attributes if they are supplied at the library
level.
@bogdanm
Copy link
Contributor

bogdanm commented Jul 22, 2016

This feature was not part of the original config system design and implementation, because those overrides are not actually configuration parameters. There are overrides of JSON attributes of the target object, and these attributes are not part of the configuration mechanism, This makes things confusing and hard to understand, just like it did with features before. Suggestions:

  • turn these internal attributes into actual configuration parameters
  • even if you don't turn them into configuration parameters, at the very least update the documentation of the configuration system, so that people understand what they can override.

@geky
Copy link
Contributor Author

geky commented Jul 22, 2016

Hi @bogdanm, I agree the config system could be improved/refactored. However I don't see how your points are relevant to the issue in #2209, which is the goal of this pr right now.

@geky
Copy link
Contributor Author

geky commented Jul 22, 2016

Hi @AlessandroA, I have updated this pr with additional handling for the extra_labels which I've tested locally. Let me know if this doesn't work for you.

@bogdanm
Copy link
Contributor

bogdanm commented Jul 22, 2016

However I don't see how your points are relevant to the issue in #2209, which is the goal of this pr right now.

Relevant:

even if you don't turn them into configuration parameters, at the very least update the documentation of the configuration system, so that people understand what they can override.

#2209 or not, a non-trivial change like this to the config system should be followed by a documentation update.

@geky geky force-pushed the tools-cumulative-overrides branch from 408802b to 41a70d3 Compare July 22, 2016 18:53
@geky
Copy link
Contributor Author

geky commented Jul 22, 2016

I agree we should add additional documentation for target overrides in the config, but it seems inappropriate to combine a documentation update and a bug fix.

I can make a separate pr for adding the target override documentation?

@geky geky force-pushed the tools-cumulative-overrides branch from 41a70d3 to a5ea143 Compare July 22, 2016 19:44
@sg-
Copy link
Contributor

sg- commented Jul 22, 2016

docs are actually moving out of this repo for now due to the way the website renders things 😕

@AlessandroA
Copy link
Contributor

@geky I tested the PR with the uVisor app and the symbols are all correctly defined. Thanks!
I agree with @bogdanm that this system should be documented ASAP, as the config implementation is diverging from those docs, and it's very hard for us (users) to track the changes.

PS: @sg- If I rebase @geky's branch on top of the latest master the compilation fails because of some UDP/TCPSocket error – Is this a known issue?

@sg-
Copy link
Contributor

sg- commented Jul 22, 2016

This could be the case due to duplicate network socket declarations in features of os an core. Try to delete one from mbed-os and let me know what happens

@AlessandroA
Copy link
Contributor

@sg- Yes, that was it. Thanks!

@sg- sg- merged commit 1880dae into ARMmbed:master Jul 22, 2016
@bogdanm
Copy link
Contributor

bogdanm commented Jul 25, 2016

I agree we should add additional documentation for target overrides in the config, but it seems inappropriate to combine a documentation update and a bug fix.

How is that inappropriate, when the actual fix for the bug introduces new behaviour in the configuration system, and people need to know how to use that? I would say that updating the documentation with the implementation is the most appropriate thing to do.

@geky
Copy link
Contributor Author

geky commented Jul 25, 2016

I just don't see how coupling this bug fix and adding documentation for a mechanism that has been around since #1906 is beneficial for either issues.

Sorry we're not agreeing here and if I'm in the wrong. Has an issue been made on github for the missing documentation on cumulative attributes? I can look into adding what is missing.

@bogdanm
Copy link
Contributor

bogdanm commented Jul 25, 2016

I always thought that updating the documentation together with the code is always a good idea, and I can't recall a single time when this wasn't the case. What tends to happen if you don't do it right after you modify the code (and in the same PR) is that you'll forget about it and go on doing other things. It has happened over and over again, to myself and pretty much all the programmers I know. I don't believe that documentation updates need a separate issue on github, they should be part of the regular workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants