]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
build: Add option for dedicated build directory
authorAndrei Tatar <andrei@unikraft.io>
Wed, 28 Jun 2023 13:47:28 +0000 (15:47 +0200)
committerUnikraft <monkey@unikraft.io>
Fri, 11 Aug 2023 16:05:36 +0000 (16:05 +0000)
This change adds the option to place build files in a dedicated
`.../build/` directory under the library build path.
This feature is opt-in per-library and enabled if the $(LIBNAME)__BUILDTREE
make variable is set.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #1001

support/build/Makefile.rules

index fe54b5fed7de60eeef3a3403a49e607539c5d112..192a4f7b9c3233021e0068ba907bb40129dfca18 100644 (file)
@@ -82,18 +82,19 @@ endef
 #
 ################################################################################
 
+# Returns the fully-qualified path for a subfolder under the build output
+# directory
+sub_build_dir = $(addprefix $(BUILD_DIR)/,$(if $($(call uc,$(1))__BUILDTREE),\
+       $(notdir $(1))/build,$(notdir $(1))))
+
 # 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),,\
-     $(error could not create directory "$(BUILD_DIR)/$(notdir $(1))"))
+$(eval _d := $(call sub_build_dir,$(1)))\
+$(if $(shell $(MKDIR) -p "$(_d)" && cd "$(_d)" >/dev/null && pwd),,\
+     $(error could not create directory "$(_d)"))
 endef
 
-# Returns the fully-qualified path for a subfolder under the build output
-# directory
-# sub_build_dir $1:subfoldername
-sub_build_dir = $(addprefix $(BUILD_DIR)/,$(notdir $(1)))
-
 # Returns the file extension
 fileext = $(subst .,,$(suffix $(1)))
 
@@ -269,15 +270,16 @@ define addplatlib_s =
 $(if $(filter y,$(3)),$(call addplatlib,$(1),$(2)),)
 endef
 
+sub_libbuild_dir = $(call sub_build_dir,$(1))/$(strip $(2))
+
 # 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),,\
-     $(error could not create directory "$(BUILD_DIR)/$(notdir $(1))/$(strip $(2))"))
+$(eval _d := $(call sub_libbuild_dir,$(1),$(2)))\
+$(if $(shell $(MKDIR) -p "$(_d)" && cd "$(_d)" >/dev/null && pwd),,\
+     $(error could not create directory "$(_d)"))
 endef
 
-sub_libbuild_dir = $(BUILD_DIR)/$(notdir $(1))/$(strip $(2))
-
 ################################################################################
 #
 # Command calling
@@ -432,7 +434,7 @@ $(error $(2): missing extraction rule for archive type)\
 ))))
 UK_FETCH-y += $(BUILD_DIR)/$(1)/.origin \
 $(eval $(call vprefix_lib,$(1),ORIGIN) = $(BUILD_DIR)/$(1)/origin)
-$(call mk_sub_libbuild_dir,$(1),origin)
+$(shell $(MKDIR) -p $(BUILD_DIR)/$(1)/origin)
 
 .PRECIOUS: $(BUILD_DIR)/$(1)/origin