1 | # $Id: qt4.kmk 1676 2008-07-11 02:03:43Z bird $
|
---|
2 | ## @file
|
---|
3 | # Qt 4 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 += QTTOOL MOCTOOL UICTOOL RCCTOOL LRCTOOL QT_TRANSLATIONS_INST QT_TRANSLATIONS_TEMPLATE
|
---|
31 | PROPS_ACCUMULATE_R += MOCDEFS MOCFLAGS UICFLAGS RCCFLAGS LRCFLAGS QT_TRANSLATIONS QT_MOCSRCS QT_MOCHDRS
|
---|
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_LRC ?= $(PATH_TOOL_QT4_BIN)/lrelease$(HOST_SUFF_EXE)
|
---|
66 | TOOL_QT4_LUPDATE ?= $(PATH_TOOL_QT4_BIN)/lupdate$(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_LRC ?= lrelease$(HOST_SUFF_EXE)
|
---|
73 | TOOL_QT4_LUPDATE ?= lupdate$(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 | ## Compile a Qt translation file (.ts).
|
---|
193 | # @param $(target) Normalized main target name.
|
---|
194 | # @param $(source) Source filename (relative).
|
---|
195 | # @param $(out) Object file name. This shall be (re)created by the compilation.
|
---|
196 | # @param $(dep) Dependcy file. This may be (re)created by the compilation.
|
---|
197 | # @param $(flags) Flags.
|
---|
198 | # @param $(defs) Definitions.
|
---|
199 | # @param $(incs) Includes.
|
---|
200 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
201 | #
|
---|
202 | TOOL_QT4_LRC_TS_DEPEND =
|
---|
203 | TOOL_QT4_LRC_TS_DEPORD =
|
---|
204 | TOOL_QT4_LRC_TS_OUTPUT =
|
---|
205 | TOOL_QT4_LRC_TS_OUTPUT_MAYBE =
|
---|
206 | define TOOL_QT4_LRC_TS_CMDS
|
---|
207 | $(QUIET)$(TOOL_QT4_LRC)\
|
---|
208 | $(flags)\
|
---|
209 | $(source)\
|
---|
210 | -qm $(out)
|
---|
211 | endef
|
---|
212 |
|
---|
213 |
|
---|
214 |
|
---|
215 | #
|
---|
216 | #
|
---|
217 | # Back to the Qt4 unit.
|
---|
218 | #
|
---|
219 | #
|
---|
220 |
|
---|
221 |
|
---|
222 | ## wrapper for the lrelease (LRC) command dependencies.
|
---|
223 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
224 | _UNIT_QT_LRC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT_LRC_CMDS_PREV_),$$(commands $(out)),FORCE)
|
---|
225 | else
|
---|
226 | _UNIT_QT_LRC_CMDS_DEP =
|
---|
227 | endif
|
---|
228 |
|
---|
229 | ##
|
---|
230 | # def_unit_qt4_target_pre_handle_translation helper that is expanded before evaluation.
|
---|
231 | #
|
---|
232 | # This is necessary to resolve reference to local variables before doing
|
---|
233 | # assignments and setting up commands. They would otherwise be resolved
|
---|
234 | # later in a different context and the result would be completely wrong.
|
---|
235 | #
|
---|
236 | define def_unit_qt4_target_pre_handle_translation_dx
|
---|
237 |
|
---|
238 | $(out) + $(more_output) +| $(maybe_output): \
|
---|
239 | $(deps) \
|
---|
240 | $(value _UNIT_QT_LRC_CMDS_DEP) \
|
---|
241 | | \
|
---|
242 | $(orderdeps)
|
---|
243 | %$$(call MSG_TOOL,lrelease,$(target),$(source),$$@)
|
---|
244 | $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
|
---|
245 |
|
---|
246 | $(cmds)
|
---|
247 |
|
---|
248 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
249 | %$$(QUIET2)$$(APPEND) '$(dep)'
|
---|
250 | %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT_LRC_CMDS_PREV_'
|
---|
251 | %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
|
---|
252 | %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
|
---|
253 | endif
|
---|
254 |
|
---|
255 | $(target)_OUT_FILES += $(out) $(more_output) $(maybe_output)
|
---|
256 | $(target)-inst-nls_SOURCES += $(out)
|
---|
257 |
|
---|
258 | endef # def_unit_qt4_target_pre_handle_translation_dx
|
---|
259 |
|
---|
260 | ##
|
---|
261 | # Handle a source file listed in QT_TRANSLATIONS.
|
---|
262 | #
|
---|
263 | # The files listed in QT_TRANSLATIONS are translation files (.ts) which needs
|
---|
264 | # to be translated into .qm files that are loadble by Qt.
|
---|
265 | #
|
---|
266 | # @remarks Invoked via $(evalvalctx ).
|
---|
267 | define def_unit_qt4_target_pre_handle_translation
|
---|
268 | local type := LRC
|
---|
269 |
|
---|
270 | # fetch the properties.
|
---|
271 | local tool := $(kb-src-tool dummy_var)
|
---|
272 | local qtnlsdir := $(PATH_$(target))/qtnls
|
---|
273 | local outbase := $(qtnlsdir)/$(notdir $(basename $(source)))
|
---|
274 | local out := $(outbase).qm
|
---|
275 | local dep := $(out).dep
|
---|
276 | local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
|
---|
277 | local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
|
---|
278 | local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
|
---|
279 |
|
---|
280 | # default path + source dep.
|
---|
281 | ifneq ($(defpath),)
|
---|
282 | local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
|
---|
283 | local incs := $(abspathex $(incs),$($(target)_PATH))
|
---|
284 | else
|
---|
285 | local deps += $(source)
|
---|
286 | endif
|
---|
287 |
|
---|
288 | # call the tool
|
---|
289 | ifndef TOOL_$(tool)_LRC_TS_CMDS
|
---|
290 | $(error kBuild: qt lrelease tool not found: TOOL_$(tool)_LRC_TS_CMDS)
|
---|
291 | endif
|
---|
292 | local cmds := $(TOOL_$(tool)_LRC_TS_CMDS)
|
---|
293 | local more_output := $(TOOL_$(tool)_LRC_TS_OUTPUT)
|
---|
294 | local maybe_output := $(TOOL_$(tool)_LRC_TS_OUTPUT_MAYBE)
|
---|
295 | local deps += $(TOOL_$(tool)_LRC_TS_DEPEND)
|
---|
296 | local orderdeps += $(TOOL_$(tool)_LRC_TS_DEPORD)
|
---|
297 |
|
---|
298 | # generate the link rule and update some source and target variables.
|
---|
299 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
300 | $(eval includedep $(dep))
|
---|
301 | endif
|
---|
302 | $(eval $(def_unit_qt4_target_pre_handle_translation_dx))
|
---|
303 |
|
---|
304 | endef # def_unit_qt4_target_pre_handle_translation
|
---|
305 |
|
---|
306 |
|
---|
307 |
|
---|
308 | ## wrapper for the UIC command dependencies.
|
---|
309 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
310 | _UNIT_QT_RCC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT_RCC_CMDS_PREV_),$$(commands $(out)),FORCE)
|
---|
311 | else
|
---|
312 | _UNIT_QT_RCC_CMDS_DEP =
|
---|
313 | endif
|
---|
314 |
|
---|
315 | ##
|
---|
316 | # def_unit_qt4_target_pre_handle_qrc helper that is expanded before evaluation.
|
---|
317 | #
|
---|
318 | # This is necessary to resolve reference to local variables before doing
|
---|
319 | # assignments and setting up commands. They would otherwise be resolved
|
---|
320 | # later in a different context and the result would be completely wrong.
|
---|
321 | #
|
---|
322 | define def_unit_qt4_target_pre_handle_rcc_dx
|
---|
323 |
|
---|
324 | $(out) +| $(realout) $(more_output) $(maybe_output): \
|
---|
325 | $(deps) \
|
---|
326 | $(value _UNIT_QT_RCC_CMDS_DEP) \
|
---|
327 | | \
|
---|
328 | $(orderdeps)
|
---|
329 | %$$(call MSG_TOOL,rcc,$(target),$(source),$$@)
|
---|
330 | $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
|
---|
331 |
|
---|
332 | $(cmds)
|
---|
333 |
|
---|
334 | $(QUIET)$(CP) --changed -f $(out) $(realout)
|
---|
335 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
336 | %$$(QUIET2)$$(APPEND) '$(dep)'
|
---|
337 | %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT_RCC_CMDS_PREV_'
|
---|
338 | %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
|
---|
339 | %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
|
---|
340 | endif
|
---|
341 |
|
---|
342 | $(target)_INTERMEDIATES += $(realout)
|
---|
343 | $(target)_GEN_SOURCES_ += $(realout)
|
---|
344 | $(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
|
---|
345 |
|
---|
346 | endef # def_unit_qt4_target_pre_handle_rcc_dx
|
---|
347 |
|
---|
348 | ##
|
---|
349 | # Source handler for .qrc sources (Qt resource files).
|
---|
350 | #
|
---|
351 | # @remarks $(evalvalctx me).
|
---|
352 | define def_unit_qt4_src_handler_qrc
|
---|
353 | local type := RCC
|
---|
354 |
|
---|
355 | # fetch the properties.
|
---|
356 | local tool := $(kb-src-tool dummy_var)
|
---|
357 | local qtrccdir := $(PATH_$(target))/qtrcc
|
---|
358 | local outbase := $(qtrccdir)/$(notdir $(basename $(source)))
|
---|
359 | local out := $(outbase).tmp.gen.cpp
|
---|
360 | local realout := $(outbase).gen.cpp
|
---|
361 | local dep := $(realout).dep
|
---|
362 | local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
|
---|
363 | local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
|
---|
364 | local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
|
---|
365 |
|
---|
366 | # default path + source dep.
|
---|
367 | ifneq ($(defpath),)
|
---|
368 | local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
|
---|
369 | local incs := $(abspathex $(incs),$($(target)_PATH))
|
---|
370 | else
|
---|
371 | local deps += $(source)
|
---|
372 | endif
|
---|
373 |
|
---|
374 | # call the tool
|
---|
375 | ifndef TOOL_$(tool)_RCC_QRC_CMDS
|
---|
376 | $(error kBuild: qt rcc tool not found: TOOL_$(tool)_RCC_QRC_CMDS)
|
---|
377 | endif
|
---|
378 | local cmds := $(TOOL_$(tool)_RCC_QRC_CMDS)
|
---|
379 | local more_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT)
|
---|
380 | local maybe_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT_MAYBE)
|
---|
381 | local deps += $(TOOL_$(tool)_RCC_QRC_DEPEND)
|
---|
382 | local orderdeps += $(TOOL_$(tool)_RCC_QRC_DEPORD)
|
---|
383 |
|
---|
384 | # generate the link rule and update some source and target variables.
|
---|
385 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
386 | $(eval includedep $(dep))
|
---|
387 | endif
|
---|
388 | $(eval $(def_unit_qt4_target_pre_handle_rcc_dx))
|
---|
389 |
|
---|
390 | endef # def_unit_qt4_src_handler_qrc
|
---|
391 |
|
---|
392 |
|
---|
393 |
|
---|
394 | ## wrapper for the UIC command dependencies.
|
---|
395 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
396 | _UNIT_QT_UIC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT_UIC_CMDS_PREV_),$$(commands $(out)),FORCE)
|
---|
397 | else
|
---|
398 | _UNIT_QT_UIC_CMDS_DEP =
|
---|
399 | endif
|
---|
400 |
|
---|
401 | ##
|
---|
402 | # def_unit_qt4_src_handler_ui helper that is expanded before evaluation.
|
---|
403 | #
|
---|
404 | # This is necessary to resolve reference to local variables before doing
|
---|
405 | # assignments and setting up commands. They would otherwise be resolved
|
---|
406 | # later in a different context and the result would be completely wrong.
|
---|
407 | #
|
---|
408 | define def_unit_qt4_target_pre_handle_ui_dx
|
---|
409 |
|
---|
410 | $(out) +| $(realout) $(more_output) $(maybe_output): \
|
---|
411 | $(deps) \
|
---|
412 | $(value _UNIT_QT_UIC_CMDS_DEP) \
|
---|
413 | | \
|
---|
414 | $(orderdeps)
|
---|
415 | %$$(call MSG_TOOL,uic,$(target),$(source),$$@)
|
---|
416 | $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
|
---|
417 |
|
---|
418 | $(cmds)
|
---|
419 |
|
---|
420 | $(QUIET)$(CP) --changed -f $(out) $(realout)
|
---|
421 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
422 | %$$(QUIET2)$$(APPEND) '$(dep)'
|
---|
423 | %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT_UIC_CMDS_PREV_'
|
---|
424 | %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
|
---|
425 | %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
|
---|
426 | endif
|
---|
427 |
|
---|
428 | $(target)_INTERMEDIATES += $(realout)
|
---|
429 | $(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
|
---|
430 |
|
---|
431 | endef # def_unit_qt4_target_pre_handle_ui_dx
|
---|
432 |
|
---|
433 | ##
|
---|
434 | # Source handler for .ui sources.
|
---|
435 | #
|
---|
436 | # @remarks $(evalvalctx me).
|
---|
437 | define def_unit_qt4_src_handler_ui
|
---|
438 | local type := UIC
|
---|
439 |
|
---|
440 | # fetch the properties.
|
---|
441 | local tool := $(kb-src-tool dummy_var)
|
---|
442 | local qtuicdir := $(PATH_$(target))/qtuic
|
---|
443 | local outbase := $(qtuicdir)/$(notdir $(basename $(source)))
|
---|
444 | local out := $(outbase).tmp.gen.h
|
---|
445 | local realout := $(outbase).gen.h
|
---|
446 | local dep := $(realout).dep
|
---|
447 | local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
|
---|
448 | local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
|
---|
449 | local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
|
---|
450 |
|
---|
451 | # default path + source dep.
|
---|
452 | ifneq ($(defpath),)
|
---|
453 | local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
|
---|
454 | local incs := $(abspathex $(incs),$($(target)_PATH))
|
---|
455 | else
|
---|
456 | local deps += $(source)
|
---|
457 | endif
|
---|
458 |
|
---|
459 | # call the tool
|
---|
460 | ifndef TOOL_$(tool)_UIC_UI_CMDS
|
---|
461 | $(error kBuild: qt uic tool not found: TOOL_$(tool)_UIC_UI_CMDS)
|
---|
462 | endif
|
---|
463 | local cmds := $(TOOL_$(tool)_UIC_UI_CMDS)
|
---|
464 | local more_output := $(TOOL_$(tool)_UIC_UI_OUTPUT)
|
---|
465 | local maybe_output := $(TOOL_$(tool)_UIC_UI_OUTPUT_MAYBE)
|
---|
466 | local deps += $(TOOL_$(tool)_UIC_UI_DEPEND)
|
---|
467 | local orderdeps += $(TOOL_$(tool)_UIC_UI_DEPORD)
|
---|
468 |
|
---|
469 | # generate the link rule and update some source and target variables.
|
---|
470 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
471 | $(eval includedep $(dep))
|
---|
472 | endif
|
---|
473 | $(eval $(def_unit_qt4_target_pre_handle_ui_dx))
|
---|
474 |
|
---|
475 | endef # def_unit_qt4_src_handler_ui
|
---|
476 |
|
---|
477 |
|
---|
478 |
|
---|
479 | ## wrapper for the MOC command dependencies.
|
---|
480 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
481 | _UNIT_QT_MOC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT_MOC_CMDS_PREV_),$$(commands $(out)),FORCE)
|
---|
482 | else
|
---|
483 | _UNIT_QT_MOC_CMDS_DEP =
|
---|
484 | endif
|
---|
485 |
|
---|
486 | ##
|
---|
487 | # def_unit_qt4_target_pre_handle_moc_hdr helper that is expanded before evaluation.
|
---|
488 | #
|
---|
489 | # This is necessary to resolve reference to local variables before doing
|
---|
490 | # assignments and setting up commands. They would otherwise be resolved
|
---|
491 | # later in a different context and the result would be completely wrong.
|
---|
492 | #
|
---|
493 | define def_unit_qt4_target_pre_handle_moc_hdr_dx
|
---|
494 |
|
---|
495 | $(out) +| $(realout) $(more_output) $(maybe_output): \
|
---|
496 | $(deps) \
|
---|
497 | $(value _UNIT_QT_MOC_CMDS_DEP) \
|
---|
498 | | \
|
---|
499 | $(orderdeps)
|
---|
500 | %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
|
---|
501 | $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
|
---|
502 |
|
---|
503 | $(cmds)
|
---|
504 |
|
---|
505 | $(QUIET)$(CP) --changed -f $(out) $(realout)
|
---|
506 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
507 | %$$(QUIET2)$$(APPEND) '$(dep)'
|
---|
508 | %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT_MOC_CMDS_PREV_'
|
---|
509 | %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
|
---|
510 | %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
|
---|
511 | endif
|
---|
512 |
|
---|
513 | $(target)_INTERMEDIATES += $(realout)
|
---|
514 | $(target)_GEN_SOURCES_ += $(realout)
|
---|
515 | $(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
|
---|
516 |
|
---|
517 | endef
|
---|
518 |
|
---|
519 | ##
|
---|
520 | # Handle a source file listed in QT_MOCHDRSS.
|
---|
521 | #
|
---|
522 | # The files listed in QT_MOCHDRS uses the Q_OBJECT macro and we will
|
---|
523 | # generate a .cpp file for each of them and add it to the generated
|
---|
524 | # sources so that it's compiled and linked. (There is an alternative
|
---|
525 | # way to do this where the .cpp file is included, this isn't currently
|
---|
526 | # supported by this unit.)
|
---|
527 | #
|
---|
528 | # @remarks Invoked via $(evalvalctx ).
|
---|
529 | define def_unit_qt4_target_pre_handle_moc_hdr
|
---|
530 | local type := MOC
|
---|
531 |
|
---|
532 | # fetch the properties.
|
---|
533 | local tool := $(kb-src-tool dummy_var)
|
---|
534 | local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
|
---|
535 | local out := $(outbase).tmp.cpp
|
---|
536 | local realout := $(outbase).cpp
|
---|
537 | local dep := $(realout).dep
|
---|
538 | local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
|
---|
539 | local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
|
---|
540 | local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
|
---|
541 | local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
|
---|
542 | local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
|
---|
543 |
|
---|
544 | # default path + source dep.
|
---|
545 | ifneq ($(defpath),)
|
---|
546 | local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
|
---|
547 | local incs := $(abspathex $(incs),$($(target)_PATH))
|
---|
548 | else
|
---|
549 | local deps += $(source)
|
---|
550 | endif
|
---|
551 |
|
---|
552 | # call the tool
|
---|
553 | ifndef TOOL_$(tool)_MOC_HPP_CMDS
|
---|
554 | $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_HPP_CMDS)
|
---|
555 | endif
|
---|
556 | local cmds := $(TOOL_$(tool)_MOC_HPP_CMDS)
|
---|
557 | local more_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT)
|
---|
558 | local maybe_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT_MAYBE)
|
---|
559 | local deps += $(TOOL_$(tool)_MOC_HPP_DEPEND)
|
---|
560 | local orderdeps += $(TOOL_$(tool)_MOC_HPP_DEPORD)
|
---|
561 |
|
---|
562 | # generate the link rule and update some source and target variables.
|
---|
563 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
564 | $(eval includedep $(dep))
|
---|
565 | endif
|
---|
566 | $(eval $(def_unit_qt4_target_pre_handle_moc_hdr_dx))
|
---|
567 |
|
---|
568 | endef # def_unit_qt4_target_pre_handle_moc_hdr
|
---|
569 |
|
---|
570 |
|
---|
571 | ##
|
---|
572 | # def_unit_qt4_target_pre_handle_moc_src helper that is expanded before evaluation.
|
---|
573 | #
|
---|
574 | # This is necessary to resolve reference to local variables before doing
|
---|
575 | # assignments and setting up commands. They would otherwise be resolved
|
---|
576 | # later in a different context and the result would be completely wrong.
|
---|
577 | #
|
---|
578 | define def_unit_qt4_target_pre_handle_moc_src_dx
|
---|
579 |
|
---|
580 | $(out) +| $(realout) $(more_output) $(maybe_output): \
|
---|
581 | $(deps) \
|
---|
582 | $(value _UNIT_QT_MOC_CMDS_DEP) \
|
---|
583 | | \
|
---|
584 | $(orderdeps)
|
---|
585 | %$$(call MSG_TOOL,moc,$(target),$(source),$$@)
|
---|
586 | $(QUIET2)$(RM) -f $(out) $(more_output) $(maybe_output) $(dep)
|
---|
587 |
|
---|
588 | $(cmds)
|
---|
589 |
|
---|
590 | $(QUIET)$(CP) --changed -f $(out) $(realout)
|
---|
591 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
592 | %$$(QUIET2)$$(APPEND) '$(dep)'
|
---|
593 | %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_QT_MOC_CMDS_PREV_'
|
---|
594 | %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
|
---|
595 | %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
|
---|
596 | endif
|
---|
597 |
|
---|
598 | $(target)_INTERMEDIATES += $(realout)
|
---|
599 | $(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
|
---|
600 |
|
---|
601 | endef
|
---|
602 |
|
---|
603 | ##
|
---|
604 | # Handle a source file listed in QT_MOCSRCS.
|
---|
605 | #
|
---|
606 | # The files listed in QT_MOCSRCS uses the Q_OBJECT macro and will include
|
---|
607 | # a .moc file that we're expected to generate here.
|
---|
608 | #
|
---|
609 | # @remarks Invoked via $(evalvalctx ).
|
---|
610 | define def_unit_qt4_target_pre_handle_moc_src
|
---|
611 | local type := MOC
|
---|
612 |
|
---|
613 | # fetch the properties.
|
---|
614 | local tool := $(kb-src-tool dummy_var)
|
---|
615 | local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
|
---|
616 | local out := $(outbase).tmp.moc
|
---|
617 | local realout := $(outbase).moc
|
---|
618 | local dep := $(realout).dep
|
---|
619 | local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
|
---|
620 | local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
|
---|
621 | local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
|
---|
622 | local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
|
---|
623 | local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
|
---|
624 |
|
---|
625 | # default path + source dep.
|
---|
626 | ifneq ($(defpath),)
|
---|
627 | local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
|
---|
628 | local incs := $(abspathex $(incs),$($(target)_PATH))
|
---|
629 | else
|
---|
630 | local deps += $(source)
|
---|
631 | endif
|
---|
632 |
|
---|
633 | # call the tool
|
---|
634 | ifndef TOOL_$(tool)_MOC_CPP_CMDS
|
---|
635 | $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_CPP_CMDS)
|
---|
636 | endif
|
---|
637 | local cmds := $(TOOL_$(tool)_MOC_CPP_CMDS)
|
---|
638 | local more_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT)
|
---|
639 | local maybe_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT_MAYBE)
|
---|
640 | local deps += $(TOOL_$(tool)_MOC_CPP_DEPEND)
|
---|
641 | local orderdeps += $(TOOL_$(tool)_MOC_CPP_DEPORD)
|
---|
642 |
|
---|
643 | # generate the link rule and update some source and target variables.
|
---|
644 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
645 | $(eval includedep $(dep))
|
---|
646 | endif
|
---|
647 | $(eval $(def_unit_qt4_target_pre_handle_moc_src_dx))
|
---|
648 |
|
---|
649 | endef # def_unit_qt4_target_pre_handle_moc_src
|
---|
650 |
|
---|
651 |
|
---|
652 | ##
|
---|
653 | # Adds sources containing Q_OBJECT to QT_MOCSRCS.
|
---|
654 | define def_unit_qt4_target_pre_cpp_source
|
---|
655 | ifneq ($(file-size $(source)),-1)
|
---|
656 | ifneq ($(strip $(shell $(SED) -f $(KBUILD_PATH)/units/qt-Q_OBJECT.sed $(source))),)
|
---|
657 | $(eval $(target)_QT_MOCSRCS += $(source))
|
---|
658 | endif
|
---|
659 | endif
|
---|
660 | endef # def_unit_qt4_target_pre_cpp_source
|
---|
661 |
|
---|
662 | ##
|
---|
663 | # Invoked early in the processing of a target that uses the Qt unit.
|
---|
664 | #
|
---|
665 | # It will append the qt source handlers to the target (.h, .ui, .ts,
|
---|
666 | # .png, .bmp, .gif).
|
---|
667 | #
|
---|
668 | # It will then check all the C++ sources and check which needs
|
---|
669 | # a .moc files and generate rules and dependencies fofor these
|
---|
670 | #
|
---|
671 | define def_unit_qt4_target_pre
|
---|
672 |
|
---|
673 | # Make QTTOOL the default for the specific Qt tools instead of TOOL.
|
---|
674 | ifneq ($($(target)_QTTOOL),)
|
---|
675 | ifeq ($($(target)_MOCTOOL),)
|
---|
676 | $($(target)_MOCTOOL := $($(target)_QTTOOL)
|
---|
677 | endif
|
---|
678 | ifeq ($($(target)_UICTOOL),)
|
---|
679 | $($(target)_UICTOOL := $($(target)_QTTOOL)
|
---|
680 | endif
|
---|
681 | ifeq ($($(target)_RCCTOOL),)
|
---|
682 | $($(target)_RCCTOOL := $($(target)_QTTOOL)
|
---|
683 | endif
|
---|
684 | ifeq ($($(target)_LRCTOOL),)
|
---|
685 | $($(target)_LRCTOOL := $($(target)_QTTOOL)
|
---|
686 | endif
|
---|
687 | endif
|
---|
688 |
|
---|
689 | # Autodetect source files with Q_OBJECT references if QT_MOCSRCS is undefined. (slow)
|
---|
690 | # Tip: Use target_QT_MOCSRCS = $(NO_SUCH_VARIABLE) to avoid this.
|
---|
691 | ifndef $(target)_QT_MOCSRCS
|
---|
692 | $(foreach source, $(filter %.cxx %.CXX %.cpp %.CPP %.cc %.CC,\
|
---|
693 | $($(target)_SOURCES.$(_bld_trg)) \
|
---|
694 | $($(target)_SOURCES.$(_bld_trg_arch)) \
|
---|
695 | $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
696 | $($(target)_SOURCES.$(_bld_trg_cpu)) \
|
---|
697 | $($(target)_SOURCES.$(_bld_type)) \
|
---|
698 | $($(target)_SOURCES) \
|
---|
699 | ), $(evalval def_unit_qt4_target_pre_cpp_source))
|
---|
700 | endif
|
---|
701 |
|
---|
702 | # Install source handlers for .ui files.
|
---|
703 | $(target)_SRC_HANDLERS += \
|
---|
704 | .ui:def_unit_qt4_src_handler_ui \
|
---|
705 | .UI:def_unit_qt4_src_handler_ui \
|
---|
706 | .qrc:def_unit_qt4_src_handler_qrc \
|
---|
707 | .qrc:def_unit_qt4_src_handler_qrc
|
---|
708 |
|
---|
709 | # Calc the MOC and UI output directories and add them to BLDDIRS and INCS.
|
---|
710 | local qtmocdir := $(PATH_$(target))/qtmoc
|
---|
711 | local qtuicdir := $(PATH_$(target))/qtuic
|
---|
712 | local qtrccdir := $(PATH_$(target))/qtrcc
|
---|
713 | local qtnlsdir := $(PATH_$(target))/qtnls
|
---|
714 | $(eval $(target)_BLDDIRS += $(qtmocdir) $(qtuicdir) $(qtrccdir) $(qtnlsdir))
|
---|
715 | $(eval $(target)_INCS += $(qtmocdir) $(qtuicdir))
|
---|
716 |
|
---|
717 | # Deal with QT_MOCSRCS.
|
---|
718 | $(foreach source, \
|
---|
719 | $($(target)_QT_MOCSRCS.$(_bld_trg)) \
|
---|
720 | $($(target)_QT_MOCSRCS.$(_bld_trg_arch)) \
|
---|
721 | $($(target)_QT_MOCSRCS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
722 | $($(target)_QT_MOCSRCS.$(_bld_trg_cpu)) \
|
---|
723 | $($(target)_QT_MOCSRCS.$(_bld_type)) \
|
---|
724 | $($(target)_QT_MOCSRCS) \
|
---|
725 | , $(evalvalctx def_unit_qt4_target_pre_handle_moc_src))
|
---|
726 |
|
---|
727 | # Deal with QT_MOCHDRS.
|
---|
728 | $(foreach source, \
|
---|
729 | $($(target)_QT_MOCHDRS.$(_bld_trg)) \
|
---|
730 | $($(target)_QT_MOCHDRS.$(_bld_trg_arch)) \
|
---|
731 | $($(target)_QT_MOCHDRS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
732 | $($(target)_QT_MOCHDRS.$(_bld_trg_cpu)) \
|
---|
733 | $($(target)_QT_MOCHDRS.$(_bld_type)) \
|
---|
734 | $($(target)_QT_MOCHDRS) \
|
---|
735 | , $(evalvalctx def_unit_qt4_target_pre_handle_moc_hdr))
|
---|
736 |
|
---|
737 | # Deal with QT_TRANSLATIONS.
|
---|
738 | # ASSUMES (_ALL_)INSTALLS is processed after the targets using this unit.
|
---|
739 | local translations := \
|
---|
740 | $($(target)_QT_TRANSLATIONS.$(_bld_trg)) \
|
---|
741 | $($(target)_QT_TRANSLATIONS.$(_bld_trg_arch)) \
|
---|
742 | $($(target)_QT_TRANSLATIONS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
743 | $($(target)_QT_TRANSLATIONS.$(_bld_trg_cpu)) \
|
---|
744 | $($(target)_QT_TRANSLATIONS.$(_bld_type)) \
|
---|
745 | $($(target)_QT_TRANSLATIONS)
|
---|
746 | ifneq ($(strip $(translations)),)
|
---|
747 | local expr := _ALL_INSTALLS += $(target)-inst-nls
|
---|
748 | $(eval $(expr))
|
---|
749 | ifdef $(target)_QT_TRANSLATIONS_TEMPLATE
|
---|
750 | $(target)-inst-nls_TEMPLATE := $($(target)_QT_TRANSLATIONS_TEMPLATE)
|
---|
751 | endif
|
---|
752 | ifdef $(target)_QT_TRANSLATIONS_INST
|
---|
753 | $(target)-inst-nls_INST := $($(target)_QT_TRANSLATIONS_INST)
|
---|
754 | endif
|
---|
755 | $(target)-inst-nls_SOURCES :=
|
---|
756 | $(foreach source, $(translations)\
|
---|
757 | , $(evalvalctx def_unit_qt4_target_pre_handle_translation))
|
---|
758 | endif
|
---|
759 |
|
---|
760 | endef # def_unit_qt4_target_pre
|
---|
761 |
|
---|