From 379b685730ca7adb3b8d1905c73a2c3df1d31799 Mon Sep 17 00:00:00 2001 From: Jan-Marek Glogowski Date: Wed, 15 Dec 2021 15:37:58 +0100 Subject: [PATCH] Filter optional component implementations by name Instead of trying to make up BUILD_TYPE items to match complex build conditions and then patch the component file with it, filter the component files based on the unique implementation name and an tag. Currently these optional implementations are grouped in external files with an identifier. Originally the optional implementations were automatically iden- tified by adding them to any external file, but this behavior is too easy to get wrong. Even better: if need arrises, one can now easily implement a feature to add implementation names directly using gbuild calls, instead of grouped files. The basic mechanism is to collect all optional implementations, remove the needed ones from that list and then filter-out all implementations not needed (AKA the rest of the list). It's no problem to have the same optional implementations selected in multiple files. This is especially used by the vcl.common component in a later patch. For gbuild this adds gb_Library_add_componentimpl. The component parameter for the call is explicitly omitted, so you must call gb_Library_set_componentfile before selecting any optional implementations. The strict naming is also enforced by appending the identifier to the component file name. This replaces commit 65c0887bca2909b2046eb5aa4aaace0cc320c3f2 ("Allow for conditional parts of component files"). Change-Id: I0261cadce8bdfebb6b3ec96669ec378a5c1d9699 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126891 Reviewed-by: Stephan Bergmann Tested-by: Jenkins --- solenv/bin/createcomponent.xslt | 10 ++-- solenv/bin/optionalimplementations.xslt | 21 +++++++++ solenv/gbuild/ComponentTarget.mk | 47 ++++++++++++++++--- solenv/gbuild/Library.mk | 14 ++++++ solenv/gbuild/extensions/post_GbuildToJson.mk | 1 + svx/Library_svx.mk | 2 + svx/util/svx.component | 4 +- svx/util/svx.component.crashreport | 7 +++ sw/Library_sw.mk | 2 + sw/util/sw.component | 8 ++-- sw/util/sw.component.mailmerge | 8 ++++ 11 files changed, 107 insertions(+), 17 deletions(-) create mode 100644 solenv/bin/optionalimplementations.xslt create mode 100644 svx/util/svx.component.crashreport create mode 100644 sw/util/sw.component.mailmerge diff --git a/solenv/bin/createcomponent.xslt b/solenv/bin/createcomponent.xslt index d33641cc62fa..ee60221dfcdd 100644 --- a/solenv/bin/createcomponent.xslt +++ b/solenv/bin/createcomponent.xslt @@ -23,7 +23,7 @@ xmlns:uc="http://openoffice.org/2010/uno-components"> - + @@ -36,15 +36,16 @@ - - - + + + + @@ -60,7 +61,6 @@ - diff --git a/solenv/bin/optionalimplementations.xslt b/solenv/bin/optionalimplementations.xslt new file mode 100644 index 000000000000..fa8ca5b1c7ff --- /dev/null +++ b/solenv/bin/optionalimplementations.xslt @@ -0,0 +1,21 @@ + + + + + + + + + + + diff --git a/solenv/gbuild/ComponentTarget.mk b/solenv/gbuild/ComponentTarget.mk index 774dd1a7f2e9..9a33f1aa46b7 100644 --- a/solenv/gbuild/ComponentTarget.mk +++ b/solenv/gbuild/ComponentTarget.mk @@ -19,9 +19,19 @@ gb_ComponentTarget__ALLCOMPONENTS := -gb_ComponentTarget_XSLTCOMMANDFILE := $(SRCDIR)/solenv/bin/createcomponent.xslt +gb_ComponentTarget_XSLT_CREATE_COMPONENT := $(SRCDIR)/solenv/bin/createcomponent.xslt +gb_ComponentTarget_XSLT_DUMP_OPTIONALS := $(SRCDIR)/solenv/bin/optionalimplementations.xslt gb_ComponentTarget_get_source = $(SRCDIR)/$(1).component +# Some comment on the prerequisite handling for gb_ComponentTarget__command: +# The whole setup feels - once again - much more complicated then it should be; for an IMHO simple task. +# We can't just add all the $(call gb_ComponentTarget_get_target,%).* target commands to gb_ComponentTarget__command, +# because $(shell cat $(1).filtered) is then evaluated too early, cat'ing a non-existing file. +# Same happens if you add them to a gb_ComponentTarget__pre_command, run before the gb_ComponentTarget__command. +# The various other "macros" add new rules to "expand" the pattern rules with normal rules and prerequisites. +# As a result, the files from the pattern rules aren't cleaned up automagically, which I consider a plus point. +# So the intermediate files must be explicitly added to $(call gb_ComponentTarget_get_clean_target,%). + # In the DISABLE_DYNLOADING case we don't need any COMPONENTPREFIX, we # put just the static library filename into the uri parameter. For # each statically linked app using some subset of LO components, there @@ -29,37 +39,55 @@ gb_ComponentTarget_get_source = $(SRCDIR)/$(1).component # corresponding PREFIX_component_getFactory functions. define gb_ComponentTarget__command $(if $(LIBFILENAME),,$(call gb_Output_error,No LIBFILENAME set at component target: $(1))) - mkdir -p $(dir $(1)) && \ $(call gb_ExternalExecutable_get_command,xsltproc) --nonet \ --stringparam uri '$(if $(filter TRUE,$(DISABLE_DYNLOADING)),,$(subst \d,$$,$(COMPONENTPREFIX)))$(LIBFILENAME)' \ --stringparam cppu_env $(CPPU_ENV) \ - --stringparam features '$(patsubst %,(BUILD_TYPE:%),$(BUILD_TYPE))' -o $(1) \ - $(gb_ComponentTarget_XSLTCOMMANDFILE) $(COMPONENTSOURCE) + --stringparam filtered '$(shell cat $(1).filtered)' \ + -o $(1) $(gb_ComponentTarget_XSLT_CREATE_COMPONENT) $(COMPONENTSOURCE) 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,$*).filtered \ + $(call gb_ComponentTarget_get_target,$*).optionals \ +$(call gb_ComponentTarget_get_target,%).dir: + mkdir -p $(dir $@) + +# %.optionals : list of all optional implementations marked in the component file +$(call gb_ComponentTarget_get_target,%).optionals : \ + $(gb_ComponentTarget_XSLT_DUMP_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 + +# %.filtered : list of all optional implementations we don't build +$(call gb_ComponentTarget_get_target,%).filtered : $(call gb_ComponentTarget_get_target,%).optionals + cat $< $(COMPONENTIMPL) | sed -e '/^#\|^\s*$$/d' | sort | uniq -u > $@ # 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. $(call gb_ComponentTarget_get_target,%) : \ $(SRCDIR)/Repository.mk \ $(SRCDIR)/RepositoryFixes.mk \ + $(gb_ComponentTarget_XSLT_CREATE_COMPONENT) \ + $(call gb_ComponentTarget_get_target,%).filtered \ | $(call gb_ExternalExecutable_get_dependencies,xsltproc) $(call gb_Output_announce,$*,$(true),CMP,1) $(call gb_Trace_StartRange,$*,CMP) - $(call gb_ComponentTarget__command,$@,$*) + $(call gb_ComponentTarget__command,$@) $(call gb_Trace_EndRange,$*,CMP) 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)) : COMPONENTIMPL := $(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_Helper_make_userfriendly_targets,$(1),ComponentTarget,$(call gb_ComponentTarget_get_target,$(1))) @@ -70,4 +98,11 @@ $(if $(4),$(eval gb_ComponentTarget__ALLCOMPONENTS += $(1))) endef +# call gb_ComponentTarget_add_componentimpl,componentfile,implid +define gb_ComponentTarget_add_componentimpl +$(call gb_ComponentTarget_get_target,$(1)) : COMPONENTIMPL += $(call gb_ComponentTarget_get_source,$(1)).$(2) +$(call gb_ComponentTarget_get_target,$(1)).filtered : $(call gb_ComponentTarget_get_source,$(1)).$(2) + +endef + # vim: set noet sw=4: diff --git a/solenv/gbuild/Library.mk b/solenv/gbuild/Library.mk index 19d77bcd29ff..4f0bcaa54841 100644 --- a/solenv/gbuild/Library.mk +++ b/solenv/gbuild/Library.mk @@ -128,6 +128,9 @@ $(if $(3),$(call gb_Output_error,gb_Library_set_soversion_script: too many argum $(call gb_Library__set_soversion_script_platform,$(1),$(2)) endef +gb_Library__get_component_var = $(call gb_Library__get_workdir_linktargetname,$(1))<>COMPONENTFILE +gb_Library__get_component = $($(call gb_Library__get_component_var,$(1))) + # The dependency from workdir component target to outdir library should ensure # that gb_CppunitTest_use_component can transitively depend on the library. # But the component target also must be delivered; use the target @@ -145,6 +148,17 @@ $(call gb_ComponentTarget_get_target,$(2)) :| \ $(call gb_Library_get_target,$(gb_Library__get_name)) $(call gb_Library_get_clean_target,$(gb_Library__get_name)) : \ $(call gb_ComponentTarget_get_clean_target,$(2)) +$(eval $(call gb_Library__get_component_var,$(1)) += $(2)) + +endef + +# The implid is appended to the component file, separated by a dot. +# +# call gb_Library_add_componentimpl,library,implid +define gb_Library_add_componentimpl +$(if $(call gb_Library__get_component,$(1)),, \ + $(error Set gb_Library_set_componentfile before using gb_Library_add_componentimpl)) +$(call gb_ComponentTarget_add_componentimpl,$(call gb_Library__get_component,$(1)),$(2)) endef diff --git a/solenv/gbuild/extensions/post_GbuildToJson.mk b/solenv/gbuild/extensions/post_GbuildToJson.mk index 78e81aa7273c..52c61b722ee6 100644 --- a/solenv/gbuild/extensions/post_GbuildToJson.mk +++ b/solenv/gbuild/extensions/post_GbuildToJson.mk @@ -151,6 +151,7 @@ gb_WinResTarget_add_defs = gb_LinkTarget_set_nativeres = gb_LinkTarget_add_nativeres = gb_Library_set_componentfile = +gb_Library_add_componentimpl = #$(call gb_Library_get_exports_target,%): $(WORKDIR)/LinkTarget/Library/%.exports: diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk index a13f1cade697..90fca2c9867e 100644 --- a/svx/Library_svx.mk +++ b/svx/Library_svx.mk @@ -21,6 +21,8 @@ $(eval $(call gb_Library_Library,svx)) $(eval $(call gb_Library_set_componentfile,svx,svx/util/svx,services)) +$(eval $(call gb_Helper_optional,BREAKPAD,$(call gb_Library_add_componentimpl,svx,crashreport))) + $(eval $(call gb_Library_set_include,svx,\ -I$(SRCDIR)/svx/inc \ -I$(SRCDIR)/svx/source/inc \ diff --git a/svx/util/svx.component b/svx/util/svx.component index 9fffed787719..db47c36fc1e7 100644 --- a/svx/util/svx.component +++ b/svx/util/svx.component @@ -33,9 +33,9 @@ + constructor="com_sun_star_comp_svx_CrashReportUI_get_implementation"> + diff --git a/svx/util/svx.component.crashreport b/svx/util/svx.component.crashreport new file mode 100644 index 000000000000..8eedf929c714 --- /dev/null +++ b/svx/util/svx.component.crashreport @@ -0,0 +1,7 @@ +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +com.sun.star.comp.svx.CrashReportUI diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk index 58639859bb0e..fd418f7064bd 100644 --- a/sw/Library_sw.mk +++ b/sw/Library_sw.mk @@ -796,6 +796,8 @@ $(eval $(call gb_Library_add_exception_objects,sw,\ sw/source/uibase/dbui/dbtree \ sw/source/uibase/dbui/mailmergetoolbarcontrols \ )) + +$(eval $(call gb_Library_add_componentimpl,sw,mailmerge)) endif $(eval $(call gb_SdiTarget_SdiTarget,sw/sdi/swslots,sw/sdi/swriter)) diff --git a/sw/util/sw.component b/sw/util/sw.component index a36eaee795a8..deadc66bf3ec 100644 --- a/sw/util/sw.component +++ b/sw/util/sw.component @@ -40,14 +40,14 @@ + constructor="lo_writer_MMCurrentEntryController_get_implementation"> + + constructor="lo_writer_MMExcludeEntryController_get_implementation"> + diff --git a/sw/util/sw.component.mailmerge b/sw/util/sw.component.mailmerge new file mode 100644 index 000000000000..b7e6ffa3ddc3 --- /dev/null +++ b/sw/util/sw.component.mailmerge @@ -0,0 +1,8 @@ +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +lo.writer.MMCurrentEntryController +lo.writer.MMExcludeEntryController