config_host.mk.in                |    1 +
 configure.ac                     |   10 +++++++++-
 solenv/gbuild/ComponentTarget.mk |   26 +++++++++++++++++++++-----
 solenv/gbuild/UnpackedTarball.mk |    2 +-
 4 files changed, 32 insertions(+), 7 deletions(-)

New commits:
commit 17ec55c48082254e1f55bcfa00808e45a50a9801
Author:     Jan-Marek Glogowski <glo...@fbihome.de>
AuthorDate: Thu Jan 20 10:06:54 2022 +0100
Commit:     Jan-Marek Glogowski <glo...@fbihome.de>
CommitDate: Thu Jan 20 14:57:49 2022 +0100

    Fail on non-optional, but filtered component names
    
    If any of the optional component lists contain a non-optional
    component implementation, fail the component file generation and
    show a diff of the offending component implementation name.
    
    Change-Id: Ieac876e613f6945362186d4586dd2aacc5669920
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128645
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glo...@fbihome.de>

diff --git a/config_host.mk.in b/config_host.mk.in
index fa1b854ca135..9a0388fa0d35 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -123,6 +123,7 @@ export DCONF_CFLAGS=@DCONF_CFLAGS@
 export DCONF_LIBS=@DCONF_LIBS@
 export DEFAULT_BRAND_IMAGES=@DEFAULT_BRAND_IMAGES@
 export DICT_SYSTEM_DIR=@DICT_SYSTEM_DIR@
+export DIFF=@DIFF@
 export DISABLE_CVE_TESTS=@DISABLE_CVE_TESTS@
 export DISABLE_DYNLOADING=@DISABLE_DYNLOADING@
 export DISABLE_PYTHON=@DISABLE_PYTHON@
diff --git a/configure.ac b/configure.ac
index 42f8291129bd..751ad1ebb872 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11408,9 +11408,17 @@ else
     fi
 fi
 AC_SUBST([FLEX])
+
+AC_PATH_PROG(DIFF, diff)
+if test -z "$DIFF"; then
+    AC_MSG_ERROR(["diff" not found in \$PATH, install it])
+fi
+AC_SUBST([DIFF])
+
 dnl ***************************************
 dnl Checking for patch
 dnl ***************************************
+
 AC_PATH_PROG(PATCH, patch)
 if test -z "$PATCH"; then
     AC_MSG_ERROR(["patch" not found in \$PATH, install it])
@@ -11441,6 +11449,7 @@ fi
 if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
     GNUPATCH=`cygpath -m $GNUPATCH`
 fi
+AC_SUBST(GNUPATCH)
 
 dnl We also need to check for --with-gnu-cp
 
@@ -11484,7 +11493,6 @@ else
     esac
 fi
 
-AC_SUBST(GNUPATCH)
 AC_SUBST(GNUCP)
 AC_SUBST(x_GNUCP)
 
diff --git a/solenv/gbuild/ComponentTarget.mk b/solenv/gbuild/ComponentTarget.mk
index d317f1b05ae7..ce0224433661 100644
--- a/solenv/gbuild/ComponentTarget.mk
+++ b/solenv/gbuild/ComponentTarget.mk
@@ -49,6 +49,7 @@ endef
 $(call gb_ComponentTarget_get_clean_target,%) :
        $(call gb_Output_announce,$*,$(false),CMP,1)
        rm -f $(call gb_ComponentTarget_get_target,$*) \
+           $(call gb_ComponentTarget_get_target,$*).allfiltered \
            $(call gb_ComponentTarget_get_target,$*).filtered \
            $(call gb_ComponentTarget_get_target,$*).optionals \
 
@@ -61,12 +62,21 @@ $(call gb_ComponentTarget_get_target,%).optionals : \
            | $(call gb_ComponentTarget_get_target,%).dir \
              $(call gb_ExternalExecutable_get_dependencies,xsltproc)
        $(call gb_ExternalExecutable_get_command,xsltproc) --nonet \
-           $(gb_ComponentTarget_XSLT_DUMP_OPTIONALS) $(COMPONENTSOURCE) > $@ 
2>&1
+           $(gb_ComponentTarget_XSLT_DUMP_OPTIONALS) $(COMPONENTSOURCE) 2>&1 | 
sort > $@
 
 # %.filtered : list of all optional implementations we don't build
 .PRECIOUS: $(call gb_ComponentTarget_get_target,%).filtered
 $(call gb_ComponentTarget_get_target,%).filtered : $(call 
gb_ComponentTarget_get_target,%).optionals
-       cat $< $(COMPONENTIMPL) | sed -e '/^#\|^\s*$$/d' | sort | uniq -u > $@
+       cat $< $(COMPONENTIMPL) | sed -e '/^#/d' -e '/^[        ]*$$/d' | sort 
| uniq -u > $@
+
+# %.allfiltered : contains all possible filtered components, which must match 
%.optionals
+.PRECIOUS: $(call gb_ComponentTarget_get_target,%).allfiltered
+$(call gb_ComponentTarget_get_target,%).allfiltered : $(call 
gb_ComponentTarget_get_target,%).optionals
+       $(if $(ALLFILTEREDIMPL), \
+           cat $(ALLFILTEREDIMPL) | sed -e '/^#/d' -e '/^[     ]*$$/d' | sort 
| uniq > $@.tmp, \
+           touch $@.tmp)
+       $(DIFF) -u $< $@.tmp
+       mv $@.tmp $@
 
 # when a library is renamed, the component file needs to be rebuilt to match.
 # hence simply depend on Repository{,Fixes}.mk since the command runs quickly.
@@ -74,6 +84,7 @@ $(call gb_ComponentTarget_get_target,%) : \
                $(SRCDIR)/Repository.mk \
                $(SRCDIR)/RepositoryFixes.mk \
                $(gb_ComponentTarget_XSLT_CREATE_COMPONENT) \
+               $(call gb_ComponentTarget_get_target,%).allfiltered \
                $(call gb_ComponentTarget_get_target,%).filtered \
                | $(call gb_ExternalExecutable_get_dependencies,xsltproc)
        $(call gb_Output_announce,$*,$(true),CMP,1)
@@ -81,14 +92,19 @@ $(call gb_ComponentTarget_get_target,%) : \
        $(call gb_ComponentTarget__command,$@)
        $(call gb_Trace_EndRange,$*,CMP)
 
+gb_ComponentTarget__init_source = $(call 
gb_ComponentTarget_get_source,$(patsubst CppunitTest/%,%,$(1)))
+gb_ComponentTarget__init_allfiltered = $(wildcard $(call 
gb_ComponentTarget__init_source,$(1)).*)
+
 define gb_ComponentTarget_ComponentTarget
 $(call gb_ComponentTarget_get_target,$(1)) : COMPONENTPREFIX := $(2)
 $(call gb_ComponentTarget_get_target,$(1)) : LIBFILENAME := $(3)
-$(call gb_ComponentTarget_get_target,$(1)) : COMPONENTSOURCE := $(call 
gb_ComponentTarget_get_source,$(patsubst CppunitTest/%,%,$(1)))
+$(call gb_ComponentTarget_get_target,$(1)) : COMPONENTSOURCE := $(call 
gb_ComponentTarget__init_source,$(1))
 $(call gb_ComponentTarget_get_target,$(1)) : COMPONENTIMPL :=
+$(call gb_ComponentTarget_get_target,$(1)) : ALLFILTEREDIMPL := $(call 
gb_ComponentTarget__init_allfiltered,$(1))
 
-$(call gb_ComponentTarget_get_target,$(1)) : $(call 
gb_ComponentTarget_get_source,$(patsubst CppunitTest/%,%,$(1)))
-$(call gb_ComponentTarget_get_target,$(1)).optionals : $(call 
gb_ComponentTarget_get_source,$(patsubst CppunitTest/%,%,$(1)))
+$(call gb_ComponentTarget_get_target,$(1)) : $(call 
gb_ComponentTarget__source,$(1))
+$(call gb_ComponentTarget_get_target,$(1)).optionals : $(call 
gb_ComponentTarget__init_source,$(1))
+$(call gb_ComponentTarget_get_target,$(1)).allfiltered : $(call 
gb_ComponentTarget__init_allfiltered,$(1))
 
 $(call gb_Helper_make_userfriendly_targets,$(1),ComponentTarget,$(call 
gb_ComponentTarget_get_target,$(1)))
 
diff --git a/solenv/gbuild/UnpackedTarball.mk b/solenv/gbuild/UnpackedTarball.mk
index fb574f6a95f1..7355f010de98 100644
--- a/solenv/gbuild/UnpackedTarball.mk
+++ b/solenv/gbuild/UnpackedTarball.mk
@@ -444,7 +444,7 @@ endef
                ( \
                    patch_file=$$(pwd)/$*.new.patch.1; \
                        cd $(call gb_UnpackedTarball_get_dir,) ; \
-                       diff -ur $*.org $* > $$patch_file; \
+                       $(DIFF) -ur $*.org $* > $$patch_file; \
                    echo "Patch $$patch_file generated" ; \
                ); \
        else \

Reply via email to