mirror of
https://github.com/starr-dusT/tzdb_to_nx
synced 2024-03-05 21:18:52 -08:00
general: Use a submodule of eggert/tz
This commit is contained in:
parent
2beb8c93d2
commit
467e965659
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "externals/tz/tz"]
|
||||
path = externals/tz/tz
|
||||
url = https://github.com/eggert/tz.git
|
@ -2,11 +2,7 @@ cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
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)
|
||||
|
||||
add_subdirectory(externals)
|
||||
add_subdirectory(src)
|
||||
|
1
externals/CMakeLists.txt
vendored
Normal file
1
externals/CMakeLists.txt
vendored
Normal file
@ -0,0 +1 @@
|
||||
add_subdirectory(tz)
|
34
externals/tz/CMakeLists.txt
vendored
Normal file
34
externals/tz/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
set(TZ_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tz")
|
||||
set(TZ_DIR "${CMAKE_CURRENT_BINARY_DIR}/tz")
|
||||
set(TZ_ZONEINFO_DIR "${TZ_DIR}/usr/share/zoneinfo" CACHE PATH "Time zone info data directory")
|
||||
set(TZIF_LIST_FILE "${CMAKE_CURRENT_BINARY_DIR}/tzif_list.txt" CACHE PATH "List of zone info files")
|
||||
|
||||
find_program(GNU_MAKE make)
|
||||
if ("${GNU_MAKE}" STREQUAL "GNU_MAKE-NOTFOUND")
|
||||
message(FATAL_ERROR "GNU make not found")
|
||||
endif()
|
||||
|
||||
if (NOT EXISTS "${TZ_DIR}" OR NOT EXISTS "${TZIF_LIST_FILE}")
|
||||
execute_process(
|
||||
COMMAND
|
||||
${GNU_MAKE} DESTDIR=${TZ_DIR} install
|
||||
WORKING_DIRECTORY
|
||||
${TZ_SOURCE_DIR}
|
||||
COMMAND_ERROR_IS_FATAL ANY
|
||||
)
|
||||
|
||||
# Step taken by Arch Linux packaging, but Nintendo apparently skips it
|
||||
# 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" "${TZ_ZONEINFO_DIR}" "${TZIF_LIST_FILE}"
|
||||
COMMAND_ERROR_IS_FATAL ANY
|
||||
)
|
||||
endif()
|
1
externals/tz/tz
vendored
Submodule
1
externals/tz/tz
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit ce4d77644d2793027bb27f095dec7b530edcd947
|
@ -1,21 +1,10 @@
|
||||
find_program(GNU_MAKE make)
|
||||
if ("${GNU_MAKE}" STREQUAL "GNU_MAKE-NOTFOUND")
|
||||
message(ERROR "make program not found")
|
||||
endif()
|
||||
set(NX_TZDB_DIR "${CMAKE_CURRENT_BINARY_DIR}/nx" CACHE PATH "Path to Switch-style time zone data")
|
||||
set(NX_ZONEINFO_DIR "${NX_TZDB_DIR}/zoneinfo")
|
||||
|
||||
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 "${PROJECT_BINARY_DIR}/nx")
|
||||
set(NX_ZONEINFO_DIR "${NX_BUILD_DIR}/zoneinfo")
|
||||
set(TZDB_VERSION_FILE ${TZDB_LOCATION}/version)
|
||||
file(TIMESTAMP ${TZDB_VERSION_FILE} TZDB_VERSION "%y%m%d" UTC)
|
||||
set(NX_VERSION_FILE ${NX_TZDB_DIR}/version.txt)
|
||||
file(WRITE ${NX_VERSION_FILE} "${TZDB_VERSION}")
|
||||
|
||||
add_custom_target(x80e
|
||||
ALL
|
||||
@ -23,37 +12,7 @@ add_custom_target(x80e
|
||||
tzdb2nx
|
||||
${NX_VERSION_FILE})
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
# Step taken by Arch Linux packaging, but Nintendo apparently skips it
|
||||
# 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()
|
||||
|
||||
set(TZDB_VERSION_FILE ${TZDB_LOCATION}/version)
|
||||
file(TIMESTAMP ${TZDB_VERSION_FILE} TZDB_VERSION "%y%m%d" UTC)
|
||||
set(NX_VERSION_FILE ${NX_BUILD_DIR}/version.txt)
|
||||
file(WRITE ${NX_VERSION_FILE} "${TZDB_VERSION}")
|
||||
|
||||
set(BINARY_LIST_TXT ${NX_BUILD_DIR}/binaryList.txt)
|
||||
set(BINARY_LIST_TXT ${NX_TZDB_DIR}/binaryList.txt)
|
||||
add_custom_target(binary_list
|
||||
bash ${CMAKE_CURRENT_SOURCE_DIR}/generate_binary_list_txt.sh ${BINARY_LIST_TXT}
|
||||
BYPRODUCTS
|
||||
@ -64,7 +23,7 @@ add_dependencies(x80e binary_list)
|
||||
|
||||
file(STRINGS "${TZIF_LIST_FILE}" TZ_FILES)
|
||||
foreach(FILE ${TZ_FILES})
|
||||
file(RELATIVE_PATH TARG "${TZDB_ZONEINFO}" "${FILE}")
|
||||
file(RELATIVE_PATH TARG "${TZ_ZONEINFO_DIR}" "${FILE}")
|
||||
get_filename_component(TARG_PATH "${NX_ZONEINFO_DIR}/${TARG}" DIRECTORY)
|
||||
string(REGEX REPLACE "\/" "_" TARG_SANITIZED "${TARG}")
|
||||
add_custom_target(${TARG_SANITIZED}
|
||||
@ -73,10 +32,9 @@ foreach(FILE ${TZ_FILES})
|
||||
COMMAND
|
||||
mkdir -p ${TARG_PATH}
|
||||
COMMAND
|
||||
"${PROJECT_BINARY_DIR}/src/tzdb2nx/tzdb2nx" ${FILE} ${NX_ZONEINFO_DIR}/${TARG}
|
||||
${TZDB2NX_PATH} ${FILE} ${NX_ZONEINFO_DIR}/${TARG}
|
||||
DEPENDS
|
||||
tzdb2nx
|
||||
)
|
||||
tzdb2nx)
|
||||
|
||||
add_dependencies(x80e ${TARG_SANITIZED})
|
||||
add_dependencies(binary_list ${TARG_SANITIZED})
|
||||
|
@ -2,3 +2,6 @@ add_executable(tzdb2nx
|
||||
main.cpp
|
||||
tzif.cpp
|
||||
tzif.h)
|
||||
|
||||
set(TZDB2NX_PATH "${CMAKE_CURRENT_BINARY_DIR}/tzdb2nx" CACHE PATH "Path to tzdb2nx path")
|
||||
set_target_properties(tzdb2nx PROPERTIES CMAKE_RUNTIME_OUTPUT_DIRECTORY ${TZDB2NX_PATH})
|
||||
|
Loading…
Reference in New Issue
Block a user