tz: Use pure CMake to list TZif files

This commit is contained in:
lat9nq 2023-06-23 17:24:33 -04:00
parent 73fcec9bda
commit e5a9681b37
3 changed files with 20 additions and 16 deletions

View File

@ -28,7 +28,23 @@ if (NOT EXISTS "${TZ_DIR}" OR NOT EXISTS "${TZIF_LIST_FILE}")
execute_process( execute_process(
COMMAND COMMAND
sh "${CMAKE_CURRENT_SOURCE_DIR}/find_tzif.sh" "${TZ_ZONEINFO_DIR}" "${TZIF_LIST_FILE}" ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_SOURCE_DIR}/list_directory.cmake"
COMMAND_ERROR_IS_FATAL ANY WORKING_DIRECTORY
"${TZ_ZONEINFO_DIR}"
OUTPUT_VARIABLE
TZIF_SCAN
) )
set(TZIF_LIST "")
foreach(CANDIDATE ${TZIF_SCAN})
if (CANDIDATE STREQUAL "\n")
continue()
endif()
set(TZIF_FILE "${TZ_ZONEINFO_DIR}/${CANDIDATE}")
file(READ "${TZIF_FILE}" HEADER LIMIT 4)
string(SUBSTRING "${HEADER}" 0 4 HEADER) # Remove trailing newline
if (HEADER STREQUAL "TZif")
file(APPEND "${TZIF_LIST_FILE}" "${TZIF_FILE}\n")
endif()
endforeach()
endif() endif()

View File

@ -1,14 +0,0 @@
#/bin/sh
set -e
directory=$1
tzif_list=$2
truncate -s 0 $tzif_list
for i in `find $directory -type f`; do
header=`head -c 4 $i`
if [ "$header" = "TZif" ]; then
echo "$i" >> $tzif_list
fi
done

2
externals/tz/list_directory.cmake vendored Normal file
View File

@ -0,0 +1,2 @@
file(GLOB_RECURSE FILE_LIST LIST_DIRECTORIES false RELATIVE ${CMAKE_SOURCE_DIR} "*")
execute_process(COMMAND ${CMAKE_COMMAND} -E echo "${FILE_LIST};")