cmake: Generate gettext pot automatically.
Remove po/update_pot.sh and generate the gettext .pot source automatically in cmake on every build instead. If the .pot is actually updated, print a loud message at the end of the build to commit the result and push to transifex. Fix the gettext tools and package loading block to only run when ENABLE_NLS is enabled and find the xgettext and msginit binaries in the Windows case as well. xgettext is used to generate the .pot. Refactor the SRC_WX/HDR_WX/RES_WX/XRC_SOURCES handling to use only relative paths and move all generated files into RES_WX. This was necessary to generate the .pot from cmake. Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
parent
a320377040
commit
d93f6350d0
|
@ -1,7 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
# Generate translation template file for the wxWidgets port
|
|
||||||
wxrc -g ../src/wx/xrc/*.xrc -o wx-xrc-strings.h
|
|
||||||
|
|
||||||
xgettext -k_ -kN_ -o wxvbam/wxvbam.pot ../src/wx/*.cpp ../src/wx/*.h ../src/wx/widgets/*.cpp wx-xrc-strings.h
|
|
||||||
|
|
||||||
rm -r wx-xrc-strings.h
|
|
|
@ -533,39 +533,41 @@ int main(int argc, char** argv) {
|
||||||
endif()
|
endif()
|
||||||
endif() # wxWidgets checks
|
endif() # wxWidgets checks
|
||||||
|
|
||||||
if(CMAKE_TOOLCHAIN_FILE MATCHES vcpkg)
|
if(ENABLE_NLS)
|
||||||
find_package(unofficial-gettext REQUIRED)
|
if(CMAKE_TOOLCHAIN_FILE MATCHES vcpkg)
|
||||||
|
find_package(unofficial-gettext REQUIRED)
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# install gettext tools from nuget
|
# install gettext tools from nuget
|
||||||
|
|
||||||
# first fetch the nuget binary
|
# first fetch the nuget binary
|
||||||
if(NOT EXISTS ${CMAKE_BINARY_DIR}/nuget.exe)
|
if(NOT EXISTS ${CMAKE_BINARY_DIR}/nuget.exe)
|
||||||
file(DOWNLOAD "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" ${CMAKE_BINARY_DIR}/nuget.exe)
|
file(DOWNLOAD "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" ${CMAKE_BINARY_DIR}/nuget.exe)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# install the Gettext.Tools package
|
# install the Gettext.Tools package
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND nuget.exe install Gettext.Tools -OutputDirectory ${CMAKE_BINARY_DIR}/nuget
|
COMMAND nuget.exe install Gettext.Tools -OutputDirectory ${CMAKE_BINARY_DIR}/nuget
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
# find the path to the binaries in the package and add them to find path
|
# find the path to the binaries in the package and add them to find path
|
||||||
file(GLOB pkg ${CMAKE_BINARY_DIR}/nuget/Gettext.Tools*)
|
file(GLOB pkg ${CMAKE_BINARY_DIR}/nuget/Gettext.Tools*)
|
||||||
|
|
||||||
list(APPEND CMAKE_PROGRAM_PATH ${pkg}/tools/bin)
|
list(APPEND CMAKE_PROGRAM_PATH ${pkg}/tools/bin)
|
||||||
|
|
||||||
find_package(Gettext REQUIRED)
|
find_package(Gettext REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
find_package(Gettext REQUIRED)
|
find_package(Gettext REQUIRED)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_program(XGETTEXT xgettext)
|
find_program(XGETTEXT xgettext)
|
||||||
find_program(MSGINIT msginit)
|
find_program(MSGINIT msginit)
|
||||||
|
|
||||||
if(ENABLE_NLS AND (NOT XGETTEXT OR NOT MSGINIT))
|
if(NOT XGETTEXT OR NOT MSGINIT)
|
||||||
message(SEND_ERROR "Cannot find gettext ${XGETTEXT} ${MSGINIT}")
|
message(SEND_ERROR "Cannot find gettext xgettext:'${XGETTEXT}' msginit:'${MSGINIT}'")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# contrib widgets
|
# contrib widgets
|
||||||
|
@ -581,47 +583,48 @@ if(NOT ZIP_PROGRAM)
|
||||||
message(FATAL_ERROR "The zip compressor program is required for building.")
|
message(FATAL_ERROR "The zip compressor program is required for building.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(XRC_SOURCES
|
set(
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/AccelConfig.xrc
|
XRC_SOURCES
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/CheatAdd.xrc
|
xrc/AccelConfig.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/CheatCreate.xrc
|
xrc/CheatAdd.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/CheatEdit.xrc
|
xrc/CheatCreate.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/CheatList.xrc
|
xrc/CheatEdit.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/CodeSelect.xrc
|
xrc/CheatList.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/DirectoriesConfig.xrc
|
xrc/CodeSelect.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/Disassemble.xrc
|
xrc/DirectoriesConfig.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/DisplayConfig.xrc
|
xrc/Disassemble.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/ExportSPS.xrc
|
xrc/DisplayConfig.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/GBAROMInfo.xrc
|
xrc/ExportSPS.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/GBColorPrefPanel.xrc
|
xrc/GBAROMInfo.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/GBDisassemble.xrc
|
xrc/GBColorPrefPanel.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/GBMapViewer.xrc
|
xrc/GBDisassemble.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/GBOAMViewer.xrc
|
xrc/GBMapViewer.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/GBPaletteViewer.xrc
|
xrc/GBOAMViewer.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/GBPrinter.xrc
|
xrc/GBPaletteViewer.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/GBROMInfo.xrc
|
xrc/GBPrinter.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/GBTileViewer.xrc
|
xrc/GBROMInfo.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/GameBoyAdvanceConfig.xrc
|
xrc/GBTileViewer.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/GameBoyConfig.xrc
|
xrc/GameBoyAdvanceConfig.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/GeneralConfig.xrc
|
xrc/GameBoyConfig.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/IOViewer.xrc
|
xrc/GeneralConfig.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/JoyPanel.xrc
|
xrc/IOViewer.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/JoypadConfig.xrc
|
xrc/JoyPanel.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/LinkConfig.xrc
|
xrc/JoypadConfig.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/Logging.xrc
|
xrc/LinkConfig.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/MainFrame.xrc
|
xrc/Logging.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/MainIcon.xrc
|
xrc/MainFrame.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/MainMenu.xrc
|
xrc/MainIcon.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/MapViewer.xrc
|
xrc/MainMenu.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/MemSelRegion.xrc
|
xrc/MapViewer.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/MemViewer.xrc
|
xrc/MemSelRegion.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/NetLink.xrc
|
xrc/MemViewer.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/OAMViewer.xrc
|
xrc/NetLink.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/PaletteViewer.xrc
|
xrc/OAMViewer.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/SoundConfig.xrc
|
xrc/PaletteViewer.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/TileViewer.xrc
|
xrc/SoundConfig.xrc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xrc/SpeedupConfig.xrc
|
xrc/TileViewer.xrc
|
||||||
)
|
xrc/SpeedupConfig.xrc
|
||||||
|
)
|
||||||
|
|
||||||
# wxrc does not support xrs files in -c output (> 10x compression)
|
# wxrc does not support xrs files in -c output (> 10x compression)
|
||||||
# we do it using the bin2c.c utility
|
# we do it using the bin2c.c utility
|
||||||
|
@ -688,22 +691,10 @@ if(NOT WXRC)
|
||||||
set(WXRC wxrc)
|
set(WXRC wxrc)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL CYGWIN)
|
|
||||||
# pass xrc sources through cygpath in case we only have native wxrc
|
|
||||||
set(new_xrc_sources)
|
|
||||||
|
|
||||||
foreach(xrc ${XRC_SOURCES})
|
|
||||||
execute_process(COMMAND cygpath -m ${xrc} OUTPUT_VARIABLE win_path OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
||||||
list(APPEND new_xrc_sources ${win_path})
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
set(XRC_SOURCES ${new_xrc_sources})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT wxvbam.xrs
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/wxvbam.xrs
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
COMMAND ${WXRC} ${XRC_SOURCES} -o ${CMAKE_CURRENT_BINARY_DIR}/wxvbam.xrs
|
||||||
COMMAND ${WXRC} ${XRC_SOURCES} "--output=wxvbam.xrs"
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
DEPENDS ${XRC_SOURCES}
|
DEPENDS ${XRC_SOURCES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -756,20 +747,11 @@ set(
|
||||||
../sdl/text.cpp
|
../sdl/text.cpp
|
||||||
# from external source with minor modifications
|
# from external source with minor modifications
|
||||||
widgets/checkedlistctrl.cpp
|
widgets/checkedlistctrl.cpp
|
||||||
# generated
|
|
||||||
cmdtab.cpp
|
|
||||||
# generated includes must be explicitly listed
|
|
||||||
builtin-xrc.h
|
|
||||||
builtin-over.h
|
|
||||||
cmdhandlers.h
|
|
||||||
cmd-evtable.h
|
|
||||||
# icon File
|
|
||||||
xrc/visualboyadvance-m.xpm
|
|
||||||
../common/version.cpp
|
../common/version.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(SRC_WX ${SRC_WX} macsupport.mm)
|
set(SRC_WX ${SRC_WX} ${CMAKE_CURRENT_SOURCE_DIR}/macsupport.mm)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(
|
set(
|
||||||
|
@ -806,6 +788,15 @@ set(
|
||||||
RES_WX
|
RES_WX
|
||||||
${XRC_SOURCES}
|
${XRC_SOURCES}
|
||||||
../vba-over.ini
|
../vba-over.ini
|
||||||
|
# icon File
|
||||||
|
xrc/visualboyadvance-m.xpm
|
||||||
|
# generated includes must be explicitly listed
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/builtin-xrc.h
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/builtin-over.h
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/cmdhandlers.h
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/cmd-evtable.h
|
||||||
|
# generated
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/cmdtab.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(
|
set(
|
||||||
|
@ -814,29 +805,24 @@ set(
|
||||||
)
|
)
|
||||||
|
|
||||||
if(ENABLE_OPENAL)
|
if(ENABLE_OPENAL)
|
||||||
set(SRC_WX ${SRC_WX} openal.cpp)
|
list(APPEND SRC_WX openal.cpp)
|
||||||
set(HDR_WX ${HDR_WX} openal.h)
|
list(APPEND HDR_WX openal.h)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_XAUDIO2)
|
if(ENABLE_XAUDIO2)
|
||||||
set(SRC_WX ${SRC_WX} xaudio2.cpp)
|
list(APPEND SRC_WX xaudio2.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_FAUDIO)
|
if(ENABLE_FAUDIO)
|
||||||
set(SRC_WX ${SRC_WX} faudio.cpp)
|
list(APPEND SRC_WX faudio.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(SRC_WX ${SRC_WX} wxvbam.rc dsound.cpp)
|
list(APPEND SRC_WX dsound.cpp)
|
||||||
list(APPEND VBAM_LIBS dxguid dsound ws2_32)
|
|
||||||
if(MSVC)
|
list(APPEND RES_WX wxvbam.rc)
|
||||||
# workaround for some symbols needed by static SDL2.lib
|
|
||||||
list(APPEND VBAM_LIBS imm32 version)
|
list(APPEND VBAM_LIBS dxguid dsound wsock32 ws2_32 imm32 version)
|
||||||
endif()
|
|
||||||
# not strictly directx, but win32-related
|
|
||||||
if(ENABLE_DEBUGGER)
|
|
||||||
list(APPEND VBAM_LIBS wsock32)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
link_directories(${CMAKE_BINARY_DIR})
|
link_directories(${CMAKE_BINARY_DIR})
|
||||||
|
@ -953,7 +939,7 @@ if(NOT WIN32 AND NOT APPLE)
|
||||||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/icons/sizes/ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor)
|
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/icons/sizes/ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# make the translations.zip for windows builds
|
# Make the translations.zip for windows builds.
|
||||||
if(ENABLE_NLS AND WIN32)
|
if(ENABLE_NLS AND WIN32)
|
||||||
file(GLOB catalogs ${CMAKE_BINARY_DIR}/po/wxvbam/*.gmo)
|
file(GLOB catalogs ${CMAKE_BINARY_DIR}/po/wxvbam/*.gmo)
|
||||||
|
|
||||||
|
@ -969,6 +955,38 @@ if(ENABLE_NLS AND WIN32)
|
||||||
add_dependencies(visualboyadvance-m translations-zip)
|
add_dependencies(visualboyadvance-m translations-zip)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Update the gettext pot source.
|
||||||
|
# Do this automatically instead of manually to make sure we don't forget to update.
|
||||||
|
if(ENABLE_NLS)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${CMAKE_BINARY_DIR}/wx-xrc-strings.h
|
||||||
|
COMMAND ${WXRC} -g ${XRC_SOURCES} -o ${CMAKE_BINARY_DIR}/wx-xrc-strings.h
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
DEPENDS ${XRC_SOURCES}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_target(xrc-strings DEPENDS ${CMAKE_BINARY_DIR}/wx-xrc-strings.h)
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${CMAKE_BINARY_DIR}/wxvbam.pot
|
||||||
|
COMMAND ${XGETTEXT} -k_ -kN_ -o ${CMAKE_BINARY_DIR}/wxvbam.pot ${SRC_WX} ${HDR_WX} ${CMAKE_BINARY_DIR}/wx-xrc-strings.h
|
||||||
|
DEPENDS ${SRC_WX} ${HDR_WX} ${CMAKE_BINARY_DIR}/wx-xrc-strings.h
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_target(gettext-pot DEPENDS ${CMAKE_BINARY_DIR}/wxvbam.pot)
|
||||||
|
|
||||||
|
add_dependencies(gettext-pot xrc-strings)
|
||||||
|
|
||||||
|
add_dependencies(visualboyadvance-m gettext-pot)
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
TARGET visualboyadvance-m
|
||||||
|
POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -D SRC_DIR=${CMAKE_SOURCE_DIR}/po/wxvbam -D BIN_DIR=${CMAKE_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/check-pot-updated.cmake
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
option(UPSTREAM_RELEASE "do some release automation tasks" OFF)
|
option(UPSTREAM_RELEASE "do some release automation tasks" OFF)
|
||||||
|
|
||||||
if(UPSTREAM_RELEASE AND WIN32)
|
if(UPSTREAM_RELEASE AND WIN32)
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
if(NOT EXISTS ${BIN_DIR}/wxvbam.pot)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
file(READ ${SRC_DIR}/wxvbam.pot src_ver)
|
||||||
|
|
||||||
|
file(READ ${BIN_DIR}/wxvbam.pot new_ver)
|
||||||
|
|
||||||
|
if(NOT src_ver STREQUAL new_ver)
|
||||||
|
file(COPY ${BIN_DIR}/wxvbam.pot DESTINATION ${SRC_DIR})
|
||||||
|
|
||||||
|
message([=[
|
||||||
|
************ ATTENTION!!! ************
|
||||||
|
|
||||||
|
The gettext source in ]=] ${SRC_DIR}/wxvbam.pot [=[ has been updated.
|
||||||
|
|
||||||
|
Please commit the result and push to transifex.
|
||||||
|
|
||||||
|
**************************************
|
||||||
|
]=])
|
||||||
|
endif()
|
Loading…
Reference in New Issue