Skip to content

Commit 20f06e3

Browse files
committed
add AllLangZip gbuild class
Change-Id: I1b0ebafac55bdfb41c5e6e64ded637313e47bae4
1 parent b4687fe commit 20f06e3

File tree

4 files changed

+111
-2
lines changed

4 files changed

+111
-2
lines changed

solenv/gbuild/AllLangZip.mk

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
2+
#
3+
# This file is part of the LibreOffice project.
4+
#
5+
# This Source Code Form is subject to the terms of the Mozilla Public
6+
# License, v. 2.0. If a copy of the MPL was not distributed with this
7+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
8+
#
9+
10+
# AllLangZip class
11+
12+
# Handles creation of a bunch of zip files with content dependent on
13+
# language
14+
15+
gb_AllLangZip_LANGS := $(gb_WITH_LANG)
16+
17+
$(dir $(call gb_AllLangZip_get_target,%)).dir :
18+
$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
19+
20+
$(call gb_AllLangZip_get_target,%) :
21+
$(call gb_Output_announce,$*,$(true),ALZ,4)
22+
touch $@
23+
24+
.PHONY : $(call gb_AllLangZip_get_clean_target,%)
25+
$(call gb_AllLangZip_get_clean_target,%) :
26+
$(call gb_Output_announce,$*,$(true),ALZ,4)
27+
rm -f $(call gb_AllLangZip_get_target,$*)
28+
29+
# Define a new zip group
30+
#
31+
# NOTE: we cannot add dependencies on the child zips here: Zip fails if
32+
# the source directory does not exist and we cannot test its existence
33+
# because the directory might be generated. So we postpone the
34+
# dependency creation to gb_AllLangZip_add_file.
35+
#
36+
# gb_AllLangZip_AllLangZip group srcdir
37+
define gb_AllLangZip_AllLangZip
38+
$(foreach lang,$(gb_AllLangZip_LANGS),$(call gb_Zip_Zip_internal,$(1)_$(lang),$(2)/$(lang)))
39+
40+
$(call gb_AllLangZip_get_target,$(1)) :| $(dir $(call gb_AllLangZip_get_target,$(1))).dir
41+
42+
$$(eval $$(call gb_Module_register_target,$(call gb_AllLangZip_get_target,$(1)),$(call gb_AllLangZip_get_clean_target,$(1))))
43+
44+
endef
45+
46+
define gb_AllLangZip__add_to_zip
47+
$(call gb_Zip_add_file,$(2),$(3))
48+
$(call gb_AllLangZip_get_target,$(1)) : $(call gb_Zip_get_outdir_target,$(2))
49+
$(call gb_AllLangZip_get_clean_target,$(1)) : $(call gb_Zip_get_clean_target,$(2))
50+
51+
endef
52+
53+
define gb_AllLangZip__add_file_impl
54+
$(if $(filter $(2),$(gb_AllLangZip_LANGS)),$(call gb_AllLangZip__add_to_zip,$(1),$(1)_$(2),$(3)))
55+
56+
endef
57+
58+
define gb_AllLangZip__add_file
59+
$(call gb_AllLangZip__add_file_impl,$(1),$(firstword $(2)),$(subst $() $(),/,$(wordlist 2,$(words $(2)),$(2))))
60+
61+
endef
62+
63+
# Add a file to one of the child zips
64+
#
65+
# The language is taken from the first component of the file name. The
66+
# file is only added if there is a zip defined for the language (i.e.,
67+
# if we are building with the language).
68+
#
69+
# gb_AllLangZip_add_file target file
70+
define gb_AllLangZip_add_file
71+
$(call gb_AllLangZip__add_file,$(1),$(subst /, ,$(2)))
72+
73+
endef
74+
75+
# Add several files to the child zips at once
76+
#
77+
# gb_AllLangZip_add_files target file(s)
78+
define gb_AllLangZip_add_files
79+
$(foreach file,$(2),$(call gb_AllLangZip_add_file,$(1),$(file)))
80+
81+
endef
82+
83+
# Add extra dependency that must exist before the archives can be created
84+
#
85+
# gb_AllLangZip_add_dependency target dep
86+
define gb_AllLangZip_add_dependency
87+
$(foreach lang,$(gb_AllLangZip_LANGS),$(call gb_Zip_add_dependency,$(1)_$(lang),$(2)))
88+
89+
endef
90+
91+
# Add extra dependencies that must exist before the archives can be created
92+
#
93+
# gb_AllLangZip_add_dependencies target dep(s)
94+
define gb_AllLangZip_add_dependencies
95+
$(foreach dependency,$(2),$(call gb_AllLangZip_add_dependency,$(1),$(dependency)))
96+
97+
endef
98+
99+
# vim: set noet sw=4 ts=4:

solenv/gbuild/TargetLocations.mk

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ endef
7676
# workdir target patterns
7777

7878
gb_AllLangResTarget_get_target = $(WORKDIR)/AllLangRes/$(1)
79+
gb_AllLangZip_get_target = $(WORKDIR)/AllLangZip/$(1)
7980
gb_AsmObject_get_target = $(WORKDIR)/AsmObject/$(1).o
8081
gb_CObject_get_target = $(WORKDIR)/CObject/$(1).o
8182
gb_GenCObject_get_target = $(WORKDIR)/GenCObject/$(1).o
@@ -197,6 +198,7 @@ endef
197198

198199
$(eval $(call gb_Helper_make_clean_targets,\
199200
AllLangResTarget \
201+
AllLangZip \
200202
ComponentTarget \
201203
ComponentsTarget \
202204
ExtensionTarget \

solenv/gbuild/Zip.mk

+9-2
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,25 @@ $(call gb_Zip__get_preparation_target,%) :
6969
# the zip package target requires that all added files have a common root directory (package location)
7070
# names of added files are relative to it; the zip will store them with their complete relative path name
7171
# the location can't be stored in a scoped variable as it is needed in the add_file macro (see rule above)
72-
define gb_Zip_Zip
72+
define gb_Zip_Zip_internal
7373
$(call gb_Zip_get_target,$(1)) : FILES :=
7474
$(call gb_Zip_get_target,$(1)) : LOCATION := $(2)
7575
$(call gb_Zip_get_clean_target,$(1)) : CLEAR_LOCATION :=
7676
gb_Package_Location_$(1) := $(2)
77-
$(eval $(call gb_Module_register_target,$(call gb_Zip_get_final_target,$(1)),$(call gb_Zip_get_clean_target,$(1))))
77+
7878
$(call gb_Deliver_add_deliverable,$(call gb_Zip_get_outdir_target,$(1)),$(call gb_Zip_get_target,$(1)),$(1))
7979
$(call gb_Zip_get_outdir_target,$(1)) : $(call gb_Zip_get_target,$(1)) \
8080
| $(dir $(call gb_Zip_get_outdir_target,$(1))).dir
8181

8282
endef
8383

84+
define gb_Zip_Zip
85+
$(call gb_Zip_Zip_internal,$(1),$(2))
86+
87+
$(eval $(call gb_Module_register_target,$(call gb_Zip_get_final_target,$(1)),$(call gb_Zip_get_clean_target,$(1))))
88+
89+
endef
90+
8491
# adding a file creates a dependency to it
8592
# the full path name of the file needs access to the package location
8693
# as scoped variables only exist in rules, we use a postfixed name to refer to the location

solenv/gbuild/gbuild.mk

+1
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ include $(foreach class, \
320320
UnpackedTarball \
321321
InternalUnoApi \
322322
Zip \
323+
AllLangZip \
323324
Configuration \
324325
ExtensionTarget \
325326
Dictionary \

0 commit comments

Comments
 (0)