From 755c161ab75ccc299651fc46cc311755942b9aec Mon Sep 17 00:00:00 2001 From: Benjamin Winger Date: Wed, 20 Apr 2022 18:57:05 -0400 Subject: [PATCH 1/4] Display fatal error if OPENMW_ICU_HOST_BUILD_DIR is not set on Android --- extern/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index f7bf9c4556..7d58ceb45e 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -248,6 +248,12 @@ if (NOT OPENMW_USE_SYSTEM_ICU) # Note: Must be a build directory, not an install root, since the configure script # looks for a configuration file which does not get installed. set(OPENMW_ICU_HOST_BUILD_DIR "" CACHE STRING "A pre-built ICU build directory for the host system if cross-compiling") + if (OPENMW_ICU_HOST_BUILD_DIR STREQUAL "") + message(FATAL_ERROR "If cross-compiling on android you must set the \ + OPENMW_ICU_HOST_BUILD_DIR to the path of a pre-compiled build of \ + ICU 70.1 for the system doing the build, as ICU needs to be able \ + to run its own executables as part of the build process.") + endif() # We need a host version of ICU so that the tools can be run when building the data library. set(NDK_STANDARD_ROOT ${CMAKE_ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64) string(REPLACE "android-" "" ANDROIDVER ${ANDROID_PLATFORM}) From 206f0d4b1d6dc7765743cea76dbc6440f237b055 Mon Sep 17 00:00:00 2001 From: Benjamin Winger Date: Wed, 20 Apr 2022 18:58:45 -0400 Subject: [PATCH 2/4] Remove some hardcoded values in when building ICU on android --- extern/CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index 7d58ceb45e..0c464381e3 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -257,17 +257,17 @@ if (NOT OPENMW_USE_SYSTEM_ICU) # We need a host version of ICU so that the tools can be run when building the data library. set(NDK_STANDARD_ROOT ${CMAKE_ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64) string(REPLACE "android-" "" ANDROIDVER ${ANDROID_PLATFORM}) - set(ICU_ENV - "CC=ccache ${NDK_STANDARD_ROOT}/bin/aarch64-linux-android${ANDROIDVER}-clang" - "CXX=ccache ${NDK_STANDARD_ROOT}/bin/aarch64-linux-android${ANDROIDVER}-clang" - "RANLIB=${NDK_STANDARD_ROOT}/bin/aarch64-linux-android-ranlib" - "AR=${NDK_STANDARD_ROOT}/bin/aarch64-linux-android-ar" - "CPPFLAGS=${ANDROID_COMPILER_FLAGS}" - "LDFLAGS=${ANDROID_LINKER_FLAGS} -lc -lstdc++" - ) # Wants a triple such as aarch64-linux-android, excluding a trailing # -clang etc. string(REGEX MATCH "^[^-]\+-[^-]+-[^-]+" ICU_TOOLCHAIN_NAME ${ANDROID_TOOLCHAIN_NAME}) + set(ICU_ENV + "CC=${CMAKE_C_COMPILER_LAUNCHER} ${NDK_STANDARD_ROOT}/bin/${ICU_TOOLCHAIN_NAME}${ANDROIDVER}-clang" + "CXX=${CMAKE_CXX_COMPILER_LAUNCHER} ${NDK_STANDARD_ROOT}/bin/${ICU_TOOLCHAIN_NAME}${ANDROIDVER}-clang" + "RANLIB=${NDK_STANDARD_ROOT}/bin/${ICU_TOOLCHAIN_NAME}-ranlib" + "AR=${NDK_STANDARD_ROOT}/bin/${ICU_TOOLCHAIN_NAME}-ar" + "CPPFLAGS=${ANDROID_COMPILER_FLAGS}" + "LDFLAGS=${ANDROID_LINKER_FLAGS} -lc -lstdc++" + ) set(ICU_ADDITIONAL_OPTS --host=${ICU_TOOLCHAIN_NAME}${ANDROIDVER} --with-cross-build=${OPENMW_ICU_HOST_BUILD_DIR}) endif() include(ExternalProject) From 8a09cec0ab64e2b8e2c9d43148ba095800952790 Mon Sep 17 00:00:00 2001 From: Benjamin Winger Date: Wed, 20 Apr 2022 18:59:31 -0400 Subject: [PATCH 3/4] Only disable building ICU tools when doing an android cross-compile Otherwise the icudata library won't be built --- extern/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index 0c464381e3..c95a9273af 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -268,7 +268,7 @@ if (NOT OPENMW_USE_SYSTEM_ICU) "CPPFLAGS=${ANDROID_COMPILER_FLAGS}" "LDFLAGS=${ANDROID_LINKER_FLAGS} -lc -lstdc++" ) - set(ICU_ADDITIONAL_OPTS --host=${ICU_TOOLCHAIN_NAME}${ANDROIDVER} --with-cross-build=${OPENMW_ICU_HOST_BUILD_DIR}) + set(ICU_ADDITIONAL_OPTS --disable-tools --host=${ICU_TOOLCHAIN_NAME}${ANDROIDVER} --with-cross-build=${OPENMW_ICU_HOST_BUILD_DIR}) endif() include(ExternalProject) ExternalProject_Add(icu @@ -277,7 +277,7 @@ if (NOT OPENMW_USE_SYSTEM_ICU) SOURCE_DIR fetched/icu CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ${ICU_ENV} /icu4c/source/configure --enable-static --disable-shared - --disable-tests --disable-samples --disable-icuio --disable-extras --disable-tools ${ICU_ADDITIONAL_OPTS} + --disable-tests --disable-samples --disable-icuio --disable-extras ${ICU_ADDITIONAL_OPTS} BUILD_COMMAND make INSTALL_COMMAND "" ) From 8179a097f837a9593d738a8567d95f9f40aaa1b3 Mon Sep 17 00:00:00 2001 From: Benjamin Winger Date: Wed, 20 Apr 2022 19:00:23 -0400 Subject: [PATCH 4/4] Added ICU feature filters to limit the size of the data library when building ICU ourselves --- extern/CMakeLists.txt | 2 ++ extern/icufilters.json | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 extern/icufilters.json diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index c95a9273af..898dfeffad 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -244,6 +244,7 @@ if (NOT OPENMW_USE_SYSTEM_YAML_CPP) endif() if (NOT OPENMW_USE_SYSTEM_ICU) + set(ICU_ENV "ICU_DATA_FILTER_FILE=${CMAKE_CURRENT_SOURCE_DIR}/icufilters.json") if (ANDROID) # Note: Must be a build directory, not an install root, since the configure script # looks for a configuration file which does not get installed. @@ -261,6 +262,7 @@ if (NOT OPENMW_USE_SYSTEM_ICU) # -clang etc. string(REGEX MATCH "^[^-]\+-[^-]+-[^-]+" ICU_TOOLCHAIN_NAME ${ANDROID_TOOLCHAIN_NAME}) set(ICU_ENV + ${ICU_ENV} "CC=${CMAKE_C_COMPILER_LAUNCHER} ${NDK_STANDARD_ROOT}/bin/${ICU_TOOLCHAIN_NAME}${ANDROIDVER}-clang" "CXX=${CMAKE_CXX_COMPILER_LAUNCHER} ${NDK_STANDARD_ROOT}/bin/${ICU_TOOLCHAIN_NAME}${ANDROIDVER}-clang" "RANLIB=${NDK_STANDARD_ROOT}/bin/${ICU_TOOLCHAIN_NAME}-ranlib" diff --git a/extern/icufilters.json b/extern/icufilters.json new file mode 100644 index 0000000000..837658e5c7 --- /dev/null +++ b/extern/icufilters.json @@ -0,0 +1,19 @@ +{ + "featureFilters": { + "brkitr_rules": "exclude", + "brkitr_dictionaries": "exclude", + "brkitr_tree": "exclude", + "coll_ucadata": "exclude", + "coll_tree": "exclude", + "confusables": "exclude", + "conversion_mappings": "exclude", + "zone_tree": "exclude", + "zone_supplemental": "exclude", + "translit": "exclude", + "cnvalias": "exclude", + "lang_tree": "exclude", + "normalization": "exclude", + "region_tree": "exclude", + "stringprep": "exclude" + } +}