diff options
author | Nicola Mazzucato <nicola.mazzucato@arm.com> | 2018-08-22 08:36:00 +0100 |
---|---|---|
committer | ronald-cron-arm <39518861+ronald-cron-arm@users.noreply.github.com> | 2018-11-21 15:45:32 +0100 |
commit | 3d712ef0913aea9e89a0a42b2d46576fcb515051 (patch) | |
tree | ac3b3dcf99ab723b5a1afed49fa05488e6a59834 /tools/build_system | |
parent | 8f4e4c5da20d73dec4b207d5193a78f4b6e6280d (diff) |
build: Add support for binary modules
Change-Id: I054a77d3295150c1e5445d430cabaad978e7e594
Signed-off-by: Nicola Mazzucato <nicola.mazzucato@arm.com>
Diffstat (limited to 'tools/build_system')
-rw-r--r-- | tools/build_system/doc.md | 17 | ||||
-rw-r--r-- | tools/build_system/firmware.mk | 60 |
2 files changed, 63 insertions, 14 deletions
diff --git a/tools/build_system/doc.md b/tools/build_system/doc.md index 2eee57f1..92671b26 100644 --- a/tools/build_system/doc.md +++ b/tools/build_system/doc.md @@ -101,11 +101,10 @@ BUILD_DISABLE_API_BAR Module ====== -Modules are the building blocks of a firmware product and are built as -libraries. Modules can be implemented under the modules/ directory at the root -of the project, or they can be product-specific and implemented under the -product/\<product\>/modules directory. In either case, modules have the -following directory structure: +Modules are the building blocks of a product firmware. Modules can be +implemented under the modules/ directory at the root of the project, or they +can be product-specific and implemented under the product/\<product\>/modules +directory. In either case, modules have the following directory structure: <module root> └── <module> @@ -114,9 +113,17 @@ following directory structure: ├── src │ ├── Makefile │ └── <source files...> + ├── lib + │ └── mod_<module>.a └── doc └── <documentation files...> +Only one of the 'src' or 'lib' directories is required. When building a +firmware, if the 'src' directory is present then the module library is built +from the module source code and the 'lib' directory, if present, is ignored. +When only the 'lib' directory is supplied, the module's pre-built static library +is used when building a firmware. + __Note:__ The name of the \<module\> directory must not contain spaces. The name of the \<module\> directory is used in __BS_FIRMWARE_MODULES__ by the diff --git a/tools/build_system/firmware.mk b/tools/build_system/firmware.mk index 9ce513a9..95e2733a 100644 --- a/tools/build_system/firmware.mk +++ b/tools/build_system/firmware.mk @@ -109,8 +109,10 @@ SOURCES = $(BS_FIRMWARE_SOURCES) # # Modules # -ALL_STANDARD_MODULES := $(shell ls $(MODULES_DIR) 2>/dev/null) -ALL_PRODUCT_MODULES := $(shell ls $(PRODUCT_MODULES_DIR) 2>/dev/null) +ALL_STANDARD_MODULES := $(patsubst $(MODULES_DIR)/%,%, \ + $(wildcard $(MODULES_DIR)/*)) +ALL_PRODUCT_MODULES := $(patsubst $(PRODUCT_MODULES_DIR)/%,%, \ + $(wildcard $(PRODUCT_MODULES_DIR)/*)) # Check for conflicts between module names CONFLICTING_MODULES := $(filter $(ALL_PRODUCT_MODULES), $(ALL_STANDARD_MODULES)) @@ -127,11 +129,44 @@ ifneq ($(MISSING_MODULES),) $(error "Missing or invalid module(s): $(MISSING_MODULES). Aborting...") endif +# Collect both the product and non product-specific module directory paths +MODULE_PATHS := $(wildcard $(MODULES_DIR)/* $(PRODUCT_MODULES_DIR)/*) + +# Filter out the module src/lib directory paths +SOURCE_MODULE_PATHS := $(wildcard $(addsuffix /src,$(MODULE_PATHS))) +LIBRARY_MODULE_PATHS := $(wildcard $(addsuffix /lib,$(MODULE_PATHS))) + +# Pull the module names from the module source directory paths +SOURCE_MODULES := \ + $(patsubst $(MODULES_DIR)/%/src,%,$(SOURCE_MODULE_PATHS)) +SOURCE_MODULES := \ + $(patsubst $(PRODUCT_MODULES_DIR)/%/src,%,$(SOURCE_MODULES)) + +# Select the source modules for the current firmware +SOURCE_MODULES := $(filter $(FIRMWARE_MODULES_LIST),$(SOURCE_MODULES)) + +# Pull the module names from the module library directory paths +LIBRARY_MODULES := \ + $(patsubst $(MODULES_DIR)/%/lib,%,$(LIBRARY_MODULE_PATHS)) +LIBRARY_MODULES := \ + $(patsubst $(PRODUCT_MODULES_DIR)/%/lib,%,$(LIBRARY_MODULES)) + +# Prefer sources over pre-built libraries for modules that provide both +LIBRARY_MODULES := \ + $(filter-out $(SOURCE_MODULES),$(LIBRARY_MODULES)) + +# Select the library modules for the current firmware +LIBRARY_MODULES := $(filter $(FIRMWARE_MODULES_LIST),$(LIBRARY_MODULES)) + +# Divide libraries into two groups +LIBRARY_MODULES_STANDARD := $(filter $(LIBRARY_MODULES),$(ALL_STANDARD_MODULES)) +LIBRARY_MODULES_PRODUCT := $(filter $(LIBRARY_MODULES),$(ALL_PRODUCT_MODULES)) + # Modules selected to be built into the firmware BUILD_STANDARD_MODULES := $(filter $(ALL_STANDARD_MODULES), \ - $(FIRMWARE_MODULES_LIST)) + $(SOURCE_MODULES)) BUILD_PRODUCT_MODULES := $(filter $(ALL_PRODUCT_MODULES), \ - $(FIRMWARE_MODULES_LIST)) + $(SOURCE_MODULES)) # Module selected to have their headers made available for inclusion by other # modules and their configuration files. These modules are not built into the @@ -169,7 +204,6 @@ else endif export BUILD_HAS_NOTIFICATION - # Add directories to the list of targets to build LIB_TARGETS_y += $(patsubst %,$(MODULES_DIR)/%/src, \ $(BUILD_STANDARD_MODULES)) @@ -181,11 +215,19 @@ MODULE_LIBS_y += $(patsubst %, \ $(BUILD_FIRMWARE_DIR)/module/%$(BUILD_SUFFIX)/$(MODE)/lib/lib.a, \ $(BUILD_STANDARD_MODULES) $(BUILD_PRODUCT_MODULES)) -# Create a list of include directories from the selected modules +# Add path for libraries +MODULE_LIBS_y += $(foreach module,$(LIBRARY_MODULES_STANDARD), \ + $(MODULES_DIR)/$(module)/lib/mod_$(module).a) +MODULE_LIBS_y += $(foreach module,$(LIBRARY_MODULES_PRODUCT), \ + $(PRODUCT_MODULES_DIR)/$(module)/lib/mod_$(module).a) + +# Create a list of include directories from the selected modules and libraries MODULE_INCLUDES += $(patsubst %,$(MODULES_DIR)/%/include, \ - $(BUILD_STANDARD_MODULES)) + $(BUILD_STANDARD_MODULES) \ + $(LIBRARY_MODULES_STANDARD)) MODULE_INCLUDES += $(patsubst %,$(PRODUCT_MODULES_DIR)/%/include, \ - $(BUILD_PRODUCT_MODULES)) + $(BUILD_PRODUCT_MODULES) \ + $(LIBRARY_MODULES_PRODUCT)) MODULE_INCLUDES += $(patsubst %,$(MODULES_DIR)/%/include, \ $(HEADER_STANDARD_MODULES)) MODULE_INCLUDES += $(patsubst %,$(PRODUCT_MODULES_DIR)/%/include, \ @@ -198,7 +240,7 @@ PRODUCT_INCLUDES += $(PRODUCT_DIR)/include # Add the firmware directory to the main INCLUDES list INCLUDES += $(FIRMWARE_DIR) -# Add module and product includes to the main INCLUDES list +# Add module, product and library includes to the main INCLUDES list export INCLUDES += $(MODULE_INCLUDES) $(PRODUCT_INCLUDES) # |