]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
build: Create minimal build folder structure earlier
authorSimon Kuenzer <simon@unikraft.io>
Wed, 9 Aug 2023 23:19:55 +0000 (01:19 +0200)
committerUnikraft <monkey@unikraft.io>
Fri, 11 Aug 2023 10:21:30 +0000 (10:21 +0000)
This commit creates the build folder substructure ealier, except that a
target was called that does not require any KConfig involvement. This
allows us to move generated Config.uk snippets under `build/kconfig` in
order to clean up the root of the build folder.
Additionally, this commit corrects
commit b8872a6b572c ("build: first level subdirectories only with `mk_sub_build_dir`")
where the `uk` subdirectory was no longer created under
`$(BUILD_ROOT)/include`. The commit also introduces consistent use
of the `$(MKDIR)` command alias.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Alexander Jung <alex@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #1034

Makefile
include/uk/config.h
support/build/Makefile.rules

index bbcebcbc09177ab083f477ebc4e90cfec5b169ec..ce60f922a3b94e4c75e25d4af9acb4c0bd10435b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -214,11 +214,12 @@ CONFIG                := $(CONFIG_UK_BASE)/support/kconfig
 CONFIGLIB            := $(CONFIG_UK_BASE)/support/kconfiglib
 UK_CONFIG_OUT         := $(BUILD_DIR)/config
 UK_GENERATED_INCLUDES := $(BUILD_DIR)/include
+KCONFIG_INCLUDES_DIR  := $(UK_GENERATED_INCLUDES)/uk/bits
 KCONFIG_DIR           := $(BUILD_DIR)/kconfig
 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_AUTOHEADER    := $(KCONFIG_INCLUDES_DIR)/config.h
 KCONFIG_APP_DIR       := $(CONFIG_UK_APP)
 KCONFIG_LIB_IN        := $(KCONFIG_DIR)/libs.uk
 KCONFIG_DEF_PLATS     := $(shell find $(CONFIG_UK_PLAT)/* -maxdepth 0 \
@@ -249,13 +250,15 @@ export DATE := $(shell date +%Y%m%d)
 
 # Makefile targets
 null_targets           := print-version print-vars help
+nokconfig_targets       := properclean distclean $(null_targets)
 noconfig_targets       := ukconfig menuconfig nconfig gconfig xconfig config \
                           oldconfig randconfig \
                           defconfig %_defconfig allyesconfig allnoconfig \
                           silentoldconfig \
-                          release olddefconfig properclean distclean \
+                          release olddefconfig \
                           scriptconfig iscriptconfig kmenuconfig guiconfig \
-                          dumpvarsconfig print-version help
+                          dumpvarsconfig \
+                          $(nokconfig_targets)
 
 # we want bash as shell
 SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
@@ -274,6 +277,19 @@ XARGS := xargs
 CONFIG_SHELL := $(SHELL)
 export SHELL CONFIG_SHELL Q KBUILD_VERBOSE
 
+################################################################################
+# Create minimal necessary folder structure
+################################################################################
+# Create them before trying to include a .config
+ifeq ($(filter $(nokconfig_targets),$(MAKECMDGOALS)),)
+$(if $(shell $(MKDIR) -pv $(KCONFIG_DIR) && cd $(KCONFIG_DIR) >/dev/null && pwd),,\
+       $(error Could not create $(KCONFIG_DIR)))
+$(if $(shell $(MKDIR) -pv $(UK_GENERATED_INCLUDES) && cd $(KCONFIG_DIR) >/dev/null && pwd),,\
+       $(error Could not create $(UK_GENERATED_INCLUDES)))
+$(if $(shell $(MKDIR) -pv $(KCONFIG_INCLUDES_DIR) && cd $(KCONFIG_DIR) >/dev/null && pwd),,\
+       $(error Could not create $(KCONFIG_INCLUDES_DIR)))
+endif
+
 ################################################################################
 # .config
 ################################################################################
@@ -653,11 +669,6 @@ CXXFLAGS += $(UK_CXXFLAGS)
 GOCFLAGS += $(UK_GOCFLAGS)
 LDFLAGS  += $(UK_LDFLAGS)
 
-# ensure $(BUILD_DIR)/kconfig, $(BUILD_DIR)/include and $(BUILD_DIR)/include/uk exists
-$(call mk_sub_build_dir,kconfig)
-$(call mk_sub_build_dir,include)
-$(call mk_sub_build_dir,include/uk)
-
 ASINCLUDES            += -I$(UK_GENERATED_INCLUDES)
 CINCLUDES             += -I$(UK_GENERATED_INCLUDES)
 CXXINCLUDES           += -I$(UK_GENERATED_INCLUDES)
index 0edc9810ab3fbf0b36fb7654c124fbd6aee7e8be..7182dedad6099ff641d2716034655d0b894d1371 100644 (file)
@@ -34,6 +34,6 @@
 #ifndef __UK_CONFIG_H__
 #define __UK_CONFIG_H__
 
-#include <uk/_config.h>
+#include <uk/bits/config.h>
 
 #endif /* __UK_CONFIG_H__ */
index 9633e07b7a09ed09af3b12e20ab8a3a1ba5de5fc..1e368db4db5793097b708c52e8db5a45349f77c5 100644 (file)
@@ -85,7 +85,7 @@ endef
 # Creates a subfolder under the build output directory
 # mk_sub_build_dir $1:subfoldername
 define mk_sub_build_dir =
-$(if $(shell mkdir -p "$(BUILD_DIR)/$(notdir $(1))" && cd "$(BUILD_DIR)/$(notdir $(1))" >/dev/null && pwd),,\
+$(if $(shell $(MKDIR) -p "$(BUILD_DIR)/$(notdir $(1))" && cd "$(BUILD_DIR)/$(notdir $(1))" >/dev/null && pwd),,\
      $(error could not create directory "$(BUILD_DIR)/$(notdir $(1))"))
 endef
 
@@ -272,7 +272,7 @@ endef
 # creates a sub build directory for a library
 # mk_sub_libbuild_dir $1:libname,$2:subdir
 define mk_sub_libbuild_dir =
-$(if $(shell mkdir -p "$(BUILD_DIR)/$(notdir $(1))/$(strip $(2))" && cd "$(BUILD_DIR)/$(notdir $(1))/$(strip $(2))" >/dev/null && pwd),,\
+$(if $(shell $(MKDIR) -p "$(BUILD_DIR)/$(notdir $(1))/$(strip $(2))" && cd "$(BUILD_DIR)/$(notdir $(1))/$(strip $(2))" >/dev/null && pwd),,\
      $(error could not create directory "$(BUILD_DIR)/$(notdir $(1))/$(strip $(2))"))
 endef