Skip to content

Commit

Permalink
build: Adjust how Translations are built
Browse files Browse the repository at this point in the history
  • Loading branch information
sithlord48 committed Apr 21, 2024
1 parent 24406ad commit 13b1804
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ jobs:
cmake --build ${{ env.makoureactor_build_path }} --target install -j3
mkdir -p ${{env.makoureactor_appbundle_path}}/usr/share/makoureactor/translations
cp ${{env.makoureactor_installation_path}}/share/makoureactor/translations/*.qm ${{env.makoureactor_appbundle_path}}/usr/share/makoureactor/translations/
cp ${{env.ff7tk_installation_path}}/share/ff7tk/translations/*.qm ${{env.makoureactor_appbundle_path}}/usr/share/ff7tk/translations
mkdir -p ${{env.makoureactor_appbundle_path}}/usr/plugins/iconengines
cp ${{ env.qt_installation_path }}/Qt/${{ matrix.qt }}/gcc_64/plugins/iconengines/libqsvgicon.so ${{env.makoureactor_appbundle_path}}/usr/plugins/iconengines/libqsvgicon.so
export VERSION=continuous
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ env.ff7tk_installation_path }}/lib
export PATH=$PATH:${{ env.qt_installation_path }}/Qt/${{ matrix.qt }}/gcc_64/libexec
Expand Down Expand Up @@ -204,7 +204,7 @@ jobs:
rm libff7tk*.deb
- name: Build
run: |
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DQT_DEFAULT_MAJOR_VERSION=6 -DCPACK_DEBIAN_PACKAGE_RELEASE=${{github.run_attempt}}~${{matrix.config.name}} -DBUNDLE_FF7TK_QM=OFF
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DQT_DEFAULT_MAJOR_VERSION=6 -DCPACK_DEBIAN_PACKAGE_RELEASE=${{github.run_attempt}}~${{matrix.config.name}}
cmake --build build
cpack -G DEB -C Release --config build/CPackConfig.cmake
- name: Upload
Expand Down
20 changes: 2 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)

option(GUI "Build the gui executable" ON)
option(CLI "Build the cli executable" OFF)
option(BUNDLE_FF7TK_QM "Include FF7tk QM Files in bundle" ON)

add_compile_definitions(
QT_DISABLE_DEPRECATED_BEFORE=0x050F00
Expand Down Expand Up @@ -505,20 +504,6 @@ elseif (WIN32)
set(EXTRA_RESOURCES_CLI "${EXTRA_RESOURCES_GUI}")
endif()

function(add_translations target)
set(oneValueArgs QM_FILES_OUTPUT_VARIABLE)
set(multiValueArgs TS_FILES)
cmake_parse_arguments(arg "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(qm_files "")
qt_add_translations(${target}
TS_FILES ${TS_FILES}
LUPDATE_OPTIONS -locations none
QM_FILES_OUTPUT_VARIABLE qm_files)
set("${arg_QM_FILES_OUTPUT_VARIABLE}" "${qm_files}" PARENT_SCOPE)
# Force lupdate
add_dependencies(${target}_lrelease ${target}_lupdate)
endfunction()

# GUI
if(GUI)
qt_add_executable(${GUI_TARGET} MANUAL_FINALIZATION MACOSX_BUNDLE WIN32 ${PROJECT_SOURCES} ${RESOURCES} ${EXTRA_RESOURCES_GUI})
Expand Down Expand Up @@ -558,9 +543,8 @@ if(GUI)
set_target_properties(${GUI_TARGET} PROPERTIES OUTPUT_NAME "${PROJECT_NAME}")
endif()

add_translations(${GUI_TARGET}
TS_FILES ${TS_FILES}
QM_FILES_OUTPUT_VARIABLE QM_FILES)
add_subdirectory(translations)

endif()

# CLI
Expand Down
15 changes: 0 additions & 15 deletions deploy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
# Deploy translations
if(APPLE)
set(TRANSLATIONS_PATH ${PROJECT_NAME}.app/Contents/MacOS/translations)
elseif(WIN32)
set(TRANSLATIONS_PATH translations)
else()
set(TRANSLATIONS_PATH share/makoureactor/translations)
endif()

install(FILES ${QM_FILES} DESTINATION "${TRANSLATIONS_PATH}")

# Deploy ff7tk
if(VCPKG_TOOLCHAIN)
cmake_path(SET _ff7tk_ROOT "${ff7tk_DIR}/../..")
Expand Down Expand Up @@ -56,10 +45,6 @@ if(WIN32)
install(FILES ${FF7TK_DEPENDS} DESTINATION ".")
endif()

list(TRANSFORM LANGS REPLACE ".+" "${_ff7tk_ROOT}/share/ff7tk/translations/ff7tk_\\0.qm" OUTPUT_VARIABLE FF7TK_QM_FILES)
if(BUNDLE_FF7TK_QM)
install(FILES ${FF7TK_QM_FILES} DESTINATION "${TRANSLATIONS_PATH}")
endif()
# Deploy Qt using macdeployqt and windeployqt scripts
if((APPLE AND GUI) OR WIN32)
install(CODE "set(_target_file_dir \"${QT_DEPLOY_TMP_DIR}\")")
Expand Down
40 changes: 40 additions & 0 deletions translations/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1)

find_package(Qt6 ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE COMPONENTS
Core
LinguistTools
)

set ( makoureactor_TRS
Makou_Reactor_fr.ts
Makou_Reactor_ja.ts
)

qt_create_translation(TRS ${CMAKE_SOURCE_DIR} ${makoureactor_TRS} OPTIONS -no-ui-lines -locations none)
add_custom_target(app_translations ALL DEPENDS ${TRS})
if(APPLE)
set(TRANSLATIONS_PATH ${PROJECT_NAME}.app/Contents/MacOS/translations)
elseif(WIN32)
set(TRANSLATIONS_PATH translations)
else()
set(TRANSLATIONS_PATH share/makoureactor/translations)
endif()

install(FILES ${makoureactor_TRS} DESTINATION "${TRANSLATIONS_PATH}")

if(WIN32 OR APPLE)
file(REAL_PATH "${ff7tk_DIR}/../../../" ff7tk_ROOT )
find_path(_ff7tk_I18N_PATH NAMES translations PATHS "${ff7tk_ROOT}" PATH_SUFFIXES "/share/ff7tk" NO_DEFAULT_PATH REQUIRED)
file(REAL_PATH "${_ff7tk_I18N_PATH}/translations" ff7tk_I18N_PATH)
install(FILES ${ff7tk_I18N_PATH}/ff7tk_en.qm DESTINATION "${TRANSLATIONS_PATH}")
install(FILES ${ff7tk_I18N_PATH}/ff7tk_fr.qm DESTINATION "${TRANSLATIONS_PATH}")
install(FILES ${ff7tk_I18N_PATH}/ff7tk_ja.qm DESTINATION "${TRANSLATIONS_PATH}")
if(APPLE)
file(REAL_PATH "${_qt_bin_dir}/../" QT_ROOT_DIR)
find_file(_QT_QM_FILE NAMES qtbase_fr.qm PATHS ${QT_ROOT_DIR} PATH_SUFFIXES "translations" "share/qt/translations" REQUIRED)
get_filename_component(MAC_QT_LANG_PATH "${_QT_QM_FILE}" DIRECTORY)
install(FILES ${MAC_QT_LANG_PATH}/qtbase_en.qm DESTINATION ${TRANSLATIONS_PATH} RENAME qt_en.qm)
install(FILES ${MAC_QT_LANG_PATH}/qtbase_fr.qm DESTINATION ${TRANSLATIONS_PATH} RENAME qt_fr.qm)
install(FILES ${MAC_QT_LANG_PATH}/qtbase_ja.qm DESTINATION ${TRANSLATIONS_PATH} RENAME qt_ja.qm)
endif()
endif()

0 comments on commit 13b1804

Please sign in to comment.