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 65c0887bca
("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
This commit is contained in:
parent
50f553caca
commit
379b685730
11 changed files with 107 additions and 17 deletions
|
@ -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>
|
||||
|
|
21
solenv/bin/optionalimplementations.xslt
Normal file
21
solenv/bin/optionalimplementations.xslt
Normal file
|
@ -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>
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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">
|
||||
|
|
7
svx/util/svx.component.crashreport
Normal file
7
svx/util/svx.component.crashreport
Normal file
|
@ -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
|
|
@ -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))
|
||||
|
|
|
@ -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">
|
||||
|
|
8
sw/util/sw.component.mailmerge
Normal file
8
sw/util/sw.component.mailmerge
Normal file
|
@ -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
|
Loading…
Reference in a new issue