Skip to content

Commit

Permalink
[examples] Add Makefile generator to select examples
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Mar 26, 2021
1 parent e75e8b1 commit 236e27c
Show file tree
Hide file tree
Showing 20 changed files with 48 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ examples/**/compile_commands.json
examples/**/SConstruct
examples/**/Makefile
examples/**/generated
examples/**/coredump.txt

# repo.lb cache file
ext/modm-devices.cache
1 change: 1 addition & 0 deletions examples/avr/assert/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
<module>modm:architecture:delay</module>
<module>modm:build:scons</module>
<module>modm:build:cmake</module>
<module>modm:build:make</module>
</modules>
</library>
1 change: 1 addition & 0 deletions examples/avr/display/dogm128/benchmark/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
<module>modm:processing:timer</module>
<module>modm:ui:display</module>
<module>modm:build:scons</module>
<module>modm:build:make</module>
</modules>
</library>
1 change: 1 addition & 0 deletions examples/linux/assert/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
<module>modm:architecture:assert</module>
<module>modm:debug</module>
<module>modm:build:scons</module>
<module>modm:build:make</module>
</modules>
</library>
1 change: 1 addition & 0 deletions examples/linux/build_info/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
<module>modm:platform:core</module>
<module>modm:debug</module>
<module>modm:build:scons</module>
<module>modm:build:make</module>
</modules>
</library>
1 change: 1 addition & 0 deletions examples/linux/git/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
<module>modm:platform:core</module>
<module>modm:debug</module>
<module>modm:build:scons</module>
<module>modm:build:make</module>
</modules>
</library>
1 change: 1 addition & 0 deletions examples/nucleo_f103rb/hard_fault/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
<module>modm:platform:fault</module>
<module>modm:platform:heap</module>
<module>modm:build:scons</module>
<module>modm:build:make</module>
</modules>
</library>
1 change: 1 addition & 0 deletions examples/nucleo_f103rb/itm/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</options>
<modules>
<module>modm:build:scons</module>
<module>modm:build:make</module>
<module>modm:platform:itm</module>
<module>modm:processing:timer</module>
</modules>
Expand Down
1 change: 1 addition & 0 deletions examples/nucleo_f103rb/undefined_irq/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
</options>
<modules>
<module>modm:build:scons</module>
<module>modm:build:make</module>
</modules>
</library>
1 change: 1 addition & 0 deletions examples/nucleo_f303k8/rtos/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
<module>modm:processing:rtos</module>
<module>modm:platform:heap</module>
<module>modm:build:scons</module>
<module>modm:build:make</module>
</modules>
</library>
1 change: 1 addition & 0 deletions examples/nucleo_f429zi/cmsis_dsp/dotproduct/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
</options>
<modules>
<module>modm:build:scons</module>
<module>modm:build:make</module>
<module>modm:cmsis:dsp:transform</module>
<module>modm:cmsis:dsp:basic_math</module>
</modules>
Expand Down
1 change: 1 addition & 0 deletions examples/nucleo_f429zi/cmsis_dsp/linear_interp/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
</collectors>
<modules>
<module>modm:build:scons</module>
<module>modm:build:make</module>
<module>modm:cmsis:dsp:fast_math</module>
</modules>
</library>
1 change: 1 addition & 0 deletions examples/nucleo_g071rb/custom_allocator/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
<module>modm:platform:gpio</module>
<module>modm:architecture:memory</module>
<module>modm:build:scons</module>
<module>modm:build:make</module>
</modules>
</library>
1 change: 1 addition & 0 deletions examples/rpi/blinky/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
</options>
<modules>
<module>modm:build:scons</module>
<module>modm:build:make</module>
</modules>
</library>
1 change: 1 addition & 0 deletions examples/samd/usbserial/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</options>
<modules>
<module>modm:build:scons</module>
<module>modm:build:make</module>
<module>modm:tinyusb</module>
<module>modm:processing:timer</module>
<module>modm:io</module>
Expand Down
1 change: 1 addition & 0 deletions examples/stm32f3_discovery/usb_dfu/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</options>
<modules>
<module>modm:build:scons</module>
<module>modm:build:make</module>
<module>modm:tinyusb</module>
<module>modm:processing:timer</module>
<module>modm:io</module>
Expand Down
1 change: 1 addition & 0 deletions examples/stm32f469_discovery/exceptions_rtti/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
<modules>
<module>modm:platform:gpio</module>
<module>modm:build:scons</module>
<module>modm:build:make</module>
</modules>
</library>
4 changes: 4 additions & 0 deletions examples/stm32f469_discovery/hard_fault/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ main()
#endif
MODM_LOG_ERROR << "firmware=" << modm::hex;
for (const auto data : FaultReporter::buildId()) MODM_LOG_ERROR << data;
MODM_LOG_ERROR << "\nor\n\tmake debug-coredump";
#ifdef MODM_DEBUG_BUILD
MODM_LOG_ERROR << " profile=debug";
#endif
MODM_LOG_ERROR << "\n\n";
for (const auto data : FaultReporter())
MODM_LOG_ERROR << modm::hex << data << modm::flush;
Expand Down
1 change: 1 addition & 0 deletions examples/stm32f469_discovery/hard_fault/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
<module>modm:platform:fault</module>
<module>modm:build:scons</module>
<module>modm:build:cmake</module>
<module>modm:build:make</module>
</modules>
</library>
38 changes: 26 additions & 12 deletions tools/scripts/examples_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
is_running_in_ci = (os.getenv("CIRCLECI") is not None or
os.getenv("TRAVIS") is not None or
os.getenv("GITHUB_ACTIONS") is not None)
is_running_on_windows = "Windows" in platform.platform()
build_dir = (Path(os.path.abspath(__file__)).parents[2] / "build")
cache_dir = build_dir / "cache"
global_options = {}
Expand Down Expand Up @@ -50,14 +51,16 @@ def build(project):
project_cfg = project.read_text()
commands = []
if ":build:scons" in project_cfg:
commands.append("scons build --cache-show --random")
if ":build:cmake" in project_cfg:
commands.append("make cmake && make build")
commands.append( ("scons build --cache-show --random", "SCons") )
if ":build:make" in project_cfg and not is_running_on_windows:
commands.append( ("make build", "Make") )
elif ":build:cmake" in project_cfg:
commands.append( ("make cmake && make build", "CMake") )

rcs = 0
for command in commands:
for command, build_system in commands:
output = ["=" * 90, "Building: {} with {}".format(
path / "main.cpp", "SCons" if "scons" in command else "CMake")]
path / "main.cpp", build_system)]
rc, ro = run_command(path, command)
rcs += rc
print("\n".join(output + [ro]))
Expand All @@ -66,13 +69,24 @@ def build(project):

def run(project):
path = project.parent
command = "scons run"
output = ["=" * 90, "Running: {} with {}".format(path / "main.cpp", "SCons" if "scons" in command else "CMake")]
rc, ro = run_command(path, command, all_output=True)
print("\n".join(output + [ro]))
if "CI: run fail" in project.read_text():
return None if not rc else project
return None if rc else project
project_cfg = project.read_text()
commands = []
if ":build:scons" in project_cfg:
commands.append( ("scons run", "SCons") )
if ":build:make" in project_cfg and not is_running_on_windows:
commands.append( ("make run", "Make") )

rcs = 0
for command, build_system in commands:
output = ["=" * 90, "Running: {} with {}".format(path / "main.cpp", build_system)]
rc, ro = run_command(path, command, all_output=True)
print("\n".join(output + [ro]))
if "CI: run fail" in project_cfg:
rcs += 0 if rc else 1
else:
rcs += rc

return None if rcs else project

def compile_examples(paths, jobs, split, part):
print("Using {}x parallelism".format(jobs))
Expand Down

0 comments on commit 236e27c

Please sign in to comment.