xref: /aoo42x/main/solenv/gbuild/UnoApiTarget.mk (revision b63233d8)
1###############################################################
2#
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19#
20###############################################################
21
22
23
24define gb_UnoApiTarget_autopackage_inc
25$$(eval $$(call gb_Package_Package,$(1)_inc,$$(patsubst %/empty,%,$$(call gb_UnoApiTarget_get_header_target,empty))))
26$(foreach onefile,$(gb_UnoApiTarget_HPPFILES_$(1)), \
27	$$(eval $$(call gb_Package_add_file,$(1)_inc,$(patsubst $(1)/%,inc/$(1)/%,$(onefile)),$(onefile))))
28
29$(call gb_Package_get_target,$(1)_inc) : $(call gb_UnoApiTarget_get_target,$(1))
30
31endef
32
33# TODO: make multi repo safe
34define gb_UnoApiTarget_autopackage_idl
35$$(eval $$(call gb_Package_Package,$(1)_idl,$(SRCDIR)))
36$(foreach onefile,$(gb_UnoApiTarget_IDLFILES_$(1)), \
37	$$(eval $$(call gb_Package_add_file,$(1)_idl,$(patsubst $(1)/%,idl/%,$(onefile)),$(onefile))))
38
39endef
40
41$(call gb_UnoApiTarget_get_header_target,$(1))/% : $(call gb_UnoApiTarget_get_target,$(1))
42	mkdir -p $$(dir $$@)
43
44define gb_UnoApiTarget_UnoApiTarget
45$$(eval $$(call gb_Module_register_target,$(call gb_UnoApiOutTarget_get_target,$(1)),$(call gb_UnoApiOutTarget_get_clean_target,$(1))))
46$(call gb_UnoApiOutTarget_get_target,$(1)) : $(call gb_UnoApiTarget_get_target,$(1))
47$(call gb_UnoApiOutTarget_get_clean_target,$(1)) : $(call gb_UnoApiTarget_get_clean_target,$(1))
48gb_UnoApiTarget_HPPFILES_$(1) :=
49gb_UnoApiTarget_IDLFILES_$(1) :=
50
51.DELETE_ON_ERROR : \
52    $(call gb_UnoApiTarget_get_clean_target,$(1)) \
53    $(call gb_UnoApiTarget_get_target,$(1))
54
55endef
56
57define gb_UnoApiTarget_add_idlfiles
58$(foreach idl,$(2),$(call gb_UnoApiTarget_add_idlfile,$(1),$(idl)))
59
60endef
61
62define gb_UnoApiTarget_add_idlfile
63$(call gb_UnoApiTarget_get_target,$(1)) : $(call gb_UnoApiPartTarget_get_target,$(2).urd)
64$(call gb_UnoApiPartTarget_get_target,$(2).urd) : $(foreach repo,$(gb_REPOS),$(realpath $(repo)/$(2).idl))
65gb_UnoApiTarget_HPPFILES_$(1) += $(2).hdl
66gb_UnoApiTarget_HPPFILES_$(1) += $(2).hpp
67gb_UnoApiTarget_IDLFILES_$(1) += $(2).idl
68
69$(call gb_UnoApiTarget_get_header_target,)$(2).hpp :| $(call gb_UnoApiTarget_get_target,$(1))
70$(call gb_UnoApiTarget_get_header_target,)$(2).hdl :| $(call gb_UnoApiTarget_get_target,$(1))
71
72endef
73
74define gb_UnoApiTarget_add_idlfiles_noheader
75$(foreach idl,$(2),$(call gb_UnoApiTarget_add_idlfile_noheader,$(1),$(idl)))
76
77endef
78
79define gb_UnoApiTarget_add_idlfile_noheader
80$(call gb_UnoApiTarget_get_target,$(1)) : $(call gb_UnoApiPartTarget_get_target,$(2).urd)
81$(call gb_UnoApiPartTarget_get_target,$(2).urd) : $(foreach repo,$(gb_REPOS),$(realpath $(repo)/$(2).idl))
82gb_UnoApiTarget_IDLFILES_$(1) += $(2).idl
83
84endef
85
86define gb_UnoApiTarget_add_idlfiles_nohdl
87$(foreach idl,$(2),$(call gb_UnoApiTarget_add_idlfile_nohdl,$(1),$(idl)))
88
89endef
90
91define gb_UnoApiTarget_add_idlfile_nohdl
92$(call gb_UnoApiTarget_get_target,$(1)) : $(call gb_UnoApiPartTarget_get_target,$(2).urd)
93$(call gb_UnoApiPartTarget_get_target,$(2).urd) : $(foreach repo,$(gb_REPOS),$(realpath $(repo)/$(2).idl))
94gb_UnoApiTarget_HPPFILES_$(1) += $(2).hpp
95gb_UnoApiTarget_IDLFILES_$(1) += $(2).idl
96
97$(call gb_UnoApiTarget_get_header_target,)$(2).hpp :| $(call gb_UnoApiTarget_get_target,$(1))
98
99endef
100
101define gb_UnoApiTarget_add_rdbfiles
102$(foreach rdb,$(2),$(call gb_UnoApiTarget_add_rdbfile,$(1),$(rdb)))
103
104endef
105
106define gb_UnoApiTarget_add_rdbfile
107$(call gb_UnoApiTarget_get_target,$(1)) : UNOAPI_DEPS += -X$(call gb_UnoApiOutTarget_get_target,$(2))
108$(call gb_UnoApiTarget_get_target,$(1)) : \
109	$(call gb_UnoApiOutTarget_get_target,$(2)) \
110	$(call gb_Package_get_target,$(2)_idl)
111
112endef
113
114define gb_UnoApiTarget_add_merge_rdbfiles
115$(foreach rdb,$(2),$(call gb_UnoApiTarget_add_merge_rdbfile,$(1),$(rdb)))
116
117endef
118
119define gb_UnoApiTarget_add_merge_rdbfile
120$(call gb_UnoApiTarget_get_target,$(1)) : UNOAPI_MERGE += $(call gb_UnoApiOutTarget_get_target,$(2))
121$(call gb_UnoApiTarget_get_target,$(1)) : $(call gb_UnoApiOutTarget_get_target,$(2))
122
123endef
124
125#UNOAPI_REFERENCE_$(1) := $(foreach repo,$(gb_REPOS),$(realpath $(repo)/$(strip $(2)).rdb))
126define gb_UnoApiTarget_add_reference_rdbfile
127$(call gb_UnoApiTarget_get_target,$(1)) : UNOAPI_REFERENCE := $(foreach repo,$(gb_REPOS),$(realpath $(repo)/$(strip $(2)).rdb))
128
129endef
130
131define gb_UnoApiTarget_set_include
132$(call gb_UnoApiTarget_get_target,$(1)) : INCLUDE := $(2)
133
134endef
135
136.PHONY : $(call gb_UnoApiOutTarget_get_clean_target,%)
137$(call gb_UnoApiOutTarget_get_clean_target,%) :
138	$(call gb_Output_announce,$*,$(false),UNOAPI,1)
139	-$(call gb_Helper_abbreviate_dirs,\
140		rm -f $(call gb_UnoApiOutTarget_get_target,$*))
141
142.PHONY : $(call gb_UnoApiTarget_get_clean_target,%)
143$(call gb_UnoApiTarget_get_clean_target,%) :
144	$(call gb_Output_announce,$*,$(false),UNOAPI,1)
145	-$(call gb_Helper_abbreviate_dirs,\
146		rm -f $(call gb_UnoApiTarget_get_target,$*))
147	-rm -rf $(call gb_UnoApiTarget_get_header_target,$*)\
148			$(call gb_UnoApiPartTarget_get_target,$*)
149
150# idlc doesn't return error codes != 0 in case of an error, so
151# check self
152define gb_UnoApiPartTarget__command
153mkdir -p $(dir $(1)) && \
154	mkdir -p  $(gb_Helper_MISC) && \
155	RESPONSEFILE=`$(gb_MKTEMP)` && \
156	echo "$(call gb_Helper_convert_native,$(5) $(6) -O $(call gb_UnoApiPartTarget_get_target,$(2)) -verbose -C $(4))" > $${RESPONSEFILE} && \
157	$(gb_UnoApiTarget_IDLCCOMMAND) @$${RESPONSEFILE} > /dev/null && \
158	rm -f $${RESPONSEFILE} && \
159	test -f $(@)
160
161endef
162
163$(call gb_UnoApiPartTarget_get_target,%) :
164	$(call gb_Output_announce,$*,$(true),IDL,2)
165	$(call gb_UnoApiPartTarget__command,$@,$(dir $*),$<,$?,$(INCLUDE),$(DEFS))
166
167
168define gb_UnoApiTarget__command
169	mkdir -p $(dir $(1)) && \
170	RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),500,$(call gb_Helper_convert_native,$(1) $(4) $(5))) && \
171	$(gb_UnoApiTarget_REGMERGECOMMAND) @$${RESPONSEFILE} && \
172	rm -f $${RESPONSEFILE}
173
174endef
175
176define gb_UnoApiHeaderTarget__command
177$(call gb_Helper_abbreviate_dirs_native,\
178	mkdir -p $(dir $(1)) && \
179	mkdir -p  $(gb_Helper_MISC) && \
180	RESPONSEFILE=`$(gb_MKTEMP)` && \
181	echo " -Gc -L -BUCR -O$(call gb_UnoApiTarget_get_header_target,$*) $(7) \
182		$(1) \
183		" > $${RESPONSEFILE} && \
184	$(gb_UnoApiTarget_CPPUMAKERCOMMAND) @$${RESPONSEFILE} && \
185	rm -f $${RESPONSEFILE})
186
187endef
188
189# TODO:
190# - get idlc switch "-P" (generate .urd into package dir)
191# - generate dependencies for included idls
192# - empty $? in headertarget?
193
194$(call gb_UnoApiTarget_get_target,%):
195	$(call gb_Output_announce,$*,$(true),RDB,3)
196	$(if $(gb_UnoApiTarget_IDLFILES_$*),$(call gb_UnoApiTarget__command,$@,$*,$<,UCR,$(addprefix $(call gb_UnoApiPartTarget_get_target,),$(patsubst %.idl,%.urd,$(gb_UnoApiTarget_IDLFILES_$*)))))
197	$(if $(UNOAPI_MERGE),$(call gb_UnoApiTarget__command,$@,$*,$<,/,$(UNOAPI_MERGE)))
198	$(if $(UNOAPI_REFERENCE), \
199		$(call gb_Output_announce,$*,$(true),RDBCHEK,4) \
200	    $(gb_UnoApiTarget_REGCOMPARECOMMAND) -f -t -r1 $(call gb_Helper_convert_native,$(UNOAPI_REFERENCE)) -r2 $(call gb_Helper_convert_native,$@))
201	$(if $(gb_UnoApiTarget_IDLFILES_$*), \
202		$(call gb_Output_announce,$*,$(true),HPP,4) \
203		$(call gb_UnoApiHeaderTarget__command,$@,$*,$<,$?,$(INCLUDE),$(DEFS),$(UNOAPI_DEPS)))
204
205# vim: set noet sw=4 ts=4:
206