Skip to content

Support default_toolchain override in mbed_app.json #4371

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

Closed
wants to merge 4 commits into from
Closed

Support default_toolchain override in mbed_app.json #4371

wants to merge 4 commits into from

Conversation

cyliangtw
Copy link
Contributor

@cyliangtw cyliangtw commented May 23, 2017

@sg-

Description

On-line IDE compiler will build the code by the default_toolchain in target.json.
For some purpose, some application will prefer to use another one in supported_toolchains.
So, to override the default tool chain by mbed_app.josn is a better way.

Status

READY

Migrations

This PR is to add one more item default_toolchain in CUMULATIVE_ATTRIBUTES.
Also to modify config python file for non-list type of overrides.

Steps to test or reproduce

  1. Prepare mbed_app.json like as:
    "target_overrides": {
        "*": {
            "target.default_toolchain": "uARM",
            "platform.stdio-flush-at-exit": false
        }
  1. $ mbed compile -m NUMAKER_PFM_NUC472
  2. Got debug log as:
Before: ConfigCumulativeOverride: update_target default_toolchain --> Attr: ARM
After: ConfigCumulativeOverride: update_target default_toolchain --> Attr: uARM

@theotherjimmy
Copy link
Contributor

@cyliangtw This seems to confuse the issue of being able to override something with having a cumulative override. You do not have to have a cumulative override to override an attribute.

@sg-
Copy link
Contributor

sg- commented May 23, 2017

@theotherjimmy what is the suggested patch? In the online IDE I tried to apply the following to mbed_app.json:

{
    "target_overrides": {
        "*": {
            "target.default_toolchain": "uARM",
            "platform.stdio-flush-at-exit": false
        }
    }
}

and got

Error: Attempt to override undefined parameter 'target.default_toolchain' in 'application[*]'

@theotherjimmy
Copy link
Contributor

diff --git a/tools/config/__init__.py b/tools/config/__init__.py
index 3f265f05a..76b2b92d6 100644
--- a/tools/config/__init__.py
+++ b/tools/config/__init__.py
@@ -642,6 +642,9 @@ class Config(object):
                     if full_name in params:
                         params[full_name].set_value(val, unit_name, unit_kind,
                                                     label)
+                    elif name.startswith("target.") and unit_kind is "application":
+                        _, attribute = name.split(".")
+                        self.target.setattr(attribute, val)
                     elif name in self.__unused_overrides:
                         pass
                     else:

@theotherjimmy
Copy link
Contributor

theotherjimmy commented May 23, 2017

That [patch ^] would get you the flexibility to override GCC_ARM's default_lib too.

@theotherjimmy
Copy link
Contributor

@sg- I don't think I was trying to say that it would currently work, just that calling an attribute which does not support adds and removes cumulative is going to be confusing to someone eons (months) from now.

@cyliangtw
Copy link
Contributor Author

cyliangtw commented May 24, 2017

Thanks of theotherjimmy mentioned patch, it seems not work at self.target.setattr(), after revise as below, it could work well to override default_toolchain by mbed_app.json.

                    elif name.startswith("target.") and unit_kind is "application":
                        _, attribute = name.split(".")
                        setattr(self.target, attribute, val)                                             

When will you apply this patch into mbed master ?

@adbridge
Copy link
Contributor

@theotherjimmy What needs to happen with this ?

@theotherjimmy
Copy link
Contributor

@cyliangtw Whoops, wrong patch. It should be:

diff --git a/tools/config/__init__.py b/tools/config/__init__.py
index 3f265f05a..76b2b92d6 100644
--- a/tools/config/__init__.py
+++ b/tools/config/__init__.py
@@ -642,6 +642,9 @@ class Config(object):
                     if full_name in params:
                         params[full_name].set_value(val, unit_name, unit_kind,
                                                     label)
+                    elif name.startswith("target.") and unit_kind is "application":
+                        _, attribute = name.split(".")
+                        setattr(self.target, attribute, val)
                     elif name in self.__unused_overrides:
                         pass
                     else:

@theotherjimmy
Copy link
Contributor

theotherjimmy commented May 24, 2017

@adbridge I would like to see overwriting non-cumulative overrides untangled from the ConfigCumulativeOverride class

@theotherjimmy
Copy link
Contributor

@cyliangtw I think that we could apply that to master soon. There is a big catch though: even though you can override the target.default_toolchain feild, you still won't get the behavior that you want: that the smaller libraries are linked. We would need to add some support code in the online compiler and in the tools to ensure that the right flags get picked up from the build profile.

@cyliangtw
Copy link
Contributor Author

@theotherjimmy Your patch could work well on off-line compiler by CI command. After finish the support code in the online compiler or arrange the plan schedule, please notify me to evaluate. Thanks a lot.

@cyliangtw cyliangtw closed this May 25, 2017
@sg- sg- removed the needs: work label May 25, 2017
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