source: trunk/kBuild/units/qt4.kmk@ 1676

Last change on this file since 1676 was 1676, checked in by bird, 17 years ago
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 24.6 KB
Line 
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
27UNIT_qt4 = qt4
28
29# Add our target properties.
30PROPS_SINGLE += QTTOOL MOCTOOL UICTOOL RCCTOOL LRCTOOL QT_TRANSLATIONS_INST QT_TRANSLATIONS_TEMPLATE
31PROPS_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#
40SDK_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#
50TOOL_QT4 = Qt4
51
52# Tool Specific Properties
53ifndef 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.
56else
57 # Resolve any fancy stuff once and for all.
58 PATH_TOOL_QT4 := $(PATH_TOOL_QT4)
59endif
60ifneq ($(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)
67else
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)
74endif
75
76# General Properties used by kBuild and/or units/qt.kmk
77TOOL_QT4_MOCFLAGS ?=
78TOOL_QT4_MOCINCS ?=
79TOOL_QT4_MOCDEFS ?=
80TOOL_QT4_MOCDEFS.darwin ?= __APPLE__ __GNUC__
81TOOL_QT4_MOCDEFS.solaris ?= __sun
82TOOL_QT4_MOCDEFS.win.amd64 ?= WIN64
83TOOL_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#
96TOOL_QT4_MOC_CPP_DEPEND =
97TOOL_QT4_MOC_CPP_DEPORD =
98TOOL_QT4_MOC_CPP_OUTPUT =
99TOOL_QT4_MOC_CPP_OUTPUT_MAYBE =
100define 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)
107endef
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#
119TOOL_QT4_MOC_HPP_DEPEND =
120TOOL_QT4_MOC_HPP_DEPORD =
121TOOL_QT4_MOC_HPP_OUTPUT =
122TOOL_QT4_MOC_HPP_OUTPUT_MAYBE =
123define 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)
130endef
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#
142TOOL_QT4_UIC_UI_DEPEND =
143TOOL_QT4_UIC_UI_DEPORD =
144TOOL_QT4_UIC_UI_OUTPUT =
145TOOL_QT4_UIC_UI_OUTPUT_MAYBE =
146define TOOL_QT4_UIC_UI_CMDS
147 $(QUIET)$(TOOL_QT4_UIC)\
148 $(flags)\
149 -o $(out)\
150 $(source)
151endef
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.
164TOOL_QT4_RCC_QRC_DEPEND =
165TOOL_QT4_RCC_QRC_DEPORD =
166TOOL_QT4_RCC_QRC_OUTPUT =
167TOOL_QT4_RCC_QRC_OUTPUT_MAYBE =
168define 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)
190endef
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#
202TOOL_QT4_LRC_TS_DEPEND =
203TOOL_QT4_LRC_TS_DEPORD =
204TOOL_QT4_LRC_TS_OUTPUT =
205TOOL_QT4_LRC_TS_OUTPUT_MAYBE =
206define TOOL_QT4_LRC_TS_CMDS
207 $(QUIET)$(TOOL_QT4_LRC)\
208 $(flags)\
209 $(source)\
210 -qm $(out)
211endef
212
213
214
215#
216#
217# Back to the Qt4 unit.
218#
219#
220
221
222## wrapper for the lrelease (LRC) command dependencies.
223ifndef NO_COMPILE_CMDS_DEPS
224 _UNIT_QT_LRC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT_LRC_CMDS_PREV_),$$(commands $(out)),FORCE)
225else
226 _UNIT_QT_LRC_CMDS_DEP =
227endif
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#
236define 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
248ifndef 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'
253endif
254
255$(target)_OUT_FILES += $(out) $(more_output) $(maybe_output)
256$(target)-inst-nls_SOURCES += $(out)
257
258endef # 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 ).
267define def_unit_qt4_target_pre_handle_translation
268local type := LRC
269
270# fetch the properties.
271local tool := $(kb-src-tool dummy_var)
272local qtnlsdir := $(PATH_$(target))/qtnls
273local outbase := $(qtnlsdir)/$(notdir $(basename $(source)))
274local out := $(outbase).qm
275local dep := $(out).dep
276local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
277local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
278local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
279
280# default path + source dep.
281ifneq ($(defpath),)
282local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
283local incs := $(abspathex $(incs),$($(target)_PATH))
284else
285local deps += $(source)
286endif
287
288# call the tool
289ifndef TOOL_$(tool)_LRC_TS_CMDS
290 $(error kBuild: qt lrelease tool not found: TOOL_$(tool)_LRC_TS_CMDS)
291endif
292local cmds := $(TOOL_$(tool)_LRC_TS_CMDS)
293local more_output := $(TOOL_$(tool)_LRC_TS_OUTPUT)
294local maybe_output := $(TOOL_$(tool)_LRC_TS_OUTPUT_MAYBE)
295local deps += $(TOOL_$(tool)_LRC_TS_DEPEND)
296local orderdeps += $(TOOL_$(tool)_LRC_TS_DEPORD)
297
298# generate the link rule and update some source and target variables.
299ifndef NO_COMPILE_CMDS_DEPS
300 $(eval includedep $(dep))
301endif
302$(eval $(def_unit_qt4_target_pre_handle_translation_dx))
303
304endef # def_unit_qt4_target_pre_handle_translation
305
306
307
308## wrapper for the UIC command dependencies.
309ifndef NO_COMPILE_CMDS_DEPS
310 _UNIT_QT_RCC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT_RCC_CMDS_PREV_),$$(commands $(out)),FORCE)
311else
312 _UNIT_QT_RCC_CMDS_DEP =
313endif
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#
322define 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)
335ifndef 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'
340endif
341
342$(target)_INTERMEDIATES += $(realout)
343$(target)_GEN_SOURCES_ += $(realout)
344$(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
345
346endef # def_unit_qt4_target_pre_handle_rcc_dx
347
348##
349# Source handler for .qrc sources (Qt resource files).
350#
351# @remarks $(evalvalctx me).
352define def_unit_qt4_src_handler_qrc
353local type := RCC
354
355# fetch the properties.
356local tool := $(kb-src-tool dummy_var)
357local qtrccdir := $(PATH_$(target))/qtrcc
358local outbase := $(qtrccdir)/$(notdir $(basename $(source)))
359local out := $(outbase).tmp.gen.cpp
360local realout := $(outbase).gen.cpp
361local dep := $(realout).dep
362local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
363local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
364local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
365
366# default path + source dep.
367ifneq ($(defpath),)
368local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
369local incs := $(abspathex $(incs),$($(target)_PATH))
370else
371local deps += $(source)
372endif
373
374# call the tool
375ifndef TOOL_$(tool)_RCC_QRC_CMDS
376 $(error kBuild: qt rcc tool not found: TOOL_$(tool)_RCC_QRC_CMDS)
377endif
378local cmds := $(TOOL_$(tool)_RCC_QRC_CMDS)
379local more_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT)
380local maybe_output := $(TOOL_$(tool)_RCC_QRC_OUTPUT_MAYBE)
381local deps += $(TOOL_$(tool)_RCC_QRC_DEPEND)
382local orderdeps += $(TOOL_$(tool)_RCC_QRC_DEPORD)
383
384# generate the link rule and update some source and target variables.
385ifndef NO_COMPILE_CMDS_DEPS
386 $(eval includedep $(dep))
387endif
388$(eval $(def_unit_qt4_target_pre_handle_rcc_dx))
389
390endef # def_unit_qt4_src_handler_qrc
391
392
393
394## wrapper for the UIC command dependencies.
395ifndef NO_COMPILE_CMDS_DEPS
396 _UNIT_QT_UIC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT_UIC_CMDS_PREV_),$$(commands $(out)),FORCE)
397else
398 _UNIT_QT_UIC_CMDS_DEP =
399endif
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#
408define 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)
421ifndef 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'
426endif
427
428$(target)_INTERMEDIATES += $(realout)
429$(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
430
431endef # def_unit_qt4_target_pre_handle_ui_dx
432
433##
434# Source handler for .ui sources.
435#
436# @remarks $(evalvalctx me).
437define def_unit_qt4_src_handler_ui
438local type := UIC
439
440# fetch the properties.
441local tool := $(kb-src-tool dummy_var)
442local qtuicdir := $(PATH_$(target))/qtuic
443local outbase := $(qtuicdir)/$(notdir $(basename $(source)))
444local out := $(outbase).tmp.gen.h
445local realout := $(outbase).gen.h
446local dep := $(realout).dep
447local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
448local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
449local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
450
451# default path + source dep.
452ifneq ($(defpath),)
453local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
454local incs := $(abspathex $(incs),$($(target)_PATH))
455else
456local deps += $(source)
457endif
458
459# call the tool
460ifndef TOOL_$(tool)_UIC_UI_CMDS
461 $(error kBuild: qt uic tool not found: TOOL_$(tool)_UIC_UI_CMDS)
462endif
463local cmds := $(TOOL_$(tool)_UIC_UI_CMDS)
464local more_output := $(TOOL_$(tool)_UIC_UI_OUTPUT)
465local maybe_output := $(TOOL_$(tool)_UIC_UI_OUTPUT_MAYBE)
466local deps += $(TOOL_$(tool)_UIC_UI_DEPEND)
467local orderdeps += $(TOOL_$(tool)_UIC_UI_DEPORD)
468
469# generate the link rule and update some source and target variables.
470ifndef NO_COMPILE_CMDS_DEPS
471 $(eval includedep $(dep))
472endif
473$(eval $(def_unit_qt4_target_pre_handle_ui_dx))
474
475endef # def_unit_qt4_src_handler_ui
476
477
478
479## wrapper for the MOC command dependencies.
480ifndef NO_COMPILE_CMDS_DEPS
481 _UNIT_QT_MOC_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_QT_MOC_CMDS_PREV_),$$(commands $(out)),FORCE)
482else
483 _UNIT_QT_MOC_CMDS_DEP =
484endif
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#
493define 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)
506ifndef 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'
511endif
512
513$(target)_INTERMEDIATES += $(realout)
514$(target)_GEN_SOURCES_ += $(realout)
515$(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
516
517endef
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 ).
529define def_unit_qt4_target_pre_handle_moc_hdr
530local type := MOC
531
532# fetch the properties.
533local tool := $(kb-src-tool dummy_var)
534local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
535local out := $(outbase).tmp.cpp
536local realout := $(outbase).cpp
537local dep := $(realout).dep
538local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
539local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
540local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
541local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
542local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
543
544# default path + source dep.
545ifneq ($(defpath),)
546local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
547local incs := $(abspathex $(incs),$($(target)_PATH))
548else
549local deps += $(source)
550endif
551
552# call the tool
553ifndef TOOL_$(tool)_MOC_HPP_CMDS
554 $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_HPP_CMDS)
555endif
556local cmds := $(TOOL_$(tool)_MOC_HPP_CMDS)
557local more_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT)
558local maybe_output := $(TOOL_$(tool)_MOC_HPP_OUTPUT_MAYBE)
559local deps += $(TOOL_$(tool)_MOC_HPP_DEPEND)
560local orderdeps += $(TOOL_$(tool)_MOC_HPP_DEPORD)
561
562# generate the link rule and update some source and target variables.
563ifndef NO_COMPILE_CMDS_DEPS
564 $(eval includedep $(dep))
565endif
566$(eval $(def_unit_qt4_target_pre_handle_moc_hdr_dx))
567
568endef # 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#
578define 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)
591ifndef 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'
596endif
597
598$(target)_INTERMEDIATES += $(realout)
599$(target)_OUT_FILES += $(out) $(realout) $(more_output) $(maybe_output)
600
601endef
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 ).
610define def_unit_qt4_target_pre_handle_moc_src
611local type := MOC
612
613# fetch the properties.
614local tool := $(kb-src-tool dummy_var)
615local outbase := $(qtmocdir)/$(notdir $(basename $(source)))
616local out := $(outbase).tmp.moc
617local realout := $(outbase).moc
618local dep := $(realout).dep
619local defs := $(kb-src-prop DEFS,dummy_var,left-to-right)
620local incs := $(kb-src-prop INCS,dummy_var,right-to-left)
621local flags := $(kb-src-prop FLAGS,dummy_var,right-to-left)
622local deps := $(kb-src-prop DEPS,dummy_var,left-to-right)
623local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
624
625# default path + source dep.
626ifneq ($(defpath),)
627local deps := $(abspathex $(deps) $(source),$($(target)_PATH))
628local incs := $(abspathex $(incs),$($(target)_PATH))
629else
630local deps += $(source)
631endif
632
633# call the tool
634ifndef TOOL_$(tool)_MOC_CPP_CMDS
635 $(error kBuild: qt moc tool not found: TOOL_$(tool)_MOC_CPP_CMDS)
636endif
637local cmds := $(TOOL_$(tool)_MOC_CPP_CMDS)
638local more_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT)
639local maybe_output := $(TOOL_$(tool)_MOC_CPP_OUTPUT_MAYBE)
640local deps += $(TOOL_$(tool)_MOC_CPP_DEPEND)
641local orderdeps += $(TOOL_$(tool)_MOC_CPP_DEPORD)
642
643# generate the link rule and update some source and target variables.
644ifndef NO_COMPILE_CMDS_DEPS
645 $(eval includedep $(dep))
646endif
647$(eval $(def_unit_qt4_target_pre_handle_moc_src_dx))
648
649endef # def_unit_qt4_target_pre_handle_moc_src
650
651
652##
653# Adds sources containing Q_OBJECT to QT_MOCSRCS.
654define def_unit_qt4_target_pre_cpp_source
655ifneq ($(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
659endif
660endef # 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#
671define def_unit_qt4_target_pre
672
673# Make QTTOOL the default for the specific Qt tools instead of TOOL.
674ifneq ($($(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
687endif
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.
691ifndef $(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))
700endif
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.
710local qtmocdir := $(PATH_$(target))/qtmoc
711local qtuicdir := $(PATH_$(target))/qtuic
712local qtrccdir := $(PATH_$(target))/qtrcc
713local 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.
739local 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)
746ifneq ($(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))
758endif
759
760endef # def_unit_qt4_target_pre
761
Note: See TracBrowser for help on using the repository browser.