-
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.
TODO Add run instructions to README - Include compile and flash targets
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
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,50 @@ | ||
# Allow the user to specify different values for 'PROFILE' and 'TOOLCHAIN' | ||
PROFILE?=develop | ||
TOOLCHAIN?=GCC_ARM | ||
|
||
# Parse setup.yml to determine the build target | ||
TARGET := $(shell grep -Po '(^\s+target:\s+)\K.+' setup.yml) | ||
# Check that a value for 'target' was found in setup.yml | ||
ifndef TARGET | ||
$(error Did not find a value for 'target' in setup.yml) | ||
endif | ||
BUILD_DIR := cmake_build/$(TARGET)/$(PROFILE)/$(TOOLCHAIN) | ||
BINARY := embedded-mbed.bin | ||
# Search for files matching *.{cpp,h}, but don't search mbed-os/ or cmake_build/ | ||
SOURCES := $(shell find . -type d \( -path ./mbed-os -o -path ./cmake_build \) -prune -o -type f -regex '.*\.\(cpp\|h\)' -print) | ||
|
||
|
||
.PHONY: flash | ||
flash: mountpoint compile | ||
cp $(BUILD_DIR)/$(BINARY) $(MOUNTPOINT) | ||
|
||
.PHONY: compile | ||
compile: $(BUILD_DIR)/$(BINARY) | ||
|
||
$(BUILD_DIR)/$(BINARY): $(BUILD_DIR)/mbed_config.cmake setup.yml tests.yml CMakeLists.txt parseConfigs.py $(SOURCES) | ||
./parseConfigs.py | ||
cmake -S . -B $(BUILD_DIR) -GNinja | ||
cmake --build $(BUILD_DIR) | ||
|
||
.PHONY: configure | ||
configure: $(BUILD_DIR)/mbed_config.cmake | ||
|
||
$(BUILD_DIR)/mbed_config.cmake: mbed-os mbed_app.json | ||
mbed-tools configure -t $(TOOLCHAIN) -m $(TARGET) | ||
|
||
.PHONY: deploy | ||
deploy: mbed-os | ||
|
||
mbed-os: mbed-os.lib | ||
mbed-tools deploy | ||
|
||
# Check that MOUNTPOINT was defined as a CLA | ||
.PHONY: mountpoint | ||
mountpoint: | ||
ifndef MOUNTPOINT | ||
$(error variable 'MOUNTPOINT' not set) | ||
endif | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf cmake_build/ mbed-os/ definitions.h |