From 5c03bda31af87bf08a404509cd0714df65471416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Tue, 15 Mar 2016 03:06:21 +0000 Subject: Qt: Generate .qm files during build Change-Id: Ia2ee723227e1b331eeec0f0463654f35a4c9f37b Reviewed-on: https://code.wireshark.org/review/14508 Petri-Dish: Martin Kaiser Tested-by: Petri Dish Buildbot Reviewed-by: Martin Kaiser --- .gitignore | 2 +- configure.ac | 2 ++ ui/qt/CMakeLists.txt | 22 ++++++++++++++++++---- ui/qt/Makefile.am | 20 ++++++++++++++++++-- ui/qt/Makefile.common | 1 - ui/qt/i18n.qrc | 30 ------------------------------ ui/qt/i18n.qrc.in | 4 ++++ ui/qt/wireshark_de.qm | Bin 346602 -> 0 bytes ui/qt/wireshark_en.qm | Bin 2152 -> 0 bytes ui/qt/wireshark_fr.qm | Bin 319647 -> 0 bytes ui/qt/wireshark_it.qm | Bin 352833 -> 0 bytes ui/qt/wireshark_ja_JP.qm | Bin 266711 -> 0 bytes ui/qt/wireshark_pl.qm | Bin 338655 -> 0 bytes ui/qt/wireshark_zh_CN.qm | Bin 253502 -> 0 bytes 14 files changed, 43 insertions(+), 38 deletions(-) delete mode 100644 ui/qt/i18n.qrc create mode 100644 ui/qt/i18n.qrc.in delete mode 100644 ui/qt/wireshark_de.qm delete mode 100644 ui/qt/wireshark_en.qm delete mode 100644 ui/qt/wireshark_fr.qm delete mode 100644 ui/qt/wireshark_it.qm delete mode 100644 ui/qt/wireshark_ja_JP.qm delete mode 100644 ui/qt/wireshark_pl.qm delete mode 100644 ui/qt/wireshark_zh_CN.qm diff --git a/.gitignore b/.gitignore index 5040f70dc4..deebf83e06 100644 --- a/.gitignore +++ b/.gitignore @@ -186,7 +186,7 @@ qtshark /ui/qt/__/ /ui/qt/*.qrc.depends /ui/qt/*.pro.user -#/ui/qt/*.qm +/ui/qt/*.qm /ui/qt/moc_*.cpp /ui/qt/moc_*.cpp_parameters /ui/qt/*.moc.cpp diff --git a/configure.ac b/configure.ac index 7bbc089284..c9b4d00152 100644 --- a/configure.ac +++ b/configure.ac @@ -1302,6 +1302,8 @@ if test "x$enable_wireshark" = "xyes"; then AC_SUBST(MOC) AC_WIRESHARK_QT_TOOL_CHECK(RCC, rcc, "$qt_version") AC_SUBST(RCC) + AC_WIRESHARK_QT_TOOL_CHECK(LRELEASE, lrelease, "$qt_version") + AC_SUBST(LRELEASE) # # On Darwin, find where the Qt frameworks are diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt index 7cdc7a3dc6..77bd10cdb1 100644 --- a/ui/qt/CMakeLists.txt +++ b/ui/qt/CMakeLists.txt @@ -450,7 +450,7 @@ set(WIRESHARK_QT_QRC ../../image/layout.qrc ../../image/toolbar.qrc ../../image/wsicon.qrc - i18n.qrc + ${CMAKE_CURRENT_BINARY_DIR}/i18n.qrc ) set(WIRESHARK_QT_TS @@ -469,7 +469,7 @@ include_directories( ) if (QT_VERSION EQUAL 5) - QT5_ADD_TRANSLATION(WIRESHARK_QT_TS_QM ${WIRESHARK_QT_TS}) + QT5_ADD_TRANSLATION(WIRESHARK_QT_QM ${WIRESHARK_QT_TS}) QT5_ADD_RESOURCES(WIRESHARK_QT_QRC_SRC ${WIRESHARK_QT_QRC}) QT5_WRAP_UI(WIRESHARK_QT_UI_SRC ${WIRESHARK_QT_UI}) # For now, do the moc stuff manually @@ -480,7 +480,7 @@ if (QT_VERSION EQUAL 5) # or # set_target_properties(${some-source-files} PROPERTIES AUTOMOC TRUE) else() - QT4_ADD_TRANSLATION(WIRESHARK_QT_TS_QM ${WIRESHARK_QT_TS}) + QT4_ADD_TRANSLATION(WIRESHARK_QT_QM ${WIRESHARK_QT_TS}) QT4_ADD_RESOURCES(WIRESHARK_QT_QRC_SRC ${WIRESHARK_QT_QRC}) QT4_WRAP_UI(WIRESHARK_QT_UI_SRC ${WIRESHARK_QT_UI}) # For now, do the moc stuff manually @@ -492,6 +492,20 @@ else() # set_target_properties(${some-source-files} PROPERTIES AUTOMOC TRUE) endif() +foreach(_file ${WIRESHARK_QT_QM}) + get_filename_component(_qresource ${_file} NAME) + set(i18n_qresource "${i18n_qresource}\n ${_qresource}") + set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/i18n.qrc PROPERTIES OBJECT_DEPENDS ${_file}) +endforeach() +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/i18n.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/i18n.qrc) + +add_custom_target( + translations ALL + DEPENDS + ${WIRESHARK_QT_QM} +) +set_target_properties(translations PROPERTIES FOLDER "UI") + if (WERROR_COMMON_FLAGS) set_source_files_properties( ${WIRESHARK_QT_FILES} @@ -513,9 +527,9 @@ add_library(qtui STATIC ${WIRESHARK_QT_UI_SRC} ${WIRESHARK_QT_MOC_SRC} ${WIRESHARK_QT_QRC_SRC} - ${WIRESHARK_QT_TS_QM} wireshark-tap-register.c ) +add_dependencies(qtui translations) set_target_properties(qtui PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}") set_target_properties(qtui PROPERTIES FOLDER "UI") diff --git a/ui/qt/Makefile.am b/ui/qt/Makefile.am index 435d494e16..c495f91c23 100644 --- a/ui/qt/Makefile.am +++ b/ui/qt/Makefile.am @@ -40,7 +40,9 @@ CLEANFILES = \ *~ DISTCLEANFILES = \ - $(NODIST_GENERATED_FILES) + $(NODIST_GENERATED_FILES) \ + $(QM_FILES) \ + i18n.qrc MAINTAINERCLEANFILES = \ $(GENERATED_FILES) \ @@ -112,6 +114,10 @@ AM_V_UIC = $(am__v_UIC_@AM_V@) am__v_UIC_ = $(am__v_UIC_@AM_DEFAULT_V@) am__v_UIC_0 = @echo " UIC " $@; +AM_V_LRELEASE = $(am__v_LRELEASE_@AM_V@) +am__v_LRELEASE_ = $(am__v_LRELEASE_@AM_DEFAULT_V@) +am__v_LRELEASE_0 = @echo " LRELEASE " $@; + # # For building .moc.cpp files from .h files by running moc, # building .rcc.cpp files from .qrc files by running rcc, @@ -148,6 +154,17 @@ qrc_wsicon.cpp: ../../image/wsicon.qrc ui_%.h: %.ui $(AM_V_UIC)$(UIC) $< -o $@ +wireshark_%.qm: wireshark_%.ts + $(AM_V_LRELEASE)$(LRELEASE) -silent $< -qm $@ + +i18n_qresource := $(foreach qm, $(QM_FILES),$(qm)) + +i18n.qrc: i18n.qrc.in $(QM_FILES) + $(AM_V_SED)$(SED) \ + -e 's,@i18n_qresource\@,$(i18n_qresource),' \ + -e 's,> *,>\n ,g' \ + < $< > $@ + # # Explicit dependencies to force the ui_ headers to be built. # See "Recording Dependencies manually" in the "Built Sources" @@ -331,7 +348,6 @@ EXTRA_DIST = \ $(UI_FILES) \ $(QRC_FILES) \ $(TS_FILES) \ - $(QM_FILES) \ CMakeLists.txt \ doxygen.cfg.in \ Makefile.common \ diff --git a/ui/qt/Makefile.common b/ui/qt/Makefile.common index a2d22fb76d..286c74d3cf 100644 --- a/ui/qt/Makefile.common +++ b/ui/qt/Makefile.common @@ -414,7 +414,6 @@ TS_FILES = \ # # .qm files. # -# Should they be auto-generated ? QM_FILES = $(TS_FILES:.ts=.qm) WIRESHARK_QT_SRC = \ diff --git a/ui/qt/i18n.qrc b/ui/qt/i18n.qrc deleted file mode 100644 index 32c7b74377..0000000000 --- a/ui/qt/i18n.qrc +++ /dev/null @@ -1,30 +0,0 @@ - - - - wireshark_de.qm - wireshark_en.qm - wireshark_fr.qm - wireshark_it.qm - wireshark_ja_JP.qm - wireshark_pl.qm - wireshark_zh_CN.qm - - diff --git a/ui/qt/i18n.qrc.in b/ui/qt/i18n.qrc.in new file mode 100644 index 0000000000..7260de040e --- /dev/null +++ b/ui/qt/i18n.qrc.in @@ -0,0 +1,4 @@ + + @i18n_qresource@ + + diff --git a/ui/qt/wireshark_de.qm b/ui/qt/wireshark_de.qm deleted file mode 100644 index 5fc15b2377..0000000000 Binary files a/ui/qt/wireshark_de.qm and /dev/null differ diff --git a/ui/qt/wireshark_en.qm b/ui/qt/wireshark_en.qm deleted file mode 100644 index acbb40498b..0000000000 Binary files a/ui/qt/wireshark_en.qm and /dev/null differ diff --git a/ui/qt/wireshark_fr.qm b/ui/qt/wireshark_fr.qm deleted file mode 100644 index dde77c8ca7..0000000000 Binary files a/ui/qt/wireshark_fr.qm and /dev/null differ diff --git a/ui/qt/wireshark_it.qm b/ui/qt/wireshark_it.qm deleted file mode 100644 index 6586f99f74..0000000000 Binary files a/ui/qt/wireshark_it.qm and /dev/null differ diff --git a/ui/qt/wireshark_ja_JP.qm b/ui/qt/wireshark_ja_JP.qm deleted file mode 100644 index 8a768d928f..0000000000 Binary files a/ui/qt/wireshark_ja_JP.qm and /dev/null differ diff --git a/ui/qt/wireshark_pl.qm b/ui/qt/wireshark_pl.qm deleted file mode 100644 index f96a16bd11..0000000000 Binary files a/ui/qt/wireshark_pl.qm and /dev/null differ diff --git a/ui/qt/wireshark_zh_CN.qm b/ui/qt/wireshark_zh_CN.qm deleted file mode 100644 index 806767f2ec..0000000000 Binary files a/ui/qt/wireshark_zh_CN.qm and /dev/null differ -- cgit v1.2.1