forked from RIOT-OS/RIOT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
arduino/sketches: build sketches as a module
Generate a module for arduino sketches in a subfolder of BINDIR. This prevents issues when doing concurrent builds or out of tree build with readonly sources. This fixes RIOT-OS#5848
- Loading branch information
Showing
3 changed files
with
38 additions
and
30 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Compile together the Arduino sketches of the application | ||
# They are declared a as new module in BINDIR | ||
SKETCHES = $(wildcard $(APPDIR)/*.sketch) | ||
# Head and tail for sketches outfile | ||
SNIPDIR = $(RIOTBASE)/sys/arduino | ||
SKETCHES_ALL = $(SNIPDIR)/pre.snip $(SKETCHES) $(SNIPDIR)/post.snip | ||
# Sketch module name and location | ||
SKETCH_MODULE ?= arduino_sketches | ||
SKETCH_MOD_DIR ?= $(BINDIR)/$(SKETCH_MODULE) | ||
SKETCH_CPP ?= $(APPLICATION)_sketches.cpp | ||
# Add dependency to the sketches module | ||
# Use `link` target to execute it before application makefile | ||
link: ..sketches_module | ||
USEMODULE += $(SKETCH_MODULE) | ||
DIRS += $(SKETCH_MOD_DIR) | ||
.PHONY: ..sketches_module | ||
..sketches_module: $(SKETCH_MOD_DIR)/$(SKETCH_CPP) $(SKETCH_MOD_DIR)/Makefile | ||
# Building the module files | ||
$(SKETCH_MOD_DIR)/$(SKETCH_CPP): $(SKETCHES_ALL) | $(SKETCH_MOD_DIR) | ||
@# Do not use $^ as Makefile is also a prerequisite | ||
$(Q)cat $(SKETCHES_ALL) > $@ | ||
$(SKETCH_MOD_DIR)/Makefile: | $(SKETCH_MOD_DIR) | ||
$(Q)echo 'SRCXX = $(SKETCH_CPP)' > $@ | ||
$(Q)echo 'include $$(RIOTBASE)/Makefile.base' >> $@ | ||
$(SKETCH_MOD_DIR): | ||
@mkdir -p $@ | ||
# Make everything rebuild if current makefile changes | ||
CURMK = $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) | ||
$(SKETCH_MOD_DIR)/$(SKETCH_CPP): $(CURMK) | ||
$(SKETCH_MOD_DIR)/Makefile: $(CURMK) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
# compile together the Arduino sketches of the application | ||
SKETCHES = $(wildcard $(APPDIR)/*.sketch) | ||
SRCDIR = $(RIOTBASE)/sys/arduino | ||
|
||
# run the Arduino pre-build script | ||
$(shell $(RIOTBASE)/dist/tools/arduino/pre_build.sh $(SRCDIR) $(APPDIR) $(SKETCHES)) | ||
# Add Arduino sketches to the application as a module | ||
include $(RIOTBASE)/sys/arduino/Makefile.arduino_sketches.ink | ||
|
||
# include the Arduino headers | ||
INCLUDES += -I$(RIOTBASE)/sys/arduino/include |