Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Multiple Languages #689

Merged
merged 36 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
69713ca
Format settings.c to have one setting per-line
Nopey Oct 27, 2024
a509d9e
Insert dummy entries to pad pre-OMFv2.1 lang dat to 1013
Nopey Oct 26, 2024
8b47d32
Support other Languages
Nopey Oct 26, 2024
447f073
Add support for encoding language files
Vagabond Oct 27, 2024
d3a9649
Fix languagetool
Nopey Oct 30, 2024
417888b
Simplify languagetool error handling
Nopey Oct 30, 2024
fcfc0e7
Don't print entire language table when saving
Nopey Oct 30, 2024
5386bdc
languagetool: exit with EXIT_FAILURE on error
Nopey Oct 30, 2024
0d9fbec
Add --check-count flag to languagetool
Nopey Oct 30, 2024
abe9271
languagetool: Print errors to stdout (with newlines)
Nopey Oct 30, 2024
70d1339
languagetool: Reject nonsequential IDs
Nopey Oct 30, 2024
e5f0e95
Add OpenOMF lang file, build lang files
Nopey Oct 30, 2024
23d6405
Add LANG_STR enum
Nopey Oct 30, 2024
9bbb4dc
Build & install OpenOMF language files in CI
Nopey Nov 2, 2024
a0bd464
Fix languagetool and pcxtool on MSVC
Nopey Oct 30, 2024
def27b6
Avoid fancy characters in mingw-w64 workflow
Nopey Oct 30, 2024
b6fad0b
Set wine DLL searchpath in mingw CI
Nopey Oct 30, 2024
7660eca
Simplify winapi scan_directory_suffix/prefix
Nopey Oct 30, 2024
04f319c
Always build languages
Nopey Oct 30, 2024
d721864
Mark the GLOB_RECURSEs as CONFIGURE_DEPENDS
Nopey Oct 30, 2024
61903ad
Add Code Page 437 UTF conversions
Nopey Oct 30, 2024
b92f3e6
Fix unit tests on Windows (MSVC)
Nopey Oct 31, 2024
a46bf4b
languagetool: check input & output extensions
Nopey Oct 31, 2024
85b1dcd
Bump languagetool version to 0.2
Nopey Oct 31, 2024
e3612b8
languagetool: Clean up Data field string handling
Nopey Oct 31, 2024
7274b30
Perform UTF-8 conversions in languagetool
Nopey Oct 31, 2024
c959159
Convert language file sources (.TXT) to UTF-8
Nopey Oct 31, 2024
3ec3337
languagetool: Fix overlong Title: handling
Nopey Oct 31, 2024
5c9b09f
Fix overlong titles in DANISH.TXT
Nopey Oct 31, 2024
53f84be
Use U+2302 ('House') to represent OMF 0x7F
Nopey Oct 31, 2024
d3388a2
Fix Linux warnings
Nopey Nov 1, 2024
297f535
compat.h: Provide char32_t on MacOS X
Nopey Nov 1, 2024
96ca84e
Clean up text_render magic number 32s
Nopey Nov 1, 2024
e0be45c
Use str_format instead of unsafe snprintf in textselector
Nopey Nov 1, 2024
2882252
Document magic number 990
Nopey Nov 1, 2024
34d6818
Simplify languagetool parsing
Nopey Nov 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ jobs:
-DUSE_TIDY=${{ matrix.config.tidy }} \
-DUSE_TESTS=On \
-DUSE_SANITIZERS=On \
-DUSE_TOOLS=On ..
-DUSE_TOOLS=On \
..
make -j $(getconf _NPROCESSORS_ONLN)

- name: Run tests
Expand Down Expand Up @@ -308,7 +309,7 @@ jobs:
- name: Install apt Dependencies
uses: Eeems-Org/[email protected]
with:
packages: mingw-w64 unzip
packages: mingw-w64 unzip wine64 wine
- name: Install Dependencies
run: |
wget -q https://github.com/omf2097/openomf-win-build/archive/refs/heads/main.zip
Expand All @@ -317,13 +318,15 @@ jobs:
- name: Generate Windows Release
run: |
mkdir build-release && cd build-release
export WINEPATH="${GITHUB_WORKSPACE}/openomf-win-build-main/bin/"
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=release \
-DCMAKE_TOOLCHAIN_FILE="${GITHUB_WORKSPACE}/cmake-scripts/mingw-w64-toolchain.cmake" \
-DCMAKE_PREFIX_PATH="${GITHUB_WORKSPACE}/openomf-win-build-main/" \
-DCMAKE_INCLUDE_PATH="${GITHUB_WORKSPACE}/openomf-win-build-main/include/" \
-DCMAKE_LIBRARY_PATH="${GITHUB_WORKSPACE}/openomf-win-build-main/lib/" \
-DCMAKE_FIND_ROOT_PATH="${GITHUB_WORKSPACE}/openomf-win-build-main/" \
-DOMF_COMMAND_WRAPPER="wine" \
"${GITHUB_WORKSPACE}"
make -j $(getconf _NPROCESSORS_ONLN)
make -j $(getconf _NPROCESSORS_ONLN) install
Expand Down
39 changes: 31 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@ if(GIT_FOUND)
endif()

if(WIN32)
# prevent Windows.h from automatically defining as many macros
add_definitions(-DWIN32_LEAN_AND_MEAN)

if(NOT MINGW)
# set source charset & runtime charset to utf-8
add_compile_options("/utf-8")
endif()
endif()

# System packages (hard dependencies)
Expand All @@ -109,7 +115,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/platform.h.in ${CMAKE_CURRENT_BIN

# If tests are enabled, find CUnit
if(USE_TESTS)
find_package(CUnit)
find_package(CUnit REQUIRED)
endif()

# Only strip on GCC (clang does not appreciate)
Expand All @@ -119,7 +125,12 @@ if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
endif()

# Find OpenOMF core sources
file(GLOB_RECURSE OPENOMF_SRC RELATIVE ${CMAKE_SOURCE_DIR} "src/*/*.c" "src/*/*.h")
file(GLOB_RECURSE OPENOMF_SRC
LIST_DIRECTORIES OFF
CONFIGURE_DEPENDS
RELATIVE ${CMAKE_SOURCE_DIR}
"src/*/*.c" "src/*/*.h"
)

set(COREINCS
src
Expand Down Expand Up @@ -224,6 +235,9 @@ add_dependencies(openomf copy_shaders)

# Build tools if requested
set(TOOL_TARGET_NAMES)
# always build languagetool, for BuildLanguages.cmake
add_executable(languagetool tools/languagetool/main.c)
list(APPEND TOOL_TARGET_NAMES languagetool)
if (USE_TOOLS)
add_executable(bktool tools/bktool/main.c
tools/shared/animation_misc.c
Expand All @@ -232,7 +246,6 @@ if (USE_TOOLS)
tools/shared/animation_misc.c
tools/shared/conversions.c)
add_executable(soundtool tools/soundtool/main.c)
add_executable(languagetool tools/languagetool/main.c)
add_executable(afdiff tools/afdiff/main.c)
add_executable(rectool tools/rectool/main.c tools/shared/pilot.c)
add_executable(pcxtool tools/pcxtool/main.c)
Expand All @@ -249,7 +262,6 @@ if (USE_TOOLS)
bktool
aftool
soundtool
languagetool
afdiff
rectool
pcxtool
Expand Down Expand Up @@ -282,9 +294,9 @@ endif()
# Formatting via clang-format
if(USE_FORMAT)
include(ClangFormat)
file(
GLOB_RECURSE
SRC_FILES
file(GLOB_RECURSE SRC_FILES
LIST_DIRECTORIES OFF
CONFIGURE_DEPENDS
RELATIVE ${CMAKE_SOURCE_DIR}
"src/*.h"
"src/*.c"
Expand Down Expand Up @@ -340,7 +352,12 @@ if(CUNIT_FOUND)
include_directories(${CUNIT_INCLUDE_DIR} testing/ src/)
SET(CORELIBS ${CORELIBS} ${CUNIT_LIBRARY})

file(GLOB_RECURSE TEST_SRC RELATIVE ${CMAKE_SOURCE_DIR} "testing/*.c")
file(GLOB_RECURSE TEST_SRC
LIST_DIRECTORIES OFF
CONFIGURE_DEPENDS
RELATIVE ${CMAKE_SOURCE_DIR}
"testing/*.c"
)

add_executable(openomf_test_main ${TEST_SRC})

Expand All @@ -350,6 +367,10 @@ if(CUNIT_FOUND)

target_link_libraries(openomf_test_main ${CORELIBS} SDL2::Main SDL2::Mixer Epoxy::Main)

if(MSVC)
target_precompile_headers(openomf_test_main PRIVATE "<stdio.h>")
endif()

if(MINGW)
# Always build as a console executable with mingw
set_target_properties(openomf_test_main PROPERTIES LINK_FLAGS "-mconsole")
Expand All @@ -362,6 +383,8 @@ else()
message(STATUS "Development: Unit-tests are disabled")
endif()

include("cmake-scripts/BuildLanguages.cmake")

# Copy some resources to destination resources directory to ease development setup.
file(COPY resources/openomf.bk resources/gamecontrollerdb.txt DESTINATION resources)

Expand Down
56 changes: 56 additions & 0 deletions cmake-scripts/BuildLanguages.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# OMF 2097 Epic Challenge Arena
set(LANG_STRCOUNT 1013)
set(OMF_LANGS ENGLISH GERMAN)
# OpenOMF-specific
set(LANG2_STRCOUNT 1)
set(OPENOMF_LANGS DANISH)

set(OMF_COMMAND_WRAPPER "" CACHE STRING "Optional wrapper to run languagetool with")

if(WIN32)
set(LANGUAGE_INSTALL_PATH "openomf/resources/")
else()
set(LANGUAGE_INSTALL_PATH "share/games/openomf/")
endif()

# generate custom target info
set(BUILD_LANG_COMMANDS)
set(BUILD_LANG_SOURCES)
foreach(LANG ${OMF_LANGS})
set(TXT2 "${PROJECT_SOURCE_DIR}/resources/${LANG}2.TXT")
set(DAT2 "${CMAKE_CURRENT_BINARY_DIR}/resources/${LANG}.DAT2")
list(APPEND BUILD_LANG_SORUCES "${TXT2}")
list(APPEND BUILD_LANG_COMMANDS
DEPENDS "${TXT2}"
BYPRODUCTS "${DAT2}"
COMMAND ${CMAKE_COMMAND} -E echo_append "${LANG}, "
COMMAND ${OMF_COMMAND_WRAPPER} "$<TARGET_FILE:languagetool>" -i "${TXT2}" -o "${DAT2}" --check-count ${LANG2_STRCOUNT}
)
install(FILES "${DAT2}" DESTINATION "${LANGUAGE_INSTALL_PATH}")
endforeach()
foreach(LANG ${OPENOMF_LANGS})
set(TXT "${PROJECT_SOURCE_DIR}/resources/${LANG}.TXT")
set(TXT2 "${PROJECT_SOURCE_DIR}/resources/${LANG}2.TXT")
set(LNG "${CMAKE_CURRENT_BINARY_DIR}/resources/${LANG}.LNG")
set(LNG2 "${CMAKE_CURRENT_BINARY_DIR}/resources/${LANG}.LNG2")
list(APPEND BUILD_LANG_SORUCES "${TXT}" "${TXT2}")
list(APPEND BUILD_LANG_COMMANDS
DEPENDS "${TXT}" "${TXT2}"
BYPRODUCTS "${LNG}" "{LNG2}"
COMMAND ${CMAKE_COMMAND} -E echo_append "${LANG}, "
COMMAND ${OMF_COMMAND_WRAPPER} "$<TARGET_FILE:languagetool>" -i "${TXT}" -o "${LNG}" --check-count ${LANG_STRCOUNT}
COMMAND ${OMF_COMMAND_WRAPPER} "$<TARGET_FILE:languagetool>" -i "${TXT2}" -o "${LNG2}" --check-count ${LANG2_STRCOUNT}
)
install(FILES "${LNG}" "${LNG2}" DESTINATION "${LANGUAGE_INSTALL_PATH}")
endforeach()



add_custom_target(build_languages
COMMAND ${CMAKE_COMMAND} -E echo_append "Building Languages... "
${BUILD_LANG_COMMANDS}
COMMAND ${CMAKE_COMMAND} -E echo_append "done"
)
target_sources(build_languages PRIVATE ${BUILD_LANG_SORUCES})
add_dependencies(openomf build_languages)
add_dependencies(build_languages languagetool)
Loading
Loading