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/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 gb_ComponentTarget__ALLCOMPONENTS
:=
22 gb_ComponentTarget_XSLT_CREATE_COMPONENT
:= $(SRCDIR
)/solenv
/bin
/createcomponent.xslt
23 gb_ComponentTarget_XSLT_DUMP_OPTIONALS
:= $(SRCDIR
)/solenv
/bin
/optionalimplementations.xslt
24 gb_ComponentTarget_get_source
= $(SRCDIR
)/$(1).component
26 # Some comment on the prerequisite handling for gb_ComponentTarget__command:
27 # The whole setup feels - once again - much more complicated then it should be; for an IMHO simple task.
28 # We can't just add all the $(call gb_ComponentTarget_get_target,%).* target commands to gb_ComponentTarget__command,
29 # because $(shell cat $(1).filtered) is then evaluated too early, cat'ing a non-existing file.
30 # Same happens if you add them to a gb_ComponentTarget__pre_command, run before the gb_ComponentTarget__command.
31 # The various other "macros" add new rules to "expand" the pattern rules with normal rules and prerequisites.
32 # As a result, the files from the pattern rules aren't cleaned up automagically, which I consider a plus point.
33 # So the intermediate files must be explicitly added to $(call gb_ComponentTarget_get_clean_target,%).
35 # In the DISABLE_DYNLOADING case we don't need any COMPONENTPREFIX, we
36 # put just the static library filename into the uri parameter. For
37 # each statically linked app using some subset of LO components, there
38 # is a mapping from library filenames to direct pointers to the
39 # corresponding PREFIX_component_getFactory functions.
40 define gb_ComponentTarget__command
41 $(if
$(LIBFILENAME
),,$(call gb_Output_error
,No LIBFILENAME set at component target
: $(1)))
42 $(call gb_ExternalExecutable_get_command
,xsltproc
) --nonet \
43 --stringparam uri
'$(if $(filter TRUE,$(DISABLE_DYNLOADING)),,$(subst \d,$$,$(COMPONENTPREFIX)))$(LIBFILENAME)' \
44 --stringparam cppu_env
$(CPPU_ENV
) \
45 --stringparam filtered
'$(shell cat $(1).filtered)' \
46 -o
$(1) $(gb_ComponentTarget_XSLT_CREATE_COMPONENT
) $(COMPONENTSOURCE
)
49 $(call gb_ComponentTarget_get_clean_target
,%) :
50 $(call gb_Output_announce
,$*,$(false
),CMP
,1)
51 rm -f
$(call gb_ComponentTarget_get_target
,$*) \
52 $(call gb_ComponentTarget_get_target
,$*).filtered \
53 $(call gb_ComponentTarget_get_target
,$*).optionals \
55 $(call gb_ComponentTarget_get_target
,%).
dir:
58 # %.optionals : list of all optional implementations marked <optional/> in the component file
59 $(call gb_ComponentTarget_get_target
,%).optionals
: \
60 $(gb_ComponentTarget_XSLT_DUMP_OPTIONALS
) \
61 |
$(call gb_ComponentTarget_get_target
,%).
dir \
62 $(call gb_ExternalExecutable_get_dependencies
,xsltproc
)
63 $(call gb_ExternalExecutable_get_command
,xsltproc
) --nonet \
64 $(gb_ComponentTarget_XSLT_DUMP_OPTIONALS
) $(COMPONENTSOURCE
) > $@
2>&1
66 # %.filtered : list of all optional implementations we don't build
67 .PRECIOUS
: $(call gb_ComponentTarget_get_target
,%).filtered
68 $(call gb_ComponentTarget_get_target
,%).filtered
: $(call gb_ComponentTarget_get_target
,%).optionals
69 cat
$< $(COMPONENTIMPL
) | sed
-e
'/^#\|^\s*$$/d' |
sort | uniq
-u
> $@
71 # when a library is renamed, the component file needs to be rebuilt to match.
72 # hence simply depend on Repository{,Fixes}.mk since the command runs quickly.
73 $(call gb_ComponentTarget_get_target
,%) : \
74 $(SRCDIR
)/Repository.mk \
75 $(SRCDIR
)/RepositoryFixes.mk \
76 $(gb_ComponentTarget_XSLT_CREATE_COMPONENT
) \
77 $(call gb_ComponentTarget_get_target
,%).filtered \
78 |
$(call gb_ExternalExecutable_get_dependencies
,xsltproc
)
79 $(call gb_Output_announce
,$*,$(true
),CMP
,1)
80 $(call gb_Trace_StartRange
,$*,CMP
)
81 $(call gb_ComponentTarget__command
,$@
)
82 $(call gb_Trace_EndRange
,$*,CMP
)
84 define gb_ComponentTarget_ComponentTarget
85 $(call gb_ComponentTarget_get_target
,$(1)) : COMPONENTPREFIX
:= $(2)
86 $(call gb_ComponentTarget_get_target
,$(1)) : LIBFILENAME
:= $(3)
87 $(call gb_ComponentTarget_get_target
,$(1)) : COMPONENTSOURCE
:= $(call gb_ComponentTarget_get_source
,$(patsubst CppunitTest
/%,%,$(1)))
88 $(call gb_ComponentTarget_get_target
,$(1)) : COMPONENTIMPL
:=
90 $(call gb_ComponentTarget_get_target
,$(1)) : $(call gb_ComponentTarget_get_source
,$(patsubst CppunitTest
/%,%,$(1)))
91 $(call gb_ComponentTarget_get_target
,$(1)).optionals
: $(call gb_ComponentTarget_get_source
,$(patsubst CppunitTest
/%,%,$(1)))
93 $(call gb_Helper_make_userfriendly_targets
,$(1),ComponentTarget
,$(call gb_ComponentTarget_get_target
,$(1)))
96 $$(eval
$$(call gb_Rdb_add_component
,$(4),$(1)))
98 $(if
$(4),$(eval gb_ComponentTarget__ALLCOMPONENTS
+= $(1)))
102 # call gb_ComponentTarget_add_componentimpl,componentfile,implid
103 define gb_ComponentTarget_add_componentimpl
104 $(call gb_ComponentTarget_get_target
,$(1)) : COMPONENTIMPL
+= $(call gb_ComponentTarget_get_source
,$(1)).
$(2)
105 $(call gb_ComponentTarget_get_target
,$(1)).filtered
: $(call gb_ComponentTarget_get_source
,$(1)).
$(2)
109 # vim: set noet sw=4: