include/package.mk: Add support for src-checkout/ folder master
authorJohn Crispin <john@phrozen.org>
Wed, 10 Jul 2019 11:32:24 +0000 (13:32 +0200)
committerJohn Crispin <john@phrozen.org>
Wed, 10 Jul 2019 11:49:19 +0000 (13:49 +0200)
This feature is similar to the SRC_TREE_OVERRIDE. However instead of having
to manually create a symlink inside the package folder, the buildsystem
will check if $(TOP_DIR)/src-checkout/$(PKG_NAME)/.git is present and use
this instead.

Signed-off-by: John Crispin <john@phrozen.org>
.gitignore
include/package.mk

index 84e1a9d6d18c50b1b82cb39b0ec808413ef22ec0..1dea10c878c5d6be0fe1acafc5cf7f30798b91cc 100644 (file)
@@ -16,6 +16,7 @@
 /overlay
 /package/feeds
 /package/openwrt-packages
 /overlay
 /package/feeds
 /package/openwrt-packages
+/src-checkout
 key-build*
 *.orig
 *.rej
 key-build*
 *.orig
 *.rej
index 06ff21b0b0afab1d4d909d10a024909c08d7f34b..c3818f176316d6cffb2282ecb24c0bb332f7bbf1 100644 (file)
@@ -40,6 +40,10 @@ include $(INCLUDE_DIR)/prereq.mk
 include $(INCLUDE_DIR)/unpack.mk
 include $(INCLUDE_DIR)/depends.mk
 
 include $(INCLUDE_DIR)/unpack.mk
 include $(INCLUDE_DIR)/depends.mk
 
+ifneq ($(wildcard $(TOPDIR)/src-checkout/$(PKG_NAME)/.git),)
+  USE_GIT_SRC_CHECKOUT:=1
+  QUILT:=1
+endif
 ifneq ($(if $(CONFIG_SRC_TREE_OVERRIDE),$(wildcard ./git-src)),)
   USE_GIT_TREE:=1
   QUILT:=1
 ifneq ($(if $(CONFIG_SRC_TREE_OVERRIDE),$(wildcard ./git-src)),)
   USE_GIT_TREE:=1
   QUILT:=1
@@ -129,6 +133,18 @@ ifeq ($(DUMP)$(filter prereq clean refresh update,$(MAKECMDGOALS)),)
   endif
 endif
 
   endif
 endif
 
+ifdef USE_GIT_SRC_CHECKOUT
+  define Build/Prepare/Default
+       mkdir -p $(PKG_BUILD_DIR)
+       ln -s $(TOPDIR)/src-checkout/$(PKG_NAME)/.git $(PKG_BUILD_DIR)/.git
+       ( cd $(PKG_BUILD_DIR); \
+               git checkout .; \
+               git submodule update --recursive; \
+               git submodule foreach git config --unset core.worktree; \
+               git submodule foreach git checkout .; \
+       )
+  endef
+endif
 ifdef USE_GIT_TREE
   define Build/Prepare/Default
        mkdir -p $(PKG_BUILD_DIR)
 ifdef USE_GIT_TREE
   define Build/Prepare/Default
        mkdir -p $(PKG_BUILD_DIR)
@@ -248,7 +264,7 @@ define Build/CoreTargets
 endef
 
 define Build/DefaultTargets
 endef
 
 define Build/DefaultTargets
-  $(if $(USE_SOURCE_DIR)$(USE_GIT_TREE),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default)))
+  $(if $(USE_SOURCE_DIR)$(USE_GIT_TREE)$(USE_GIT_SRC_CHECKOUT),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default)))
   $(if $(DUMP),,$(Build/CoreTargets))
 
   define Build/DefaultTargets
   $(if $(DUMP),,$(Build/CoreTargets))
 
   define Build/DefaultTargets