|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCH v3 18/23] build: Pre-process Config.uk within kconfig
Hi Sharan,
This patch looks ok.
-- Felipe
Reviewed-by: Felipe Huici <felipe.huici@xxxxxxxxx>
On 19.09.19, 11:17, "Minios-devel on behalf of Sharan Santhanam"
<minios-devel-bounces@xxxxxxxxxxxxxxxxxxxx on behalf of
Sharan.Santhanam@xxxxxxxxx> wrote:
The kconfig external library were processed in the Makefile. With
this patch we use the kconfig preprocess feature to generate the
necessary Config.uk files
Signed-off-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>
---
Config.uk | 23 +++-----
Makefile | 86 +++++++++++-----------------
lib/Config.uk | 8 ---
plat/Config.uk | 4 --
support/scripts/uk_build_configure.sh | 102
++++++++++++++++++++++++++++++++++
5 files changed, 141 insertions(+), 82 deletions(-)
create mode 100755 support/scripts/uk_build_configure.sh
diff --git a/Config.uk b/Config.uk
index 21ae657..01a7ac8 100644
--- a/Config.uk
+++ b/Config.uk
@@ -3,16 +3,6 @@
# see
https://www.kernel.org/doc/Documentation/kbuild/Config.in-language.txt.
#
mainmenu "Unikraft/$(UK_FULLVERSION) Configuration"
-config KCONFIG_APP_IN
- string
- default "$(KCONFIG_APP_IN)"
-config KCONFIG_ELIB_IN
- string
- default "$(KCONFIG_ELIB_IN)"
-config KCONFIG_EPLAT_IN
- string
- default "$(KCONFIG_EPLAT_IN)"
-
config UK_FULLVERSION
string
default "$(UK_FULLVERSION)"
@@ -22,6 +12,9 @@ config UK_CODENAME
config UK_ARCH
string
default "$(UK_ARCH)"
+config NO_APP
+ def_bool $(shell,test $(UK_BASE) = $(UK_APP) && echo y || echo n)
+
config UK_BASE
string
default "$(UK_BASE)"
@@ -37,13 +30,11 @@ menu "Architecture Selection"
endmenu
menu "Platform Configuration"
- source "plat/Config.uk"
- source "$(KCONFIG_EPLAT_IN)"
+ source "$(shell,$(UK_BASE)/support/scripts/uk_build_configure.sh -p
'$(KCONFIG_PLAT_DIR)' -o '$(KCONFIG_PLAT_IN)')"
endmenu
menu "Library Configuration"
- source "lib/Config.uk"
- source "$(KCONFIG_ELIB_IN)"
+ source "$(shell,$(UK_BASE)/support/scripts/uk_build_configure.sh -e
'$(KCONFIG_LIB_DIR)' -o '$(KCONFIG_LIB_IN)')"
endmenu
menu "Build Options"
@@ -182,9 +173,9 @@ config CROSS_COMPILE
# system.
endmenu
-if UK_APP != UK_BASE
+if !NO_APP
menu "Application Options"
- source "$(KCONFIG_APP_IN)"
+ source
"$(shell,$(UK_BASE)/support/scripts/uk_build_configure.sh -a
'$(KCONFIG_APP_DIR)')"
endmenu
endif
diff --git a/Makefile b/Makefile
index 9df2ee7..4e873f1 100644
--- a/Makefile
+++ b/Makefile
@@ -125,6 +125,8 @@ endif
ELIB_DIR := $(realpath $(patsubst %/,%,$(patsubst %.,%,$(ELIB_DIR))))
# KConfig settings
+
+CONFIG_UK_PLAT := $(CONFIG_UK_BASE)/plat/
CONFIG_DIR := $(CONFIG_UK_APP)
CONFIG_CONFIG_IN := $(CONFIG_UK_BASE)/Config.uk
CONFIG := $(CONFIG_UK_BASE)/support/kconfig.new
@@ -137,9 +139,12 @@ UK_FIXDEP := $(KCONFIG_DIR)/fixdep
KCONFIG_AUTOCONFIG := $(KCONFIG_DIR)/auto.conf
KCONFIG_TRISTATE := $(KCONFIG_DIR)/tristate.config
KCONFIG_AUTOHEADER := $(UK_GENERATED_INCLUDES)/uk/_config.h
-KCONFIG_APP_IN := $(KCONFIG_DIR)/app.uk
-KCONFIG_EPLAT_IN := $(KCONFIG_DIR)/eplat.uk
-KCONFIG_ELIB_IN := $(KCONFIG_DIR)/elib.uk
+KCONFIG_APP_DIR := $(CONFIG_UK_APP)
+KCONFIG_LIB_IN := $(KCONFIG_DIR)/libs.uk
+KCONFIG_DEF_PLATS := $(addprefix $(CONFIG_UK_PLAT),linuxu kvm xen)
+KCONFIG_LIB_DIR := $(CONFIG_UK_BASE)/lib $(ELIB_DIR)
+KCONFIG_PLAT_DIR := $(KCONFIG_DEF_PLATS) $(EPLAT_DIR)
$(CONFIG_UK_PLAT)
+KCONFIG_PLAT_IN := $(KCONFIG_DIR)/plat.uk
# Makefile support scripts
SCRIPTS_DIR := $(CONFIG_UK_BASE)/support/scripts
@@ -638,36 +643,6 @@ endif
HOSTCFLAGS = $(CFLAGS_FOR_BUILD)
export HOSTCFLAGS
-# auto-generated KConfig files for including external app
-$(KCONFIG_APP_IN) $(KCONFIG_ELIB_IN) $(KCONFIG_EPLAT_IN): %: %.new
- @cmp -s $^ $@; if [ $$? -ne 0 ]; then cp $^ $@; fi
-
-$(KCONFIG_APP_IN).new:
- @echo '# external application' > $@
-ifneq ($(CONFIG_UK_BASE),$(CONFIG_UK_APP))
- @echo 'source "$(APP_DIR)/Config.uk"' >> $@
-else
- @echo 'comment "No external application specified"' >> $@
-endif
-
-# auto-generated KConfig files for including external libraries
-$(KCONFIG_ELIB_IN).new:
- @echo '# external libraries' > $@
- @$(foreach E,$(ELIB_DIR), \
- echo 'source "$(E)/Config.uk"' >> $@; \
- )
-
-# auto-generated KConfig file for including
-# external platform libraries to the menu
-$(KCONFIG_EPLAT_IN).new:
- @echo '# external platform libraries' > $@
- @$(foreach E,$(EPLAT_DIR), \
- echo 'source "$(E)/Config.uk"' >> $@; \
- )
-
-# enforce execution
-.PHONY: $(KCONFIG_APP_IN).new $(KCONFIG_ELIB_IN).new
$(KCONFIG_EPLAT_IN).new
-
KCONFIG_TOOLS = conf mconf gconf nconf qconf fixdep
KCONFIG_TOOLS := $(addprefix $(KCONFIG_DIR)/,$(KCONFIG_TOOLS))
@@ -694,9 +669,11 @@ COMMON_CONFIG_ENV = \
UK_FULLVERSION="$(UK_FULLVERSION)" \
UK_CODENAME="$(UK_CODENAME)" \
UK_ARCH="$(CONFIG_UK_ARCH)" \
- KCONFIG_APP_IN="$(KCONFIG_APP_IN)" \
- KCONFIG_ELIB_IN="$(KCONFIG_ELIB_IN)" \
- KCONFIG_EPLAT_IN="$(KCONFIG_EPLAT_IN)" \
+ KCONFIG_APP_DIR="$(KCONFIG_APP_DIR)" \
+ KCONFIG_LIB_DIR="$(KCONFIG_LIB_DIR)" \
+ KCONFIG_LIB_IN="$(KCONFIG_LIB_IN)" \
+ KCONFIG_PLAT_DIR="$(KCONFIG_PLAT_DIR)" \
+ KCONFIG_PLAT_IN="$(KCONFIG_PLAT_IN)" \
UK_NAME="$(CONFIG_UK_NAME)"
PHONY += scriptconfig iscriptconfig kmenuconfig guiconfig dumpvarsconfig
@@ -719,11 +696,12 @@ iscriptconfig: $(KCONFIG_DIR)/fixdep
kconf = kconfiglib.Kconfig('$(UK_CONFIG)'); \
print('A Kconfig instance \'kconf\' for the architecture $(ARCH) has
been created.')"
-kmenuconfig:$(KCONFIG_DIR)/fixdep $(KCONFIG_APP_IN) $(KCONFIG_ELIB_IN)
$(KCONFIG_EPLAT_IN)
- @$(COMMON_CONFIG_ENV) $(kpython) $(CONFIGLIB)/menuconfig.py
$(CONFIG_CONFIG_IN)
+kmenuconfig:$(KCONFIG_DIR)/fixdep
+ @$(COMMON_CONFIG_ENV) $(kpython) $(CONFIGLIB)/menuconfig.py \
+ $(CONFIG_CONFIG_IN)
@$(SCRIPTS_DIR)/configupdate $(UK_CONFIG) $(UK_CONFIG_OUT)
-guiconfig: $(KCONFIG_DIR)/fixdep $(KCONFIG_APP_IN) $(KCONFIG_ELIB_IN)
$(KCONFIG_EPLAT_IN)
+guiconfig: $(KCONFIG_DIR)/fixdep
@$(COMMON_CONFIG_ENV) $(kpython) $(CONFIGLIB)/guiconfig.py
$(CONFIG_CONFIG_IN)
@$(SCRIPTS_DIR)/configupdate $(UK_CONFIG) $(UK_CONFIG_OUT)
@@ -731,23 +709,23 @@ dumpvarsconfig:$(KCONFIG_DIR)/fixdep
$(Q)$(COMMON_CONFIG_ENV) $(kpython) $(CONFIGLIB)/examples/dumpvars.py
$(CONFIG_CONFIG_IN)
@$(SCRIPTS_DIR)/configupdate $(UK_CONFIG) $(UK_CONFIG_OUT)
-xconfig: $(KCONFIG_DIR)/qconf $(KCONFIG_APP_IN) $(KCONFIG_ELIB_IN)
$(KCONFIG_EPLAT_IN)
+xconfig: $(KCONFIG_DIR)/qconf
@$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
@$(SCRIPTS_DIR)/configupdate $(UK_CONFIG) $(UK_CONFIG_OUT)
-gconfig: $(KCONFIG_DIR)/gconf $(KCONFIG_APP_IN) $(KCONFIG_ELIB_IN)
$(KCONFIG_EPLAT_IN)
+gconfig: $(KCONFIG_DIR)/gconf
@$(COMMON_CONFIG_ENV) srctree=$(CONFIG_UK_BASE) $< $(CONFIG_CONFIG_IN)
@$(SCRIPTS_DIR)/configupdate $(UK_CONFIG) $(UK_CONFIG_OUT)
-menuconfig: $(KCONFIG_DIR)/mconf $(KCONFIG_APP_IN) $(KCONFIG_ELIB_IN)
$(KCONFIG_EPLAT_IN)
+menuconfig: $(KCONFIG_DIR)/mconf
@$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
@$(SCRIPTS_DIR)/configupdate $(UK_CONFIG) $(UK_CONFIG_OUT)
-nconfig: $(KCONFIG_DIR)/nconf $(KCONFIG_APP_IN) $(KCONFIG_ELIB_IN)
$(KCONFIG_EPLAT_IN)
+nconfig: $(KCONFIG_DIR)/nconf
@$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
@$(SCRIPTS_DIR)/configupdate $(UK_CONFIG) $(UK_CONFIG_OUT)
-config: $(KCONFIG_DIR)/conf $(KCONFIG_APP_IN) $(KCONFIG_ELIB_IN)
$(KCONFIG_EPLAT_IN)
+config: $(KCONFIG_DIR)/conf
@$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
@$(SCRIPTS_DIR)/configupdate $(UK_CONFIG) $(UK_CONFIG_OUT)
@@ -755,43 +733,43 @@ config: $(KCONFIG_DIR)/conf $(KCONFIG_APP_IN)
$(KCONFIG_ELIB_IN) $(KCONFIG_EPLAT
# SKIP_LEGACY=y to disable the legacy options. However, in that case
# no values are set for the legacy options so a subsequent oldconfig
# will query them. Therefore, run an additional olddefconfig.
-oldconfig: $(KCONFIG_DIR)/conf $(KCONFIG_APP_IN) $(KCONFIG_ELIB_IN)
$(KCONFIG_EPLAT_IN)
+oldconfig: $(KCONFIG_DIR)/conf
@$(COMMON_CONFIG_ENV) $< --oldconfig $(CONFIG_CONFIG_IN)
@$(SCRIPTS_DIR)/configupdate $(UK_CONFIG) $(UK_CONFIG_OUT)
-randconfig: $(KCONFIG_DIR)/conf $(KCONFIG_APP_IN) $(KCONFIG_ELIB_IN)
$(KCONFIG_EPLAT_IN)
+randconfig: $(KCONFIG_DIR)/conf
@$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --randconfig $(CONFIG_CONFIG_IN)
@$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
@$(SCRIPTS_DIR)/configupdate $(UK_CONFIG) $(UK_CONFIG_OUT)
-allyesconfig: $(KCONFIG_DIR)/conf $(KCONFIG_APP_IN) $(KCONFIG_ELIB_IN)
$(KCONFIG_EPLAT_IN)
+allyesconfig: $(KCONFIG_DIR)/conf
@$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --allyesconfig
$(CONFIG_CONFIG_IN)
@$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
@$(SCRIPTS_DIR)/configupdate $(UK_CONFIG) $(UK_CONFIG_OUT)
-allnoconfig: $(KCONFIG_DIR)/conf $(KCONFIG_APP_IN) $(KCONFIG_ELIB_IN)
$(KCONFIG_EPLAT_IN)
+allnoconfig: $(KCONFIG_DIR)/conf
@$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --allnoconfig $(CONFIG_CONFIG_IN)
@$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
@$(SCRIPTS_DIR)/configupdate $(UK_CONFIG) $(UK_CONFIG_OUT)
-syncconfig: $(KCONFIG_DIR)/conf $(KCONFIG_APP_IN) $(KCONFIG_ELIB_IN)
$(KCONFIG_EPLAT_IN)
+syncconfig: $(KCONFIG_DIR)/conf
@$(COMMON_CONFIG_ENV) $< --syncconfig $(CONFIG_CONFIG_IN)
@$(SCRIPTS_DIR)/configupdate $(UK_CONFIG) $(UK_CONFIG_OUT)
-olddefconfig: $(KCONFIG_DIR)/conf $(KCONFIG_APP_IN) $(KCONFIG_ELIB_IN)
$(KCONFIG_EPLAT_IN)
+olddefconfig: $(KCONFIG_DIR)/conf
@$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN)
@$(SCRIPTS_DIR)/configupdate $(UK_CONFIG) $(UK_CONFIG_OUT)
-defconfig: $(KCONFIG_DIR)/conf $(KCONFIG_APP_IN) $(KCONFIG_ELIB_IN)
$(KCONFIG_EPLAT_IN)
+defconfig: $(KCONFIG_DIR)/conf
@$(COMMON_CONFIG_ENV) $< --defconfig$(if $(DEFCONFIG),=$(DEFCONFIG))
$(CONFIG_CONFIG_IN)
@$(SCRIPTS_DIR)/configupdate $(UK_CONFIG) $(UK_CONFIG_OUT)
# Override the UK_DEFCONFIG from COMMON_CONFIG_ENV with the new defconfig
-%_defconfig: $(KCONFIG_DIR)/conf $(A)/configs/%_defconfig
$(KCONFIG_APP_IN) $(KCONFIG_ELIB_IN) $(KCONFIG_EPLAT_IN)
+%_defconfig: $(KCONFIG_DIR)/conf $(A)/configs/%_defconfig
@$(COMMON_CONFIG_ENV) UK_DEFCONFIG=$(A)/configs/$@ \
$< --defconfig=$(A)/configs/$@ $(CONFIG_CONFIG_IN)
-savedefconfig: $(KCONFIG_DIR)/conf $(KCONFIG_APP_IN) $(KCONFIG_ELIB_IN)
$(KCONFIG_EPLAT_IN)
+savedefconfig: $(KCONFIG_DIR)/conf
@$(COMMON_CONFIG_ENV) $< \
--savedefconfig=$(if
$(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig) \
$(CONFIG_CONFIG_IN)
@@ -801,7 +779,7 @@ savedefconfig: $(KCONFIG_DIR)/conf $(KCONFIG_APP_IN)
$(KCONFIG_ELIB_IN) $(KCONFI
.PHONY: defconfig savedefconfig silentoldconfig
# Regenerate $(KCONFIG_AUTOHEADER) whenever $(UK_CONFIG) changed
-$(KCONFIG_AUTOHEADER): $(UK_CONFIG) $(KCONFIG_DIR)/conf $(KCONFIG_APP_IN)
$(KCONFIG_ELIB_IN) $(KCONFIG_EPLAT_IN)
+$(KCONFIG_AUTOHEADER): $(UK_CONFIG) $(KCONFIG_DIR)/conf
@$(COMMON_CONFIG_ENV) $(KCONFIG_DIR)/conf --syncconfig
$(CONFIG_CONFIG_IN)
diff --git a/lib/Config.uk b/lib/Config.uk
index 23e705d..44311de 100644
--- a/lib/Config.uk
+++ b/lib/Config.uk
@@ -20,11 +20,3 @@ config HAVE_SCHED
config HAVE_NW_STACK
bool
default n
-
-
-################################################################################
-#
-# Library definitions
-#
-################################################################################
-source "lib/*/Config.uk"
diff --git a/plat/Config.uk b/plat/Config.uk
index 8a878eb..0eb5a10 100644
--- a/plat/Config.uk
+++ b/plat/Config.uk
@@ -1,7 +1,3 @@
-source "plat/xen/Config.uk"
-source "plat/kvm/Config.uk"
-source "plat/linuxu/Config.uk"
-
menu "Platform Interface Options"
config UKPLAT_MEMRNAME
bool "Memory region names"
diff --git a/support/scripts/uk_build_configure.sh
b/support/scripts/uk_build_configure.sh
new file mode 100755
index 0000000..1df8c5d
--- /dev/null
+++ b/support/scripts/uk_build_configure.sh
@@ -0,0 +1,102 @@
+#!/bin/bash
+
+OPT_BASENAME=`basename $0`
+OPT_STRING="a:e:ho:p:"
+
+read -r -d '' OPT_HELP <<- EOH
+ a - The application location
+ e - The location of the external libraries
+ p - The location of external platforms
+ o - The output configuration file
+ h - Print Usage
+EOH
+
+print_usage() {
+ printf "%s [%s]\n" ${OPT_BASENAME} ${OPT_STRING};
+ printf "%s\n" "${OPT_HELP}"
+}
+
+fetch_plats() {
+ local files=;
+ files=`find ${@} -maxdepth 1 -name "Config.uk"`
+ echo ${files}
+}
+
+fetch_libs() {
+ local files=;
+ files=`find ${@} -name "Config.uk"`
+ echo ${files}
+}
+
+fetch_app() {
+ local files=;
+ files=`find ${1} -name "Config.uk"`
+ echo ${files}
+}
+
+config_out_create() {
+
+ [[ -f ${2} ]] || touch ${2};
+
+ for file in ${1}
+ do
+ [[ -z `cat ${2} | grep ${file}` ]] && \
+ { echo "source \"${file}\"" >> ${2}; }
+ done
+}
+
+if [ $# -eq 0 ];
+then
+ print_usage
+ exit 1;
+fi
+
+[[ -n ${CONFIG_UK_BASE} ]] && UK_BASE=${CONFIG_UK_BASE};
+[[ -n ${UK_BASE} ]] || UK_BASE=$(readlink -f $(dirname $0)/../..)
+
+CONFIG_FILES=;
+
+while getopts ${OPT_STRING} opt
+do
+ case ${opt} in
+ a)
+ APP_DIR="${OPTARG}"
+ [[ -d ${APP_DIR} ]] || \
+ { echo "Cannot find the application"; exit 1; }
+ if [ ${UK_BASE} != ${APP_DIR} ]
+ then
+ CONFIG_FILES=$(fetch_app ${APP_DIR})
+ echo ${CONFIG_FILES};
+ else
+ CONFIG_FILES=${BUILD_DIR}/app.uk
+ [[ -f ${BUILD_DIR}/app.uk ]] || \
+ { touch ${CONFIG_FILES}; }
+ echo '# external application' >> ${CONFIG_FILES}
+ echo 'comment "No external application specified"'\
+ >> ${CONFIG_FILES}
+ echo ${CONFIG_FILES};
+ fi
+ exit 0;
+ ;;
+ e)
+ CONFIG_FILES=`fetch_libs "${OPTARG}"`
+ ;;
+ p)
+ CONFIG_FILES=`fetch_plats "${OPTARG}"`
+ ;;
+ h)
+ print_usage;
+ exit 0;
+ ;;
+ o)
+ CONFIG_OUT_FILE=${OPTARG}
+ ;;
+ *)
+ print_usage
+ exit 1;
+ ;;
+ esac
+done
+
+config_out_create "${CONFIG_FILES}" ${CONFIG_OUT_FILE}
+echo ${CONFIG_OUT_FILE}
--
2.7.4
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |