Meta: Move invoke_generator to utils.cmake

This commit is contained in:
Timothy Flynn 2021-12-22 16:30:21 -05:00 committed by Linus Groh
parent d5f14b5ff9
commit 9ba386a7bb
Notes: sideshowbarker 2024-07-17 21:26:59 +09:00
2 changed files with 25 additions and 17 deletions

View file

@ -87,23 +87,6 @@ function(extract_cldr_file source path)
endif()
endfunction()
function(invoke_generator name generator header implementation)
cmake_parse_arguments(invoke_generator "" "" "arguments" ${ARGN})
add_custom_command(
OUTPUT "${header}" "${implementation}"
COMMAND $<TARGET_FILE:${generator}> -h "${header}.tmp" -c "${implementation}.tmp" ${invoke_generator_arguments}
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${header}.tmp" "${header}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${implementation}.tmp" "${implementation}"
COMMAND "${CMAKE_COMMAND}" -E remove "${header}.tmp" "${implementation}.tmp"
VERBATIM
DEPENDS ${generator} "${UCD_VERSION_FILE}" "${CLDR_VERSION_FILE}"
)
add_custom_target(generate_${UNICODE_META_TARGET_PREFIX}${name} DEPENDS "${header}" "${implementation}")
add_dependencies(all_generated generate_${UNICODE_META_TARGET_PREFIX}${name})
endfunction()
if (ENABLE_UNICODE_DATABASE_DOWNLOAD)
remove_path_if_version_changed("${UCD_VERSION}" "${UCD_VERSION_FILE}" "${UCD_PATH}")
remove_path_if_version_changed("${CLDR_VERSION}" "${CLDR_VERSION_FILE}" "${CLDR_PATH}")
@ -167,6 +150,8 @@ if (ENABLE_UNICODE_DATABASE_DOWNLOAD)
invoke_generator(
"UnicodeData"
Lagom::GenerateUnicodeData
"${UCD_VERSION_FILE}"
"${UNICODE_META_TARGET_PREFIX}"
"${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}"
@ -174,6 +159,8 @@ if (ENABLE_UNICODE_DATABASE_DOWNLOAD)
invoke_generator(
"UnicodeDateTimeFormat"
Lagom::GenerateUnicodeDateTimeFormat
"${CLDR_VERSION_FILE}"
"${UNICODE_META_TARGET_PREFIX}"
"${UNICODE_DATE_TIME_FORMAT_HEADER}"
"${UNICODE_DATE_TIME_FORMAT_IMPLEMENTATION}"
arguments -r "${CLDR_CORE_PATH}" -d "${CLDR_DATES_PATH}"
@ -181,6 +168,8 @@ if (ENABLE_UNICODE_DATABASE_DOWNLOAD)
invoke_generator(
"UnicodeLocale"
Lagom::GenerateUnicodeLocale
"${CLDR_VERSION_FILE}"
"${UNICODE_META_TARGET_PREFIX}"
"${UNICODE_LOCALE_HEADER}"
"${UNICODE_LOCALE_IMPLEMENTATION}"
arguments -r "${CLDR_CORE_PATH}" -l "${CLDR_LOCALES_PATH}" -m "${CLDR_MISC_PATH}" -n "${CLDR_NUMBERS_PATH}" -d "${CLDR_DATES_PATH}"
@ -188,6 +177,8 @@ if (ENABLE_UNICODE_DATABASE_DOWNLOAD)
invoke_generator(
"UnicodeNumberFormat"
Lagom::GenerateUnicodeNumberFormat
"${CLDR_VERSION_FILE}"
"${UNICODE_META_TARGET_PREFIX}"
"${UNICODE_NUMBER_FORMAT_HEADER}"
"${UNICODE_NUMBER_FORMAT_IMPLEMENTATION}"
arguments -n "${CLDR_NUMBERS_PATH}" -u "${CLDR_UNITS_PATH}"

View file

@ -175,3 +175,20 @@ function(remove_path_if_version_changed version version_file cache_path)
file(WRITE "${version_file}" "${version}")
endif()
endfunction()
function(invoke_generator name generator version_file prefix header implementation)
cmake_parse_arguments(invoke_generator "" "" "arguments" ${ARGN})
add_custom_command(
OUTPUT "${header}" "${implementation}"
COMMAND $<TARGET_FILE:${generator}> -h "${header}.tmp" -c "${implementation}.tmp" ${invoke_generator_arguments}
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${header}.tmp" "${header}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${implementation}.tmp" "${implementation}"
COMMAND "${CMAKE_COMMAND}" -E remove "${header}.tmp" "${implementation}.tmp"
VERBATIM
DEPENDS ${generator} "${version_file}"
)
add_custom_target("generate_${prefix}${name}" DEPENDS "${header}" "${implementation}")
add_dependencies(all_generated "generate_${prefix}${name}")
endfunction()