diff options
author | lat9nq <22451773+lat9nq@users.noreply.github.com> | 2023-06-03 19:18:51 +0200 |
---|---|---|
committer | lat9nq <22451773+lat9nq@users.noreply.github.com> | 2023-06-05 21:15:22 +0200 |
commit | 73036c83a3805e5a0460cd5871743c88fe9405a5 (patch) | |
tree | c2f6e12af6ddeb38fd06f8549517a30ed0b4c7b7 /externals/nx_tzdb/NxTzdbCreateHeader.cmake | |
parent | time: Implement missing services (diff) | |
download | yuzu-73036c83a3805e5a0460cd5871743c88fe9405a5.tar yuzu-73036c83a3805e5a0460cd5871743c88fe9405a5.tar.gz yuzu-73036c83a3805e5a0460cd5871743c88fe9405a5.tar.bz2 yuzu-73036c83a3805e5a0460cd5871743c88fe9405a5.tar.lz yuzu-73036c83a3805e5a0460cd5871743c88fe9405a5.tar.xz yuzu-73036c83a3805e5a0460cd5871743c88fe9405a5.tar.zst yuzu-73036c83a3805e5a0460cd5871743c88fe9405a5.zip |
Diffstat (limited to 'externals/nx_tzdb/NxTzdbCreateHeader.cmake')
-rw-r--r-- | externals/nx_tzdb/NxTzdbCreateHeader.cmake | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/externals/nx_tzdb/NxTzdbCreateHeader.cmake b/externals/nx_tzdb/NxTzdbCreateHeader.cmake new file mode 100644 index 000000000..69166aa5b --- /dev/null +++ b/externals/nx_tzdb/NxTzdbCreateHeader.cmake @@ -0,0 +1,46 @@ +# SPDX-FileCopyrightText: 2023 yuzu Emulator Project +# SPDX-License-Identifier: GPL-2.0-or-later + +set(ZONE_PATH ${CMAKE_ARGV3}) +set(HEADER_NAME ${CMAKE_ARGV4}) +set(NX_TZDB_INCLUDE_DIR ${CMAKE_ARGV5}) +set(NX_TZDB_SOURCE_DIR ${CMAKE_ARGV6}) + +execute_process( + COMMAND ${CMAKE_COMMAND} -P ${NX_TZDB_SOURCE_DIR}/ListFilesInDirectory.cmake + WORKING_DIRECTORY ${ZONE_PATH} + OUTPUT_VARIABLE FILE_LIST) + +set(DIRECTORY_NAME ${HEADER_NAME}) + +set(FILE_DATA "") +foreach(ZONE_FILE ${FILE_LIST}) + if ("${ZONE_FILE}" STREQUAL "\n") + continue() + endif() + + string(APPEND FILE_DATA "{\"${ZONE_FILE}\",\n{") + + file(READ ${ZONE_PATH}/${ZONE_FILE} ZONE_DATA HEX) + string(LENGTH "${ZONE_DATA}" ZONE_DATA_LEN) + foreach(I RANGE 0 ${ZONE_DATA_LEN} 2) + math(EXPR BREAK_LINE "(${I} + 2) % 38") + + string(SUBSTRING "${ZONE_DATA}" "${I}" "2" HEX_DATA) + if ("${HEX_DATA}" STREQUAL "") + break() + endif() + + string(APPEND FILE_DATA "0x${HEX_DATA},") + if ("${BREAK_LINE}" STREQUAL "0") + string(APPEND FILE_DATA "\n") + else() + string(APPEND FILE_DATA " ") + endif() + endforeach() + + string(APPEND FILE_DATA "}},\n") +endforeach() + +file(READ ${NX_TZDB_SOURCE_DIR}/tzdb_template.h.in NX_TZDB_TEMPLATE_H_IN) +file(CONFIGURE OUTPUT ${NX_TZDB_INCLUDE_DIR}/nx_tzdb/${HEADER_NAME}.h CONTENT "${NX_TZDB_TEMPLATE_H_IN}") |