Przeglądaj źródła

makefile clean up

allow board to define CROSS_COMPILE (default to arm gcc)
hathach 6 lat temu
rodzic
commit
d74a92bf45
4 zmienionych plików z 34 dodań i 39 usunięć
  1. 27 38
      examples/make.mk
  2. 3 0
      hw/bsp/fomu/board.mk
  3. 3 0
      hw/bsp/msp_exp430f5529lp/board.mk
  4. 1 1
      tools/build_all.py

+ 27 - 38
examples/make.mk

@@ -1,56 +1,45 @@
-#
+# ---------------------------------------
 # Common make definition for all examples
-#
+# ---------------------------------------
 
-# Compiler
-ifeq ($(BOARD), msp_exp430f5529lp)
-  CROSS_COMPILE = msp430-elf-
-else ifeq ($(BOARD), fomu)
-  CROSS_COMPILE = riscv-none-embed-
-else
-  CROSS_COMPILE = arm-none-eabi-
+#-------------- Select the board to build for. ------------
+BOARD_LIST = $(sort $(subst /.,,$(subst $(TOP)/hw/bsp/,,$(wildcard $(TOP)/hw/bsp/*/.))))
+
+ifeq ($(filter $(BOARD),$(BOARD_LIST)),)
+  $(info You must provide a BOARD parameter with 'BOARD=', supported boards are:)
+  $(foreach b,$(BOARD_LIST),$(info - $(b)))
+  $(error Invalid BOARD specified)
 endif
-CC = $(CROSS_COMPILE)gcc
-CXX = $(CROSS_COMPILE)g++
-OBJCOPY = $(CROSS_COMPILE)objcopy
-SIZE = $(CROSS_COMPILE)size
-MKDIR = mkdir
-SED = sed
-CP = cp
-RM = rm
-PYTHON ?= python
 
+# Handy check parameter function
 check_defined = \
     $(strip $(foreach 1,$1, \
     $(call __check_defined,$1,$(strip $(value 2)))))
 __check_defined = \
     $(if $(value $1),, \
     $(error Undefined make flag: $1$(if $2, ($2))))
-
-
-define newline
-
-
-endef
-
-# Select the board to build for.
-ifeq ($(BOARD),)
-  $(info You must provide a BOARD parameter with 'BOARD=')
-  $(info Supported boards are:)
-  $(info $(sort $(subst /.,,$(subst $(TOP)/hw/bsp/, $(newline)-,$(wildcard $(TOP)/hw/bsp/*/.)))))
-  $(error BOARD not defined)
-else
-  ifeq ($(wildcard $(TOP)/hw/bsp/$(BOARD)/.),)
-    $(error Invalid BOARD specified)
-  endif
-endif
-
+    
 # Build directory
 BUILD = _build/build-$(BOARD)
 
-# Board specific
+# Board specific define
 include $(TOP)/hw/bsp/$(BOARD)/board.mk
 
+#-------------- Cross Compiler  ------------
+# Can be set by board, default to ARM GCC
+CROSS_COMPILE ?= arm-none-eabi-
+
+CC = $(CROSS_COMPILE)gcc
+CXX = $(CROSS_COMPILE)g++
+OBJCOPY = $(CROSS_COMPILE)objcopy
+SIZE = $(CROSS_COMPILE)size
+MKDIR = mkdir
+SED = sed
+CP = cp
+RM = rm
+
+#-------------- Source files and compiler flags --------------
+
 # Include all source C in board folder
 SRC_C += hw/bsp/board.c
 SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/$(BOARD)/*.c))

+ 3 - 0
hw/bsp/fomu/board.mk

@@ -5,6 +5,9 @@ CFLAGS += \
   -nostdlib \
   -DCFG_TUSB_MCU=OPT_MCU_VALENTYUSB_EPTRI
 
+# Cross Compiler for RISC-V
+CROSS_COMPILE = riscv-none-embed-
+
 MCU_DIR = hw/mcu/fomu
 BSP_DIR = hw/bsp/fomu
 

+ 3 - 0
hw/bsp/msp_exp430f5529lp/board.mk

@@ -6,6 +6,9 @@ CFLAGS += \
 
 #-mmcu=msp430f5529
 
+# Cross Compiler for MSP430
+CROSS_COMPILE = msp430-elf-
+
 # All source paths should be relative to the top level.
 LD_FILE = hw/mcu/ti/msp430/msp430-gcc-support-files/include/msp430f5529.ld
 LDINC += $(TOP)/hw/mcu/ti/msp430/msp430-gcc-support-files/include

+ 1 - 1
tools/build_all.py

@@ -88,7 +88,7 @@ for example in all_examples:
                 fail_count += 1
 
             build_duration = time.monotonic() - start_time
-            print(build_format.format(example, board, success, "{:.2f}".format(build_duration), flash_size, sram_size))
+            print(build_format.format(example, board, success, "{:.2f}s".format(build_duration), flash_size, sram_size))
 
             if build_result.returncode != 0:
                 print(build_result.stdout.decode("utf-8"))