Skip to content

[Exporters] Update exporters to include and use mbed_conf.h (Was #1964) #1975

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 11 commits into from
Jun 28, 2016

Conversation

theotherjimmy
Copy link
Contributor

@theotherjimmy theotherjimmy commented Jun 20, 2016

Affected exporters:

  • gcc_arm
  • uVision4
  • IAR
  • emblocks
  • atmelstudio
  • codered
  • simplicityv3

Summary of discussion:

@0xc0170:
We should wait until the name of mbed_conf.h is set in stone.

@bogdanm:
We should introduce a configuration variable for all exporters to indicate if they export the mbed_conf.h. This will help eliminate duplication.

@bogdanm
Copy link
Contributor

bogdanm commented Jun 20, 2016

We should introduce a configuration variable for all exporters to indicate if they export the mbed_conf.h.

That's more an attribute of the exporter itself than a configuration variable. If it supports mbed_conf.h or whatever its name is going to end up being, that's the mechanism it should use; if not (because it was not upgraded it or simply because it can't support prefix headers for whatever reason), it should still use the old method of defining macros.

@theotherjimmy
Copy link
Contributor Author

Thanks for the clarification @bogdanm. That was what I was trying to say, but used the wrong word (configuration varible) as opposed to exporter attribute.

@theotherjimmy theotherjimmy force-pushed the export-mbed-conf branch 2 times, most recently from 6ac1703 to b202db5 Compare June 20, 2016 19:33
@theotherjimmy
Copy link
Contributor Author

@bogdanm, does the 7th commit (Create and enable...) resolve the switching between -D style and mbed_confi.h (or whatever we decide to call it) style that you suggested?

@theotherjimmy
Copy link
Contributor Author

To answer my own question, No the mechanism does not work yet.

@theotherjimmy
Copy link
Contributor Author

Well, actually it might. I don't have any content in my mbed_conf.h files, and therefore cannot test it.

@@ -47,6 +48,9 @@ def flags(self):
def progen_flags(self):
if not hasattr(self, "_progen_flag_cache") :
self._progen_flag_cache = dict([(key + "_flags", value) for key,value in self.flags.iteritems()])
if self.config_header:
self._progen_flag_cache['c_flags'] += self.toolchain.get_config_option(self.config_header)
self._progen_flag_cache['cxx_flags'] += self.toolchain.get_config_option(self.config_header)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realized that you might need to add this to ASM files as well, since some toolchains (like GCC) can preprocess the ASM file before invoking the assembler, and we use this feature in a few parts of the system. Not sure though if this is something that we want to enable for all toolchains or only for a few of them.

@bogdanm
Copy link
Contributor

bogdanm commented Jun 21, 2016

The mechanism looks like it'll probably work, but I didn't test it locally yet.

@theotherjimmy
Copy link
Contributor Author

Let me know when you do.

@bogdanm
Copy link
Contributor

bogdanm commented Jun 23, 2016

Let me know when you do.

Doing my best, but there seem to be some unrelated issues with the exporters right now. We don't really have a test suite for exporters, so all I can do is try a few manually and see if they work.

Also, #1968 happened meanwhile, so the name of the configuration file is now mbed_config.h. Which means that this shouold be declared somewhere (maybe in mbedToolchain) rather than hard-coded in more than one place.

@theotherjimmy
Copy link
Contributor Author

Rebased. @bogdanm is the move to one location commit what you want?

@@ -121,6 +121,8 @@ class GccArm(Exporter):

DOT_IN_RELATIVE_PATH = True

MBED_CONF_ACTIVE = True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@theotherjimmy Can you rename this to HAS_MBED_CONFIG please?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this flag to signal if mbed config is active (=present) or if there is a configuration somewhere (has config)? I would say the former, same as PROGEN_ACTIVE flag. @theotherjimmy what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should really be MBED_CONF_HEADER_SUPPORTED. If present, this field says "this exporter can use the header files generated by the configuration system". If not present, the exporter can still work with the configuration system, but using the old method (direct generation of macros for the configuration system).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing now.

@screamerbg
Copy link
Contributor

LGTM
+1

@screamerbg
Copy link
Contributor

Minor comment. Noticed that MBED_CONF_ACTIVE is always true. Isn't it fair/safe to assume that the config is always there (even if empty)?

@bogdanm
Copy link
Contributor

bogdanm commented Jun 24, 2016

Noticed that MBED_CONF_ACTIVE is always true.

The point of MBED_CONF_ACTIVE is to differentiate between exporters that support configuration using the new mechanism (with automatically included configuration header) and exporters that support only the old mechanism (adding the config macros to the exporter's macro list directly). MBED_CONF_ACTIVE (which should probably be callsed MBED_CONFIG_ACTIVE now) is only True for those exporters that support the new mechanism. In time, as more exporters are updated, the intention is to get rid of MBED_CONF_ACITVE completely.

@bogdanm
Copy link
Contributor

bogdanm commented Jun 24, 2016

@theotherjimmy, did you test this PR with uvision? It doesn't seem to work for me. A .uvproj file is created and I can see this line in it:

<MiscControls> --restrict --preinclude --multibyte_chars --apcs=interwork -c -O3 -Otime --brief_diagnostics --cpu=Cortex-M4.fp -D__ASSERT_MSG --no_depend_system_headers mbed_config.h --md --split_sections --no_rtti --gnu</MiscControls>

As you can see, mbed_config.h appears there without --preinclude (this is the only place in the .uvproj file where mbed_config.h appears). Consequently, when compiling, I get this error: Error: C4065E: type of input file 'mbed_config.h' unknown.

Tested with uVision 5.20, project-generator 0.9.4.

@theotherjimmy
Copy link
Contributor Author

@bogdanm this looks better I think:
<MiscControls> --restrict --multibyte_chars --apcs=interwork -c -O3 --cpu=Cortex-M3 -Otime --brief_diagnostics -D__ASSERT_MSG --no_depend_system_headers --preinclude=mbed_config.h --md --split_sections --no_rtti --gnu</MiscControls>

@bogdanm
Copy link
Contributor

bogdanm commented Jun 27, 2016

@theotherjimmy, that looks better indeed. Now I'm getting a different set of errors:

"no source": Error:  #5: cannot open source input file "mbed-os\core\hal\common\AnalogIn.cpp": No such file or directory
"no source": Error:  #5: cannot open source input file "mbed-os\core\hal\common\assert.c": No such file or directory
"no source": Error:  #5: cannot open source input file "main.cpp": No such file or directory

and so on. It looks like that paths are messed up. I doubt this is because of this PR, but in any case, it means that I can't really test it. Cc @0xc0170.

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 27, 2016

I am looking at it, seems to me that master is broken, thus is not fault of this PR. The paths are wrong. I should have a fix for it today.

@bogdanm
Copy link
Contributor

bogdanm commented Jun 27, 2016

With #2026 in place, this works with uVision on blinky. IAR still fails, but for a different reason (duplicate object names). So I'd say that after we merge #2026 we're good to merge this.
Take also a look at #2020 which fixes a issue with --preinclude and IAR (I added a comment about that this to this PR a while ago).

self.config_macros = config.get_config_data_macros()


if hasattr(self, "MBED_CONFIG_HEADER_SUPPORTED") and self.MBED_CONF_ACTIVE :
Copy link
Contributor

@bogdanm bogdanm Jun 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and self.MBED_CONFIG_HEADER_SUPPORTED. Please do not issue/modify a PR without testing its functionality at least once locally.

@screamerbg screamerbg changed the title Update exporters to include and use mbed_conf.h (Was #1964) [Exporters] Update exporters to include and use mbed_conf.h (Was #1964) Jun 27, 2016
@theotherjimmy
Copy link
Contributor Author

thanks @screamerbg!

@theotherjimmy
Copy link
Contributor Author

@bogdanm, @0xc0170, @screamerbg is this ready to merge?

@theotherjimmy
Copy link
Contributor Author

theotherjimmy commented Jun 27, 2016

Just a moment, the changes in this branch is out of date. Rebasing.

@bogdanm
Copy link
Contributor

bogdanm commented Jun 27, 2016

I suspect we'll have some problems related to assembler flags, but let's merge it like this for now and see how it goes. However, it looks like it needs to be rebased.

@theotherjimmy
Copy link
Contributor Author

Yeah, I'm working on it right now.

@theotherjimmy
Copy link
Contributor Author

Don't merge just yet, I need to verify that IAR asm gets the right flags.

theotherjimmy and others added 9 commits June 27, 2016 14:06
get_conifg_option -> get_config_option
The mbed_conf_active feature disables configuration macros on the
command line and replaces them with a preinclude header file
relpaces the --preinclude mbed_config.h with --preinclude=mbed_config.h
…rt/$file -e "s/MBED_CONF_ACTIVE/MBED_CONFIG_HEADER_SUPPORTED/"; done
@theotherjimmy
Copy link
Contributor Author

Looks fine. Side note: IAR IDE works on my Linux machine!

def get_compile_options(self, defines, includes, for_asm=False):
opts = ['-D%s' % d for d in defines] + ['-f', self.get_inc_file(includes)]
opts = ['-f', self.get_inc_file(includes)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defines isn't used anymore ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, whoops. I did not intend to delete that. OTOH, they still seem to propagate to the exporters. I suspect this would break the direct build on IAR, but not an exported project.

def get_compile_options(self, defines, includes, for_asm=False):
opts = ['-D%s' % d for d in defines] + ['-f', self.get_inc_file(includes)]
config_header = self.get_config_header()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated (see below in the else: block). Not a real problem though.

@bogdanm
Copy link
Contributor

bogdanm commented Jun 27, 2016

+1, ready to merge.

@bogdanm bogdanm merged commit af71d87 into ARMmbed:master Jun 28, 2016
@bogdanm bogdanm deleted the export-mbed-conf branch June 28, 2016 08:15
bogdanm pushed a commit that referenced this pull request Jul 13, 2016
This commit address the issue presented in
#2073. Previously, mbed_config.h
was automatically included by the toolchain. With this change, all the
sources that need "mbed_config.h" need to include it manually. However,
"mbed.h" now includes "mbed_config.h", so configuration data is
automatically available to sources that include "mbed.h".

With this change, even if there's no configuration data in the project
being built, an empty "mbed_config.h" is generated by the build system.

This change looks big, but most of it is an almost complete reversal of
#1975.

This is likely a breaking change, and needs to be properly
communicated.
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