Kaydet (Commit) 7a9f6df7 authored tarafından Tamas Bunth's avatar Tamas Bunth Kaydeden (comit) Andras Timar

single source file for licensing info with conditional text

... for easier maintenance. This commit only introduces the
framework. Follow up commits will update the license file.
Advantages:
* single source, multiple outputs (html, txt)
* conditional text, i.e. output will not include license
  terms of components that are not configured in the build

Change-Id: I0ffad41119228a0a26fd1b6ce19930ca6085adb2
Reviewed-on: https://gerrit.libreoffice.org/69396
Tested-by: Jenkins
Reviewed-by: 's avatarAndras Timar <andras.timar@collabora.com>
üst 37399c71
......@@ -1030,7 +1030,7 @@ $(eval $(call gb_Helper_register_packages_for_install,brand,\
) \
) \
readlicense_oo_files \
$(if $(filter WNT,$(OS)),readlicense_oo_license) \
readlicense_oo_license \
$(call gb_Helper_optional,DESKTOP,setup_native_packinfo) \
))
......
......@@ -7,17 +7,19 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_Package_Package,odk_share_readme,$(SRCDIR)))
readlicense_oo_DIR := $(call gb_CustomTarget_get_workdir,readlicense_oo/license)
$(eval $(call gb_Package_Package,odk_share_readme,$(readlicense_oo_DIR)))
$(eval $(call gb_Package_set_outdir,odk_share_readme,$(INSTDIR)))
$(eval $(call gb_Package_add_files,odk_share_readme,$(SDKDIRNAME)/share/readme,\
readlicense_oo/license/LICENSE.html \
license.html \
))
# for WNT see Package_share_readme_generated.mk
ifneq ($(OS),WNT)
$(eval $(call gb_Package_add_file,odk_share_readme,$(SDKDIRNAME)/share/readme/LICENSE,readlicense_oo/license/LICENSE))
readlicense_oo_DIR := $(call gb_CustomTarget_get_workdir,readlicense_oo/license)
$(eval $(call gb_Package_add_file,odk_share_readme,$(SDKDIRNAME)/share/readme/LICENSE,LICENSE))
endif
# vim: set noet sw=4 ts=4:
......@@ -10,15 +10,60 @@
$(eval $(call gb_CustomTarget_CustomTarget,readlicense_oo/license))
readlicense_oo_DIR := $(call gb_CustomTarget_get_workdir,readlicense_oo/license)
readlicense_oo_LICENSE_xml := $(SRCDIR)/readlicense_oo/license/license.xml
$(call gb_CustomTarget_get_target,readlicense_oo/license) : $(readlicense_oo_DIR)/license.html
ifeq ($(OS),WNT)
$(call gb_CustomTarget_get_target,readlicense_oo/license) : $(readlicense_oo_DIR)/license.txt
else
$(call gb_CustomTarget_get_target,readlicense_oo/license) : $(readlicense_oo_DIR)/LICENSE
endif
$(readlicense_oo_DIR)/license.html : \
$(SRCDIR)/readlicense_oo/license/license_html.xsl \
$(readlicense_oo_LICENSE_xml) \
| $(readlicense_oo_DIR)/.dir \
$(call gb_ExternalExecutable_get_dependencies,xsltproc)
$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),XSL,1)
$(call gb_Helper_abbreviate_dirs, \
$(call gb_ExternalExecutable_get_command,xsltproc) --nonet --novalid -o $@ \
--stringparam build_type "$(BUILD_TYPE)" \
--stringparam os "$(OS)" \
--stringparam themes "$(WITH_THEMES)" \
$(if $(MPL_SUBSET),,--stringparam no_mpl_subset no_mpl_subset) \
$< \
$(readlicense_oo_LICENSE_xml) \
$(if $(filter WNT,$(OS)), \
&& $(gb_AWK) 'sub("$$","\r")' $@ > $@.tmp \
&& mv $@.tmp $@ \
) \
)
$(readlicense_oo_DIR)/LICENSE : \
$(SRCDIR)/readlicense_oo/license/license_plain_text.xsl \
$(readlicense_oo_LICENSE_xml) \
| $(readlicense_oo_DIR)/.dir \
$(call gb_ExternalExecutable_get_dependencies,xsltproc)
$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),XSL,1)
$(call gb_Helper_abbreviate_dirs, \
$(call gb_ExternalExecutable_get_command,xsltproc) --nonet --novalid -o $@ \
--stringparam build_type "$(BUILD_TYPE)" \
--stringparam os "$(OS)" \
--stringparam themes "$(WITH_THEMES)" \
$(if $(MPL_SUBSET),,--stringparam no_mpl_subset no_mpl_subset) \
$< \
$(readlicense_oo_LICENSE_xml) \
)
ifeq ($(OS),WNT)
$(readlicense_oo_DIR)/license.txt : \
$(SRCDIR)/readlicense_oo/license/LICENSE \
$(readlicense_oo_DIR)/LICENSE \
| $(readlicense_oo_DIR)/.dir
$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),AWK,1)
$(call gb_Helper_abbreviate_dirs, \
$(gb_AWK) 'sub("$$","\r")' $< > $@.tmp && mv $@.tmp $@ \
)
endif
# vim:set shiftwidth=4 tabstop=4 noexpandtab:
......@@ -11,15 +11,10 @@ $(eval $(call gb_Module_Module,readlicense_oo))
$(eval $(call gb_Module_add_targets,readlicense_oo,\
CustomTarget_readme \
Package_files \
Package_readlicense_oo_readmes \
))
ifeq (WNT,$(OS))
$(eval $(call gb_Module_add_targets,readlicense_oo,\
CustomTarget_license \
Package_files \
Package_license \
Package_readlicense_oo_readmes \
))
endif
# vim:set noet sw=4 ts=4:
......@@ -9,26 +9,12 @@
$(eval $(call gb_Package_Package,readlicense_oo_files,$(SRCDIR)/readlicense_oo/license))
# LICENSE (upper case) is copied without EOL conversion
# license.txt is converted, prior to copy, see Package_license.mk
ifneq ($(OS),WNT)
ifneq ($(OS),MACOSX)
$(eval $(call gb_Package_add_file,readlicense_oo_files,LICENSE,LICENSE))
else
$(eval $(call gb_Package_add_file,readlicense_oo_files,Resources/LICENSE,LICENSE))
endif
endif
ifneq ($(OS),MACOSX)
$(eval $(call gb_Package_add_file,readlicense_oo_files,NOTICE,NOTICE))
$(eval $(call gb_Package_add_file,readlicense_oo_files,LICENSE.fodt,LICENSE.fodt))
$(eval $(call gb_Package_add_file,readlicense_oo_files,CREDITS.fodt,CREDITS.fodt))
$(eval $(call gb_Package_add_file,readlicense_oo_files,LICENSE.html,LICENSE.html))
else
$(eval $(call gb_Package_add_file,readlicense_oo_files,Resources/NOTICE,NOTICE))
$(eval $(call gb_Package_add_file,readlicense_oo_files,Resources/LICENSE.fodt,LICENSE.fodt))
$(eval $(call gb_Package_add_file,readlicense_oo_files,Resources/CREDITS.fodt,CREDITS.fodt))
$(eval $(call gb_Package_add_file,readlicense_oo_files,Resources/LICENSE.html,LICENSE.html))
endif
# vim: set noet sw=4 ts=4:
......@@ -9,6 +9,18 @@
$(eval $(call gb_Package_Package,readlicense_oo_license,$(call gb_CustomTarget_get_workdir,readlicense_oo/license)))
$(eval $(call gb_Package_add_file,readlicense_oo_license,license.txt,license.txt))
ifneq ($(OS),WNT)
ifneq ($(OS),MACOSX)
$(eval $(call gb_Package_add_file,readlicense_oo_license,LICENSE,LICENSE))
else
$(eval $(call gb_Package_add_file,readlicense_oo_license,Resources/LICENSE,LICENSE))
endif
endif
ifneq ($(OS),MACOSX)
$(eval $(call gb_Package_add_file,readlicense_oo_license,LICENSE.html,license.html))
else
$(eval $(call gb_Package_add_file,readlicense_oo_license,Resources/LICENSE.html,license.html))
endif
# vim: set noet sw=4 ts=4:
Contains the stock libreoffice licensing blurb, as distributed in the install
directory, and also potentially at run-time.
Generating licence files
------------------------
License files are generated from a single source file (licese/license.xml).
Output file formats are plain text and html.
- The plain text and the html format is generated with xslt. There are two
separate xsl files for plain text and html.
Conditional text
----------------
The contents of the license file depends on the build configuration. Several
externals may or may not be shipped with LibreOffice. Therefore, we need to pass
information about build configuration to the xslt processor.
Variables used for conditional text:
- BUILD_TYPE: A space separated list of libraries/externals. If an external is
present in that list, then the related license text should be included.
- MPL_SUBSET: If the variable is defined, then GPL and LGPL license text will not
be included, because none of the built-in code need it.
- OS: The target platform. E.g. MSVC Runtime is packaged and used only on Windows.
- WITH_THEMES: A space separated list of icon sets that are used in the build.
Conditional text are surrounded by and extra <div> tag. The class attribute of
that <div> tag decides which parameter values are taken into consideration.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:x="http://www.w3.org/1999/xhtml" version="1.0">
<xsl:output method="xml"/>
<xsl:param name="build_type" />
<xsl:param name="no_mpl_subset" />
<xsl:param name="os" />
<xsl:param name="themes" />
<xsl:template match="x:div">
<xsl:choose>
<xsl:when test="(
not(contains($build_type,@class)) and
not(contains($no_mpl_subset,@class)) and
not(contains($os,@class)) and
not(contains($themes,@class)) and @class)">
<!-- do not write out license text for these externals -->
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="node()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:x="http://www.w3.org/1999/xhtml" version="1.0">
<xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
<xsl:param name="build_type" />
<xsl:param name="no_mpl_subset" />
<xsl:param name="os" />
<xsl:param name="themes" />
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:apply-templates select="x:html/x:body"/>
</xsl:template>
<xsl:template match="x:body">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="x:div">
<xsl:choose>
<xsl:when test="(
not(contains($build_type,@class)) and
not(contains($no_mpl_subset,@class)) and
not(contains($os,@class)) and
not(contains($themes,@class)) and @class)">
<!-- do not write out license text for these externals -->
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="x:p|x:li">
<xsl:value-of select="concat(.,'&#10;')"/>
<xsl:text>&#xa;</xsl:text>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="x:h1">
<xsl:text># </xsl:text>
<xsl:value-of select="concat(.,'&#10;')"/>
<xsl:text>&#xA;</xsl:text>
</xsl:template>
<xsl:template match="x:h2">
<xsl:text>## </xsl:text>
<xsl:value-of select="concat(.,'&#10;')"/>
<xsl:text>&#xa;</xsl:text>
</xsl:template>
<xsl:template match="x:h3">
<xsl:text>### </xsl:text>
<xsl:value-of select="concat(.,'&#10;')"/>
<xsl:text>&#xa;</xsl:text>
</xsl:template>
<xsl:template match="text()|@*"></xsl:template>
</xsl:stylesheet>
......@@ -235,7 +235,7 @@ namespace
}
}
}
/// Find the correct location of the document (LICENSE.fodt, etc.), and return
/// Find the correct location of the document (CREDITS.fodt, etc.), and return
/// it in rURL if found.
static bool checkURL( const char *pName, const char *pExt, OUString &rURL )
{
......
......@@ -59,7 +59,7 @@ sub create_pathvariables
my $filelistpath = $environment->{'WORKDIR'};
$variables{'filelistpath'} = $filelistpath;
my $licensepath = $environment->{'SRCDIR'} . $installer::globals::separator . "readlicense_oo/license";
my $licensepath = $environment->{'WORKDIR'} . $installer::globals::separator . "CustomTarget/readlicense_oo/license";
$variables{'licensepath'} = $licensepath;
my $packinfopath = $environment->{'SRCDIR'} . $installer::globals::separator . "setup_native/source/packinfo";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment