From: Simon Kuenzer Date: Mon, 18 Sep 2023 12:17:40 +0000 (+0200) Subject: build: Introduce `E=` parameter for excluding libraries X-Git-Tag: RELEASE-0.15.0~1 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=bd59fe545a6b0ad43a6f95c074520cecf2922c32;p=unikraft%2Funikraft.git build: Introduce `E=` parameter for excluding libraries This commit introduces the build system parameter `E=` which expects a colon separated list of paths that are matched against any library path that the build system is including. This mechanism is intended to be used for replacing internal libraries. For example, to replace `uksched`, the replacing library (that has to match configuration name(s) and APIs) needs to be included with `L=` while at the same time, the Unikraft-internal library has to be excluded with `E=`: ``` make L=/path/to/external-uksched E=/path/to/unikraft/lib/uksched ``` Signed-off-by: Simon Kuenzer Reviewed-by: Cezar Craciunoiu Reviewed-by: Michalis Pappas Reviewed-by: Maria Sfiraiala Approved-by: Razvan Deaconescu GitHub-Closes: #1104 --- diff --git a/Config.uk b/Config.uk index cbb56ace7..7d71cd2b8 100644 --- a/Config.uk +++ b/Config.uk @@ -41,19 +41,19 @@ menu "Architecture Selection" endmenu menu "Platform Configuration" - source "$(shell,$(UK_BASE)/support/build/config-submenu.sh -q -o '$(KCONFIG_DIR)/plats.uk' -r '$(KCONFIG_PLAT_BASE)' -l '$(KCONFIG_PLAT_BASE)' -c '$(KCONFIG_EPLAT_DIRS)')" + source "$(shell,$(UK_BASE)/support/build/config-submenu.sh -q -o '$(KCONFIG_DIR)/plats.uk' -r '$(KCONFIG_PLAT_BASE)' -l '$(KCONFIG_PLAT_BASE)' -c '$(KCONFIG_EPLAT_DIRS)' -e '$(KCONFIG_EXCLUDEDIRS)')" endmenu menu "Device Drivers" - source "$(shell,$(UK_BASE)/support/build/config-submenu.sh -q -o '$(KCONFIG_DIR)/drivers.uk' -r '$(KCONFIG_DRIV_BASE)' -l '$(KCONFIG_DRIV_BASE)')" + source "$(shell,$(UK_BASE)/support/build/config-submenu.sh -q -o '$(KCONFIG_DIR)/drivers.uk' -r '$(KCONFIG_DRIV_BASE)' -l '$(KCONFIG_DRIV_BASE)' -e '$(KCONFIG_EXCLUDEDIRS)')" endmenu menu "Library Configuration" - source "$(shell,$(UK_BASE)/support/build/config-submenu.sh -q -o '$(KCONFIG_DIR)/libs.uk' -r '$(KCONFIG_LIB_BASE)' -l '$(KCONFIG_LIB_BASE)' -c '$(KCONFIG_ELIB_DIRS)')" + source "$(shell,$(UK_BASE)/support/build/config-submenu.sh -q -o '$(KCONFIG_DIR)/libs.uk' -r '$(KCONFIG_LIB_BASE)' -l '$(KCONFIG_LIB_BASE)' -c '$(KCONFIG_ELIB_DIRS)' -e '$(KCONFIG_EXCLUDEDIRS)')" endmenu if !NO_APP - source "$(shell,$(UK_BASE)/support/build/config-submenu.sh -q -o '$(KCONFIG_DIR)/app.uk' -t "Application Options" -l '$(KCONFIG_EAPP_DIR)')" + source "$(shell,$(UK_BASE)/support/build/config-submenu.sh -q -o '$(KCONFIG_DIR)/app.uk' -t "Application Options" -l '$(KCONFIG_EAPP_DIR)' -e '$(KCONFIG_EXCLUDEDIRS)')" endif menu "Build Options" diff --git a/Makefile b/Makefile index 48deb4db2..a3fcddfef 100644 --- a/Makefile +++ b/Makefile @@ -192,18 +192,35 @@ ifeq ("$(origin L)", "command line") $(foreach ITR,$(subst :, ,$(L)), \ $(if $(filter /%,$(ITR)),,$(error Path to external library "$(ITR)" (L) is not absolute));\ $(if $(wildcard $(ITR)), \ -$(eval ELIB_DIR += $(ITR)), \ +$(eval ELIB_DIR += $(realpath $(patsubst %/,%,$(patsubst %.,%,$(ITR))))), \ $(error Cannot find library: $(ITR)) \ ) \ ) endif ELIB_DIR := $(realpath $(patsubst %/,%,$(patsubst %.,%,$(ELIB_DIR)))) +# IMPORT_EXCLUDEDIRS (list of (library) paths to exclude) +# Retrieved from E variable from the command line +# (paths are separated by colon) +KCONFIG_EXCLUDEDIRS:= +IMPORT_EXCLUDEDIRS:= +ifeq ("$(origin E)", "command line") +$(foreach ITR,$(subst :, ,$(E)), \ +$(if $(filter /%,$(ITR)),,$(error Path to library to exclude "$(ITR)" (E) is not absolute));\ +$(if $(wildcard $(ITR)), \ +$(eval IMPORT_EXCLUDEDIRS += $(realpath $(patsubst %/,%,$(patsubst %.,%,$(ITR))))) \ +$(eval KCONFIG_EXCLUDEDIRS = $(KCONFIG_EXCLUDEDIRS)$(colon)$(realpath $(patsubst %/,%,$(patsubst %.,%,$(ITR))))), \ +$(error Cannot find library for exclusion: $(ITR)) \ +) \ +) +endif + $(call verbose_info,* Unikraft base: $(CONFIG_UK_BASE)) $(call verbose_info,* Configuration: $(UK_CONFIG)) $(call verbose_info,* Application base: $(CONFIG_UK_APP)) $(call verbose_info,* External platforms: [ $(EPLAT_DIR) ]) $(call verbose_info,* External libraries: [ $(ELIB_DIR) ]) +$(call verbose_info,* Import excludes: [ $(IMPORT_EXCLUDEDIRS) ]) $(call verbose_info,* Build output: $(BUILD_DIR)) build_dir_make := 0 @@ -889,6 +906,7 @@ COMMON_CONFIG_ENV = \ KCONFIG_EPLAT_DIRS="$(KCONFIG_EPLAT_DIRS)" \ KCONFIG_DRIV_BASE="$(KCONFIG_DRIV_BASE)" \ KCONFIG_EAPP_DIR="$(KCONFIG_EAPP_DIR)" \ + KCONFIG_EXCLUDEDIRS="$(KCONFIG_EXCLUDEDIRS)" \ UK_NAME="$(CONFIG_UK_NAME)" PHONY += scriptconfig scriptsyncconfig iscriptconfig kmenuconfig guiconfig \ @@ -1191,6 +1209,11 @@ endif @echo ' (note: the name in the configuration file is not overwritten)' @echo ' L=[PATH]:[PATH]:.. - colon-separated list of paths to external libraries' @echo ' P=[PATH]:[PATH]:.. - colon-separated list of paths to external platforms' + @echo ' E=[PATH]:[PATH]:.. - colon-separated list of paths to libraries that shall be skipped/excluded' + @echo ' (note: `E=` acts as a global exclusion mask, which means that the mask' + @echo ' is applied to every internal and external import of libraries, platforms,' + @echo ' and applications. For example, an external library (via `L=`) will also be' + @echo ' skipped if its path was specified with `E=` at the same time.)' @echo '' @echo 'Environment variables:' @echo ' UK_ASFLAGS - explicit Unikraft-specific additions to the assembler flags (the ASFLAGS variable is ignored)' diff --git a/drivers/Config.uk b/drivers/Config.uk index 1d8fdbad8..3c5afb5a2 100644 --- a/drivers/Config.uk +++ b/drivers/Config.uk @@ -1,17 +1,17 @@ menu "Bus drivers" -source "$(shell,$(UK_BASE)/support/build/config-submenu.sh -q -o '$(KCONFIG_DIR)/drivers-bus.uk' -r '$(KCONFIG_DRIV_BASE)/ukbus' -l '$(KCONFIG_DRIV_BASE)/ukbus')" +source "$(shell,$(UK_BASE)/support/build/config-submenu.sh -q -o '$(KCONFIG_DIR)/drivers-bus.uk' -r '$(KCONFIG_DRIV_BASE)/ukbus' -l '$(KCONFIG_DRIV_BASE)/ukbus' -e '$(KCONFIG_EXCLUDEDIRS)')" endmenu menu "Interrupt controller" -source "$(shell,$(UK_BASE)/support/build/config-submenu.sh -q -o '$(KCONFIG_DIR)/drivers-intctlr.uk' -r '$(KCONFIG_DRIV_BASE)/ukintctlr' -l '$(KCONFIG_DRIV_BASE)/ukintctlr')" +source "$(shell,$(UK_BASE)/support/build/config-submenu.sh -q -o '$(KCONFIG_DIR)/drivers-intctlr.uk' -r '$(KCONFIG_DRIV_BASE)/ukintctlr' -l '$(KCONFIG_DRIV_BASE)/ukintctlr' -e '$(KCONFIG_EXCLUDEDIRS)')" endmenu menu "Virtio" -source "$(shell,$(UK_BASE)/support/build/config-submenu.sh -q -o '$(KCONFIG_DIR)/drivers-virtio.uk' -r '$(KCONFIG_DRIV_BASE)/virtio' -l '$(KCONFIG_DRIV_BASE)/virtio')" +source "$(shell,$(UK_BASE)/support/build/config-submenu.sh -q -o '$(KCONFIG_DIR)/drivers-virtio.uk' -r '$(KCONFIG_DRIV_BASE)/virtio' -l '$(KCONFIG_DRIV_BASE)/virtio' -e '$(KCONFIG_EXCLUDEDIRS)')" endmenu