]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
build: Introduce `E=` parameter for excluding libraries
authorSimon Kuenzer <simon@unikraft.io>
Mon, 18 Sep 2023 12:17:40 +0000 (14:17 +0200)
committerRazvan Deaconescu <razvand@unikraft.io>
Fri, 20 Oct 2023 16:35:55 +0000 (19:35 +0300)
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 <simon@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1104

Config.uk
Makefile
drivers/Config.uk

index cbb56ace760235d64bed4cfdff27543d77733e06..7d71cd2b83a58750b1d12fc33f0f71baaa926dac 100644 (file)
--- 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"
index 48deb4db2843ba7527961e539976d583b8900e8d..a3fcddfef334f794136c95b4e2b63c673cb68fd4 100644 (file)
--- 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)'
index 1d8fdbad8ee91075ec84d1ba16a01f109d05605a..3c5afb5a29da6664828c13f2ecb417776d0c4fa4 100644 (file)
@@ -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