Skip to content

Commit

Permalink
LibUnicode: Extract cldr-misc dataset from CLDR database
Browse files Browse the repository at this point in the history
  • Loading branch information
trflynn89 authored and linusg committed Sep 6, 2021
1 parent 285a888 commit 9cd986d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Meta/CMake/unicode_data.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ set(CLDR_CORE_PATH ${CLDR_PATH}/${CLDR_CORE_SOURCE})
set(CLDR_LOCALES_SOURCE cldr-localenames-modern)
set(CLDR_LOCALES_PATH ${CLDR_PATH}/${CLDR_LOCALES_SOURCE})

set(CLDR_MISC_SOURCE cldr-misc-modern)
set(CLDR_MISC_PATH ${CLDR_PATH}/${CLDR_MISC_SOURCE})

set(CLDR_NUMBERS_SOURCE cldr-numbers-modern)
set(CLDR_NUMBERS_PATH ${CLDR_PATH}/${CLDR_NUMBERS_SOURCE})

Expand Down Expand Up @@ -117,6 +120,13 @@ if (ENABLE_UNICODE_DATABASE_DOWNLOAD)
message(FATAL_ERROR "Failed to unzip ${CLDR_LOCALES_SOURCE} from ${CLDR_ZIP_PATH} with status ${unzip_result}")
endif()
endif()
if(EXISTS ${CLDR_ZIP_PATH} AND NOT EXISTS ${CLDR_MISC_PATH})
message(STATUS "Extracting CLDR ${CLDR_MISC_SOURCE} from ${CLDR_ZIP_PATH}...")
execute_process(COMMAND unzip -q ${CLDR_ZIP_PATH} "${CLDR_MISC_SOURCE}/**" -d ${CLDR_PATH} RESULT_VARIABLE unzip_result)
if (NOT unzip_result EQUAL 0)
message(FATAL_ERROR "Failed to unzip ${CLDR_MISC_SOURCE} from ${CLDR_ZIP_PATH} with status ${unzip_result}")
endif()
endif()
if(EXISTS ${CLDR_ZIP_PATH} AND NOT EXISTS ${CLDR_NUMBERS_PATH})
message(STATUS "Extracting CLDR ${CLDR_NUMBERS_SOURCE} from ${CLDR_ZIP_PATH}...")
execute_process(COMMAND unzip -q ${CLDR_ZIP_PATH} "${CLDR_NUMBERS_SOURCE}/**" -d ${CLDR_PATH} RESULT_VARIABLE unzip_result)
Expand Down Expand Up @@ -153,9 +163,9 @@ if (ENABLE_UNICODE_DATABASE_DOWNLOAD)

add_custom_command(
OUTPUT ${UNICODE_LOCALE_HEADER} ${UNICODE_LOCALE_IMPLEMENTATION}
COMMAND $<TARGET_FILE:GenerateUnicodeLocale> -h ${UNICODE_LOCALE_HEADER} -c ${UNICODE_LOCALE_IMPLEMENTATION} -r ${CLDR_CORE_PATH} -l ${CLDR_LOCALES_PATH} -n ${CLDR_NUMBERS_PATH}
COMMAND $<TARGET_FILE:GenerateUnicodeLocale> -h ${UNICODE_LOCALE_HEADER} -c ${UNICODE_LOCALE_IMPLEMENTATION} -r ${CLDR_CORE_PATH} -l ${CLDR_LOCALES_PATH} -m ${CLDR_MISC_PATH} -n ${CLDR_NUMBERS_PATH}
VERBATIM
DEPENDS GenerateUnicodeLocale ${CLDR_CORE_PATH} ${CLDR_LOCALES_PATH} ${CLDR_NUMBERS_PATH}
DEPENDS GenerateUnicodeLocale ${CLDR_CORE_PATH} ${CLDR_LOCALES_PATH} ${CLDR_MISC_PATH} ${CLDR_NUMBERS_PATH}
)
add_custom_target(generate_${UNICODE_META_TARGET_PREFIX}UnicodeLocale DEPENDS ${UNICODE_LOCALE_HEADER} ${UNICODE_LOCALE_IMPLEMENTATION})
add_dependencies(all_generated generate_${UNICODE_META_TARGET_PREFIX}UnicodeLocale)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -937,13 +937,15 @@ int main(int argc, char** argv)
char const* generated_implementation_path = nullptr;
char const* core_path = nullptr;
char const* locale_names_path = nullptr;
char const* misc_path = nullptr;
char const* numbers_path = nullptr;

Core::ArgsParser args_parser;
args_parser.add_option(generated_header_path, "Path to the Unicode locale header file to generate", "generated-header-path", 'h', "generated-header-path");
args_parser.add_option(generated_implementation_path, "Path to the Unicode locale implementation file to generate", "generated-implementation-path", 'c', "generated-implementation-path");
args_parser.add_option(core_path, "Path to cldr-core directory", "core-path", 'r', "core-path");
args_parser.add_option(locale_names_path, "Path to cldr-localenames directory", "locale-names-path", 'l', "locale-names-path");
args_parser.add_option(misc_path, "Path to cldr-misc directory", "misc-path", 'm', "misc-path");
args_parser.add_option(numbers_path, "Path to cldr-numbers directory", "numbers-path", 'n', "numbers-path");
args_parser.parse(argc, argv);

Expand Down

0 comments on commit 9cd986d

Please sign in to comment.