mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[build] rule_for now takes both "local" and "global" parameters
Previous the build would fail on macOS if you had an epsilon.elf file in at the root of the project. Indeed, the %.elf -> %.bin rule would get triggered, but this rule should only operate on generated (intermediate) elf file.
This commit is contained in:
committed by
LeaNumworks
parent
7d5cad32b1
commit
84f6b179de
@@ -8,15 +8,20 @@ define rule_label
|
||||
@ echo "$(shell printf "%-8s" $(strip $(1)))$(@:$(BUILD_DIR)/%=%)"
|
||||
endef
|
||||
|
||||
# rule_for can define both global and local rules
|
||||
# - use local if the source can be an intermediate file
|
||||
# - use global if the source can be in the main tree
|
||||
define rule_for
|
||||
ifeq ($(strip $(5)),with_local_version)
|
||||
ifneq ($(filter global,$(5)),)
|
||||
$(addprefix $$(BUILD_DIR)/,$(strip $(2))): $(strip $(3)) | $$$$(@D)/.
|
||||
@ echo "$(shell printf "%-8s" $(strip $(1)))$$(@:$$(BUILD_DIR)/%=%)"
|
||||
$(Q) $(4)
|
||||
endif
|
||||
ifneq ($(filter local,$(5)),)
|
||||
$(addprefix $$(BUILD_DIR)/,$(strip $(2))): $(addprefix $$(BUILD_DIR)/,$(strip $(3)))
|
||||
@ echo "$(shell printf "%-8s" $(strip $(1)))$$(@:$$(BUILD_DIR)/%=%)"
|
||||
$(Q) $(4)
|
||||
endif
|
||||
$(addprefix $$(BUILD_DIR)/,$(strip $(2))): $(strip $(3)) | $$$$(@D)/.
|
||||
@ echo "$(shell printf "%-8s" $(strip $(1)))$$(@:$$(BUILD_DIR)/%=%)"
|
||||
$(Q) $(4)
|
||||
endef
|
||||
|
||||
# Helper functions to work with variants
|
||||
|
||||
@@ -2,56 +2,62 @@
|
||||
|
||||
$(eval $(call rule_for, \
|
||||
AS, %.o, %.s, \
|
||||
$$(CC) $$(SFLAGS) -c $$< -o $$@ \
|
||||
$$(CC) $$(SFLAGS) -c $$< -o $$@, \
|
||||
global \
|
||||
))
|
||||
|
||||
$(eval $(call rule_for, \
|
||||
CC, %.o, %.c, \
|
||||
$$(CC) $$(CFLAGS) $$(SFLAGS) -c $$< -o $$@, \
|
||||
with_local_version \
|
||||
global local \
|
||||
))
|
||||
|
||||
$(eval $(call rule_for, \
|
||||
CPP, %, %.inc, \
|
||||
$$(CPP) -P $$< $$@ \
|
||||
$$(CPP) -P $$< $$@, \
|
||||
global \
|
||||
))
|
||||
|
||||
$(eval $(call rule_for, \
|
||||
CXX, %.o, %.cpp, \
|
||||
$$(CXX) $$(CXXFLAGS) $$(SFLAGS) -c $$< -o $$@, \
|
||||
with_local_version \
|
||||
global local \
|
||||
))
|
||||
|
||||
$(eval $(call rule_for, \
|
||||
DFUSE, %.dfu, %.elf, \
|
||||
$$(PYTHON) build/device/elf2dfu.py $$< $$@, \
|
||||
with_local_version \
|
||||
local \
|
||||
))
|
||||
|
||||
$(eval $(call rule_for, \
|
||||
OBJCOPY, %.hex, %.elf, \
|
||||
$$(OBJCOPY) -O ihex $$< $$@ \
|
||||
$$(OBJCOPY) -O ihex $$< $$@, \
|
||||
local \
|
||||
))
|
||||
|
||||
$(eval $(call rule_for, \
|
||||
OBJCOPY, %.bin, %.elf, \
|
||||
$$(OBJCOPY) -O binary $$< $$@, \
|
||||
with_local_version \
|
||||
local \
|
||||
))
|
||||
|
||||
$(eval $(call rule_for, \
|
||||
OCC, %.o, %.m, \
|
||||
$$(CC) $$(CFLAGS) $$(SFLAGS) -c $$< -o $$@ \
|
||||
$$(CC) $$(CFLAGS) $$(SFLAGS) -c $$< -o $$@, \
|
||||
global \
|
||||
))
|
||||
|
||||
$(eval $(call rule_for, \
|
||||
OCC, %.o, %.mm, \
|
||||
$$(CXX) $$(CXXFLAGS) $$(SFLAGS) -c $$< -o $$@ \
|
||||
$$(CXX) $$(CXXFLAGS) $$(SFLAGS) -c $$< -o $$@, \
|
||||
global \
|
||||
))
|
||||
|
||||
$(eval $(call rule_for, \
|
||||
WINDRES, %.o, %.rc, \
|
||||
$$(WINDRES) $$< -O coff -o $$@ \
|
||||
$$(WINDRES) $$< -O coff -o $$@, \
|
||||
global \
|
||||
))
|
||||
|
||||
ifdef EXE
|
||||
@@ -63,12 +69,14 @@ ifeq ($(OS),Windows_NT)
|
||||
# the linker to read its arguments from this file.
|
||||
$(eval $(call rule_for, \
|
||||
LD, %.$$(EXE), , \
|
||||
echo $$^ > $$@.objs && $$(LD) @$$@.objs $$(LDFLAGS) -o $$@ && rm $$@.objs \
|
||||
echo $$^ > $$@.objs && $$(LD) @$$@.objs $$(LDFLAGS) -o $$@ && rm $$@.objs, \
|
||||
global \
|
||||
))
|
||||
else
|
||||
$(eval $(call rule_for, \
|
||||
LD, %.$$(EXE), , \
|
||||
$$(LD) $$^ $$(LDFLAGS) -o $$@ \
|
||||
$$(LD) $$^ $$(LDFLAGS) -o $$@, \
|
||||
global \
|
||||
))
|
||||
endif
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user