VirtualBox

Changeset 1675 in kBuild


Ignore:
Timestamp:
Jul 11, 2008 2:03:20 AM (17 years ago)
Author:
bird
Message:

Compile and install translation units. Added QTTOOL so the user doesn't have to set all XYZTOOL properties but can get away with just QTTOOL.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kBuild/units/qt4.kmk

    r1671 r1675  
    2828
    2929# Add our target properties.
    30 PROPS_SINGLE += MOCTOOL UICTOOL RCCTOOL
    31 PROPS_ACCUMULATE_R += MOCDEFS MOCFLAGS UICFLAGS RCCFLAGS
     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
    3232
    3333
     
    6363 TOOL_QT4_UIC       ?= $(PATH_TOOL_QT4_BIN)/uic$(HOST_SUFF_EXE)
    6464 TOOL_QT4_RCC       ?= $(PATH_TOOL_QT4_BIN)/rcc$(HOST_SUFF_EXE)
     65 TOOL_QT4_LRC       ?= $(PATH_TOOL_QT4_BIN)/lrelease$(HOST_SUFF_EXE)
    6566 TOOL_QT4_LUPDATE   ?= $(PATH_TOOL_QT4_BIN)/lupdate$(HOST_SUFF_EXE)
    66  TOOL_QT4_LRELEASE  ?= $(PATH_TOOL_QT4_BIN)/lrelease$(HOST_SUFF_EXE)
    6767else
    6868 # Pathless, relies on the environment.
     
    7070 TOOL_QT4_UIC       ?= uic$(HOST_SUFF_EXE)
    7171 TOOL_QT4_RCC       ?= rcc$(HOST_SUFF_EXE)
     72 TOOL_QT4_LRC       ?= lrelease$(HOST_SUFF_EXE)
    7273 TOOL_QT4_LUPDATE   ?= lupdate$(HOST_SUFF_EXE)
    73  TOOL_QT4_LRELEASE  ?= lrelease$(HOST_SUFF_EXE)
    7474endif
    7575
     
    190190endef
    191191
     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
    192213
    193214
     
    199220
    200221
    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
     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
    209306
    210307
     
    294391
    295392
     393
    296394## wrapper for the UIC command dependencies.
    297395ifndef NO_COMPILE_CMDS_DEPS
     
    302400
    303401##
    304 # def_unit_qt4_target_pre_handle_uic_ui helper that is expanded before evaluation.
     402# def_unit_qt4_src_handler_ui helper that is expanded before evaluation.
    305403#
    306404# This is necessary to resolve reference to local variables before doing
     
    378476
    379477
     478
    380479## wrapper for the MOC command dependencies.
    381480ifndef NO_COMPILE_CMDS_DEPS
     
    419518
    420519##
    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.
     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.)
    425527#
    426528# @remarks Invoked via $(evalvalctx ).
     
    569671define def_unit_qt4_target_pre
    570672
     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
    571689# Autodetect source files with Q_OBJECT references if QT_MOCSRCS is undefined. (slow)
    572690# Tip: Use target_QT_MOCSRCS = $(NO_SUCH_VARIABLE) to avoid this.
     
    587705         .UI:def_unit_qt4_src_handler_ui \
    588706        .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
     707        .qrc:def_unit_qt4_src_handler_qrc
    592708
    593709# Calc the MOC and UI output directories and add them to BLDDIRS and INCS.
     
    595711local qtuicdir := $(PATH_$(target))/qtuic
    596712local qtrccdir := $(PATH_$(target))/qtrcc
    597 $(eval $(target)_BLDDIRS += $(qtmocdir) $(qtuicdir) $(qtrccdir))
    598 $(eval $(target)_INCS    += $(qtmocdir) $(qtuicdir) $(qtrccdir))
     713local qtnlsdir := $(PATH_$(target))/qtnls
     714$(eval $(target)_BLDDIRS += $(qtmocdir) $(qtuicdir) $(qtrccdir) $(qtnlsdir))
     715$(eval $(target)_INCS    += $(qtmocdir) $(qtuicdir))
    599716
    600717# Deal with QT_MOCSRCS.
     
    618735        , $(evalvalctx def_unit_qt4_target_pre_handle_moc_hdr))
    619736
     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
    620760endef # def_unit_qt4_target_pre
    621761
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette