-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
81 lines (65 loc) · 2.21 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Copyright (C) 2024 Toitware ApS.
# Use of this source code is governed by a Zero-Clause BSD license that can
# be found in the LICENSE file.
SOURCE_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
SHELL := bash
.SHELLFLAGS += -e
# Change to your configuration. See toit/toolchains for the available targets.
# Then run 'make init'.
IDF_TARGET := esp32
# Set to false to avoid initializing submodules at every build.
INITIALIZE_SUBMODULES := true
# A semicolon-separated list of directories that contain components
# and external libraries.
COMPONENTS := $(SOURCE_DIR)/components
# Constants that typically don't need to be changed.
BUILD_ROOT := $(SOURCE_DIR)/build-root
BUILD_PATH := $(SOURCE_DIR)/build
TOIT_ROOT := $(SOURCE_DIR)/toit
IDF_PATH := $(TOIT_ROOT)/third_party/esp-idf
IDF_PY := $(IDF_PATH)/tools/idf.py
all: esp32
define toit-make
@$(MAKE) -C "$(BUILD_ROOT)" \
COMPONENTS=$(COMPONENTS) \
BUILD_PATH=$(BUILD_PATH) \
TOIT_ROOT=$(TOIT_ROOT) \
IDF_TARGET=$(IDF_TARGET) \
IDF_PATH=$(IDF_PATH) \
IDF_PY=$(IDF_PY) \
$(1)
endef
.PHONY: initialize-submodules
initialize-submodules:
@if [[ "$(INITIALIZE_SUBMODULES)" == "true" ]]; then \
echo "Initializing submodules"; \
pushd toit && git submodule update --init --recursive && popd; \
fi
.PHONY: host
host: initialize-submodules
@$(call toit-make,build-host)
.PHONY: build-host
build-host: host
.PHONY: esp32
esp32: initialize-submodules
@if [[ ! -f $(BUILD_ROOT)/sdkconfig.defaults ]]; then \
echo "Run 'make init' first"; \
exit 1; \
fi
@$(call toit-make,esp32)
.PHONY: menuconfig
menuconfig: initialize-submodules
@$(call toit-make,menuconfig)
.PHONY: clean
clean:
@$(call toit-make,clean)
.PHONY: init
init: $(BUILD_ROOT)/sdkconfig.defaults $(BUILD_ROOT)/partitions.csv
$(BUILD_ROOT)/sdkconfig.defaults: initialize-submodules
@cp $(TOIT_ROOT)/toolchains/$(IDF_TARGET)/sdkconfig.defaults $@
$(BUILD_ROOT)/partitions.csv: initialize-submodules
@cp $(TOIT_ROOT)/toolchains/$(IDF_TARGET)/partitions.csv $@
.PHONY: diff
diff:
@diff -U0 --color $(TOIT_ROOT)/toolchains/$(IDF_TARGET)/sdkconfig.defaults $(BUILD_ROOT)/sdkconfig.defaults || true
@diff -U0 --color $(TOIT_ROOT)/toolchains/$(IDF_TARGET)/partitions.csv $(BUILD_ROOT)/partitions.csv || true