Skip to content
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

[build] Add Makefile build script generator #557

Merged
merged 6 commits into from
Mar 26, 2021

Conversation

salkinium
Copy link
Member

@salkinium salkinium commented Feb 13, 2021

Makefiles are quite simple to use and I wanted a build system that didn't require Python3 (at least for building, all our tooling requires it of course). It may also make it easier for people wary of SCons or CMake to use modm.

  • Compilation and linking of .elf file
  • Compilation of source files with custom flags
  • Merging of Makefile generated by::cmake (almost identical) CMake Makefile will go away soon.
  • Move all special tools from :::scons to ::build and also implement in :::make
    • unit test tool
    • information tool
    • bitmap tool
  • Add Makefile generator to examples
  • Test Makefile Tools
    • Bitmap tool
    • infomation tool: git + build
    • unit test
    • program, program-bossac, program-fuses, program-dfu
    • debug, debug-coredump with ui=tui and ui=web
    • reset
  • Documentation

cc @rleh @chris-durand

@rleh
Copy link
Member

rleh commented Feb 26, 2021

  • Merging of Makefile generated by ::cmake (almost identical)

I never understood why there is a Makefile generated by the cmake generator. With the rework of the cmake generator in #568 it will probably disappear?!

Copy link
Member

@rleh rleh left a comment

Choose a reason for hiding this comment

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

Looks nice and clean! 👍🏽

(and I like Makefiles 😆)

tools/build_script_generator/make/resources/Makefile.in Outdated Show resolved Hide resolved
@ghost

This comment has been minimized.

@salkinium

This comment has been minimized.

@rleh

This comment has been minimized.

@salkinium salkinium force-pushed the feature/makefile branch 5 times, most recently from 0dccf3e to 1a338af Compare March 20, 2021 15:42
@salkinium salkinium marked this pull request as ready for review March 20, 2021 15:42
@salkinium salkinium force-pushed the feature/makefile branch 2 times, most recently from 4ea2e53 to 5f06e6b Compare March 20, 2021 18:13
@salkinium
Copy link
Member Author

Ok, this is ready for review now. It's a copy of the SCons "API" with all features except make artifact and there's no XPCC integration.

@salkinium salkinium force-pushed the feature/makefile branch 3 times, most recently from 08de09d to f203126 Compare March 20, 2021 19:58
@rleh rleh self-requested a review March 21, 2021 09:54
examples/avr/assert/project.xml Show resolved Hide resolved
tools/build_script_generator/cmake/module.lb Show resolved Hide resolved
tools/build_script_generator/make/module.lb Show resolved Hide resolved
tools/build_script_generator/make/module.md Outdated Show resolved Hide resolved
tools/build_script_generator/make/module.md Outdated Show resolved Hide resolved
tools/build_script_generator/make/module.md Outdated Show resolved Hide resolved
tools/build_script_generator/make/module.md Outdated Show resolved Hide resolved
tools/build_script_generator/make/module.md Outdated Show resolved Hide resolved
tools/build_script_generator/scons/module.md Outdated Show resolved Hide resolved
tools/scripts/examples_compile.py Outdated Show resolved Hide resolved
@salkinium
Copy link
Member Author

Ah, of course, using shell commands doesn't work on Windows. That's going to be annoying…

Compiling C++·· release/modmsrcmodmdebugloggerhosteddefault_style.omkdir: unknown option -- M
74
Try 'mkdir --help' for more information.

@salkinium salkinium force-pushed the feature/makefile branch 2 times, most recently from 35a5e39 to 208cb9b Compare March 21, 2021 15:42
@salkinium
Copy link
Member Author

Ok, so now that I have a Windows VM I can say that generating a Windows-compatible Makefile requires dealing manually (!!!) with the path seperator \ vs / incl. in generated paths (ie. make does not care either). I've therefore decided not to care about Windows support for the Makefile generator (ie. you can use SCons or CMake) and will simply put a big warning about not using it on Windows.

@salkinium
Copy link
Member Author

This is ready for merging, unless someone™ wants to review.

@salkinium salkinium requested a review from rleh March 25, 2021 00:27
@salkinium
Copy link
Member Author

I added an alias mechanism to lbuild v1.16.0 so that the move of :build:scons:info.git to :build:info.git is backwards compatible and prints a warning about what happened.

 $ lbuild -D :build:scons:info.git=Info discover -t :build:scons --developer
[WARNING] lbuild.node: Node 'modm:build:scons:info.git' has been moved to ':build:info.git'!

>> modm:build:scons:info.git  [Alias]

Moved into `modm:build` module

Alias: :build:info.git

>> modm:build:info.git  [EnumerationOption]

# Generate git repository state information

- `Info`: generates information about the last commit.
- `Info+Status`: like `Info` plus git file status.

Value: Disabled
Inputs: [Disabled, Info, Info+Status]

Module(modm:build:scons)   SCons Build Script Generator
├── Option(cache_dir) = [] in [Path]   Path to SConstruct CacheDir
├── Option(include_sconstruct) = True in [True, False]   Generate a SConstruct file
├── Option(path.artifact) = artifacts in [Path]   Path to Artifact Store
├── Collector(flag_format) in [Callable]   Formatting compile flags for SCons
├── Collector(path.tools) in [Path]   SCons tool paths to be added to the Environment
├── Collector(tools) in [String]   SCons tools to be added to the Environment
├── Alias(image.source) -> :build:image.source   Moved into `modm:build` module
├── Alias(info.build) -> :build:info.build   Moved into `modm:build` module
├── Alias(info.git) -> :build:info.git   Moved into `modm:build` module
╰── Alias(unittest.source) -> :build:unittest.source   Moved into `modm:build` module

@salkinium
Copy link
Member Author

Ping @rleh, please review so I can merge…

Copy link
Member

@rleh rleh left a comment

Choose a reason for hiding this comment

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

Make uses the build folder make-release/, so scons should also use scons-release/ (currently release/).

@rleh
Copy link
Member

rleh commented Mar 26, 2021

With the stm32f469_discovery/hard_fault example the *.elf files are different, the one produced by Make is 228 Bytes smaller.

@salkinium
Copy link
Member Author

The interesting question is if the .bin file is different? I would assume so perhaps because of link order…

examples/nucleo_f103rb/undefined_irq/main.cpp Outdated Show resolved Hide resolved
Comment on lines +89 to +92
using LedD13 = GpioA17;
using LedTx = GpioA27;
using LedRx = GpioB03;
using Leds = LedTx;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
using LedD13 = GpioA17;
using LedTx = GpioA27;
using LedRx = GpioB03;
using Leds = LedTx;
// User LED (Rx and Tx LEDs inverted, because connected to 3V3)
using LedD13 = GpioA17;
using LedTx = GpioInverted<GpioOutputA27>;
using LedRx = GpioInverted<GpioOutputB03>;
using Leds = SoftwareGpioPort< LedTx, LedRx >;

grafik
https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/sparkfun-samd21-mini-breakout-v10.pdf

Copy link
Member Author

Choose a reason for hiding this comment

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

I know, but the problem is that the SAM GPIO implementation does not have GpioInverted or SoftwareGpioPort implemented…

Copy link
Member

Choose a reason for hiding this comment

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

Ohhh :D

Maybe we (you) should create a issue about that and add the "help wanted" label?

Copy link
Member Author

Choose a reason for hiding this comment

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

If I'm honest I would rather rework the Targets support matrix to something that's generated from lbuild using the data we already accumulate in generate_module_docs (but perhaps not so slow). That would give a much more detailed look at what peripherals are supported.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also not sure if the "help wanted" is generally useful, so far I've not seen a contributor specifically fix things they are not personally motivated to do.

Copy link
Member

Choose a reason for hiding this comment

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

I think this is also because we hardly have such "help-wanted" problems that are suitable for beginners.
We could also try to participate in events like hacktoberfest to attract new contributors.

@rleh
Copy link
Member

rleh commented Mar 26, 2021

The interesting question is if the .bin file is different? I would assume so perhaps because of link order…

Bin (and hex) files differ only slightly, probably because of GCCs build id?
grafik

I think that's fine!

@salkinium salkinium requested a review from rleh March 26, 2021 14:16
@salkinium salkinium merged commit 236e27c into modm-io:develop Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants