Avoid potential negative array index access to cached text.
[LibreOffice.git] / solenv / gbuild / Rdb.mk
blobfff774dcb5b8983987325f904194a45b2b172181
1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
3 # This file is part of the LibreOffice project.
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/.
10 gb_Rdb__get_install_target = $(INSTROOT)/$(LIBO_ETC_FOLDER)/services/$(1).rdb
12 define gb_Rdb__command
13 $(if $(COMPONENTS),,$(call gb_Output_error,Rdb without components: partial build of module postprocess is not possible currently - only top-level make works))
14 $(call gb_Helper_abbreviate_dirs,\
15 RESPONSEFILE=$(call gb_var2file,$(shell $(call gb_MKTEMP)),\
16 <list> \
17 $(foreach component,$(COMPONENTS),\
18 <filename>$(call gb_ComponentTarget_get_target,$(component))</filename>) \
19 </list>) && \
20 mkdir -p $(dir $@) && \
21 $(call gb_ExternalExecutable_get_command,xsltproc) --nonet -o $(1) \
22 $(SRCDIR)/solenv/bin/packcomponents.xslt $$RESPONSEFILE && \
23 rm $$RESPONSEFILE)
24 endef
26 $(call gb_Rdb_get_target,%) :| $(call gb_ExternalExecutable_get_dependencies,xsltproc)
27 $(call gb_Output_announce,$*,$(true),RDB,1)
28 $(call gb_Trace_StartRange,$*,RDB)
29 $(call gb_Rdb__command,$@,$*,$?,$^)
30 $(call gb_Trace_EndRange,$*,RDB)
32 .PHONY : $(call gb_Rdb_get_clean_target,%)
33 $(call gb_Rdb_get_clean_target,%) :
34 $(call gb_Output_announce,$*,$(false),RDB,1)
35 $(call gb_Helper_abbreviate_dirs,\
36 rm -f $(call gb_Rdb__get_install_target,$*) $(call gb_Rdb_get_target,$*))
38 define gb_Rdb__Rdb_impl
39 # gb_Rdb_add_component, which adds to the target-specific COMPONENTS variable, can be called (from
40 # gb_ComponentTarget_ComponentTarget) before gb_Rdb__Rdb_impl is called, so using `COMPONENTS :=`
41 # here could lose content; but still use `COMPONENTS ?=` here to establish COMPONENTS as target-
42 # specific even in the corner case of an empty Rdb with no gb_Rdb_add_component calls, so that the
43 # use of $(COMPONENTS) in gb_Rdb__command would not accidentally pick a global COMPONENTS variable:
44 $(call gb_Rdb_get_target,$(1)) : COMPONENTS ?=
45 $(call gb_Rdb_get_target,$(1)) : $(gb_Module_CURRENTMAKEFILE)
46 $$(eval $$(call gb_Module_register_target,$(2),$(call gb_Rdb_get_clean_target,$(1))))
47 $(call gb_Helper_make_userfriendly_targets,$(1),Rdb,$(2))
49 endef
51 define gb_Rdb_Rdb
52 $(call gb_Rdb__Rdb_impl,$(1),$(call gb_Rdb_get_target,$(1)))
54 endef
56 # FIXME this needs some layer-like thing for the special case in URE
57 define gb_Rdb_Rdb_install
58 $(call gb_Rdb__Rdb_impl,$(1),$(if $(2),$(INSTROOT)/$(2),$(call gb_Rdb__get_install_target,$(1))))
59 $(call gb_Helper_install_final, \
60 $(if $(2),$(INSTROOT)/$(2),$(call gb_Rdb__get_install_target,$(1))), \
61 $(call gb_Rdb_get_target,$(1)))
63 endef
65 define gb_Rdb_add_component
66 $(call gb_Rdb_get_target,$(1)) : $(call gb_ComponentTarget_get_target,$(2))
67 $(call gb_Rdb_get_target,$(1)) : COMPONENTS += $(2)
69 endef
71 define gb_Rdb_add_components
72 $(foreach component,$(2),$(call gb_Rdb_add_component,$(1),$(component)))
74 endef
76 # vim: set noet sw=4 ts=4: