From d86b25c460e6d51ac70319423a94f6bb94b7d56a Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Mon, 22 Aug 2022 10:31:06 -0400 Subject: [PATCH] Meta: Move downloading of emoji-test.txt to unicode_data.cmake The current emoji_txt.cmake does not handle download errors (which were a common source of issues in the build problems channel) or Unicode versioning. These are both handled by unicode_data.cmake. Move the download to unicode_data.cmake so that we can more easily handle next month's Unicode 15 release. --- CMakeLists.txt | 1 - Meta/CMake/emoji_txt.cmake | 23 ----------------------- Meta/CMake/unicode_data.cmake | 20 ++++++++++++++++++++ 3 files changed, 20 insertions(+), 24 deletions(-) delete mode 100644 Meta/CMake/emoji_txt.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 101d4465faf..4f80c58178a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -206,7 +206,6 @@ option(BUILD_EVERYTHING "Build all optional components" ON) include(utils) include(wasm_spec_tests) -include(emoji_txt) serenity_component( Tests diff --git a/Meta/CMake/emoji_txt.cmake b/Meta/CMake/emoji_txt.cmake deleted file mode 100644 index 387be723399..00000000000 --- a/Meta/CMake/emoji_txt.cmake +++ /dev/null @@ -1,23 +0,0 @@ -option(ENABLE_EMOJI_TXT_GENERATION "Enable download of emoji-test.txt and generation of emoji.txt at build time" ON) - -set(EMOJI_TEST_TXT_PATH ${CMAKE_BINARY_DIR}/emoji-test.txt) -set(EMOJI_TEST_TXT_URL https://unicode.org/Public/emoji/14.0/emoji-test.txt) - -if(ENABLE_EMOJI_TXT_GENERATION) - if(NOT EXISTS ${EMOJI_TEST_TXT_PATH}) - file(DOWNLOAD ${EMOJI_TEST_TXT_URL} ${EMOJI_TEST_TXT_PATH}) - endif() - set(EMOJI_RES_PATH "${SerenityOS_SOURCE_DIR}/Base/res/emoji") - set(EMOJI_TXT_INSTALL_PATH "${SerenityOS_SOURCE_DIR}/Base/home/anon/Documents/emoji.txt") - add_custom_command( - OUTPUT ${EMOJI_TXT_INSTALL_PATH} - COMMAND ${SerenityOS_SOURCE_DIR}/Meta/generate-emoji-txt.sh "${EMOJI_TEST_TXT_PATH}" "${EMOJI_RES_PATH}" "${EMOJI_TXT_INSTALL_PATH}" - # This will make this command only run when the modified time of the directory changes, - # which only happens if files within it are added or deleted, but not when a file is modified. - # This is fine for this use-case, because the contents of a file changing should not affect - # the generated emoji.txt file. - MAIN_DEPENDENCY ${EMOJI_RES_PATH} - USES_TERMINAL - ) - add_custom_target(generate_emoji_txt ALL DEPENDS ${EMOJI_TXT_INSTALL_PATH}) -endif() diff --git a/Meta/CMake/unicode_data.cmake b/Meta/CMake/unicode_data.cmake index 0adbed2d50b..7af21f69f1e 100644 --- a/Meta/CMake/unicode_data.cmake +++ b/Meta/CMake/unicode_data.cmake @@ -63,6 +63,12 @@ set(WORD_BREAK_PROP_PATH "${UCD_PATH}/${WORD_BREAK_PROP_SOURCE}") set(SENTENCE_BREAK_PROP_SOURCE "auxiliary/SentenceBreakProperty.txt") set(SENTENCE_BREAK_PROP_PATH "${UCD_PATH}/${SENTENCE_BREAK_PROP_SOURCE}") +string(REGEX REPLACE "([0-9]+\\.[0-9]+)\\.[0-9]+" "\\1" EMOJI_VERSION "${UCD_VERSION}") +set(EMOJI_TEST_URL "https://unicode.org/Public/emoji/${EMOJI_VERSION}/emoji-test.txt") +set(EMOJI_TEST_PATH "${UCD_PATH}/emoji-test.txt") +set(EMOJI_RES_PATH "${SerenityOS_SOURCE_DIR}/Base/res/emoji") +set(EMOJI_INSTALL_PATH "${SerenityOS_SOURCE_DIR}/Base/home/anon/Documents/emoji.txt") + 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 "${CLDR_PATH}/cldr.zip") @@ -120,6 +126,8 @@ if (ENABLE_UNICODE_DATABASE_DOWNLOAD) extract_path("${UCD_PATH}" "${UCD_ZIP_PATH}" "${WORD_BREAK_PROP_SOURCE}" "${WORD_BREAK_PROP_PATH}") extract_path("${UCD_PATH}" "${UCD_ZIP_PATH}" "${SENTENCE_BREAK_PROP_SOURCE}" "${SENTENCE_BREAK_PROP_PATH}") + download_file("${EMOJI_TEST_URL}" "${EMOJI_TEST_PATH}") + download_file("${CLDR_ZIP_URL}" "${CLDR_ZIP_PATH}") extract_path("${CLDR_PATH}" "${CLDR_ZIP_PATH}" "${CLDR_BCP47_SOURCE}/**" "${CLDR_BCP47_PATH}") extract_path("${CLDR_PATH}" "${CLDR_ZIP_PATH}" "${CLDR_CORE_SOURCE}/**" "${CLDR_CORE_PATH}") @@ -226,6 +234,18 @@ if (ENABLE_UNICODE_DATABASE_DOWNLOAD) arguments -d "${CLDR_DATES_PATH}" ) + add_custom_command( + OUTPUT "${EMOJI_INSTALL_PATH}" + COMMAND "${SerenityOS_SOURCE_DIR}/Meta/generate-emoji-txt.sh" "${EMOJI_TEST_PATH}" "${EMOJI_RES_PATH}" "${EMOJI_INSTALL_PATH}" + # This will make this command only run when the modified time of the directory changes, + # which only happens if files within it are added or deleted, but not when a file is modified. + # This is fine for this use-case, because the contents of a file changing should not affect + # the generated emoji.txt file. + DEPENDS "${EMOJI_RES_PATH}" "${EMOJI_TEST_PATH}" + USES_TERMINAL + ) + add_custom_target(generate_emoji_txt ALL DEPENDS "${EMOJI_INSTALL_PATH}") + set(UNICODE_DATA_SOURCES ${UNICODE_DATA_HEADER} ${UNICODE_DATA_IMPLEMENTATION}