2021-12-22 16:12:59 -05:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/utils.cmake)
|
|
|
|
|
2021-09-15 09:35:18 -04:00
|
|
|
set(UCD_VERSION 14.0.0)
|
2021-11-09 10:50:37 -05:00
|
|
|
set(CLDR_VERSION 40.0.0)
|
2021-09-15 08:46:27 -04:00
|
|
|
|
2021-09-15 13:27:17 -04:00
|
|
|
set(UCD_PATH "${CMAKE_BINARY_DIR}/UCD" CACHE PATH "Download location for UCD files")
|
|
|
|
set(CLDR_PATH "${CMAKE_BINARY_DIR}/CLDR" CACHE PATH "Download location for CLDR files")
|
2021-07-25 15:10:51 -04:00
|
|
|
|
2021-09-15 09:33:55 -04:00
|
|
|
set(UCD_VERSION_FILE "${UCD_PATH}/version.txt")
|
|
|
|
set(CLDR_VERSION_FILE "${CLDR_PATH}/version.txt")
|
|
|
|
|
2021-09-15 08:46:27 -04:00
|
|
|
set(UNICODE_DATA_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/UnicodeData.txt")
|
2021-09-15 13:27:17 -04:00
|
|
|
set(UNICODE_DATA_PATH "${UCD_PATH}/UnicodeData.txt")
|
2021-07-25 15:10:51 -04:00
|
|
|
|
2021-09-15 08:46:27 -04:00
|
|
|
set(SPECIAL_CASING_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/SpecialCasing.txt")
|
2021-09-15 13:27:17 -04:00
|
|
|
set(SPECIAL_CASING_PATH "${UCD_PATH}/SpecialCasing.txt")
|
2021-07-27 10:39:37 -04:00
|
|
|
|
2021-09-15 08:46:27 -04:00
|
|
|
set(DERIVED_GENERAL_CATEGORY_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/extracted/DerivedGeneralCategory.txt")
|
2021-09-15 13:27:17 -04:00
|
|
|
set(DERIVED_GENERAL_CATEGORY_PATH "${UCD_PATH}/DerivedGeneralCategory.txt")
|
2021-08-10 07:17:24 -04:00
|
|
|
|
2021-09-15 08:46:27 -04:00
|
|
|
set(PROP_LIST_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/PropList.txt")
|
2021-09-15 13:27:17 -04:00
|
|
|
set(PROP_LIST_PATH "${UCD_PATH}/PropList.txt")
|
2021-07-27 17:37:47 -04:00
|
|
|
|
2021-09-15 08:46:27 -04:00
|
|
|
set(DERIVED_CORE_PROP_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/DerivedCoreProperties.txt")
|
2021-09-15 13:27:17 -04:00
|
|
|
set(DERIVED_CORE_PROP_PATH "${UCD_PATH}/DerivedCoreProperties.txt")
|
2021-07-28 18:39:41 -04:00
|
|
|
|
2021-09-15 08:46:27 -04:00
|
|
|
set(DERIVED_BINARY_PROP_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/extracted/DerivedBinaryProperties.txt")
|
2021-09-15 13:27:17 -04:00
|
|
|
set(DERIVED_BINARY_PROP_PATH "${UCD_PATH}/DerivedBinaryProperties.txt")
|
2021-08-04 07:53:24 -04:00
|
|
|
|
2021-09-15 08:46:27 -04:00
|
|
|
set(PROP_ALIAS_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/PropertyAliases.txt")
|
2021-09-15 13:27:17 -04:00
|
|
|
set(PROP_ALIAS_PATH "${UCD_PATH}/PropertyAliases.txt")
|
2021-07-28 20:14:42 -04:00
|
|
|
|
2021-09-15 08:46:27 -04:00
|
|
|
set(PROP_VALUE_ALIAS_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/PropertyValueAliases.txt")
|
2021-09-15 13:27:17 -04:00
|
|
|
set(PROP_VALUE_ALIAS_PATH "${UCD_PATH}/PropertyValueAliases.txt")
|
2021-07-31 13:45:05 -04:00
|
|
|
|
2021-11-18 23:23:58 +01:00
|
|
|
set(NAME_ALIAS_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/NameAliases.txt")
|
|
|
|
set(NAME_ALIAS_PATH "${UCD_PATH}/NameAliases.txt")
|
|
|
|
|
2021-09-15 08:46:27 -04:00
|
|
|
set(SCRIPTS_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/Scripts.txt")
|
2021-09-15 13:27:17 -04:00
|
|
|
set(SCRIPTS_PATH "${UCD_PATH}/Scripts.txt")
|
2021-08-03 17:11:19 -04:00
|
|
|
|
2021-09-15 08:46:27 -04:00
|
|
|
set(SCRIPT_EXTENSIONS_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/ScriptExtensions.txt")
|
2021-09-15 13:27:17 -04:00
|
|
|
set(SCRIPT_EXTENSIONS_PATH "${UCD_PATH}/ScriptExtensions.txt")
|
2021-08-04 07:05:30 -04:00
|
|
|
|
2021-09-15 08:46:27 -04:00
|
|
|
set(EMOJI_DATA_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/emoji/emoji-data.txt")
|
2021-09-15 13:27:17 -04:00
|
|
|
set(EMOJI_DATA_PATH "${UCD_PATH}/emoji-data.txt")
|
2021-08-04 07:46:36 -04:00
|
|
|
|
2021-09-15 08:46:27 -04:00
|
|
|
set(NORM_PROPS_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/DerivedNormalizationProps.txt")
|
2021-09-15 13:27:17 -04:00
|
|
|
set(NORM_PROPS_PATH "${UCD_PATH}/DerivedNormalizationProps.txt")
|
2021-08-10 15:29:28 -04:00
|
|
|
|
2021-09-15 08:46:27 -04:00
|
|
|
set(CLDR_ZIP_URL "https://github.com/unicode-org/cldr-json/releases/download/${CLDR_VERSION}/cldr-${CLDR_VERSION}-json-modern.zip")
|
2021-09-15 13:27:17 -04:00
|
|
|
set(CLDR_ZIP_PATH "${CLDR_PATH}/cldr.zip")
|
2021-08-24 19:50:18 -04:00
|
|
|
|
2021-08-30 08:56:28 -04:00
|
|
|
set(CLDR_CORE_SOURCE cldr-core)
|
2021-09-15 13:27:17 -04:00
|
|
|
set(CLDR_CORE_PATH "${CLDR_PATH}/${CLDR_CORE_SOURCE}")
|
2021-08-30 08:56:28 -04:00
|
|
|
|
2021-11-19 11:36:28 -05:00
|
|
|
set(CLDR_DATES_SOURCE cldr-dates-modern)
|
|
|
|
set(CLDR_DATES_PATH "${CLDR_PATH}/${CLDR_DATES_SOURCE}")
|
|
|
|
|
2021-08-24 19:50:18 -04:00
|
|
|
set(CLDR_LOCALES_SOURCE cldr-localenames-modern)
|
2021-09-15 13:27:17 -04:00
|
|
|
set(CLDR_LOCALES_PATH "${CLDR_PATH}/${CLDR_LOCALES_SOURCE}")
|
2021-08-24 19:50:18 -04:00
|
|
|
|
2021-09-05 22:46:03 -04:00
|
|
|
set(CLDR_MISC_SOURCE cldr-misc-modern)
|
2021-09-15 13:27:17 -04:00
|
|
|
set(CLDR_MISC_PATH "${CLDR_PATH}/${CLDR_MISC_SOURCE}")
|
2021-09-05 22:46:03 -04:00
|
|
|
|
2021-08-26 08:31:31 -04:00
|
|
|
set(CLDR_NUMBERS_SOURCE cldr-numbers-modern)
|
2021-09-15 13:27:17 -04:00
|
|
|
set(CLDR_NUMBERS_PATH "${CLDR_PATH}/${CLDR_NUMBERS_SOURCE}")
|
2021-08-26 08:31:31 -04:00
|
|
|
|
2021-11-16 09:31:15 -05:00
|
|
|
set(CLDR_UNITS_SOURCE cldr-units-modern)
|
|
|
|
set(CLDR_UNITS_PATH "${CLDR_PATH}/${CLDR_UNITS_SOURCE}")
|
|
|
|
|
2021-09-15 08:46:56 -04: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 15:29:28 -04:00
|
|
|
endif()
|
2021-09-15 08:46:56 -04:00
|
|
|
endfunction()
|
|
|
|
|
2021-09-15 08:50:45 -04: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}...")
|
2021-09-15 13:27:17 -04:00
|
|
|
execute_process(COMMAND unzip -q "${CLDR_ZIP_PATH}" "${source}/**" -d "${CLDR_PATH}" RESULT_VARIABLE unzip_result)
|
2021-09-15 08:50:45 -04:00
|
|
|
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 08:46:56 -04:00
|
|
|
if (ENABLE_UNICODE_DATABASE_DOWNLOAD)
|
2021-12-22 16:12:59 -05:00
|
|
|
remove_path_if_version_changed("${UCD_VERSION}" "${UCD_VERSION_FILE}" "${UCD_PATH}")
|
|
|
|
remove_path_if_version_changed("${CLDR_VERSION}" "${CLDR_VERSION_FILE}" "${CLDR_PATH}")
|
2021-09-15 09:33:55 -04:00
|
|
|
|
2021-09-15 08:46:56 -04:00
|
|
|
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}")
|
2021-11-18 23:23:58 +01:00
|
|
|
download_ucd_file("${NAME_ALIAS_URL}" "${NAME_ALIAS_PATH}")
|
2021-09-15 08:46:56 -04:00
|
|
|
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 15:10:51 -04:00
|
|
|
|
2021-09-15 08:50:45 -04:00
|
|
|
if (NOT EXISTS "${CLDR_ZIP_PATH}")
|
2021-08-24 19:50:18 -04:00
|
|
|
message(STATUS "Downloading CLDR database from ${CLDR_ZIP_URL}...")
|
2021-09-15 08:50:45 -04:00
|
|
|
file(DOWNLOAD "${CLDR_ZIP_URL}" "${CLDR_ZIP_PATH}" INACTIVITY_TIMEOUT 10)
|
2021-08-24 19:50:18 -04:00
|
|
|
endif()
|
|
|
|
|
2021-09-15 08:50:45 -04:00
|
|
|
extract_cldr_file("${CLDR_CORE_SOURCE}" "${CLDR_CORE_PATH}")
|
2021-11-19 11:36:28 -05:00
|
|
|
extract_cldr_file("${CLDR_DATES_SOURCE}" "${CLDR_DATES_PATH}")
|
2021-09-15 08:50:45 -04:00
|
|
|
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-11-16 09:31:15 -05:00
|
|
|
extract_cldr_file("${CLDR_UNITS_SOURCE}" "${CLDR_UNITS_PATH}")
|
2021-09-15 08:50:45 -04:00
|
|
|
|
2021-07-29 02:18:52 -06:00
|
|
|
set(UNICODE_DATA_HEADER LibUnicode/UnicodeData.h)
|
|
|
|
set(UNICODE_DATA_IMPLEMENTATION LibUnicode/UnicodeData.cpp)
|
2021-07-25 15:10:51 -04:00
|
|
|
|
2021-11-19 11:36:28 -05:00
|
|
|
set(UNICODE_DATE_TIME_FORMAT_HEADER LibUnicode/UnicodeDateTimeFormat.h)
|
|
|
|
set(UNICODE_DATE_TIME_FORMAT_IMPLEMENTATION LibUnicode/UnicodeDateTimeFormat.cpp)
|
|
|
|
|
2021-08-24 19:50:18 -04:00
|
|
|
set(UNICODE_LOCALE_HEADER LibUnicode/UnicodeLocale.h)
|
|
|
|
set(UNICODE_LOCALE_IMPLEMENTATION LibUnicode/UnicodeLocale.cpp)
|
|
|
|
|
2021-11-12 09:09:48 -05:00
|
|
|
set(UNICODE_NUMBER_FORMAT_HEADER LibUnicode/UnicodeNumberFormat.h)
|
|
|
|
set(UNICODE_NUMBER_FORMAT_IMPLEMENTATION LibUnicode/UnicodeNumberFormat.cpp)
|
|
|
|
|
2021-08-29 19:27:50 -07:00
|
|
|
set(UNICODE_META_TARGET_PREFIX LibUnicode_)
|
|
|
|
|
2021-07-29 02:18:52 -06: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 19:50:18 -04:00
|
|
|
|
2021-11-19 11:36:28 -05:00
|
|
|
set(UNICODE_DATE_TIME_FORMAT_HEADER UnicodeDateTimeFormat.h)
|
|
|
|
set(UNICODE_DATE_TIME_FORMAT_IMPLEMENTATION UnicodeDateTimeFormat.cpp)
|
|
|
|
|
2021-08-24 19:50:18 -04:00
|
|
|
set(UNICODE_LOCALE_HEADER UnicodeLocale.h)
|
|
|
|
set(UNICODE_LOCALE_IMPLEMENTATION UnicodeLocale.cpp)
|
2021-11-12 09:09:48 -05:00
|
|
|
|
|
|
|
set(UNICODE_NUMBER_FORMAT_HEADER UnicodeNumberFormat.h)
|
|
|
|
set(UNICODE_NUMBER_FORMAT_IMPLEMENTATION UnicodeNumberFormat.cpp)
|
|
|
|
|
2021-08-29 19:27:50 -07:00
|
|
|
set(UNICODE_META_TARGET_PREFIX "")
|
2021-07-25 15:15:47 -04:00
|
|
|
endif()
|
|
|
|
|
2021-11-19 11:25:02 -05:00
|
|
|
invoke_generator(
|
|
|
|
"UnicodeData"
|
|
|
|
Lagom::GenerateUnicodeData
|
2021-12-22 16:30:21 -05:00
|
|
|
"${UCD_VERSION_FILE}"
|
|
|
|
"${UNICODE_META_TARGET_PREFIX}"
|
2021-11-19 11:25:02 -05:00
|
|
|
"${UNICODE_DATA_HEADER}"
|
|
|
|
"${UNICODE_DATA_IMPLEMENTATION}"
|
|
|
|
arguments -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}" -m "${NAME_ALIAS_PATH}" -n "${NORM_PROPS_PATH}"
|
2021-07-25 15:10:51 -04:00
|
|
|
)
|
2021-11-19 11:36:28 -05:00
|
|
|
invoke_generator(
|
|
|
|
"UnicodeDateTimeFormat"
|
|
|
|
Lagom::GenerateUnicodeDateTimeFormat
|
2021-12-22 16:30:21 -05:00
|
|
|
"${CLDR_VERSION_FILE}"
|
|
|
|
"${UNICODE_META_TARGET_PREFIX}"
|
2021-11-19 11:36:28 -05:00
|
|
|
"${UNICODE_DATE_TIME_FORMAT_HEADER}"
|
|
|
|
"${UNICODE_DATE_TIME_FORMAT_IMPLEMENTATION}"
|
LibUnicode: Parse and generate regional hour cycles
Unlike most data in the CLDR, hour cycles are not stored on a per-locale
basis. Instead, they are keyed by a string that is usually a region, but
sometimes is a locale. Therefore, given a locale, to determine the hour
cycles for that locale, we:
1. Check if the locale itself is assigned hour cycles.
2. If the locale has a region, check if that region is assigned hour
cycles.
3. Otherwise, maximize that locale, and if the maximized locale has
a region, check if that region is assigned hour cycles.
4. If the above all fail, fallback to the "001" region.
Further, each locale's default hour cycle is the first assigned hour
cycle.
2021-11-27 20:57:21 -05:00
|
|
|
arguments -r "${CLDR_CORE_PATH}" -d "${CLDR_DATES_PATH}"
|
2021-11-19 11:36:28 -05:00
|
|
|
)
|
2021-11-19 11:25:02 -05:00
|
|
|
invoke_generator(
|
|
|
|
"UnicodeLocale"
|
|
|
|
Lagom::GenerateUnicodeLocale
|
2021-12-22 16:30:21 -05:00
|
|
|
"${CLDR_VERSION_FILE}"
|
|
|
|
"${UNICODE_META_TARGET_PREFIX}"
|
2021-11-19 11:25:02 -05:00
|
|
|
"${UNICODE_LOCALE_HEADER}"
|
|
|
|
"${UNICODE_LOCALE_IMPLEMENTATION}"
|
2021-11-28 10:39:55 -05:00
|
|
|
arguments -r "${CLDR_CORE_PATH}" -l "${CLDR_LOCALES_PATH}" -m "${CLDR_MISC_PATH}" -n "${CLDR_NUMBERS_PATH}" -d "${CLDR_DATES_PATH}"
|
2021-08-24 19:50:18 -04:00
|
|
|
)
|
2021-11-19 11:25:02 -05:00
|
|
|
invoke_generator(
|
|
|
|
"UnicodeNumberFormat"
|
|
|
|
Lagom::GenerateUnicodeNumberFormat
|
2021-12-22 16:30:21 -05:00
|
|
|
"${CLDR_VERSION_FILE}"
|
|
|
|
"${UNICODE_META_TARGET_PREFIX}"
|
2021-11-19 11:25:02 -05:00
|
|
|
"${UNICODE_NUMBER_FORMAT_HEADER}"
|
|
|
|
"${UNICODE_NUMBER_FORMAT_IMPLEMENTATION}"
|
|
|
|
arguments -n "${CLDR_NUMBERS_PATH}" -u "${CLDR_UNITS_PATH}"
|
2021-11-12 09:09:48 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
set(UNICODE_DATA_SOURCES
|
|
|
|
${UNICODE_DATA_HEADER}
|
|
|
|
${UNICODE_DATA_IMPLEMENTATION}
|
2021-11-19 11:36:28 -05:00
|
|
|
${UNICODE_DATE_TIME_FORMAT_HEADER}
|
|
|
|
${UNICODE_DATE_TIME_FORMAT_IMPLEMENTATION}
|
2021-11-12 09:09:48 -05:00
|
|
|
${UNICODE_LOCALE_HEADER}
|
|
|
|
${UNICODE_LOCALE_IMPLEMENTATION}
|
|
|
|
${UNICODE_NUMBER_FORMAT_HEADER}
|
|
|
|
${UNICODE_NUMBER_FORMAT_IMPLEMENTATION}
|
|
|
|
)
|
2021-07-25 15:10:51 -04:00
|
|
|
endif()
|