-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7654 from cladmi/pr/arduino_sketches.cpp
arduino/sketches: build sketches as a module
- Loading branch information
Showing
4 changed files
with
57 additions
and
37 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 |
---|---|---|
@@ -1,9 +1,15 @@ | ||
# compile together the Arduino sketches of the application | ||
SKETCHES = $(wildcard $(APPDIR)/*.sketch) | ||
SRCDIR = $(RIOTBASE)/sys/arduino | ||
# Add Arduino sketches to the application as a module | ||
|
||
# run the Arduino pre-build script | ||
$(shell $(RIOTTOOLS)/arduino/pre_build.sh $(SRCDIR) $(APPDIR) $(SKETCHES)) | ||
# Define application sketches module, it will be generated into $(BINDIR) | ||
SKETCH_MODULE ?= arduino_sketches | ||
SKETCH_MODULE_DIR ?= $(BINDIR)/$(SKETCH_MODULE) | ||
SKETCHES = $(wildcard $(APPDIR)/*.sketch) | ||
include $(RIOTBASE)/sys/arduino/sketches.inc.mk | ||
|
||
# Depends on module | ||
USEMODULE += $(SKETCH_MODULE) | ||
DIRS += $(SKETCH_MODULE_DIR) | ||
BUILDDEPS += $(SKETCH_GENERATED_FILES) | ||
|
||
# include the Arduino headers | ||
INCLUDES += -I$(RIOTBASE)/sys/arduino/include |
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
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,34 @@ | ||
# Compile together the Arduino sketches of the application | ||
# They are declared a as new module $(SKETCH_MODULE) in $(SKETCH_MODULE_DIR) | ||
|
||
ifndef SKETCH_MODULE | ||
$(error SKETCH_MODULE undefined. It should be defined to the sketches module name) | ||
endif | ||
ifndef SKETCH_MODULE_DIR | ||
$(error SKETCH_MODULE_DIR undefined. It should be defined to the sketches module directory) | ||
endif | ||
ifndef SKETCHES | ||
$(error SKETCHES undefined. It should be defined to the list of sketches files) | ||
endif | ||
|
||
SNIPDIR = $(RIOTBASE)/sys/arduino | ||
SKETCHES_ALL = $(SNIPDIR)/pre.snip $(SKETCHES) $(SNIPDIR)/post.snip | ||
SKETCH_CPP ?= arduino_sketches.cpp | ||
SKETCH_GENERATED_FILES = $(SKETCH_MODULE_DIR)/Makefile $(SKETCH_MODULE_DIR)/$(SKETCH_CPP) | ||
|
||
# Building the module files | ||
# Do not use $^ in receipes as Makefile is also a prerequisite | ||
$(SKETCH_MODULE_DIR)/Makefile: $(SKETCH_MODULE_DIR)/$(SKETCH_CPP) | ||
$(Q)echo 'SRCXX = $(SKETCH_CPP)' > $@ | ||
$(Q)echo 'include $$(RIOTBASE)/Makefile.base' >> $@ | ||
$(SKETCH_MODULE_DIR)/$(SKETCH_CPP): $(SKETCHES_ALL) | ||
@mkdir -p $(@D) | ||
$(Q)cat $(SKETCHES_ALL) > $@ | ||
|
||
# Make everything rebuild if current makefile changes | ||
_ARDUINO_SKETCHES_MAKEFILE := $(lastword $(MAKEFILE_LIST)) | ||
$(SKETCH_MODULE_DIR)/$(SKETCH_CPP): $(_ARDUINO_SKETCHES_MAKEFILE) | ||
$(SKETCH_MODULE_DIR)/Makefile: $(_ARDUINO_SKETCHES_MAKEFILE) | ||
|
||
# HACK Rebuild cpp files everytime in case one of the `SKETCHES` is deleted | ||
$(SKETCH_MODULE_DIR)/$(SKETCH_CPP): FORCE |