From 3ca025f214cdfb5b9815fd20e9443be1ad365e0e Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sun, 15 Jul 2012 09:59:35 +0000 Subject: [PATCH] Add DEBUG_FORMAT and DEBUG_LEVEL optional parameters to the BUILD module. Turn off generation of debug information when performing a validation build, and when running the build tests. --- BuildTests/BoardDriverTest/makefile.test | 1 + BuildTests/BootloaderTest/makefile | 2 +- BuildTests/ModuleTest/makefile.test | 1 + BuildTests/SingleUSBModeTest/makefile.test | 1 + LUFA/Build/lufa_build.mk | 32 ++++++++++++++-------- LUFA/DoxygenPages/BuildSystem.txt | 10 ++++++- Maintenance/makefile | 2 +- 7 files changed, 35 insertions(+), 14 deletions(-) diff --git a/BuildTests/BoardDriverTest/makefile.test b/BuildTests/BoardDriverTest/makefile.test index ea2c8368dd..234add1a37 100644 --- a/BuildTests/BoardDriverTest/makefile.test +++ b/BuildTests/BoardDriverTest/makefile.test @@ -19,6 +19,7 @@ TARGET = Test SRC = $(TARGET).c LUFA_PATH = ../../LUFA CC_FLAGS = -Werror +DEBUG_LEVEL = 0 # Include LUFA build script makefiles include $(LUFA_PATH)/Build/lufa_build.mk \ No newline at end of file diff --git a/BuildTests/BootloaderTest/makefile b/BuildTests/BootloaderTest/makefile index 7b6b5d0bd3..e3f60d77ad 100644 --- a/BuildTests/BootloaderTest/makefile +++ b/BuildTests/BootloaderTest/makefile @@ -46,7 +46,7 @@ testbootloaders: printf "Found '%s' bootloader configuration (FLASH: %3s KB | BOOT: %3s KB | MCU: %12s / %4s)\n" $$build_bootloader $$build_flashsize $$build_bootsize $$build_mcu $$build_arch; \ \ printf "\t@echo Building bootloader %s - %s - FLASH: %s KB, BOOT: %s KB\n" $$build_bootloader $$build_mcu $$build_flashsize $$build_bootsize >> BuildMakefile; \ - printf "\t$(MAKE) -C $(patsubst %/,%,$(LUFA_PATH))/../Bootloaders/%s/ clean elf ARCH=%s MCU=%s BOARD=%s FLASH_SIZE_KB=%s BOOT_SECTION_SIZE_KB=%s\n\n" $$build_bootloader $$build_arch $$build_mcu $$build_board $$build_flashsize $$build_bootsize >> BuildMakefile; \ + printf "\t$(MAKE) -C $(patsubst %/,%,$(LUFA_PATH))/../Bootloaders/%s/ clean elf ARCH=%s MCU=%s BOARD=%s FLASH_SIZE_KB=%s BOOT_SECTION_SIZE_KB=%s DEBUG_LEVEL=0\n\n" $$build_bootloader $$build_arch $$build_mcu $$build_board $$build_flashsize $$build_bootsize >> BuildMakefile; \ fi; \ done < BootloaderDeviceMap.cfg diff --git a/BuildTests/ModuleTest/makefile.test b/BuildTests/ModuleTest/makefile.test index b61c42b525..b01998f4be 100644 --- a/BuildTests/ModuleTest/makefile.test +++ b/BuildTests/ModuleTest/makefile.test @@ -17,6 +17,7 @@ OPTIMIZATION = 1 TARGET = Test SRC = $(TARGET)_C.c $(TARGET)_CPP.cpp Dummy.S $(LUFA_SRC_USB) LUFA_PATH = ../../LUFA +DEBUG_LEVEL = 0 ifeq ($(ARCH), AVR8) F_USB = 8000000 diff --git a/BuildTests/SingleUSBModeTest/makefile.test b/BuildTests/SingleUSBModeTest/makefile.test index 4d8ddc5f89..800e3c3a65 100644 --- a/BuildTests/SingleUSBModeTest/makefile.test +++ b/BuildTests/SingleUSBModeTest/makefile.test @@ -13,6 +13,7 @@ MCU = ARCH = BOARD = NONE F_CPU = $(F_USB) +DEBUG_LEVEL = 0 ifeq ($(ARCH), AVR8) F_USB = 8000000 diff --git a/LUFA/Build/lufa_build.mk b/LUFA/Build/lufa_build.mk index a78d0f9ba8..bed98c272f 100644 --- a/LUFA/Build/lufa_build.mk +++ b/LUFA/Build/lufa_build.mk @@ -9,7 +9,7 @@ LUFA_BUILD_MODULES += BUILD LUFA_BUILD_TARGETS += size check-source symbol-sizes all lib elf hex lss clean mostlyclean LUFA_BUILD_MANDATORY_VARS += TARGET ARCH MCU SRC F_USB LUFA_PATH -LUFA_BUILD_OPTIONAL_VARS += BOARD OPTIMIZATION C_STANDARD CPP_STANDARD F_CPU C_FLAGS CPP_FLAGS ASM_FLAGS CC_FLAGS LD_FLAGS OBJDIR OBJECT_FILES +LUFA_BUILD_OPTIONAL_VARS += BOARD OPTIMIZATION C_STANDARD CPP_STANDARD F_CPU C_FLAGS CPP_FLAGS ASM_FLAGS CC_FLAGS LD_FLAGS OBJDIR OBJECT_FILES DEBUG_TYPE DEBUG_LEVEL LUFA_BUILD_PROVIDED_VARS += LUFA_BUILD_PROVIDED_MACROS += @@ -64,6 +64,10 @@ LUFA_BUILD_PROVIDED_MACROS += # files; if equal to ".", the output files will # be generated in the same folder as the sources # OBJECT_FILES - Extra object files to link in to the binaries +# DEBUG_FORMAT - Format of the debugging information to +# generate in the compiled object files +# DEBUG_LEVEL - Level the debugging information to generate in +# the compiled object files # # PROVIDED VARIABLES: # @@ -93,6 +97,8 @@ ASM_FLAGS ?= CC_FLAGS ?= OBJDIR ?= . OBJECT_FILES ?= +DEBUG_FORMAT ?= dwarf-2 +DEBUG_LEVEL ?= 3 # Sanity check user supplied values $(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR))) @@ -106,6 +112,8 @@ $(call ERROR_IF_EMPTY, OPTIMIZATION) $(call ERROR_IF_EMPTY, C_STANDARD) $(call ERROR_IF_EMPTY, CPP_STANDARD) $(call ERROR_IF_EMPTY, OBJDIR) +$(call ERROR_IF_EMPTY, DEBUG_FORMAT) +$(call ERROR_IF_EMPTY, DEBUG_LEVEL) # Determine the utility prefix to use for the selected architecture ifeq ($(ARCH), AVR8) @@ -159,13 +167,13 @@ endif DEPENDENCY_FILES := $(OBJECT_FILES:%.o=%.d) # Create a list of common flags to pass to the compiler/linker/assembler -BASE_CC_FLAGS := -pipe +BASE_CC_FLAGS := -pipe -g$(DEBUG_FORMAT) -g$(DEBUG_LEVEL) ifeq ($(ARCH), AVR8) - BASE_CC_FLAGS += -mmcu=$(MCU) -gdwarf-2 -fshort-enums -fno-inline-small-functions -fpack-struct + BASE_CC_FLAGS += -mmcu=$(MCU) -fshort-enums -fno-inline-small-functions -fpack-struct else ifeq ($(ARCH), XMEGA) - BASE_CC_FLAGS += -mmcu=$(MCU) -gdwarf-2 -fshort-enums -fno-inline-small-functions -fpack-struct + BASE_CC_FLAGS += -mmcu=$(MCU) -fshort-enums -fno-inline-small-functions -fpack-struct else ifeq ($(ARCH), UC3) - BASE_CC_FLAGS += -mpart=$(MCU:at32%=%) -g3 -masm-addr-pseudos + BASE_CC_FLAGS += -mpart=$(MCU:at32%=%) -masm-addr-pseudos endif BASE_CC_FLAGS += -Wall -fno-strict-aliasing -funsigned-char -funsigned-bitfields -ffunction-sections BASE_CC_FLAGS += -I. -I$(patsubst %/,%,$(LUFA_PATH))/.. @@ -180,11 +188,13 @@ BASE_CPP_FLAGS := -x c++ -O$(OPTIMIZATION) -std=$(CPP_STANDARD) BASE_ASM_FLAGS := -x assembler-with-cpp # Create a list of flags to pass to the linker -BASE_LD_FLAGS := -lm -Wl,-Map=$(TARGET).map,--cref -Wl,--gc-sections -ifeq ($(ARCH), UC3) - BASE_LD_FLAGS += --rodata-writable --direct-data -else - BASE_LD_FLAGS += -Wl,--relax +BASE_LD_FLAGS := -lm -Wl,-Map=$(TARGET).map,--cref -Wl,--gc-sections -Wl,--relax +ifeq ($(ARCH), AVR8) + BASE_LD_FLAGS += -mmcu=$(MCU) +else ifeq ($(ARCH), XMEGA) + BASE_LD_FLAGS += -mmcu=$(MCU) +else ifeq ($(ARCH), UC3) + BASE_LD_FLAGS += -mpart=$(MCU:at32%=%) --rodata-writable --direct-data endif # Determine flags to pass to the size utility based on its reported features (only invoke if size target required) @@ -261,7 +271,7 @@ $(OBJDIR)/%.o: %.S $(MAKEFILE_LIST) .SECONDARY : %.elf %.elf: $(OBJECT_FILES) @echo $(MSG_LINK_CMD) Linking object files into \"$@\" - $(CROSS)-gcc $(BASE_CC_FLAGS) $(BASE_LD_FLAGS) $(CC_FLAGS) $(LD_FLAGS) $^ -o $@ + $(CROSS)-gcc $(BASE_LD_FLAGS) $(LD_FLAGS) $^ -o $@ %.hex: %.elf @echo $(MSG_OBJCPY_CMD) Extracting HEX file data from \"$<\" diff --git a/LUFA/DoxygenPages/BuildSystem.txt b/LUFA/DoxygenPages/BuildSystem.txt index 3ecb9459ad..c30a88bb4d 100644 --- a/LUFA/DoxygenPages/BuildSystem.txt +++ b/LUFA/DoxygenPages/BuildSystem.txt @@ -155,6 +155,14 @@ * Version of the C++ standard to apply when compiling C++ source files (see GCC manual). * * + * DEBUG_FORMAT + * Format of the debug information to embed in the generated object files (see GCC manual). + * + * + * DEBUG_LEVEL + * Level of the debugging information to embed in the generated object files (see GCC manual). + * + * * F_CPU * Speed of the processor CPU clock, in Hz. * @@ -172,7 +180,7 @@ * * * CC_FLAGS - * Common flags to pass to the compiler, assembler and linker, after the automatically generated flags. + * Common flags to pass to the C/C++ compiler and assembler, after the automatically generated flags. * * * LD_FLAGS diff --git a/Maintenance/makefile b/Maintenance/makefile index d31a384ecf..ca3059996e 100644 --- a/Maintenance/makefile +++ b/Maintenance/makefile @@ -84,7 +84,7 @@ check-documentation-placeholders: # Validate the working branch - compile all documentation, demos/projects/examples and run build tests validate-branch: $(MAKE) -C $(LUFA_ROOT) doxygen - $(MAKE) -C $(LUFA_ROOT) all + $(MAKE) -C $(LUFA_ROOT) all DEBUG_LEVEL=0 $(MAKE) -C $(LUFA_ROOT)/BuildTests all # Validate the working branch for general release, check for placeholder documentation then build and test everything