From 0c83253d2ef0db48fbb6c2dcfc30e53c0af08ed6 Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Tue, 5 Mar 2019 22:03:05 +0100 Subject: [PATCH] [scripts] Use BUILD_DIR instead of build_dir --- .gitignore | 2 +- Makefile | 25 ++++++++++++------------- apps/Makefile | 10 +++++----- escher/Makefile | 4 ++-- ion/src/device/Makefile | 8 ++++---- ion/src/device/usb/Makefile | 6 +++--- kandinsky/Makefile | 2 +- python/Makefile | 4 ++-- scripts/defaults.mak | 2 ++ 9 files changed, 32 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index 2e261bfd8..a49e8c8c0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ # Quiz output quiz/src/symbols.c -outputs +build diff --git a/Makefile b/Makefile index 0be03da61..4c145c3b0 100644 --- a/Makefile +++ b/Makefile @@ -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_%: diff --git a/apps/Makefile b/apps/Makefile index 3b247ce34..d47845f1a 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -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 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) diff --git a/escher/Makefile b/escher/Makefile index 9f0607e99..91799fdf4 100644 --- a/escher/Makefile +++ b/escher/Makefile @@ -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, \ diff --git a/ion/src/device/Makefile b/ion/src/device/Makefile index ca71adb6c..d40d8aa51 100644 --- a/ion/src/device/Makefile +++ b/ion/src/device/Makefile @@ -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 diff --git a/ion/src/device/usb/Makefile b/ion/src/device/usb/Makefile index eb539a3ad..3aaa4c5ac 100644 --- a/ion/src/device/usb/Makefile +++ b/ion/src/device/usb/Makefile @@ -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 $@) diff --git a/kandinsky/Makefile b/kandinsky/Makefile index 7e7ab6a48..9705de6fe 100644 --- a/kandinsky/Makefile +++ b/kandinsky/Makefile @@ -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, \ diff --git a/python/Makefile b/python/Makefile index ee277e8d6..1072474dd 100644 --- a/python/Makefile +++ b/python/Makefile @@ -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) diff --git a/scripts/defaults.mak b/scripts/defaults.mak index e7b364888..467083951 100644 --- a/scripts/defaults.mak +++ b/scripts/defaults.mak @@ -33,3 +33,5 @@ ifeq ("$(origin V)", "command line") Q= endif endif + +BUILD_DIR = build/$(PLATFORM)