mirror of
https://github.com/starr-dusT/tzdb_to_nx
synced 2024-03-05 21:18:52 -08:00
tz: Use pure CMake to list TZif files
This commit is contained in:
parent
73fcec9bda
commit
e5a9681b37
20
externals/tz/CMakeLists.txt
vendored
20
externals/tz/CMakeLists.txt
vendored
@ -28,7 +28,23 @@ if (NOT EXISTS "${TZ_DIR}" OR NOT EXISTS "${TZIF_LIST_FILE}")
|
||||
|
||||
execute_process(
|
||||
COMMAND
|
||||
sh "${CMAKE_CURRENT_SOURCE_DIR}/find_tzif.sh" "${TZ_ZONEINFO_DIR}" "${TZIF_LIST_FILE}"
|
||||
COMMAND_ERROR_IS_FATAL ANY
|
||||
${CMAKE_COMMAND} -P "${CMAKE_CURRENT_SOURCE_DIR}/list_directory.cmake"
|
||||
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()
|
||||
|
14
externals/tz/find_tzif.sh
vendored
14
externals/tz/find_tzif.sh
vendored
@ -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
2
externals/tz/list_directory.cmake
vendored
Normal 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};")
|
Loading…
Reference in New Issue
Block a user