From 325f0cd29387e38c57cad6acd6f9e209946a2cd1 Mon Sep 17 00:00:00 2001 From: Haaris Farooq Date: Fri, 16 Aug 2024 13:08:59 +0100 Subject: [PATCH 1/3] Makefile: Allow for direct build in makefile wrapper Currently, if you are building with the makefile wrapper, the build directory that is specified gets modified. There are cases when this is unwanted, this patch adds a DIRECT_BUILD variable so we can build directly to a specific directory without having extra fields appended to our build directory. Signed-off-by: Haaris Farooq --- Makefile.cmake | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Makefile.cmake b/Makefile.cmake index 569833b9c..2b9552f6e 100644 --- a/Makefile.cmake +++ b/Makefile.cmake @@ -59,6 +59,7 @@ DEFAULT_BUILD_SYSTEM := Ninja export CMSIS_DIR := $(TOP_DIR)/contrib/cmsis/git/CMSIS/Core DEFAULT_LOG_LEVEL_debug := INFO DEFAULT_LOG_LEVEL_release := WARN +DEFAULT_DIRECT_BUILD := n DEFAULT_CMAKE_TOOL_LOG_LEVEL := NOTICE @@ -110,6 +111,10 @@ else MAKEFLAGS += --no-print-directory endif +# Build directly to build directory +DIRECT_BUILD ?= $(DEFAULT_DIRECT_BUILD) +export DIRECT_BUILD + # Include debugger library: y/n DEBUGGER ?= $(DEFAULT_DEBUGGER) ifeq ($(DEBUGGER),y) @@ -155,10 +160,12 @@ ifneq ($(filter-out $(PRODUCT_INDEPENDENT_GOALS), $(MAKECMDGOALS)),) FIRMWARE_TARGETS := $(addprefix firmware-, $(BS_FIRMWARE_LIST)) -ifndef PLATFORM_VARIANT - PRODUCT_BUILD_PATH := $(BUILD_PATH)/$(BS_PRODUCT_NAME)/$(TOOLCHAIN)/$(MODE) -else - PRODUCT_BUILD_PATH := $(BUILD_PATH)/$(BS_PRODUCT_NAME)/platform_variant_$(PLATFORM_VARIANT)/$(TOOLCHAIN)/$(MODE) +ifeq ($(DIRECT_BUILD), n) + ifndef PLATFORM_VARIANT + BUILD_PATH := $(BUILD_PATH)/$(BS_PRODUCT_NAME)/$(TOOLCHAIN)/$(MODE) + else + BUILD_PATH := $(BUILD_PATH)/$(BS_PRODUCT_NAME)/platform_variant_$(PLATFORM_VARIANT)/$(TOOLCHAIN)/$(MODE) + endif endif define msg_start @@ -298,19 +305,23 @@ help: @echo " Enable or disable generation of code coverage reports for unit tests." @echo " Use ENABLE_COVERAGE=y to enable coverage for 'fwk_test' and 'mod_test' targets." @echo "" - + @echo " DIRECT_BUILD" + @echo " Value: " + @echo " Default: n" + @echo " Build directly to the specified build path without modifying it." + @echo "" .SECONDEXPANSION: .PHONY: all all: $(FIRMWARE_TARGETS) -firmware-%: $(PRODUCT_BUILD_PATH)/$$@/CMakeCache.txt +firmware-%: $(BUILD_PATH)/$$@/CMakeCache.txt $(CMAKE) --build $( Date: Fri, 16 Aug 2024 17:12:49 +0100 Subject: [PATCH 2/3] tools: Add use of direct build flag for builds Currently, in the CI when products are built, the output directory is replicated by the makefile wrapper. This patch makes build use the new DIRECT_BUILD flag in the makefile wrapper to ensure the build path is used directly and not modified. Signed-off-by: Haaris Farooq --- tools/product.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/product.py b/tools/product.py index 57bd71742..f35c6fd35 100644 --- a/tools/product.py +++ b/tools/product.py @@ -108,6 +108,7 @@ class Build: for extra in self.config.arguments) + ' ' if build_path: cmd += f'BUILD_PATH={build_path} ' + cmd += f'DIRECT_BUILD=y ' return cmd @classmethod -- GitLab From 63f4d3846971ef6eb9bcfc6ed2a0450b979b167f Mon Sep 17 00:00:00 2001 From: Haaris Farooq Date: Mon, 19 Aug 2024 12:27:51 +0100 Subject: [PATCH 3/3] ci: Fix log generation for build-products Currently, the log files are not being fetched as artifacts due to a change in the build directories. This is corrected by changing the extension to .log and recursively finding the artifact files within the build directory. Signed-off-by: Haaris Farooq --- .gitlab/templates/build-test.yml | 2 +- tools/product.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab/templates/build-test.yml b/.gitlab/templates/build-test.yml index ad82ba1fb..3bbc4a30d 100644 --- a/.gitlab/templates/build-test.yml +++ b/.gitlab/templates/build-test.yml @@ -30,7 +30,7 @@ when: on_failure expire_in: 2 days paths: - - build/*.txt + - build/**/*.log .build-products-all-products: extends: .build-products diff --git a/tools/product.py b/tools/product.py index f35c6fd35..9e94e7606 100644 --- a/tools/product.py +++ b/tools/product.py @@ -67,7 +67,7 @@ class Build: filename += f'_{self.variant.name}' if self.config: filename += f'_{self.config.name}' - filename += '.txt' + filename += '.log' return filename def build_output_directory(self): -- GitLab