[scripts] Use BUILD_DIR instead of build_dir

This commit is contained in:
Romain Goyet
2019-03-05 22:03:05 +01:00
committed by LeaNumworks
parent ef3f5b877c
commit 0c83253d2e
9 changed files with 32 additions and 31 deletions

2
.gitignore vendored
View File

@@ -1,4 +1,4 @@
# Quiz output
quiz/src/symbols.c
outputs
build

View File

@@ -3,23 +3,22 @@ include scripts/config.mak
# Disable default Make rules
.SUFFIXES:
build_dir = build
object_for = $(addprefix $(build_dir)/,$(addsuffix .o,$(basename $(1))))
object_for = $(addprefix $(BUILD_DIR)/,$(addsuffix .o,$(basename $(1))))
default: $(build_dir)/epsilon.$(EXE)
default: $(BUILD_DIR)/epsilon.$(EXE)
# Define a standard rule helper
# If passed a last parameter value of with_local_version, we also define an
# extra rule that can build source files within the $(build_dir). This is useful
# extra rule that can build source files within the $(BUILD_DIR). This is useful
# for rules that can be applied for intermediate objects (for example, when
# going .png -> .cpp -> .o).
define rule_for
$(addprefix $$(build_dir)/,$(strip $(2))): $(strip $(3)) | $$$$(@D)/.
@ echo "$(shell printf "%-8s" $(strip $(1)))$$(@:$$(build_dir)/%=%)"
$(addprefix $$(BUILD_DIR)/,$(strip $(2))): $(strip $(3)) | $$$$(@D)/.
@ echo "$(shell printf "%-8s" $(strip $(1)))$$(@:$$(BUILD_DIR)/%=%)"
$(Q) $(4)
ifeq ($(strip $(5)),with_local_version)
$(addprefix $$(build_dir)/,$(strip $(2))): $(addprefix $$(build_dir)/,$(strip $(3)))
@ echo "$(shell printf "%-8s" $(strip $(1)))$$(@:$$(build_dir)/%=%)"
$(addprefix $$(BUILD_DIR)/,$(strip $(2))): $(addprefix $$(BUILD_DIR)/,$(strip $(3)))
@ echo "$(shell printf "%-8s" $(strip $(1)))$$(@:$$(BUILD_DIR)/%=%)"
$(Q) $(4)
endif
endef
@@ -37,8 +36,8 @@ info:
# "output/foo/bar.o" because the directory "output/foo" doesn't exist).
# We need to mark those directories as precious, otherwise Make will try to get
# rid of them upon completion (and fail, since those folders won't be empty).
.PRECIOUS: $(build_dir)/. $(build_dir)%/.
$(build_dir)/. $(build_dir)%/.:
.PRECIOUS: $(BUILD_DIR)/. $(BUILD_DIR)%/.
$(BUILD_DIR)/. $(BUILD_DIR)%/.:
$(Q) mkdir -p $(dir $@)
# To make objects dependent on their directory, we need a second expansion
@@ -75,8 +74,8 @@ objs = $(call object_for,$(src))
-include $(objs:.o=.d)
.SECONDARY: $(objs)
$(build_dir)/epsilon.$(EXE): $(objs)
$(build_dir)/test.$(EXE): $(objs)
$(BUILD_DIR)/epsilon.$(EXE): $(objs)
$(BUILD_DIR)/test.$(EXE): $(objs)
# Define standard compilation rules
@@ -105,7 +104,7 @@ $(eval $(call rule_for, \
.PHONY: clean
clean:
@echo "CLEAN"
$(Q) rm -rf $(build_dir)
$(Q) rm -rf $(BUILD_DIR)
.PHONY: cowsay_%
cowsay_%:

View File

@@ -47,7 +47,7 @@ $(call object_for,apps/apps_container_storage.cpp apps/main.cpp): CXXFLAGS += $(
# I18n file generation
# The header is refered to as <apps/i18n.h> so make sure it's findable this way
SFLAGS += -I$(build_dir)
SFLAGS += -I$(BUILD_DIR)
i18n_files += $(addprefix apps/language_,$(addsuffix .universal.i18n, $(EPSILON_I18N)))
i18n_files += $(addprefix apps/,\
@@ -81,9 +81,9 @@ $(eval $(call rule_for, \
# by the object_for function.
app_src += apps/i18n.py
$(build_dir)/apps/i18n.h: $(build_dir)/apps/i18n.cpp
$(BUILD_DIR)/apps/i18n.h: $(BUILD_DIR)/apps/i18n.cpp
$(call object_for,$(app_src)): $(build_dir)/apps/i18n.h
$(call object_for,$(app_src)): $(BUILD_DIR)/apps/i18n.h
# Handle PNG files
@@ -96,8 +96,8 @@ $(eval $(call depends_on_image,apps/title_bar_view.cpp,apps/exam_icon.png))
# As a shortcut, we simply say that every app file depends on every image. In
# practice, this forces all the images to be before the app.
#app_image_objs := $(build_dir)/$(app_images:.png=.o)
#.SECONDARY: $(build_dir)/$(app_images:.png=.cpp)
#app_image_objs := $(BUILD_DIR)/$(app_images:.png=.o)
#.SECONDARY: $(BUILD_DIR)/$(app_images:.png=.cpp)
#$(app_objs): $(app_image_objs)
#app_image_src := $(app_images:.png=.cpp)

View File

@@ -95,9 +95,9 @@ $(eval $(call rule_for, \
$$(HOSTCC) -std=c99 `libpng-config --cflags` $$^ `libpng-config --ldflags` -o $$@ \
))
INLINER := $(build_dir)/escher/image/inliner
INLINER := $(BUILD_DIR)/escher/image/inliner
.PRECIOUS: $(build_dir)/%.h $(build_dir)/%.cpp
.PRECIOUS: $(BUILD_DIR)/%.h $(BUILD_DIR)/%.cpp
$(eval $(call rule_for, \
INLINER, \
%.h %.cpp, \

View File

@@ -41,10 +41,10 @@ src += $(addprefix ion/src/device/, \
ifneq ($(DEBUG),1)
ifneq ($(COMPILER),llvm)
$(build_dir)/ion/src/device/led.o: SFLAGS+=-O3
$(build_dir)/ion/src/device/console.o: SFLAGS+=-O3
$(build_dir)/ion/src/device/display.o: SFLAGS+=-O3
$(build_dir)/ion/src/device/swd.o: SFLAGS+=-O3
$(BUILD_DIR)/ion/src/device/led.o: SFLAGS+=-O3
$(BUILD_DIR)/ion/src/device/console.o: SFLAGS+=-O3
$(BUILD_DIR)/ion/src/device/display.o: SFLAGS+=-O3
$(BUILD_DIR)/ion/src/device/swd.o: SFLAGS+=-O3
endif
endif

View File

@@ -52,8 +52,8 @@ dfu_src += ion/src/device/base64.cpp
dfu_src += ion/src/device/flash.cpp
dfu_src += ion/src/device/timing.cpp
$(build_dir)/ion/src/device/usb/dfu.elf: LDSCRIPT = ion/src/device/usb/dfu.ld
$(build_dir)/ion/src/device/usb/dfu.elf: $(call object_for,$(usb_src)) $(call object_for,$(dfu_src))
$(BUILD_DIR)/ion/src/device/usb/dfu.elf: LDSCRIPT = ion/src/device/usb/dfu.ld
$(BUILD_DIR)/ion/src/device/usb/dfu.elf: $(call object_for,$(usb_src)) $(call object_for,$(dfu_src))
# This command embeds a binary file into an object one.
# This allows us to embed standalone code (the dfu routines) into the final
@@ -62,7 +62,7 @@ $(build_dir)/ion/src/device/usb/dfu.elf: $(call object_for,$(usb_src)) $(call ob
# and end), but prefixes them with a mangled file path. To have consistent names
# we simply "cd" into the directory. This assumes input and output lives in the
# same directory.
$(build_dir)/ion/src/device/usb/dfu.o: $(build_dir)/ion/src/device/usb/dfu.bin
$(BUILD_DIR)/ion/src/device/usb/dfu.o: $(BUILD_DIR)/ion/src/device/usb/dfu.bin
@echo "OBJCOPY $@"
$(Q) cd $(dir $<) ; $(OBJCOPY) -I binary -O elf32-littlearm -B arm --rename-section .data=.rodata --redefine-sym _binary_dfu_bin_start=_dfu_bootloader_flash_start --redefine-sym _binary_dfu_bin_end=_dfu_bootloader_flash_end $(notdir $<) $(notdir $@)

View File

@@ -41,7 +41,7 @@ $(eval $(call rule_for, \
$$(HOSTCC) $$(RASTERIZER_CFLAGS) $$^ $$(RASTERIZER_LDFLAGS) -o $$@ \
))
RASTERIZER := $(build_dir)/kandinsky/fonts/rasterizer
RASTERIZER := $(BUILD_DIR)/kandinsky/fonts/rasterizer
$(eval $(call rule_for, \
RASTER, \

View File

@@ -1,6 +1,6 @@
SFLAGS += -Ipython/src
SFLAGS += -Ipython/port
SFLAGS += -I$(build_dir)/python/port
SFLAGS += -I$(BUILD_DIR)/python/port
# How to maintain this Makefile
# - Copy PY_CORE_O_BASENAME from py.mk into py_objs
@@ -177,6 +177,6 @@ $(eval $(call rule_for, \
$$(PYTHON) python/src/py/makeqstrdata.py $$< > $$@ \
))
$(call object_for,$(python_src)): $(build_dir)/python/port/genhdr/qstrdefs.generated.h
$(call object_for,$(python_src)): $(BUILD_DIR)/python/port/genhdr/qstrdefs.generated.h
src += $(python_src)

View File

@@ -33,3 +33,5 @@ ifeq ("$(origin V)", "command line")
Q=
endif
endif
BUILD_DIR = build/$(PLATFORM)