From 4a0f5cbd6332a9ae76dc2eea293024fab2c81885 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 26 Jan 2021 12:46:24 +0700 Subject: change output filename to BOARD-Directory --- examples/device/audio_test/CMakeLists.txt | 3 ++- examples/device/board_test/CMakeLists.txt | 1 + examples/device/cdc_dual_ports/CMakeLists.txt | 1 + examples/device/cdc_msc/CMakeLists.txt | 1 + examples/device/cdc_msc_freertos/CMakeLists.txt | 14 ++++++------- examples/device/dfu_rt/CMakeLists.txt | 1 + .../device/dynamic_configuration/CMakeLists.txt | 1 + examples/device/hid_composite/CMakeLists.txt | 1 + .../device/hid_composite_freertos/CMakeLists.txt | 14 ++++++------- examples/device/hid_generic_inout/CMakeLists.txt | 1 + .../device/hid_multiple_interface/CMakeLists.txt | 1 + examples/device/midi_test/CMakeLists.txt | 1 + examples/device/msc_dual_lun/CMakeLists.txt | 1 + examples/device/net_lwip_webserver/CMakeLists.txt | 1 + examples/device/uac2_headset/CMakeLists.txt | 1 + examples/device/usbtmc/CMakeLists.txt | 1 + examples/device/webusb_serial/CMakeLists.txt | 1 + examples/make.mk | 1 + examples/rules.mk | 23 ++++++++++++---------- 19 files changed, 44 insertions(+), 25 deletions(-) (limited to 'examples') diff --git a/examples/device/audio_test/CMakeLists.txt b/examples/device/audio_test/CMakeLists.txt index 99ee77bd3..645d57157 100644 --- a/examples/device/audio_test/CMakeLists.txt +++ b/examples/device/audio_test/CMakeLists.txt @@ -1,5 +1,6 @@ -# use directory name for project id +# use BOARD-Directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/board_test/CMakeLists.txt b/examples/device/board_test/CMakeLists.txt index 68577ba73..573f026f3 100644 --- a/examples/device/board_test/CMakeLists.txt +++ b/examples/device/board_test/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/cdc_dual_ports/CMakeLists.txt b/examples/device/cdc_dual_ports/CMakeLists.txt index 99ee77bd3..c358eddab 100644 --- a/examples/device/cdc_dual_ports/CMakeLists.txt +++ b/examples/device/cdc_dual_ports/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/cdc_msc/CMakeLists.txt b/examples/device/cdc_msc/CMakeLists.txt index 7f5d5a998..5f4d9ba4e 100644 --- a/examples/device/cdc_msc/CMakeLists.txt +++ b/examples/device/cdc_msc/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/cdc_msc_freertos/CMakeLists.txt b/examples/device/cdc_msc_freertos/CMakeLists.txt index 2e55d8c47..dabb4bc80 100644 --- a/examples/device/cdc_msc_freertos/CMakeLists.txt +++ b/examples/device/cdc_msc_freertos/CMakeLists.txt @@ -1,18 +1,18 @@ cmake_minimum_required(VERSION 3.5) -# use directory name for project id +# use BOARD-Directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") get_filename_component(TOP "${TOP}" REALPATH) # Check for -DFAMILY= -if(NOT DEFINED FAMILY) +if(FAMILY STREQUAL "esp32s2") + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + project(${PROJECT}) + +else() message(FATAL_ERROR "Invalid FAMILY specified") endif() - -include(${TOP}/hw/bsp/${FAMILY}/family.cmake) -project(${PROJECT}) - -project(cdc_msc_freertos) diff --git a/examples/device/dfu_rt/CMakeLists.txt b/examples/device/dfu_rt/CMakeLists.txt index 99ee77bd3..c358eddab 100644 --- a/examples/device/dfu_rt/CMakeLists.txt +++ b/examples/device/dfu_rt/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/dynamic_configuration/CMakeLists.txt b/examples/device/dynamic_configuration/CMakeLists.txt index f26465729..a759e56e8 100644 --- a/examples/device/dynamic_configuration/CMakeLists.txt +++ b/examples/device/dynamic_configuration/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/hid_composite/CMakeLists.txt b/examples/device/hid_composite/CMakeLists.txt index 99ee77bd3..c358eddab 100644 --- a/examples/device/hid_composite/CMakeLists.txt +++ b/examples/device/hid_composite/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/hid_composite_freertos/CMakeLists.txt b/examples/device/hid_composite_freertos/CMakeLists.txt index c4777f122..dabb4bc80 100644 --- a/examples/device/hid_composite_freertos/CMakeLists.txt +++ b/examples/device/hid_composite_freertos/CMakeLists.txt @@ -1,18 +1,18 @@ cmake_minimum_required(VERSION 3.5) -# use directory name for project id +# use BOARD-Directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") get_filename_component(TOP "${TOP}" REALPATH) # Check for -DFAMILY= -if(NOT DEFINED FAMILY) +if(FAMILY STREQUAL "esp32s2") + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + project(${PROJECT}) + +else() message(FATAL_ERROR "Invalid FAMILY specified") endif() - -include(${TOP}/hw/bsp/${FAMILY}/family.cmake) -project(${PROJECT}) - -project(hid_composite_freertos) diff --git a/examples/device/hid_generic_inout/CMakeLists.txt b/examples/device/hid_generic_inout/CMakeLists.txt index 99ee77bd3..c358eddab 100644 --- a/examples/device/hid_generic_inout/CMakeLists.txt +++ b/examples/device/hid_generic_inout/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/hid_multiple_interface/CMakeLists.txt b/examples/device/hid_multiple_interface/CMakeLists.txt index 99ee77bd3..c358eddab 100644 --- a/examples/device/hid_multiple_interface/CMakeLists.txt +++ b/examples/device/hid_multiple_interface/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/midi_test/CMakeLists.txt b/examples/device/midi_test/CMakeLists.txt index 99ee77bd3..c358eddab 100644 --- a/examples/device/midi_test/CMakeLists.txt +++ b/examples/device/midi_test/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/msc_dual_lun/CMakeLists.txt b/examples/device/msc_dual_lun/CMakeLists.txt index 084565400..f0e050f9c 100644 --- a/examples/device/msc_dual_lun/CMakeLists.txt +++ b/examples/device/msc_dual_lun/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/net_lwip_webserver/CMakeLists.txt b/examples/device/net_lwip_webserver/CMakeLists.txt index 695dd7c59..ec4996086 100644 --- a/examples/device/net_lwip_webserver/CMakeLists.txt +++ b/examples/device/net_lwip_webserver/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/uac2_headset/CMakeLists.txt b/examples/device/uac2_headset/CMakeLists.txt index 99ee77bd3..c358eddab 100644 --- a/examples/device/uac2_headset/CMakeLists.txt +++ b/examples/device/uac2_headset/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/usbtmc/CMakeLists.txt b/examples/device/usbtmc/CMakeLists.txt index 03bb04389..686e8dc2d 100644 --- a/examples/device/usbtmc/CMakeLists.txt +++ b/examples/device/usbtmc/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/webusb_serial/CMakeLists.txt b/examples/device/webusb_serial/CMakeLists.txt index 99ee77bd3..c358eddab 100644 --- a/examples/device/webusb_serial/CMakeLists.txt +++ b/examples/device/webusb_serial/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/make.mk b/examples/make.mk index 556b0c41a..329efa774 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -4,6 +4,7 @@ # Build directory BUILD = _build/$(BOARD) +PROJECT = $(BOARD)-$(notdir $(CURDIR)) # Handy check parameter function check_defined = \ diff --git a/examples/rules.mk b/examples/rules.mk index ab0373bac..12ec35043 100644 --- a/examples/rules.mk +++ b/examples/rules.mk @@ -43,6 +43,9 @@ all: clean: $(RM) -rf $(BUILD) +#copy-artifact: +# @$(CP) + else # GNU Make build system @@ -100,9 +103,9 @@ endif # Set all as default goal .DEFAULT_GOAL := all -all: $(BUILD)/$(BOARD)-firmware.bin $(BUILD)/$(BOARD)-firmware.hex size +all: $(BUILD)/$(PROJECT).bin $(BUILD)/$(PROJECT).hex size -uf2: $(BUILD)/$(BOARD)-firmware.uf2 +uf2: $(BUILD)/$(PROJECT).uf2 OBJ_DIRS = $(sort $(dir $(OBJ))) $(OBJ): | $(OBJ_DIRS) @@ -113,20 +116,20 @@ else @$(MKDIR) -p $@ endif -$(BUILD)/$(BOARD)-firmware.elf: $(OBJ) +$(BUILD)/$(PROJECT).elf: $(OBJ) @echo LINK $@ @$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group -$(BUILD)/$(BOARD)-firmware.bin: $(BUILD)/$(BOARD)-firmware.elf +$(BUILD)/$(PROJECT).bin: $(BUILD)/$(PROJECT).elf @echo CREATE $@ @$(OBJCOPY) -O binary $^ $@ -$(BUILD)/$(BOARD)-firmware.hex: $(BUILD)/$(BOARD)-firmware.elf +$(BUILD)/$(PROJECT).hex: $(BUILD)/$(PROJECT).elf @echo CREATE $@ @$(OBJCOPY) -O ihex $^ $@ UF2_FAMILY ?= 0x00 -$(BUILD)/$(BOARD)-firmware.uf2: $(BUILD)/$(BOARD)-firmware.hex +$(BUILD)/$(PROJECT).uf2: $(BUILD)/$(PROJECT).hex @echo CREATE $@ $(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f $(UF2_FAMILY) -c -o $@ $^ @@ -150,7 +153,7 @@ $(BUILD)/obj/%.o: %.S @echo AS $(notdir $@) @$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $< -size: $(BUILD)/$(BOARD)-firmware.elf +size: $(BUILD)/$(PROJECT).elf -@echo '' @$(SIZE) $< -@echo '' @@ -178,7 +181,7 @@ endif JLINK_IF ?= swd # Flash using jlink -flash-jlink: $(BUILD)/$(BOARD)-firmware.hex +flash-jlink: $(BUILD)/$(PROJECT).hex @echo halt > $(BUILD)/$(BOARD).jlink @echo r > $(BUILD)/$(BOARD).jlink @echo loadfile $^ >> $(BUILD)/$(BOARD).jlink @@ -188,11 +191,11 @@ flash-jlink: $(BUILD)/$(BOARD)-firmware.hex $(JLINKEXE) -device $(JLINK_DEVICE) -if $(JLINK_IF) -JTAGConf -1,-1 -speed auto -CommandFile $(BUILD)/$(BOARD).jlink # flash STM32 MCU using stlink with STM32 Cube Programmer CLI -flash-stlink: $(BUILD)/$(BOARD)-firmware.elf +flash-stlink: $(BUILD)/$(PROJECT).elf STM32_Programmer_CLI --connect port=swd --write $< --go # flash with pyocd -flash-pyocd: $(BUILD)/$(BOARD)-firmware.hex +flash-pyocd: $(BUILD)/$(PROJECT).hex pyocd flash -t $(PYOCD_TARGET) $< pyocd reset -t $(PYOCD_TARGET) -- cgit v1.3.1