2021-09-15 12:46:27 +00:00
|
|
|
set(UCD_VERSION 13.0.0)
|
|
|
|
set(CLDR_VERSION 39.0.0)
|
|
|
|
|
2021-09-07 06:49:21 +00:00
|
|
|
set(LOCALE_DATA_CACHE_LOCATION "${CMAKE_BINARY_DIR}/CLDR" CACHE PATH "Download location for CLDR files")
|
|
|
|
set(UNICODE_CACHE_LOCATION "${CMAKE_BINARY_DIR}/UCD" CACHE PATH "Download location for UCD files")
|
2021-07-25 19:10:51 +00:00
|
|
|
|
2021-09-15 12:46:27 +00:00
|
|
|
set(UNICODE_DATA_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/UnicodeData.txt")
|
|
|
|
set(UNICODE_DATA_PATH "${UNICODE_CACHE_LOCATION}/UnicodeData.txt")
|
2021-07-25 19:10:51 +00:00
|
|
|
|
2021-09-15 12:46:27 +00:00
|
|
|
set(SPECIAL_CASING_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/SpecialCasing.txt")
|
|
|
|
set(SPECIAL_CASING_PATH "${UNICODE_CACHE_LOCATION}/SpecialCasing.txt")
|
2021-07-27 14:39:37 +00:00
|
|
|
|
2021-09-15 12:46:27 +00:00
|
|
|
set(DERIVED_GENERAL_CATEGORY_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/extracted/DerivedGeneralCategory.txt")
|
|
|
|
set(DERIVED_GENERAL_CATEGORY_PATH "${UNICODE_CACHE_LOCATION}/DerivedGeneralCategory.txt")
|
2021-08-10 11:17:24 +00:00
|
|
|
|
2021-09-15 12:46:27 +00:00
|
|
|
set(PROP_LIST_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/PropList.txt")
|
|
|
|
set(PROP_LIST_PATH "${UNICODE_CACHE_LOCATION}/PropList.txt")
|
2021-07-27 21:37:47 +00:00
|
|
|
|
2021-09-15 12:46:27 +00:00
|
|
|
set(DERIVED_CORE_PROP_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/DerivedCoreProperties.txt")
|
|
|
|
set(DERIVED_CORE_PROP_PATH "${UNICODE_CACHE_LOCATION}/DerivedCoreProperties.txt")
|
2021-07-28 22:39:41 +00:00
|
|
|
|
2021-09-15 12:46:27 +00:00
|
|
|
set(DERIVED_BINARY_PROP_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/extracted/DerivedBinaryProperties.txt")
|
|
|
|
set(DERIVED_BINARY_PROP_PATH "${UNICODE_CACHE_LOCATION}/DerivedBinaryProperties.txt")
|
2021-08-04 11:53:24 +00:00
|
|
|
|
2021-09-15 12:46:27 +00:00
|
|
|
set(PROP_ALIAS_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/PropertyAliases.txt")
|
|
|
|
set(PROP_ALIAS_PATH "${UNICODE_CACHE_LOCATION}/PropertyAliases.txt")
|
2021-07-29 00:14:42 +00:00
|
|
|
|
2021-09-15 12:46:27 +00:00
|
|
|
set(PROP_VALUE_ALIAS_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/PropertyValueAliases.txt")
|
|
|
|
set(PROP_VALUE_ALIAS_PATH "${UNICODE_CACHE_LOCATION}/PropertyValueAliases.txt")
|
2021-07-31 17:45:05 +00:00
|
|
|
|
2021-09-15 12:46:27 +00:00
|
|
|
set(SCRIPTS_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/Scripts.txt")
|
|
|
|
set(SCRIPTS_PATH "${UNICODE_CACHE_LOCATION}/Scripts.txt")
|
2021-08-03 21:11:19 +00:00
|
|
|
|
2021-09-15 12:46:27 +00:00
|
|
|
set(SCRIPT_EXTENSIONS_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/ScriptExtensions.txt")
|
|
|
|
set(SCRIPT_EXTENSIONS_PATH "${UNICODE_CACHE_LOCATION}/ScriptExtensions.txt")
|
2021-08-04 11:05:30 +00:00
|
|
|
|
2021-09-15 12:46:27 +00:00
|
|
|
set(EMOJI_DATA_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/emoji/emoji-data.txt")
|
|
|
|
set(EMOJI_DATA_PATH "${UNICODE_CACHE_LOCATION}/emoji-data.txt")
|
2021-08-04 11:46:36 +00:00
|
|
|
|
2021-09-15 12:46:27 +00:00
|
|
|
set(NORM_PROPS_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/DerivedNormalizationProps.txt")
|
|
|
|
set(NORM_PROPS_PATH "${UNICODE_CACHE_LOCATION}/DerivedNormalizationProps.txt")
|
2021-08-10 19:29:28 +00:00
|
|
|
|
2021-09-15 12:46:27 +00:00
|
|
|
set(CLDR_ZIP_URL "https://github.com/unicode-org/cldr-json/releases/download/${CLDR_VERSION}/cldr-${CLDR_VERSION}-json-modern.zip")
|
|
|
|
set(CLDR_ZIP_PATH "${LOCALE_DATA_CACHE_LOCATION}/cldr.zip")
|
2021-08-24 23:50:18 +00:00
|
|
|
|
2021-08-30 12:56:28 +00:00
|
|
|
set(CLDR_CORE_SOURCE cldr-core)
|
2021-09-15 12:46:27 +00:00
|
|
|
set(CLDR_CORE_PATH "${LOCALE_DATA_CACHE_LOCATION}/${CLDR_CORE_SOURCE}")
|
2021-08-30 12:56:28 +00:00
|
|
|
|
2021-08-24 23:50:18 +00:00
|
|
|
set(CLDR_LOCALES_SOURCE cldr-localenames-modern)
|
2021-09-15 12:46:27 +00:00
|
|
|
set(CLDR_LOCALES_PATH "${LOCALE_DATA_CACHE_LOCATION}/${CLDR_LOCALES_SOURCE}")
|
2021-08-24 23:50:18 +00:00
|
|
|
|
2021-09-06 02:46:03 +00:00
|
|
|
set(CLDR_MISC_SOURCE cldr-misc-modern)
|
2021-09-15 12:46:27 +00:00
|
|
|
set(CLDR_MISC_PATH "${LOCALE_DATA_CACHE_LOCATION}/${CLDR_MISC_SOURCE}")
|
2021-09-06 02:46:03 +00:00
|
|
|
|
2021-08-26 12:31:31 +00:00
|
|
|
set(CLDR_NUMBERS_SOURCE cldr-numbers-modern)
|
2021-09-15 12:46:27 +00:00
|
|
|
set(CLDR_NUMBERS_PATH "${LOCALE_DATA_CACHE_LOCATION}/${CLDR_NUMBERS_SOURCE}")
|
2021-08-26 12:31:31 +00:00
|
|
|
|
2021-09-15 12:46:56 +00:00
|
|
|
function(download_ucd_file url path)
|
|
|
|
if (NOT EXISTS "${path}")
|
|
|
|
get_filename_component(file "${path}" NAME)
|
|
|
|
message(STATUS "Downloading UCD ${file} from ${url}...")
|
|
|
|
file(DOWNLOAD "${url}" "${path}" INACTIVITY_TIMEOUT 10)
|
2021-08-10 19:29:28 +00:00
|
|
|
endif()
|
2021-09-15 12:46:56 +00:00
|
|
|
endfunction()
|
|
|
|
|
2021-09-15 12:50:45 +00:00
|
|
|
function(extract_cldr_file source path)
|
|
|
|
if(EXISTS "${CLDR_ZIP_PATH}" AND NOT EXISTS "${path}")
|
|
|
|
message(STATUS "Extracting CLDR ${source} from ${CLDR_ZIP_PATH}...")
|
|
|
|
execute_process(COMMAND unzip -q "${CLDR_ZIP_PATH}" "${source}/**" -d "${LOCALE_DATA_CACHE_LOCATION}" RESULT_VARIABLE unzip_result)
|
|
|
|
if (NOT unzip_result EQUAL 0)
|
|
|
|
message(FATAL_ERROR "Failed to unzip ${source} from ${CLDR_ZIP_PATH} with status ${unzip_result}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2021-09-15 12:46:56 +00:00
|
|
|
if (ENABLE_UNICODE_DATABASE_DOWNLOAD)
|
|
|
|
download_ucd_file("${UNICODE_DATA_URL}" "${UNICODE_DATA_PATH}")
|
|
|
|
download_ucd_file("${SPECIAL_CASING_URL}" "${SPECIAL_CASING_PATH}")
|
|
|
|
download_ucd_file("${DERIVED_GENERAL_CATEGORY_URL}" "${DERIVED_GENERAL_CATEGORY_PATH}")
|
|
|
|
download_ucd_file("${PROP_LIST_URL}" "${PROP_LIST_PATH}")
|
|
|
|
download_ucd_file("${DERIVED_CORE_PROP_URL}" "${DERIVED_CORE_PROP_PATH}")
|
|
|
|
download_ucd_file("${DERIVED_BINARY_PROP_URL}" "${DERIVED_BINARY_PROP_PATH}")
|
|
|
|
download_ucd_file("${PROP_ALIAS_URL}" "${PROP_ALIAS_PATH}")
|
|
|
|
download_ucd_file("${PROP_VALUE_ALIAS_URL}" "${PROP_VALUE_ALIAS_PATH}")
|
|
|
|
download_ucd_file("${SCRIPTS_URL}" "${SCRIPTS_PATH}")
|
|
|
|
download_ucd_file("${SCRIPT_EXTENSIONS_URL}" "${SCRIPT_EXTENSIONS_PATH}")
|
|
|
|
download_ucd_file("${EMOJI_DATA_URL}" "${EMOJI_DATA_PATH}")
|
|
|
|
download_ucd_file("${NORM_PROPS_URL}" "${NORM_PROPS_PATH}")
|
2021-07-25 19:10:51 +00:00
|
|
|
|
2021-09-15 12:50:45 +00:00
|
|
|
if (NOT EXISTS "${CLDR_ZIP_PATH}")
|
2021-08-24 23:50:18 +00:00
|
|
|
message(STATUS "Downloading CLDR database from ${CLDR_ZIP_URL}...")
|
2021-09-15 12:50:45 +00:00
|
|
|
file(DOWNLOAD "${CLDR_ZIP_URL}" "${CLDR_ZIP_PATH}" INACTIVITY_TIMEOUT 10)
|
2021-08-24 23:50:18 +00:00
|
|
|
endif()
|
|
|
|
|
2021-09-15 12:50:45 +00:00
|
|
|
extract_cldr_file("${CLDR_CORE_SOURCE}" "${CLDR_CORE_PATH}")
|
|
|
|
extract_cldr_file("${CLDR_LOCALES_SOURCE}" "${CLDR_LOCALES_PATH}")
|
|
|
|
extract_cldr_file("${CLDR_MISC_SOURCE}" "${CLDR_MISC_PATH}")
|
|
|
|
extract_cldr_file("${CLDR_NUMBERS_SOURCE}" "${CLDR_NUMBERS_PATH}")
|
|
|
|
|
2021-07-29 08:18:52 +00:00
|
|
|
set(UNICODE_DATA_HEADER LibUnicode/UnicodeData.h)
|
|
|
|
set(UNICODE_DATA_IMPLEMENTATION LibUnicode/UnicodeData.cpp)
|
2021-07-25 19:10:51 +00:00
|
|
|
|
2021-08-24 23:50:18 +00:00
|
|
|
set(UNICODE_LOCALE_HEADER LibUnicode/UnicodeLocale.h)
|
|
|
|
set(UNICODE_LOCALE_IMPLEMENTATION LibUnicode/UnicodeLocale.cpp)
|
|
|
|
|
2021-08-30 02:27:50 +00:00
|
|
|
set(UNICODE_META_TARGET_PREFIX LibUnicode_)
|
|
|
|
|
2021-07-29 08:18:52 +00:00
|
|
|
if (CMAKE_CURRENT_BINARY_DIR MATCHES ".*/LibUnicode") # Serenity build.
|
|
|
|
set(UNICODE_DATA_HEADER UnicodeData.h)
|
|
|
|
set(UNICODE_DATA_IMPLEMENTATION UnicodeData.cpp)
|
2021-08-24 23:50:18 +00:00
|
|
|
|
|
|
|
set(UNICODE_LOCALE_HEADER UnicodeLocale.h)
|
|
|
|
set(UNICODE_LOCALE_IMPLEMENTATION UnicodeLocale.cpp)
|
2021-08-30 02:27:50 +00:00
|
|
|
set(UNICODE_META_TARGET_PREFIX "")
|
2021-07-25 19:15:47 +00:00
|
|
|
endif()
|
|
|
|
|
2021-07-25 19:10:51 +00:00
|
|
|
add_custom_command(
|
2021-08-02 14:47:41 +00:00
|
|
|
OUTPUT ${UNICODE_DATA_HEADER} ${UNICODE_DATA_IMPLEMENTATION}
|
2021-09-07 06:49:21 +00:00
|
|
|
COMMAND $<TARGET_FILE:Lagom::GenerateUnicodeData> -h ${UNICODE_DATA_HEADER}.tmp -c ${UNICODE_DATA_IMPLEMENTATION}.tmp -u ${UNICODE_DATA_PATH} -s ${SPECIAL_CASING_PATH} -g ${DERIVED_GENERAL_CATEGORY_PATH} -p ${PROP_LIST_PATH} -d ${DERIVED_CORE_PROP_PATH} -b ${DERIVED_BINARY_PROP_PATH} -a ${PROP_ALIAS_PATH} -v ${PROP_VALUE_ALIAS_PATH} -r ${SCRIPTS_PATH} -x ${SCRIPT_EXTENSIONS_PATH} -e ${EMOJI_DATA_PATH} -n ${NORM_PROPS_PATH}
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${UNICODE_DATA_HEADER}.tmp ${UNICODE_DATA_HEADER}
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${UNICODE_DATA_IMPLEMENTATION}.tmp ${UNICODE_DATA_IMPLEMENTATION}
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E remove ${UNICODE_DATA_HEADER}.tmp ${UNICODE_DATA_IMPLEMENTATION}.tmp
|
2021-07-25 19:10:51 +00:00
|
|
|
VERBATIM
|
2021-09-07 06:49:21 +00:00
|
|
|
DEPENDS Lagom::GenerateUnicodeData ${UNICODE_DATA_PATH} ${SPECIAL_CASING_PATH} ${DERIVED_GENERAL_CATEGORY_PATH} ${PROP_LIST_PATH} ${DERIVED_CORE_PROP_PATH} ${DERIVED_BINARY_PROP_PATH} ${PROP_ALIAS_PATH} ${PROP_VALUE_ALIAS_PATH} ${SCRIPTS_PATH} ${SCRIPT_EXTENSIONS_PATH} ${EMOJI_DATA_PATH} ${NORM_PROPS_PATH}
|
2021-07-25 19:10:51 +00:00
|
|
|
)
|
2021-08-30 02:27:50 +00:00
|
|
|
add_custom_target(generate_${UNICODE_META_TARGET_PREFIX}UnicodeData DEPENDS ${UNICODE_DATA_HEADER} ${UNICODE_DATA_IMPLEMENTATION})
|
|
|
|
add_dependencies(all_generated generate_${UNICODE_META_TARGET_PREFIX}UnicodeData)
|
2021-07-25 19:10:51 +00:00
|
|
|
|
2021-08-24 23:50:18 +00:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${UNICODE_LOCALE_HEADER} ${UNICODE_LOCALE_IMPLEMENTATION}
|
2021-09-07 06:49:21 +00:00
|
|
|
COMMAND $<TARGET_FILE:Lagom::GenerateUnicodeLocale> -h ${UNICODE_LOCALE_HEADER}.tmp -c ${UNICODE_LOCALE_IMPLEMENTATION}.tmp -r ${CLDR_CORE_PATH} -l ${CLDR_LOCALES_PATH} -m ${CLDR_MISC_PATH} -n ${CLDR_NUMBERS_PATH}
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${UNICODE_LOCALE_HEADER}.tmp ${UNICODE_LOCALE_HEADER}
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${UNICODE_LOCALE_IMPLEMENTATION}.tmp ${UNICODE_LOCALE_IMPLEMENTATION}
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E remove ${UNICODE_LOCALE_HEADER}.tmp ${UNICODE_LOCALE_IMPLEMENTATION}.tmp
|
2021-08-24 23:50:18 +00:00
|
|
|
VERBATIM
|
2021-09-07 06:49:21 +00:00
|
|
|
DEPENDS Lagom::GenerateUnicodeLocale ${CLDR_CORE_PATH} ${CLDR_LOCALES_PATH} ${CLDR_MISC_PATH} ${CLDR_NUMBERS_PATH}
|
2021-08-24 23:50:18 +00:00
|
|
|
)
|
2021-08-30 02:27:50 +00:00
|
|
|
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)
|
2021-08-24 23:50:18 +00:00
|
|
|
|
|
|
|
set(UNICODE_DATA_SOURCES ${UNICODE_DATA_HEADER} ${UNICODE_DATA_IMPLEMENTATION} ${UNICODE_LOCALE_HEADER} ${UNICODE_LOCALE_IMPLEMENTATION})
|
2021-07-25 19:10:51 +00:00
|
|
|
endif()
|