mirror of
https://github.com/starr-dusT/tzdb_to_nx
synced 2024-03-05 21:18:52 -08:00
tzdb: Generate nx time zone files
This commit is contained in:
parent
e2eec38882
commit
526b765d8c
@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 3.10)
|
|||||||
|
|
||||||
project(tzdb2nx VERSION 1.0)
|
project(tzdb2nx VERSION 1.0)
|
||||||
|
|
||||||
|
set(TZDB_VERSION "$ENV{TZDB_VERSION}")
|
||||||
|
if ("${TZDB_VERSION}" STREQUAL "")
|
||||||
|
set(TZDB_VERSION "2022c")
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
@ -8,3 +8,4 @@ add_compile_options(
|
|||||||
include_directories(.)
|
include_directories(.)
|
||||||
|
|
||||||
add_subdirectory(tzdb2nx)
|
add_subdirectory(tzdb2nx)
|
||||||
|
add_subdirectory(tzdb)
|
||||||
|
65
src/tzdb/CMakeLists.txt
Normal file
65
src/tzdb/CMakeLists.txt
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
find_program(GNU_MAKE make)
|
||||||
|
if ("${GNU_MAKE}" STREQUAL "GNU_MAKE-NOTFOUND")
|
||||||
|
message(ERROR "make program not found")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(TZDB_ARCHIVE "tzdb-${TZDB_VERSION}.tar.lz")
|
||||||
|
set(TZDB_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/tzdb-${TZDB_VERSION}")
|
||||||
|
if (NOT (EXISTS "${CMAKE_CURRENT_BINARY_DIR}/${TZDB_ARCHIVE}" AND EXISTS "${TZDB_LOCATION}"))
|
||||||
|
file(DOWNLOAD "https://data.iana.org/time-zones/releases/${TZDB_ARCHIVE}" "${CMAKE_CURRENT_BINARY_DIR}/${TZDB_ARCHIVE}")
|
||||||
|
file(ARCHIVE_EXTRACT INPUT "${CMAKE_CURRENT_BINARY_DIR}/${TZDB_ARCHIVE}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(TZDB_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/build")
|
||||||
|
set(TZDB_ZONEINFO "${TZDB_BUILD_DIR}/usr/share/zoneinfo")
|
||||||
|
set(TZIF_LIST_FILE "${CMAKE_CURRENT_BINARY_DIR}/tzif_list.txt")
|
||||||
|
|
||||||
|
set(NX_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/nx")
|
||||||
|
|
||||||
|
add_custom_target(x80e
|
||||||
|
ALL
|
||||||
|
DEPENDS
|
||||||
|
tzdb2nx)
|
||||||
|
|
||||||
|
if (NOT EXISTS "${TZDB_BUILD_DIR}" OR NOT EXISTS ${TZIF_LIST_FILE})
|
||||||
|
execute_process(
|
||||||
|
COMMAND
|
||||||
|
"${GNU_MAKE}" DESTDIR=${TZDB_BUILD_DIR} install
|
||||||
|
WORKING_DIRECTORY
|
||||||
|
"${TZDB_LOCATION}"
|
||||||
|
COMMAND_ERROR_IS_FATAL ANY
|
||||||
|
)
|
||||||
|
|
||||||
|
# execute_process(
|
||||||
|
# COMMAND
|
||||||
|
# "${TZDB_LOCATION}/zic" -b fat -d ${TZDB_ZONEINFO} africa antarctica asia australasia europe northamerica southamerica etcetera backward factory
|
||||||
|
# WORKING_DIRECTORY
|
||||||
|
# "${TZDB_LOCATION}"
|
||||||
|
# COMMAND_ERROR_IS_FATAL ANY
|
||||||
|
# )
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND
|
||||||
|
/bin/bash "${CMAKE_CURRENT_SOURCE_DIR}/find_tzif.sh" "${TZDB_ZONEINFO}" "${TZIF_LIST_FILE}"
|
||||||
|
COMMAND_ERROR_IS_FATAL ANY
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
file(STRINGS "${TZIF_LIST_FILE}" TZ_FILES)
|
||||||
|
foreach(FILE ${TZ_FILES})
|
||||||
|
file(RELATIVE_PATH TARG "${TZDB_ZONEINFO}" "${FILE}")
|
||||||
|
get_filename_component(TARG_PATH "${NX_BUILD_DIR}/${TARG}" DIRECTORY)
|
||||||
|
string(REGEX REPLACE "\/" "_" TARG_SANITIZED "${TARG}")
|
||||||
|
add_custom_target(${TARG_SANITIZED}
|
||||||
|
BYPRODUCTS
|
||||||
|
${NX_BUILD_DIR}/${TARG}
|
||||||
|
COMMAND
|
||||||
|
mkdir -p ${TARG_PATH}
|
||||||
|
COMMAND
|
||||||
|
"${PROJECT_BINARY_DIR}/src/tzdb2nx/tzdb2nx" ${FILE} ${NX_BUILD_DIR}/${TARG}
|
||||||
|
DEPENDS
|
||||||
|
tzdb2nx
|
||||||
|
)
|
||||||
|
|
||||||
|
add_dependencies(x80e ${TARG_SANITIZED})
|
||||||
|
endforeach()
|
14
src/tzdb/find_tzif.sh
Normal file
14
src/tzdb/find_tzif.sh
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#/bin/bash
|
||||||
|
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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user