Skip to content

Commit

Permalink
Merge pull request #2339 from hathach/move-build-file
Browse files Browse the repository at this point in the history
Move build file from tools/ to examples/build_system
  • Loading branch information
hathach authored Nov 23, 2023
2 parents 08f9ed6 + 26ca48e commit d6b8b35
Show file tree
Hide file tree
Showing 144 changed files with 290 additions and 846 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_aarch64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
run: python3 tools/get_deps.py ${{ matrix.family }}

- name: Build
run: python3 tools/build_family.py ${{ matrix.family }}
run: python3 tools/build_make.py ${{ matrix.family }}

- name: Linker Map
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
run: python3 tools/get_deps.py ${{ matrix.family }}

- name: Build
run: python3 tools/build_family.py ${{ matrix.family }}
run: python3 tools/build_make.py ${{ matrix.family }}

- name: Linker Map
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_msp430.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
run: python3 tools/get_deps.py ${{ matrix.family }}

- name: Build
run: python3 tools/build_family.py ${{ matrix.family }}
run: python3 tools/build_make.py ${{ matrix.family }}

- name: Linker Map
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_renesas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
run: python3 tools/get_deps.py ${{ matrix.family }}

- name: Build
run: python3 tools/build_family.py ${{ matrix.family }}
run: python3 tools/build_make.py ${{ matrix.family }}

- name: Linker Map
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_riscv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
run: python3 tools/get_deps.py ${{ matrix.family }}

- name: Build
run: python3 tools/build_family.py ${{ matrix.family }}
run: python3 tools/build_make.py ${{ matrix.family }}

- name: Linker Map
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_win_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ jobs:
run: python3 tools/get_deps.py stm32f4

- name: Build
run: python3 tools/build_family.py stm32f4 stm32f411disco
run: python3 tools/build_make.py stm32f4 stm32f411disco
2 changes: 1 addition & 1 deletion .idea/cmake.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ list(APPEND TOOLCHAIN_COMMON_FLAGS
-fno-strict-aliasing
)

set(TOOLCHAIN_EXE_LINKER_FLAGS
list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS
-Wl,--print-memory-usage
-Wl,--gc-sections
-Wl,--cref
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions examples/build_system/make/cpu/cortex-m23.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ifeq ($(TOOLCHAIN),gcc)
CFLAGS += \
-mthumb \
-mcpu=cortex-m23 \
-mfloat-abi=soft \

else ifeq ($(TOOLCHAIN),iar)
# IAR Flags
CFLAGS += --cpu cortex-m23
ASFLAGS += --cpu cortex-m23
endif

# For freeRTOS port source
FREERTOS_PORTABLE_SRC ?= $(FREERTOS_PORTABLE_PATH)/ARM_CM23
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 10 additions & 12 deletions examples/make.mk → examples/build_system/make/make.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@
# Common make definition for all examples
# ---------------------------------------

# Supported toolchain: gcc, iar
TOOLCHAIN ?= gcc

#-------------- TOP and CURRENT_PATH ------------

# Set TOP to be the path to get from the current directory (where make was
# invoked) to the top of the tree. $(lastword $(MAKEFILE_LIST)) returns
# the name of this makefile relative to where make was invoked.
# Set TOP to be the path to get from the current directory (where make was invoked) to the top of the tree.
# $(lastword $(MAKEFILE_LIST)) returns the name of this makefile relative to where make was invoked.
THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))

# strip off /tools/top.mk to get for example ../../..
# strip off /examples/build_system/make to get for example ../../..
# and Set TOP to an absolute path
TOP = $(abspath $(subst make.mk,..,$(THIS_MAKEFILE)))
TOP = $(abspath $(subst make.mk,../../..,$(THIS_MAKEFILE)))

# Set CURRENT_PATH to the relative path from TOP to the current directory, ie examples/device/cdc_msc_freertos
CURRENT_PATH = $(subst $(TOP)/,,$(abspath .))
Expand All @@ -38,7 +34,6 @@ __check_defined = \
$(if $(value $1),, \
$(error Undefined make flag: $1$(if $2, ($2))))


# Build directory
BUILD := _build/$(BOARD)

Expand Down Expand Up @@ -73,7 +68,10 @@ else
SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(FAMILY_PATH)/*.c))
endif

#-------------- Cross Compiler ------------
#-------------- Toolchain ------------

# Supported toolchain: gcc, iar
TOOLCHAIN ?= gcc

# Can be set by board, default to ARM GCC
CROSS_COMPILE ?= arm-none-eabi-
Expand Down Expand Up @@ -139,8 +137,8 @@ endif

# CPU specific flags
ifdef CPU_CORE
include $(TOP)/tools/make/cpu/$(CPU_CORE).mk
include ${TOP}/examples/build_system/make/cpu/$(CPU_CORE).mk
endif

# toolchain specific
include $(TOP)/tools/make/toolchain/arm_$(TOOLCHAIN).mk
include ${TOP}/examples/build_system/make/toolchain/arm_$(TOOLCHAIN).mk
2 changes: 1 addition & 1 deletion examples/rules.mk → examples/build_system/make/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ vpath %.c . $(TOP)
vpath %.s . $(TOP)
vpath %.S . $(TOP)

include $(TOP)/tools/make/toolchain/arm_$(TOOLCHAIN)_rules.mk
include ${TOP}/examples/build_system/make/toolchain/arm_$(TOOLCHAIN)_rules.mk


OBJ_DIRS = $(sort $(dir $(OBJ)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ GDB = $(CROSS_COMPILE)gdb
OBJCOPY = $(CROSS_COMPILE)objcopy
SIZE = $(CROSS_COMPILE)size

CC_VERSION := $(shell $(CC) -dumpversion)
CC_VERSION_MAJOR = $(firstword $(subst ., ,$(CC_VERSION)))

# ---------------------------------------
# Compiler Flags
# ---------------------------------------
Expand Down Expand Up @@ -65,7 +68,12 @@ LDFLAGS += \
-Wl,-cref \
-Wl,-gc-sections \

# Some toolchain such as renesas rx does not support --print-memory-usage flags
# renesas rx does not support --print-memory-usage flags
ifneq ($(FAMILY),rx)
LDFLAGS += -Wl,--print-memory-usage
endif

# from version 12
ifeq ($(shell expr $(CC_VERSION_MAJOR) \>= 12),1)
LDFLAGS += -Wl,--no-warn-rwx-segment
endif
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ ifdef LD_FILE_GCC
LDFLAGS += -Wl,-T,$(TOP)/$(LD_FILE_GCC)
endif

ifneq ($(SKIP_NANOLIB), 1)
LDFLAGS += --specs=nosys.specs --specs=nano.specs
endif

ASFLAGS += $(CFLAGS)

LIBS_GCC ?= -lgcc -lm -lnosys
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/device/audio_4_channel_mic/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ../../make.mk
include ../../build_system/make/make.mk

INC += \
src \
Expand All @@ -11,4 +11,4 @@ EXAMPLE_SOURCE += \

SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))

include ../../rules.mk
include ../../build_system/make/rules.mk
4 changes: 2 additions & 2 deletions examples/device/audio_test/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ../../make.mk
include ../../build_system/make/make.mk

INC += \
src \
Expand All @@ -8,4 +8,4 @@ INC += \
EXAMPLE_SOURCE += $(wildcard src/*.c)
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))

include ../../rules.mk
include ../../build_system/make/rules.mk
4 changes: 2 additions & 2 deletions examples/device/audio_test_multi_rate/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ../../make.mk
include ../../build_system/make/make.mk

INC += \
src \
Expand All @@ -8,4 +8,4 @@ INC += \
EXAMPLE_SOURCE += $(wildcard src/*.c)
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))

include ../../rules.mk
include ../../build_system/make/rules.mk
4 changes: 2 additions & 2 deletions examples/device/board_test/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ../../make.mk
include ../../build_system/make/make.mk

INC += \
src \
Expand All @@ -8,4 +8,4 @@ INC += \
EXAMPLE_SOURCE += $(wildcard src/*.c)
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))

include ../../rules.mk
include ../../build_system/make/rules.mk
4 changes: 2 additions & 2 deletions examples/device/cdc_dual_ports/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ../../make.mk
include ../../build_system/make/make.mk

INC += \
src \
Expand All @@ -8,4 +8,4 @@ INC += \
EXAMPLE_SOURCE += $(wildcard src/*.c)
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))

include ../../rules.mk
include ../../build_system/make/rules.mk
4 changes: 2 additions & 2 deletions examples/device/cdc_msc/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ../../make.mk
include ../../build_system/make/make.mk

INC += \
src \
Expand All @@ -12,4 +12,4 @@ EXAMPLE_SOURCE += \

SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))

include ../../rules.mk
include ../../build_system/make/rules.mk
4 changes: 2 additions & 2 deletions examples/device/cdc_msc_freertos/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ../../make.mk
include ../../build_system/make/make.mk

FREERTOS_SRC = lib/FreeRTOS-Kernel
FREERTOS_PORTABLE_PATH= $(FREERTOS_SRC)/portable/$(if $(USE_IAR),IAR,GCC)
Expand Down Expand Up @@ -43,4 +43,4 @@ CFLAGS_GCC += -Wno-error=cast-qual
# FreeRTOS (lto + Os) linker issue
LDFLAGS_GCC += -Wl,--undefined=vTaskSwitchContext

include ../../rules.mk
include ../../build_system/make/rules.mk
4 changes: 2 additions & 2 deletions examples/device/cdc_uac2/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ../../make.mk
include ../../build_system/make/make.mk

INC += \
src \
Expand All @@ -13,4 +13,4 @@ EXAMPLE_SOURCE += \

SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))

include ../../rules.mk
include ../../build_system/make/rules.mk
4 changes: 2 additions & 2 deletions examples/device/dfu/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ../../make.mk
include ../../build_system/make/make.mk

INC += \
src \
Expand All @@ -11,4 +11,4 @@ EXAMPLE_SOURCE = \

SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))

include ../../rules.mk
include ../../build_system/make/rules.mk
4 changes: 2 additions & 2 deletions examples/device/dfu_runtime/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ../../make.mk
include ../../build_system/make/make.mk

INC += \
src \
Expand All @@ -8,4 +8,4 @@ INC += \
EXAMPLE_SOURCE += $(wildcard src/*.c)
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))

include ../../rules.mk
include ../../build_system/make/rules.mk
4 changes: 2 additions & 2 deletions examples/device/dynamic_configuration/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ../../make.mk
include ../../build_system/make/make.mk

INC += \
src \
Expand All @@ -8,4 +8,4 @@ INC += \
EXAMPLE_SOURCE += $(wildcard src/*.c)
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))

include ../../rules.mk
include ../../build_system/make/rules.mk
4 changes: 2 additions & 2 deletions examples/device/hid_boot_interface/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ../../make.mk
include ../../build_system/make/make.mk

INC += \
src \
Expand All @@ -11,4 +11,4 @@ EXAMPLE_SOURCE = \

SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))

include ../../rules.mk
include ../../build_system/make/rules.mk
4 changes: 2 additions & 2 deletions examples/device/hid_composite/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ../../make.mk
include ../../build_system/make/make.mk

INC += \
src \
Expand All @@ -8,4 +8,4 @@ INC += \
EXAMPLE_SOURCE += $(wildcard src/*.c)
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))

include ../../rules.mk
include ../../build_system/make/rules.mk
4 changes: 2 additions & 2 deletions examples/device/hid_composite_freertos/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
DEPS_SUBMODULES += lib/FreeRTOS-Kernel

include ../../make.mk
include ../../build_system/make/make.mk

FREERTOS_SRC = lib/FreeRTOS-Kernel
FREERTOS_PORTABLE_PATH= $(FREERTOS_SRC)/portable/$(if $(USE_IAR),IAR,GCC)
Expand Down Expand Up @@ -44,4 +44,4 @@ CFLAGS_GCC += -Wno-error=cast-qual
# FreeRTOS (lto + Os) linker issue
LDFLAGS_GCC += -Wl,--undefined=vTaskSwitchContext

include ../../rules.mk
include ../../build_system/make/rules.mk
4 changes: 2 additions & 2 deletions examples/device/hid_generic_inout/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ../../make.mk
include ../../build_system/make/make.mk

INC += \
src \
Expand All @@ -8,4 +8,4 @@ INC += \
EXAMPLE_SOURCE += $(wildcard src/*.c)
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))

include ../../rules.mk
include ../../build_system/make/rules.mk
4 changes: 2 additions & 2 deletions examples/device/hid_multiple_interface/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ../../make.mk
include ../../build_system/make/make.mk

INC += \
src \
Expand All @@ -8,4 +8,4 @@ INC += \
EXAMPLE_SOURCE += $(wildcard src/*.c)
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))

include ../../rules.mk
include ../../build_system/make/rules.mk
4 changes: 2 additions & 2 deletions examples/device/midi_test/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ../../make.mk
include ../../build_system/make/make.mk

INC += \
src \
Expand All @@ -8,4 +8,4 @@ INC += \
EXAMPLE_SOURCE += $(wildcard src/*.c)
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))

include ../../rules.mk
include ../../build_system/make/rules.mk
Loading

0 comments on commit d6b8b35

Please sign in to comment.