Skip to content

Move config system into it's own folder and refactor header generation #4150

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 2 commits into from
Apr 20, 2017

Conversation

theotherjimmy
Copy link
Contributor

@theotherjimmy theotherjimmy commented Apr 10, 2017

Descritpion

The config system is a huge file, and seems to be growing to support
things such as bootloader. This implies that the Config class may grow
to beyond the size of this one file.

Furthermore, I saw an error generated by the online build system recently.
This was the traceback:

ValueError: max() arg is an empty sequence
  File "mbed/build_tasks/tasks.py", line 33, in perform_build
    result = _perform_build(build_params)
  File "mbed/build_tasks/tasks.py", line 139, in _perform_build
    result = build(build_params=build_params)
  File "mbed_compiler/build.py", line 223, in build
    mbed_compiler.build_api.build_program(build_params=build_params, notify=notify)
  File "mbed_compiler/build_api.py", line 227, in build_program
    resources.objects = toolchain.compile_sources(resources, build_params['chrooted_build']) + resources.objects
  File "tools/toolchains/__init__.py", line 802, in compile_sources
    self.get_config_header()
  File "tools/toolchains/__init__.py", line 1134, in get_config_header
    crt_data = Config.config_to_header(self.config_data) if self.config_data else None
  File "tools/config.py", line 823, in config_to_header
    if params else 0)

How to reproduce

Simply create an mbed_app.json that removes all macros. This will
cause the macros array to be empty without causing a ConfigException.
When the macros array is empty, max() becomes very confused, as it
is asked to take the maximum of an empty array.

New behavior

We just add a [0] to the end to prevent that silly traceback.

@theotherjimmy theotherjimmy force-pushed the refactor-config-header branch 2 times, most recently from b332395 to be6c58f Compare April 10, 2017 21:46
@theotherjimmy
Copy link
Contributor Author

/morph test

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1874

Build failed!

@0xc0170
Copy link
Contributor

0xc0170 commented Apr 11, 2017

morph test - known failure, will be fixed soon (patch already proposed, waiting for CI to complete)

Copy link
Contributor

@0xc0170 0xc0170 left a comment

Choose a reason for hiding this comment

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

Looking good, just 2 small things in the template. Tools are slowly becoming more organized 👍

@@ -0,0 +1,26 @@
// Automatically generated configuration file.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this file contain license header? I would say yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also say yes. now it has one.

{%- endif %}
{% endfor %}
{%- endif %}
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

should have a new line at the end of file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@theotherjimmy
Copy link
Contributor Author

@0xc0170 The gig's up! you noticed that I was organizing the tools.

@theotherjimmy
Copy link
Contributor Author

Thanks for the review. I addressed all of the comments, so I'm moving this to needs Review and needs CI

@theotherjimmy
Copy link
Contributor Author

/morph test

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1889

Example Build failed!

@tommikas
Copy link
Contributor

Something wrong with mbed_config.h generation?

armcc failing:

Compile [  0.3%]: FlashIAP.cpp
[Warning] mbed_config.h@66,0:  #2775-D: white space is required between the macro name "MEM_ALLOC" and its replacement text
[Warning] mbed_config.h@67,0:  #2775-D: white space is required between the macro name "MEM_FREE" and its replacement text
[Warning] mbed_config.h@70,0:  #2775-D: white space is required between the macro name "MBED_HEAP_STATS_ENABLED" and its replacement text
[Warning] mbed_config.h@72,0:  #1-D: last line of file ends without a newline
Compile [  0.7%]: ns_cmdline.c
[Warning] mbed_config.h@66,0:  #2775-D: white space is required between the macro name "MEM_ALLOC" and its replacement text
[Warning] mbed_config.h@67,0:  #2775-D: white space is required between the macro name "MEM_FREE" and its replacement text
[Warning] mbed_config.h@70,0:  #2775-D: white space is required between the macro name "MBED_HEAP_STATS_ENABLED" and its replacement text
[Warning] mbed_config.h@72,0:  #1-D: last line of file ends without a newline
[Error] ns_cmdline.c@342,0:  #29: expected an expression
[Error] ns_cmdline.c@344,0:  #29: expected an expression
[Error] ns_cmdline.c@437,0:  #29: expected an expression

gcc:

Compile [  0.3%]: FlashIAP.cpp
[Warning] mbed_config.h@66,18: missing whitespace after the macro name
[Warning] mbed_config.h@67,17: missing whitespace after the macro name
[Warning] mbed_config.h@70,32: missing whitespace after the macro name
Compile [  0.7%]: Ethernet.cpp
[Warning] mbed_config.h@66,18: missing whitespace after the macro name
[Warning] mbed_config.h@67,17: missing whitespace after the macro name
[Warning] mbed_config.h@70,32: missing whitespace after the macro name
Compile [  1.0%]: ns_cmdline.c
[Warning] mbed_config.h@66,18: ISO C99 requires whitespace after the macro name
[Warning] mbed_config.h@67,17: ISO C99 requires whitespace after the macro name
[Warning] mbed_config.h@70,32: ISO C99 requires whitespace after the macro name
[Error] mbed_config.h@67,17: expected expression before '=' token
[Error] mbed_config.h@67,17: expected expression before '=' token
[Error] mbed_config.h@67,17: expected expression before '=' token
[Error] mbed_config.h@67,17: expected expression before '=' token

@theotherjimmy
Copy link
Contributor Author

@tommikas Thanks for the info. I'll check into the failure.

I also broke the config header template into it's own file. Further, I
fixed a bug in the config header generation where if no macros, builds
would crash.
@theotherjimmy theotherjimmy force-pushed the refactor-config-header branch from 6e556e4 to 1570233 Compare April 12, 2017 15:50
@theotherjimmy
Copy link
Contributor Author

That should do it. I was using ConfigMacro.name instead of ConfigMacro.macro_name.

name included the value...

@theotherjimmy
Copy link
Contributor Author

/morph test

1 similar comment
@theotherjimmy
Copy link
Contributor Author

/morph test

@sg- sg- added needs: CI and removed needs: work labels Apr 19, 2017
@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 31

All builds and test passed!

@0xc0170 0xc0170 removed the needs: CI label Apr 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants