summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2021-12-15 15:37:58 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2021-12-21 00:20:07 +0100
commit379b685730ca7adb3b8d1905c73a2c3df1d31799 (patch)
tree85a4d96a22b7e367e7eefd737623f951917cd5ca
parent50f553cacad76da22166d058db98f28d5ce6d65d (diff)
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 <optional/> 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 <sbergman@redhat.com> Tested-by: Jenkins
-rw-r--r--solenv/bin/createcomponent.xslt10
-rw-r--r--solenv/bin/optionalimplementations.xslt21
-rw-r--r--solenv/gbuild/ComponentTarget.mk47
-rw-r--r--solenv/gbuild/Library.mk14
-rw-r--r--solenv/gbuild/extensions/post_GbuildToJson.mk1
-rw-r--r--svx/Library_svx.mk2
-rw-r--r--svx/util/svx.component4
-rw-r--r--svx/util/svx.component.crashreport7
-rw-r--r--sw/Library_sw.mk2
-rw-r--r--sw/util/sw.component8
-rw-r--r--sw/util/sw.component.mailmerge8
11 files changed, 107 insertions, 17 deletions
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">
<xsl:param name="uri"/>
<xsl:param name="cppu_env"/>
- <xsl:param name="features"/>
+ <xsl:param name="filtered"/>
<xsl:strip-space elements="*"/>
<xsl:template match="uc:component">
<components>
@@ -36,15 +36,16 @@
</xsl:copy>
</components>
</xsl:template>
- <xsl:template match="uc:implementation[@CONDITION]">
- <xsl:variable name="feature" select="concat('(',@CONDITION,')')"/>
- <xsl:if test="contains($features,$feature)">
+ <xsl:template match="uc:implementation">
+ <xsl:if test="not(contains($filtered,@name))">
<xsl:copy>
<xsl:apply-templates select="@*"/>
+ <xsl:apply-templates select="uc:optional"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:if>
</xsl:template>
+ <xsl:template match="uc:optional"/>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="@*"/>
@@ -60,7 +61,6 @@
</xsl:call-template>
</xsl:attribute>
</xsl:template>
- <xsl:template match="@CONDITION"/>
<xsl:template match="@*">
<xsl:copy/>
</xsl:template>
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 @@
+<?xml version="1.0" encoding="UTF-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/.
+ *
+ * this "misuses" xsl:message to dump all optional components
+-->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns="http://openoffice.org/2010/uno-components"
+ xmlns:uc="http://openoffice.org/2010/uno-components">
+<xsl:template match="uc:component">
+ <xsl:for-each select="uc:implementation">
+ <xsl:if test="uc:optional">
+ <xsl:message><xsl:value-of select="@name"/></xsl:message>
+ </xsl:if>
+ </xsl:for-each>
+</xsl:template>
+</xsl:stylesheet>
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 <optional/> 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 @@
<service name="com.sun.star.dialog.RecoveryUI"/>
</implementation>
<implementation name="com.sun.star.comp.svx.CrashReportUI"
- constructor="com_sun_star_comp_svx_CrashReportUI_get_implementation"
- CONDITION="BUILD_TYPE:BREAKPAD">
+ constructor="com_sun_star_comp_svx_CrashReportUI_get_implementation">
<service name="com.sun.star.dialog.CrashReportUI"/>
+ <optional/>
</implementation>
<implementation name="com.sun.star.comp.svx.SafeModeUI"
constructor="com_sun_star_comp_svx_SafeModeUI_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 @@
<service name="com.sun.star.text.MailMerge"/>
</implementation>
<implementation name="lo.writer.MMCurrentEntryController"
- constructor="lo_writer_MMCurrentEntryController_get_implementation"
- CONDITION="BUILD_TYPE:DBCONNECTIVITY">
+ constructor="lo_writer_MMCurrentEntryController_get_implementation">
<service name="com.sun.star.frame.ToolbarController"/>
+ <optional/>
</implementation>
<implementation name="lo.writer.MMExcludeEntryController"
- constructor="lo_writer_MMExcludeEntryController_get_implementation"
- CONDITION="BUILD_TYPE:DBCONNECTIVITY">
+ constructor="lo_writer_MMExcludeEntryController_get_implementation">
<service name="com.sun.star.frame.ToolbarController"/>
+ <optional/>
</implementation>
<implementation name="lo.writer.PageSizeToolBoxControl"
constructor="lo_writer_PageSizeToolBoxControl_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