solenv/gbuild/TargetLocations.mk |    1 +
 solenv/gbuild/UnpackedTarball.mk |   31 ++++++++++++++++++++++++++++++-
 solenv/gbuild/gbuild.mk          |    8 ++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)

New commits:
commit 363e0b67e9ce5de317603a76a5ffc159fc964722
Author: Norbert Thiebaud <[email protected]>
Date:   Thu Sep 27 16:19:14 2012 -0500

    add supporting target and options to generate patches for ExternalProjects
    
    also add the support for the convention that a patch filename
    encode the -p value if it end with .[0-9]
    for instance foo.patch.2 indicate a -p2 patch
    
    usage:
    
    generate a 'reference' copy of the expanded and patched file structure
    $> make clucene.clean
    $> patches=t make clucene
    
    go to the module
    $> cd clucene
    
    edit files in $WORKDIR/UnpackedTarball/clucene
    
    force a rebuild of things that depend on that UnpackedTarball
    $> make clucene.rebuild
    
    
    create a -p1 patch named clucene.new.patch.1 in the module's directory
    $> make clucene.genpatch
    
    you can then rename it, place it where appropriate in the module
    hierarchy, update the UnpackedTarball_lucene.mk to apply it.
    
    rinse and repeat from the top (yes the make lucene.clean is needed
    to regenerate a 'reference' expanded and patched tarball)
    
    Change-Id: I419c54a5981cffa385521596ba5016d2ca7ef52a
    Reviewed-on: https://gerrit.libreoffice.org/712
    Reviewed-by: Norbert Thiebaud <[email protected]>
    Tested-by: Norbert Thiebaud <[email protected]>

diff --git a/solenv/gbuild/TargetLocations.mk b/solenv/gbuild/TargetLocations.mk
index be268ba..28c7dd4 100644
--- a/solenv/gbuild/TargetLocations.mk
+++ b/solenv/gbuild/TargetLocations.mk
@@ -171,6 +171,7 @@ gb_UnoApiHeadersTarget_get_comprehensive_target = 
$(WORKDIR)/UnoApiHeadersTarget
 gb_UnoApiHeadersTarget_get_target = 
$(WORKDIR)/UnoApiHeadersTarget/$(1)/normal.done
 gb_UnoApiPartTarget_get_target = $(WORKDIR)/UnoApiPartTarget/$(1)
 gb_UnpackedTarball_get_dir = $(WORKDIR)/UnpackedTarball/$(1)
+gb_UnpackedTarball_get_pristine_dir = $(WORKDIR)/UnpackedTarball/$(1).org
 gb_UnpackedTarball_get_final_target = $(WORKDIR)/UnpackedTarball/$(1).update
 gb_UnpackedTarball_get_target = $(WORKDIR)/UnpackedTarball/$(1).done
 gb_UnpackedTarball_get_preparation_target = 
$(WORKDIR)/UnpackedTarball/$(1).prepare
diff --git a/solenv/gbuild/UnpackedTarball.mk b/solenv/gbuild/UnpackedTarball.mk
index a9cf53e..c96d4ce 100644
--- a/solenv/gbuild/UnpackedTarball.mk
+++ b/solenv/gbuild/UnpackedTarball.mk
@@ -131,7 +131,9 @@ $(call gb_Helper_abbreviate_dirs,\
                $(foreach file,$(UNPACKED_FIX_EOL),$(call 
gb_UnpackedTarball_CONVERTTOUNIX,$(file)) && ) \
                $(if $(UNPACKED_PATCHES),\
                        for p in $(UNPACKED_PATCHES); do \
-                               $(GNUPATCH) -s -p$(UNPACKED_PATCHLEVEL) < "$$p" 
|| exit 1;\
+                               pl=$(UNPACKED_PATCHLEVEL); \
+                               s=$${p##*.}; case "$$s" in [0-9]$(CLOSE_PAREN) 
pl="$$s"; ;; esac ; \
+                               $(GNUPATCH) -s -p$$pl < "$$p" || exit 1;\
                        done && \
                ) \
                $(foreach file,$(UNPACKED_FIX_EOL),$(call 
gb_UnpackedTarball_CONVERTTODOS,$(file)) && ) \
@@ -145,6 +147,10 @@ $(call gb_Helper_abbreviate_dirs,\
                $(if $(UNPACKED_POST_ACTION),\
                        $(UNPACKED_POST_ACTION) && \
                ) \
+           $(if $(gb_KEEP_PRISTINE), \
+                       rm -fr $(call gb_UnpackedTarball_get_pristine_dir,$(2)) 
&& \
+                       cp -r $(call gb_UnpackedTarball_get_dir,$(2)) $(call 
gb_UnpackedTarball_get_pristine_dir,$(2)) && \
+               ) \
                touch $(1) \
        ) || \
        ( \
@@ -174,6 +180,7 @@ $(call gb_UnpackedTarball_get_clean_target,%) :
                        $(call gb_UnpackedTarball_get_target,$*) \
                        $(call gb_UnpackedTarball_get_preparation_target,$*) \
                        $(call gb_UnpackedTarball_get_dir,$*) \
+                       $(call gb_UnpackedTarball_get_pristine_dir,$*) \
                        $(foreach 
subdir,$(UNPACKED_SUBDIRS),$(gb_EXTERNAL_HEADERS_DIR)/$(subdir)) \
        )
 
@@ -365,4 +372,26 @@ $(foreach file,$(2),$(call 
gb_UnpackedTarball_mark_output_file,$(1),$(file)))
 
 endef
 
+# force the rebuild of an external target
+# this only works when running as partial build.
+#
+%.rebuild :
+       if [ -f $(call gb_UnpackedTarball_get_target,$*) ] ; then \
+               touch $(call gb_UnpackedTarball_get_target,$*) ; \
+               make ;\
+       fi
+
+%.genpatch :
+       if [ -d $(call gb_UnpackedTarball_get_dir,$*) -a -d  $(call 
gb_UnpackedTarball_get_pristine_dir,$*) ] ; then \
+               ( \
+                   patch_file=$$(pwd)/$*.new.patch.1; \
+                       cd $(call gb_UnpackedTarball_get_dir,) ; \
+                       diff -ur $*.org $* > $$patch_file; \
+                   echo "Patch $$patch_file generated" ; \
+               ); \
+       else \
+               echo "Error: No pristine tarball avaialable for $*" 1>&2 ; \
+       fi
+
+
 # vim: set noet sw=4 ts=4:
diff --git a/solenv/gbuild/gbuild.mk b/solenv/gbuild/gbuild.mk
index 91bb68b..02f8998 100644
--- a/solenv/gbuild/gbuild.mk
+++ b/solenv/gbuild/gbuild.mk
@@ -71,6 +71,8 @@ endef
 
 COMMA :=,
 
+CLOSE_PAREN :=)
+
 # optional extensions that should never be essential
 ifneq ($(wildcard $(GBUILDDIR)/extensions/pre_*.mk),)
 include $(wildcard $(GBUILDDIR)/extensions/pre_*.mk)
@@ -145,6 +147,12 @@ gb_FULLDEPS := $(true)
 endif
 endif
 
+ifneq ($(strip $(patches)$(PATCHES)),)
+gb_KEEP_PRISTINE := $(true)
+else
+gb_KEEP_PRISTINE := $(false)
+endif
+
 # save user-supplied flags for latter use
 # TODO remove after the old build system is abolished
 ifneq ($(strip $(ENVCFLAGS)),)
_______________________________________________
Libreoffice-commits mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to