diff options
author | Timothy Flynn <trflynn89@pm.me> | 2021-09-15 09:33:55 -0400 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-09-30 17:37:57 +0100 |
commit | a466b78bf32f7d31b13122324b151e190cfce30e (patch) | |
tree | 35b5e3a0f8c2bfa71deb7ac30a30f50afcc43a7b /Meta/CMake | |
parent | 0ec6b4f1326a69696eac49186a82248f5bedd0fe (diff) | |
download | serenity-a466b78bf32f7d31b13122324b151e190cfce30e.zip |
LibUnicode: Remove cached UCD and CLDR files when their version changes
Diffstat (limited to 'Meta/CMake')
-rw-r--r-- | Meta/CMake/unicode_data.cmake | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Meta/CMake/unicode_data.cmake b/Meta/CMake/unicode_data.cmake index 0da98d9025..cf5fe7a34c 100644 --- a/Meta/CMake/unicode_data.cmake +++ b/Meta/CMake/unicode_data.cmake @@ -4,6 +4,9 @@ set(CLDR_VERSION 39.0.0) 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") +set(UCD_VERSION_FILE "${UCD_PATH}/version.txt") +set(CLDR_VERSION_FILE "${CLDR_PATH}/version.txt") + set(UNICODE_DATA_URL "https://www.unicode.org/Public/${UCD_VERSION}/ucd/UnicodeData.txt") set(UNICODE_DATA_PATH "${UCD_PATH}/UnicodeData.txt") @@ -55,6 +58,23 @@ 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}") +function(remove_unicode_data_if_version_changed version version_file cache_path) + set(version_differs YES) + + if (EXISTS "${version_file}") + file(STRINGS "${version_file}" active_version) + if (version STREQUAL active_version) + set(version_differs NO) + endif() + endif() + + if (version_differs) + message(STATUS "Removing outdated ${cache_path} for version ${version}") + file(REMOVE_RECURSE "${cache_path}") + file(WRITE "${version_file}" "${version}") + endif() +endfunction() + function(download_ucd_file url path) if (NOT EXISTS "${path}") get_filename_component(file "${path}" NAME) @@ -74,6 +94,9 @@ function(extract_cldr_file source path) endfunction() if (ENABLE_UNICODE_DATABASE_DOWNLOAD) + remove_unicode_data_if_version_changed("${UCD_VERSION}" "${UCD_VERSION_FILE}" "${UCD_PATH}") + remove_unicode_data_if_version_changed("${CLDR_VERSION}" "${CLDR_VERSION_FILE}" "${CLDR_PATH}") + 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}") |