1 | # $Id: qt4.kmk 1671 2008-07-07 21:36:05Z bird $
|
---|
2 | ## @file
|
---|
3 | # lex unit.
|
---|
4 | #
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (c) 2008 knut st. osmundsen <bird-src-spam@anduin.net>
|
---|
8 | #
|
---|
9 | # This file is part of kBuild.
|
---|
10 | #
|
---|
11 | # kBuild is free software; you can redistribute it and/or modify
|
---|
12 | # it under the terms of the GNU General Public License as published by
|
---|
13 | # the Free Software Foundation; either version 2 of the License, or
|
---|
14 | # (at your option) any later version.
|
---|
15 | #
|
---|
16 | # kBuild is distributed in the hope that it will be useful,
|
---|
17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | # GNU General Public License for more details.
|
---|
20 | #
|
---|
21 | # You should have received a copy of the GNU General Public License
|
---|
22 | # along with kBuild; if not, write to the Free Software
|
---|
23 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
---|
24 | #
|
---|
25 | #
|
---|
26 |
|
---|
27 | UNIT_qt4 = qt4
|
---|
28 |
|
---|
29 | # Add our target properties.
|
---|
30 | PROPS_SINGLE += MOCTOOL UICTOOL RCCTOOL
|
---|
31 | PROPS_ACCUMULATE_R += MOCDEFS MOCFLAGS UICFLAGS RCCFLAGS
|
---|
32 |
|
---|
33 |
|
---|
34 | #
|
---|
35 | # The QT4 SDK.
|
---|
36 | #
|
---|
37 | # This is implemented here rather than in sdks/QT4.kmk to enforce the global USES.
|
---|
38 | # It also makes things easier to develop, with fewer files I mean.
|
---|
39 | #
|
---|
40 | SDK_QT4 = Qt4
|
---|
41 | ## @todo
|
---|
42 |
|
---|
43 |
|
---|
44 | #
|
---|
45 | # The QT4 tool.
|
---|
46 | #
|
---|
47 | # This is implemented here rather than in tools/QT4.kmk to enforce the global USES.
|
---|
48 | # It also makes things easier to develop, with fewer files I mean.
|
---|
49 | #
|
---|
50 | TOOL_QT4 = Qt4
|
---|
51 |
|
---|
52 | # Tool Specific Properties
|
---|
53 | ifndef PATH_TOOL_QT4
|
---|
54 | PATH_TOOL_QT4 := $(firstword $(rsort $(wildcard $(PATH_DEVTOOLS_BLD)/qt/v4*)))
|
---|
55 | # If not found, we'll enter the 'pathless' mode.
|
---|
56 | else
|
---|
57 | # Resolve any fancy stuff once and for all.
|
---|
58 | PATH_TOOL_QT4 := $(PATH_TOOL_QT4)
|
---|
59 | endif
|
---|
60 | ifneq ($(PATH_TOOL_QT4),)
|
---|
61 | PATH_TOOL_QT4_BIN ?= $(PATH_TOOL_QT4)/bin
|
---|
62 | TOOL_QT4_MOC ?= $(PATH_TOOL_QT4_BIN)/moc$(HOST_SUFF_EXE)
|
---|
63 | TOOL_QT4_UIC ?= $(PATH_TOOL_QT4_BIN)/uic$(HOST_SUFF_EXE)
|
---|
64 | TOOL_QT4_RCC ?= $(PATH_TOOL_QT4_BIN)/rcc$(HOST_SUFF_EXE)
|
---|
65 | TOOL_QT4_LUPDATE ?= $(PATH_TOOL_QT4_BIN)/lupdate$(HOST_SUFF_EXE)
|
---|
66 | TOOL_QT4_LRELEASE ?= $(PATH_TOOL_QT4_BIN)/lrelease$(HOST_SUFF_EXE)
|
---|
67 | else
|
---|
68 | # Pathless, relies on the environment.
|
---|
69 | TOOL_QT4_MOC ?= moc$(HOST_SUFF_EXE)
|
---|
70 | TOOL_QT4_UIC ?= uic$(HOST_SUFF_EXE)
|
---|
71 | TOOL_QT4_RCC ?= rcc$(HOST_SUFF_EXE)
|
---|
72 | TOOL_QT4_LUPDATE ?= lupdate$(HOST_SUFF_EXE)
|
---|
73 | TOOL_QT4_LRELEASE ?= lrelease$(HOST_SUFF_EXE)
|
---|
74 | endif
|
---|
75 |
|
---|
76 | # General Properties used by kBuild and/or units/qt.kmk
|
---|
77 | TOOL_QT4_MOCFLAGS ?=
|
---|
78 | TOOL_QT4_MOCINCS ?=
|
---|
79 | TOOL_QT4_MOCDEFS ?=
|
---|
80 | TOOL_QT4_MOCDEFS.darwin ?= __APPLE__ __GNUC__
|
---|
81 | TOOL_QT4_MOCDEFS.solaris ?= __sun
|
---|
82 | TOOL_QT4_MOCDEFS.win.amd64 ?= WIN64
|
---|
83 | TOOL_QT4_MOCDEFS.win.x86 ?= WIN32
|
---|
84 |
|
---|
85 |
|
---|
86 | ## MOC a C++ source file.
|
---|
87 | # @param $(target) Normalized main target name.
|
---|
88 | # @param $(source) Source filename (relative).
|
---|
89 | # @param $(out) Object file name. This shall be (re)created by the compilation.
|
---|
90 | # @param $(dep) Dependcy file. This may be (re)created by the compilation.
|
---|
91 | # @param $(flags) Flags.
|
---|
92 | # @param $(defs) Definitions.
|
---|
93 | # @param $(incs) Includes.
|
---|
94 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
95 | #
|
---|
96 | TOOL_QT4_MOC_CPP_DEPEND =
|
---|
97 | TOOL_QT4_MOC_CPP_DEPORD =
|
---|
98 | TOOL_QT4_MOC_CPP_OUTPUT =
|
---|
99 | TOOL_QT4_MOC_CPP_OUTPUT_MAYBE =
|
---|
100 | define TOOL_QT4_MOC_CPP_CMDS
|
---|
101 | $(QUIET)$(TOOL_QT4_MOC)\
|
---|
102 | $(flags)\
|
---|
103 | $(addprefix -I, $(incs))\
|
---|
104 | $(addprefix -D, $(defs))\
|
---|
105 | -o $(out)\
|
---|
106 | $(source)
|
---|
107 | endef
|
---|
108 |
|
---|
109 | ## MOC a C++ header file.
|
---|
110 | # @param $(target) Normalized main target name.
|
---|
111 | # @param $(source) Source filename (relative).
|
---|
112 | # @param $(out) Object file name. This shall be (re)created by the compilation.
|
---|
113 | # @param $(dep) Dependcy file. This may be (re)created by the compilation.
|
---|
114 | # @param $(flags) Flags.
|
---|
115 | # @param $(defs) Definitions.
|
---|
116 | # @param $(incs) Includes.
|
---|
117 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
118 | #
|
---|
119 | TOOL_QT4_MOC_HPP_DEPEND =
|
---|
120 | TOOL_QT4_MOC_HPP_DEPORD =
|
---|
121 | TOOL_QT4_MOC_HPP_OUTPUT =
|
---|
122 | TOOL_QT4_MOC_HPP_OUTPUT_MAYBE =
|
---|
123 | define TOOL_QT4_MOC_HPP_CMDS
|
---|
124 | $(QUIET)$(TOOL_QT4_MOC)\
|
---|
125 | $(flags)\
|
---|
126 | $(addprefix -I, $(incs))\
|
---|
127 | $(addprefix -D, $(defs))\
|
---|
128 | -o $(out)\
|
---|
129 | $(source)
|
---|
130 | endef
|
---|
131 |
|
---|
132 | ## Compile a Qt user interface file (.ui).
|
---|
133 | # @param $(target) Normalized main target name.
|
---|
134 | # @param $(source) Source filename (relative).
|
---|
135 | # @param $(out) Object file name. This shall be (re)created by the compilation.
|
---|
136 | # @param $(dep) Dependcy file. This may be (re)created by the compilation.
|
---|
137 | # @param $(flags) Flags.
|
---|
138 | # @param $(defs) Definitions.
|
---|
139 | # @param $(incs) Includes.
|
---|
140 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
141 | #
|
---|
142 | TOOL_QT4_UIC_UI_DEPEND =
|
---|
143 | TOOL_QT4_UIC_UI_DEPORD =
|
---|
144 | TOOL_QT4_UIC_UI_OUTPUT =
|
---|
145 | TOOL_QT4_UIC_UI_OUTPUT_MAYBE =
|
---|
146 | define TOOL_QT4_UIC_UI_CMDS
|
---|
147 | $(QUIET)$(TOOL_QT4_UIC)\
|
---|
148 | $(flags)\
|
---|
149 | -o $(out)\
|
---|
150 | $(source)
|
---|
151 | endef
|
---|
152 |
|
---|
153 | ## Compile a Qt resource file (.qrc).
|
---|
154 | # @param $(target) Normalized main target name.
|
---|
155 | # @param $(source) Source filename (relative).
|
---|
156 | # @param $(out) Object file name. This shall be (re)created by the compilation.
|
---|
157 | # @param $(dep) Dependcy file. This may be (re)created by the compilation.
|
---|
158 | # @param $(flags) Flags.
|
---|
159 | # @param $(defs) Definitions.
|
---|
160 | # @param $(incs) Includes.
|
---|
161 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
162 | #
|
---|
163 | # @remarks The sed script generating the dependency file is a bit naive.
|
---|
164 | TOOL_QT4_RCC_QRC_DEPEND =
|
---|
165 | TOOL_QT4_RCC_QRC_DEPORD =
|
---|
166 | TOOL_QT4_RCC_QRC_OUTPUT =
|
---|
167 | TOOL_QT4_RCC_QRC_OUTPUT_MAYBE =
|
---|
168 | define TOOL_QT4_RCC_QRC_CMDS
|
---|
169 | $(QUIET)$(TOOL_QT4_RCC)\
|
---|
170 | $(flags)\
|
---|
171 | -o $(out)\
|
---|
172 | $(source)
|
---|
173 | $(APPEND) $(dep) '$(source): \'
|
---|
174 | $(SED) \
|
---|
175 | -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \
|
---|
176 | -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \
|
---|
177 | -e 's|^[^/]|$(abspathex $(dir $(source)),$(defpath))/&|' \
|
---|
178 | -e 's|$$$$| \\|' \
|
---|
179 | --append $(dep) \
|
---|
180 | $(source)
|
---|
181 | $(APPEND) $(dep)
|
---|
182 | $(SED) \
|
---|
183 | -e '/^[[:blank:]]*<file[[:blank:]][^>]*>/!d' \
|
---|
184 | -e 's/^.*<file[[:blank:]][^>]*>\([^<]*\)<\/file>.*$$$$/\1/' \
|
---|
185 | -e 's|^[^/]|$(abspathex $(dir $(source)),$(defpath))/&|' \
|
---|
186 | -e 's|$$$$|:\n|' \
|
---|
187 | --append $(dep) \
|
---|
188 | $(source)
|
---|
189 | $(APPEND) $(dep)
|
---|
190 | endef
|
---|
191 |
|
---|
192 |
|
---|
193 |
|
---|
194 | #
|
---|
195 | #
|
---|
196 | # Back to the Qt4 unit.
|
---|
197 | #
|
---|
198 | #
|
---|
199 |
|
---|
200 |
|
---|
201 | ##
|
---|
202 | # Source handler for .ts sources (translations).
|
---|
203 | #
|
---|
204 | # @remarks $(evalvalctx me).
|
---|
205 | define def_unit_qt4_src_handler_ts
|
---|
206 | $(warning def_unit_qt4_src_handler_ts: $(source))
|
---|
207 | ## @todo not quite sure about this bugger, perhaps the translations doesn't really belong here...
|
---|
208 | endef
|
---|
209 |
|
---|
210 |
|
---|
211 | ## wrapper for the UIC command dependencies.
|
---|
212 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
213 | _UNIT_QT_RCC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT_RCC_CMDS_PREV_),$$(commands $(out)),FORCE)
|
---|
214 | else
|
---|
215 | _UNIT_QT_RCC_CMDS_DEP =
|
---|
216 | endif
|
---|
217 |
|
---|
218 | ##
|
---|
219 | # def_unit_qt4_target_pre_handle_qrc helper that is expanded before evaluation.
|
---|
220 | #
|
---|
221 | # This is necessary to resolve reference to local variables before doing
|
---|
222 | # assignments and setting up commands. They would otherwise be resolved
|
---|
223 | # later in a different context and the result would be completely wrong.
|
---|
224 | #
|
---|
225 | define def_unit_qt4_target_pre_handle_rcc_dx
|
---|
226 |
|
---|
227 | $(out) +| $(realout) $(more_output) $(maybe_output): \
|
---|
228 | $(deps) \
|
---|
229 | $(value _UNIT_QT_RCC_CMDS_DEP) \
|
---|
230 | | \
|
---|
231 | $(orderdeps)
|
---|
232 | %$$(call MSG_TOOL,rcc,$(target),$(source),$$@)
|
---|
233 | $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
|
---|
234 |
|
---|
235 | $(cmds)
|
---|
236 |
|
---|
237 | $(QUIET)$(CP) --changed -f $(out) $(realout)
|
---|
238 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
239 | %$$(QUIET2)$$(APPEND) '$(dep)'
|
---|
240 | %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT_RCC_CMDS_PREV_'
|
---|
241 | %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
|
---|
242 | %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
|
---|
243 | endif
|
---|
244 |
|
---|
245 | $(target)_INTERMEDIATES += $(realout)
|
---|
246 | $(target)_GEN_SOURCES_ += $(realout)
|
---|
247 | $(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
|
---|
248 |
|
---|
249 | endef # def_unit_qt4_target_pre_handle_rcc_dx
|
---|
250 |
|
---|
251 | ##
|
---|
252 | # Source handler for .qrc sources (Qt resource files).
|
---|
253 | #
|
---|
254 | # @remarks $(evalvalctx me).
|
---|
255 | define def_unit_qt4_src_handler_qrc
|
---|
256 | local type := RCC
|
---|
257 |
|
---|
258 | # fetch the properties.
|
---|
259 | local tool := $(kb-src-tool dummy_var)
|
---|
260 | local qtrccdir := $(PATH_$(target))/qtrcc
|
---|
261 | local outbase := $(qtrccdir)/$(notdir $(basename $(source)))
|
---|
262 | local out := $(outbase).tmp.gen.cpp
|
---|
263 | local realout := $(outbase).gen.cpp
|
---|
264 | local dep := $(realout).dep
|
---|
265 | local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
|
---|
266 | local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
|
---|
267 | local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
|
---|
268 |
|
---|
269 | # default path + source dep.
|
---|
270 | ifneq ($(defpath),)
|
---|
271 | local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
|
---|
272 | local incs := $(abspathex $(incs),$($(target)_PATH))
|
---|
273 | else
|
---|
274 | local deps += $(source)
|
---|
275 | endif
|
---|
276 |
|
---|
277 | # call the tool
|
---|
278 | ifndef TOOL_$(tool)_RCC_QRC_CMDS
|
---|
279 | $(error kBuild: qt rcc tool not found: TOOL_$(tool)_RCC_QRC_CMDS)
|
---|
280 | endif
|
---|
281 | local cmds := $(TOOL_$(tool)_RCC_QRC_CMDS)
|
---|
282 | local more_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT)
|
---|
283 | local maybe_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT_MAYBE)
|
---|
284 | local deps += $(TOOL_$(tool)_RCC_QRC_DEPEND)
|
---|
285 | local orderdeps += $(TOOL_$(tool)_RCC_QRC_DEPORD)
|
---|
286 |
|
---|
287 | # generate the link rule and update some source and target variables.
|
---|
288 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
289 | $(eval includedep $(dep))
|
---|
290 | endif
|
---|
291 | $(eval $(def_unit_qt4_target_pre_handle_rcc_dx))
|
---|
292 |
|
---|
293 | endef # def_unit_qt4_src_handler_qrc
|
---|
294 |
|
---|
295 |
|
---|
296 | ## wrapper for the UIC command dependencies.
|
---|
297 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
298 | _UNIT_QT_UIC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT_UIC_CMDS_PREV_),$$(commands $(out)),FORCE)
|
---|
299 | else
|
---|
300 | _UNIT_QT_UIC_CMDS_DEP =
|
---|
301 | endif
|
---|
302 |
|
---|
303 | ##
|
---|
304 | # def_unit_qt4_target_pre_handle_uic_ui helper that is expanded before evaluation.
|
---|
305 | #
|
---|
306 | # This is necessary to resolve reference to local variables before doing
|
---|
307 | # assignments and setting up commands. They would otherwise be resolved
|
---|
308 | # later in a different context and the result would be completely wrong.
|
---|
309 | #
|
---|
310 | define def_unit_qt4_target_pre_handle_ui_dx
|
---|
311 |
|
---|
312 | $(out) +| $(realout) $(more_output) $(maybe_output): \
|
---|
313 | $(deps) \
|
---|
314 | $(value _UNIT_QT_UIC_CMDS_DEP) \
|
---|
315 | | \
|
---|
316 | $(orderdeps)
|
---|
317 | %$$(call MSG_TOOL,uic,$(target),$(source),$$@)
|
---|
318 | $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
|
---|
319 |
|
---|
320 | $(cmds)
|
---|
321 |
|
---|
322 | $(QUIET)$(CP) --changed -f $(out) $(realout)
|
---|
323 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
324 | %$$(QUIET2)$$(APPEND) '$(dep)'
|
---|
325 | %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT_UIC_CMDS_PREV_'
|
---|
326 | %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
|
---|
327 | %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
|
---|
328 | endif
|
---|
329 |
|
---|
330 | $(target)_INTERMEDIATES += $(realout)
|
---|
331 | $(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
|
---|
332 |
|
---|
333 | endef # def_unit_qt4_target_pre_handle_ui_dx
|
---|
334 |
|
---|
335 | ##
|
---|
336 | # Source handler for .ui sources.
|
---|
337 | #
|
---|
338 | # @remarks $(evalvalctx me).
|
---|
339 | define def_unit_qt4_src_handler_ui
|
---|
340 | local type := UIC
|
---|
341 |
|
---|
342 | # fetch the properties.
|
---|
343 | local tool := $(kb-src-tool dummy_var)
|
---|
344 | local qtuicdir := $(PATH_$(target))/qtuic
|
---|
345 | local outbase := $(qtuicdir)/$(notdir $(basename $(source)))
|
---|
346 | local out := $(outbase).tmp.gen.h
|
---|
347 | local realout := $(outbase).gen.h
|
---|
348 | local dep := $(realout).dep
|
---|
349 | local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
|
---|
350 | local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
|
---|
351 | local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
|
---|
352 |
|
---|
353 | # default path + source dep.
|
---|
354 | ifneq ($(defpath),)
|
---|
355 | local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
|
---|
356 | local incs := $(abspathex $(incs),$($(target)_PATH))
|
---|
357 | else
|
---|
358 | local deps += $(source)
|
---|
359 | endif
|
---|
360 |
|
---|
361 | # call the tool
|
---|
362 | ifndef TOOL_$(tool)_UIC_UI_CMDS
|
---|
363 | $(error kBuild: qt uic tool not found: TOOL_$(tool)_UIC_UI_CMDS)
|
---|
364 | endif
|
---|
365 | local cmds := $(TOOL_$(tool)_UIC_UI_CMDS)
|
---|
366 | local more_output := $(TOOL_$(tool)_UIC_UI_OUTPUT)
|
---|
367 | local maybe_output := $(TOOL_$(tool)_UIC_UI_OUTPUT_MAYBE)
|
---|
368 | local deps += $(TOOL_$(tool)_UIC_UI_DEPEND)
|
---|
369 | local orderdeps += $(TOOL_$(tool)_UIC_UI_DEPORD)
|
---|
370 |
|
---|
371 | # generate the link rule and update some source and target variables.
|
---|
372 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
373 | $(eval includedep $(dep))
|
---|
374 | endif
|
---|
375 | $(eval $(def_unit_qt4_target_pre_handle_ui_dx))
|
---|
376 |
|
---|
377 | endef # def_unit_qt4_src_handler_ui
|
---|
378 |
|
---|
379 |
|
---|
380 | ## wrapper for the MOC command dependencies.
|
---|
381 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
382 | _UNIT_QT_MOC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT_MOC_CMDS_PREV_),$$(commands $(out)),FORCE)
|
---|
383 | else
|
---|
384 | _UNIT_QT_MOC_CMDS_DEP =
|
---|
385 | endif
|
---|
386 |
|
---|
387 | ##
|
---|
388 | # def_unit_qt4_target_pre_handle_moc_hdr helper that is expanded before evaluation.
|
---|
389 | #
|
---|
390 | # This is necessary to resolve reference to local variables before doing
|
---|
391 | # assignments and setting up commands. They would otherwise be resolved
|
---|
392 | # later in a different context and the result would be completely wrong.
|
---|
393 | #
|
---|
394 | define def_unit_qt4_target_pre_handle_moc_hdr_dx
|
---|
395 |
|
---|
396 | $(out) +| $(realout) $(more_output) $(maybe_output): \
|
---|
397 | $(deps) \
|
---|
398 | $(value _UNIT_QT_MOC_CMDS_DEP) \
|
---|
399 | | \
|
---|
400 | $(orderdeps)
|
---|
401 | %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
|
---|
402 | $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
|
---|
403 |
|
---|
404 | $(cmds)
|
---|
405 |
|
---|
406 | $(QUIET)$(CP) --changed -f $(out) $(realout)
|
---|
407 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
408 | %$$(QUIET2)$$(APPEND) '$(dep)'
|
---|
409 | %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT_MOC_CMDS_PREV_'
|
---|
410 | %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
|
---|
411 | %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
|
---|
412 | endif
|
---|
413 |
|
---|
414 | $(target)_INTERMEDIATES += $(realout)
|
---|
415 | $(target)_GEN_SOURCES_ += $(realout)
|
---|
416 | $(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
|
---|
417 |
|
---|
418 | endef
|
---|
419 |
|
---|
420 | ##
|
---|
421 | # Handle a source file listed in QT_MOCSRCS.
|
---|
422 | #
|
---|
423 | # The files listed in QT_MOCSRCS uses the Q_OBJECT macro and will include
|
---|
424 | # a .moc file that we're expected to generate here.
|
---|
425 | #
|
---|
426 | # @remarks Invoked via $(evalvalctx ).
|
---|
427 | define def_unit_qt4_target_pre_handle_moc_hdr
|
---|
428 | local type := MOC
|
---|
429 |
|
---|
430 | # fetch the properties.
|
---|
431 | local tool := $(kb-src-tool dummy_var)
|
---|
432 | local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
|
---|
433 | local out := $(outbase).tmp.cpp
|
---|
434 | local realout := $(outbase).cpp
|
---|
435 | local dep := $(realout).dep
|
---|
436 | local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
|
---|
437 | local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
|
---|
438 | local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
|
---|
439 | local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
|
---|
440 | local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
|
---|
441 |
|
---|
442 | # default path + source dep.
|
---|
443 | ifneq ($(defpath),)
|
---|
444 | local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
|
---|
445 | local incs := $(abspathex $(incs),$($(target)_PATH))
|
---|
446 | else
|
---|
447 | local deps += $(source)
|
---|
448 | endif
|
---|
449 |
|
---|
450 | # call the tool
|
---|
451 | ifndef TOOL_$(tool)_MOC_HPP_CMDS
|
---|
452 | $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_HPP_CMDS)
|
---|
453 | endif
|
---|
454 | local cmds := $(TOOL_$(tool)_MOC_HPP_CMDS)
|
---|
455 | local more_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT)
|
---|
456 | local maybe_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT_MAYBE)
|
---|
457 | local deps += $(TOOL_$(tool)_MOC_HPP_DEPEND)
|
---|
458 | local orderdeps += $(TOOL_$(tool)_MOC_HPP_DEPORD)
|
---|
459 |
|
---|
460 | # generate the link rule and update some source and target variables.
|
---|
461 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
462 | $(eval includedep $(dep))
|
---|
463 | endif
|
---|
464 | $(eval $(def_unit_qt4_target_pre_handle_moc_hdr_dx))
|
---|
465 |
|
---|
466 | endef # def_unit_qt4_target_pre_handle_moc_hdr
|
---|
467 |
|
---|
468 |
|
---|
469 | ##
|
---|
470 | # def_unit_qt4_target_pre_handle_moc_src helper that is expanded before evaluation.
|
---|
471 | #
|
---|
472 | # This is necessary to resolve reference to local variables before doing
|
---|
473 | # assignments and setting up commands. They would otherwise be resolved
|
---|
474 | # later in a different context and the result would be completely wrong.
|
---|
475 | #
|
---|
476 | define def_unit_qt4_target_pre_handle_moc_src_dx
|
---|
477 |
|
---|
478 | $(out) +| $(realout) $(more_output) $(maybe_output): \
|
---|
479 | $(deps) \
|
---|
480 | $(value _UNIT_QT_MOC_CMDS_DEP) \
|
---|
481 | | \
|
---|
482 | $(orderdeps)
|
---|
483 | %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
|
---|
484 | $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
|
---|
485 |
|
---|
486 | $(cmds)
|
---|
487 |
|
---|
488 | $(QUIET)$(CP) --changed -f $(out) $(realout)
|
---|
489 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
490 | %$$(QUIET2)$$(APPEND) '$(dep)'
|
---|
491 | %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT_MOC_CMDS_PREV_'
|
---|
492 | %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
|
---|
493 | %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
|
---|
494 | endif
|
---|
495 |
|
---|
496 | $(target)_INTERMEDIATES += $(realout)
|
---|
497 | $(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
|
---|
498 |
|
---|
499 | endef
|
---|
500 |
|
---|
501 | ##
|
---|
502 | # Handle a source file listed in QT_MOCSRCS.
|
---|
503 | #
|
---|
504 | # The files listed in QT_MOCSRCS uses the Q_OBJECT macro and will include
|
---|
505 | # a .moc file that we're expected to generate here.
|
---|
506 | #
|
---|
507 | # @remarks Invoked via $(evalvalctx ).
|
---|
508 | define def_unit_qt4_target_pre_handle_moc_src
|
---|
509 | local type := MOC
|
---|
510 |
|
---|
511 | # fetch the properties.
|
---|
512 | local tool := $(kb-src-tool dummy_var)
|
---|
513 | local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
|
---|
514 | local out := $(outbase).tmp.moc
|
---|
515 | local realout := $(outbase).moc
|
---|
516 | local dep := $(realout).dep
|
---|
517 | local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
|
---|
518 | local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
|
---|
519 | local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
|
---|
520 | local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
|
---|
521 | local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
|
---|
522 |
|
---|
523 | # default path + source dep.
|
---|
524 | ifneq ($(defpath),)
|
---|
525 | local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
|
---|
526 | local incs := $(abspathex $(incs),$($(target)_PATH))
|
---|
527 | else
|
---|
528 | local deps += $(source)
|
---|
529 | endif
|
---|
530 |
|
---|
531 | # call the tool
|
---|
532 | ifndef TOOL_$(tool)_MOC_CPP_CMDS
|
---|
533 | $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_CPP_CMDS)
|
---|
534 | endif
|
---|
535 | local cmds := $(TOOL_$(tool)_MOC_CPP_CMDS)
|
---|
536 | local more_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT)
|
---|
537 | local maybe_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT_MAYBE)
|
---|
538 | local deps += $(TOOL_$(tool)_MOC_CPP_DEPEND)
|
---|
539 | local orderdeps += $(TOOL_$(tool)_MOC_CPP_DEPORD)
|
---|
540 |
|
---|
541 | # generate the link rule and update some source and target variables.
|
---|
542 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
543 | $(eval includedep $(dep))
|
---|
544 | endif
|
---|
545 | $(eval $(def_unit_qt4_target_pre_handle_moc_src_dx))
|
---|
546 |
|
---|
547 | endef # def_unit_qt4_target_pre_handle_moc_src
|
---|
548 |
|
---|
549 |
|
---|
550 | ##
|
---|
551 | # Adds sources containing Q_OBJECT to QT_MOCSRCS.
|
---|
552 | define def_unit_qt4_target_pre_cpp_source
|
---|
553 | ifneq ($(file-size $(source)),-1)
|
---|
554 | ifneq ($(strip $(shell $(SED) -f $(KBUILD_PATH)/units/qt-Q_OBJECT.sed $(source))),)
|
---|
555 | $(eval $(target)_QT_MOCSRCS += $(source))
|
---|
556 | endif
|
---|
557 | endif
|
---|
558 | endef # def_unit_qt4_target_pre_cpp_source
|
---|
559 |
|
---|
560 | ##
|
---|
561 | # Invoked early in the processing of a target that uses the Qt unit.
|
---|
562 | #
|
---|
563 | # It will append the qt source handlers to the target (.h, .ui, .ts,
|
---|
564 | # .png, .bmp, .gif).
|
---|
565 | #
|
---|
566 | # It will then check all the C++ sources and check which needs
|
---|
567 | # a .moc files and generate rules and dependencies fofor these
|
---|
568 | #
|
---|
569 | define def_unit_qt4_target_pre
|
---|
570 |
|
---|
571 | # Autodetect source files with Q_OBJECT references if QT_MOCSRCS is undefined. (slow)
|
---|
572 | # Tip: Use target_QT_MOCSRCS = $(NO_SUCH_VARIABLE) to avoid this.
|
---|
573 | ifndef $(target)_QT_MOCSRCS
|
---|
574 | $(foreach source, $(filter %.cxx %.CXX %.cpp %.CPP %.cc %.CC,\
|
---|
575 | $($(target)_SOURCES.$(_bld_trg)) \
|
---|
576 | $($(target)_SOURCES.$(_bld_trg_arch)) \
|
---|
577 | $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
578 | $($(target)_SOURCES.$(_bld_trg_cpu)) \
|
---|
579 | $($(target)_SOURCES.$(_bld_type)) \
|
---|
580 | $($(target)_SOURCES) \
|
---|
581 | ), $(evalval def_unit_qt4_target_pre_cpp_source))
|
---|
582 | endif
|
---|
583 |
|
---|
584 | # Install source handlers for .ui files.
|
---|
585 | $(target)_SRC_HANDLERS += \
|
---|
586 | .ui:def_unit_qt4_src_handler_ui \
|
---|
587 | .UI:def_unit_qt4_src_handler_ui \
|
---|
588 | .qrc:def_unit_qt4_src_handler_qrc \
|
---|
589 | .qrc:def_unit_qt4_src_handler_qrc \
|
---|
590 | .ts:def_unit_qt4_src_handler_ts \
|
---|
591 | .TS:def_unit_qt4_src_handler_ts
|
---|
592 |
|
---|
593 | # Calc the MOC and UI output directories and add them to BLDDIRS and INCS.
|
---|
594 | local qtmocdir := $(PATH_$(target))/qtmoc
|
---|
595 | local qtuicdir := $(PATH_$(target))/qtuic
|
---|
596 | local qtrccdir := $(PATH_$(target))/qtrcc
|
---|
597 | $(eval $(target)_BLDDIRS += $(qtmocdir) $(qtuicdir) $(qtrccdir))
|
---|
598 | $(eval $(target)_INCS += $(qtmocdir) $(qtuicdir) $(qtrccdir))
|
---|
599 |
|
---|
600 | # Deal with QT_MOCSRCS.
|
---|
601 | $(foreach source, \
|
---|
602 | $($(target)_QT_MOCSRCS.$(_bld_trg)) \
|
---|
603 | $($(target)_QT_MOCSRCS.$(_bld_trg_arch)) \
|
---|
604 | $($(target)_QT_MOCSRCS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
605 | $($(target)_QT_MOCSRCS.$(_bld_trg_cpu)) \
|
---|
606 | $($(target)_QT_MOCSRCS.$(_bld_type)) \
|
---|
607 | $($(target)_QT_MOCSRCS) \
|
---|
608 | , $(evalvalctx def_unit_qt4_target_pre_handle_moc_src))
|
---|
609 |
|
---|
610 | # Deal with QT_MOCHDRS.
|
---|
611 | $(foreach source, \
|
---|
612 | $($(target)_QT_MOCHDRS.$(_bld_trg)) \
|
---|
613 | $($(target)_QT_MOCHDRS.$(_bld_trg_arch)) \
|
---|
614 | $($(target)_QT_MOCHDRS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
615 | $($(target)_QT_MOCHDRS.$(_bld_trg_cpu)) \
|
---|
616 | $($(target)_QT_MOCHDRS.$(_bld_type)) \
|
---|
617 | $($(target)_QT_MOCHDRS) \
|
---|
618 | , $(evalvalctx def_unit_qt4_target_pre_handle_moc_hdr))
|
---|
619 |
|
---|
620 | endef # def_unit_qt4_target_pre
|
---|
621 |
|
---|