From 3f62edcfc4af5d1e08a1c9638bb71ff175eed43e Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Wed, 16 Feb 2022 16:56:22 +0000 Subject: [PATCH] first stab at having all intermediate + binary files in a different folders - hopefully allow more than one build at the same time eventually --- Makefile | 43 ++++++++++++++++++++++++----------- bin/README.md | 1 + build/README.md | 1 + make/family/NRF52.make | 10 ++++---- make/misc/tensorflow.make | 2 +- scripts/get_makefile_decls.py | 4 ++-- 6 files changed, 40 insertions(+), 21 deletions(-) create mode 100644 bin/README.md create mode 100644 build/README.md diff --git a/Makefile b/Makefile index d4be09442..9e56f7c50 100755 --- a/Makefile +++ b/Makefile @@ -37,8 +37,9 @@ # CC3000=1 # If compiling for a non-linux target that has internet support, use CC3000 support # USB_PRODUCT_ID=0x1234 # force a specific USB Product ID (default 0x5740) # -# GENDIR=MyGenDir # sets directory for files generated during make -# # GENDIR=/home/mydir/mygendir +# GENDIR=MyGenDir # sets directory for intermediate files generated during make +# OBJDIR=MyObjDir # sets directory for object files generated during make +# BINDIR=MyBinDir # sets directory for binaries generated during make # SETDEFINES=FileDefines # settings which are called after definitions for board are done # # SETDEFINES=/home/mydir/myDefines # UNSUPPORTEDMAKE=FileUnsu# Adds additional files from unsupported sources(means not supported by Gordon) to actual make @@ -65,6 +66,12 @@ include make/sanitycheck.make ifndef GENDIR GENDIR=gen endif +ifndef OBJDIR +OBJDIR=obj +endif +ifndef BINDIR +BINDIR=bin +endif ifndef SINGLETHREAD MAKEFLAGS=-j5 # multicore @@ -172,9 +179,9 @@ endif # Get info out of BOARDNAME.py # --------------------------------------------------------------------------------- # TODO: could check board here and make clean if it's different? -$(shell rm -f CURRENT_BOARD.make) -$(shell python scripts/get_makefile_decls.py $(BOARD) > CURRENT_BOARD.make) -include CURRENT_BOARD.make +$(shell rm -f $(GENDIR)/CURRENT_BOARD.make) +$(shell python scripts/get_makefile_decls.py $(BOARD) > $(GENDIR)/CURRENT_BOARD.make) +include $(GENDIR)/CURRENT_BOARD.make #set or reset defines like USE_GRAPHIC from an external file to customize firmware ifdef SETDEFINES @@ -668,7 +675,13 @@ PININFOFILE=$(GENDIR)/jspininfo SOURCES += $(PININFOFILE).c SOURCES += $(WRAPPERSOURCES) $(TARGETSOURCES) -SOURCEOBJS = $(SOURCES:.c=.o) $(CPPSOURCES:.cpp=.o) $(CCSOURCES:.cc=.o) +SOURCEOBJS = $(patsubst %.c,$(OBJDIR)/%.o,$(SOURCES)) +ifdef CPPSOURCES +SOURCEOBJS += $(patsubst %.cpp,$(OBJDIR)/%.cpp.o,$(CPPSOURCES)) +endif +ifdef CCSOURCES +SOURCEOBJS += $(patsubst %.cc,$(OBJDIR)/%.cc.o,$(CCSOURCES)) +endif OBJS = $(PRECOMPILED_OBJS) $(SOURCEOBJS) @@ -795,25 +808,30 @@ quiet_link= LD $@ quiet_obj_dump= GEN $(PROJ_NAME).lst quiet_obj_to_bin= GEN $(PROJ_NAME).$2 -%.o: %.c $(PLATFORM_CONFIG_FILE) $(PININFOFILE).h +$(OBJDIR)/%.o: %.c $(PLATFORM_CONFIG_FILE) $(PININFOFILE).h @echo $($(quiet_)compile) + @mkdir -p $(shell dirname $@) # create directory if it doesn't exist @$(call compile) -.cc.o: %.cc $(PLATFORM_CONFIG_FILE) $(PININFOFILE).h +$(OBJDIR)/%.cc.o: %.cc $(PLATFORM_CONFIG_FILE) $(PININFOFILE).h @echo $($(quiet_)compile) + @mkdir -p $(shell dirname $@) # create directory if it doesn't exist @$(CC) $(CCFLAGS) $(CFLAGS) $< -o $@ -.cpp.o: $(PLATFORM_CONFIG_FILE) $(PININFOFILE).h +$(OBJDIR)/%.cpp.o: $(PLATFORM_CONFIG_FILE) $(PININFOFILE).h @echo $($(quiet_)compile) + @mkdir -p $(shell dirname $@) # create directory if it doesn't exist @$(call compile) # case sensitive - Nordic's files are capitals -.s.o: +$(OBJDIR)/%.s.o: @echo $($(quiet_)compile) + @mkdir -p $(shell dirname $@) # create directory if it doesn't exist @$(call compile) -.S.o: +$(OBJDIR)/%.S.o: @echo $($(quiet_)compile) + @mkdir -p $(shell dirname $@) # create directory if it doesn't exist @$(call compile) ifdef LINUX # --------------------------------------------------- @@ -832,8 +850,7 @@ lst: $(PROJ_NAME).lst clean: @echo Cleaning targets - $(Q)find . -name \*.o | grep -v "./arm-bcm2708\|./gcc-arm-none-eabi" | xargs rm -f - $(Q)find . -name \*.d | grep -v "./arm-bcm2708\|./gcc-arm-none-eabi" | xargs rm -f + $(Q)rm -rf $(OBJDIR)/* $(Q)rm -f $(ROOT)/gen/*.c $(ROOT)/gen/*.h $(ROOT)/gen/*.ld $(Q)rm -f $(ROOT)/scripts/*.pyc $(ROOT)/boards/*.pyc $(Q)rm -f $(PROJ_NAME).elf diff --git a/bin/README.md b/bin/README.md new file mode 100644 index 000000000..bdc6c1ee1 --- /dev/null +++ b/bin/README.md @@ -0,0 +1 @@ +This is where built binaries go diff --git a/build/README.md b/build/README.md new file mode 100644 index 000000000..ad08bd1a0 --- /dev/null +++ b/build/README.md @@ -0,0 +1 @@ +Intermediate build files end up here diff --git a/make/family/NRF52.make b/make/family/NRF52.make index b2e8c7f8a..5c0e532b0 100644 --- a/make/family/NRF52.make +++ b/make/family/NRF52.make @@ -12,7 +12,7 @@ ifdef NRF_SDK17 # Use SDK17 NRF5X_SDK=17 NRF5X_SDK_17=1 -NRF5X_SDK_PATH=$(ROOT)/targetlibs/nrf5x_17 +NRF5X_SDK_PATH=targetlibs/nrf5x_17 DEFINES += -DNRF_SD_BLE_API_VERSION=7 DEFINES += -D__HEAP_SIZE=0 ifeq ($(CHIP),NRF52840) @@ -29,7 +29,7 @@ ifdef NRF_SDK15 # Use SDK15 NRF5X_SDK=15 NRF5X_SDK_15=1 -NRF5X_SDK_PATH=$(ROOT)/targetlibs/nrf5x_15 +NRF5X_SDK_PATH=targetlibs/nrf5x_15 DEFINES += -DNRF_SD_BLE_API_VERSION=6 DEFINES += -D__HEAP_SIZE=0 ifeq ($(CHIP),NRF52840) @@ -48,7 +48,7 @@ ifdef NRF_SDK14 # Use SDK14 NRF5X_SDK=14 NRF5X_SDK_14=1 -NRF5X_SDK_PATH=$(ROOT)/targetlibs/nrf5x_14 +NRF5X_SDK_PATH=targetlibs/nrf5x_14 DEFINES += -DNRF_SD_BLE_API_VERSION=5 DEFINES += -D__HEAP_SIZE=0 ifeq ($(CHIP),NRF52840) @@ -61,14 +61,14 @@ ifdef NRF_SDK11 # Use SDK11 NRF5X_SDK=11 NRF5X_SDK_11=1 -NRF5X_SDK_PATH=$(ROOT)/targetlibs/nrf5x_11 +NRF5X_SDK_PATH=targetlibs/nrf5x_11 DEFINES += -DNRF_SD_BLE_API_VERSION=2 SOFTDEVICE = $(SOFTDEVICE_PATH)/hex/s132_nrf52_2.0.0_softdevice.hex else # Use SDK12 NRF5X_SDK=12 NRF5X_SDK_12=1 -NRF5X_SDK_PATH=$(ROOT)/targetlibs/nrf5x_12 +NRF5X_SDK_PATH=targetlibs/nrf5x_12 DEFINES += -DNRF_SD_BLE_API_VERSION=3 SOFTDEVICE = $(SOFTDEVICE_PATH)/hex/s132_nrf52_3.1.0_softdevice.hex endif diff --git a/make/misc/tensorflow.make b/make/misc/tensorflow.make index fc496d344..6647ae03f 100644 --- a/make/misc/tensorflow.make +++ b/make/misc/tensorflow.make @@ -1,4 +1,4 @@ -TENSOR_ROOT := $(ROOT)/libs/tensorflow +TENSOR_ROOT := libs/tensorflow CCSOURCES += \ $(TENSOR_ROOT)/tensorflow/lite/micro/simple_memory_allocator.cc \ $(TENSOR_ROOT)/tensorflow/lite/micro/memory_helpers.cc \ diff --git a/scripts/get_makefile_decls.py b/scripts/get_makefile_decls.py index e8a792bf0..ece333c1b 100644 --- a/scripts/get_makefile_decls.py +++ b/scripts/get_makefile_decls.py @@ -53,7 +53,7 @@ if binaryName.find('.bin')>=0: binaryName = binaryName[:binaryName.find('.bin')] if binaryName.find('.hex')>=0: binaryName = binaryName[:binaryName.find('.hex')] -print("PROJ_NAME="+binaryName) +print("PROJ_NAME=$(BINDIR)/"+binaryName) if board.chip["family"]!="LINUX": print("EMBEDDED=1") @@ -76,5 +76,5 @@ if 'USB' in board.devices: if 'bootloader' in board.info and board.info['bootloader']==1: print("USE_BOOTLOADER:=1") - print("BOOTLOADER_PROJ_NAME:=bootloader_$(PROJ_NAME)") + print("BOOTLOADER_PROJ_NAME:=$(BINDIR)/bootloader_"+binaryName) print("DEFINES+=-DUSE_BOOTLOADER")