10 changed files with 0 additions and 327 deletions
-
3externals/CMakeLists.txt
-
10externals/cpmfile.json
-
111externals/nx_tzdb/CMakeLists.txt
-
8externals/nx_tzdb/ListFilesInDirectory.cmake
-
50externals/nx_tzdb/NxTzdbCreateHeader.cmake
-
27externals/nx_tzdb/include/nx_tzdb.h
-
18externals/nx_tzdb/tzdb_template.h.in
-
2src/core/CMakeLists.txt
-
86src/core/file_sys/system_archive/time_zone_binary.cpp
-
12src/core/file_sys/system_archive/time_zone_binary.h
@ -1,111 +0,0 @@ |
|||
# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project |
|||
# SPDX-License-Identifier: GPL-3.0-or-later |
|||
|
|||
# SPDX-FileCopyrightText: 2023 yuzu Emulator Project |
|||
# SPDX-License-Identifier: GPL-2.0-or-later |
|||
|
|||
set(NX_TZDB_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/include") |
|||
|
|||
add_library(nx_tzdb INTERFACE) |
|||
|
|||
find_program(GIT git) |
|||
find_program(GNU_MAKE make) |
|||
find_program(DATE_PROG date) |
|||
|
|||
set(CAN_BUILD_NX_TZDB true) |
|||
|
|||
if (NOT (GIT AND GNU_MAKE AND DATE_PROG) OR CMAKE_SYSTEM_NAME STREQUAL "Windows" OR ANDROID) |
|||
# tzdb_to_nx currently requires a posix-compliant host |
|||
# MinGW and Android are handled here due to the executable format being different from the host system |
|||
# TODO (lat9nq): cross-compiling support |
|||
|
|||
set(CAN_BUILD_NX_TZDB false) |
|||
endif() |
|||
|
|||
if (CAN_BUILD_NX_TZDB AND NOT YUZU_DOWNLOAD_TIME_ZONE_DATA) |
|||
message(FATAL_ERROR "Building tzdb is currently unsupported. Check back later.") |
|||
add_subdirectory(tzdb_to_nx) |
|||
add_dependencies(nx_tzdb x80e) |
|||
|
|||
set(NX_TZDB_BASE_DIR "${NX_TZDB_DIR}") |
|||
set(NX_TZDB_TZ_DIR "${NX_TZDB_BASE_DIR}/zoneinfo") |
|||
endif() |
|||
|
|||
if(NOT YUZU_TZDB_PATH STREQUAL "") |
|||
set(NX_TZDB_BASE_DIR "${YUZU_TZDB_PATH}") |
|||
elseif (MSVC AND NOT CXX_CLANG AND ENABLE_LTO) |
|||
# TODO(crueter): boot up the windows vm |
|||
set(NX_TZDB_VERSION "250725") |
|||
set(NX_TZDB_ARCHIVE "${CPM_SOURCE_CACHE}/nx_tzdb/${NX_TZDB_VERSION}.zip") |
|||
|
|||
set(NX_TZDB_BASE_DIR "${CPM_SOURCE_CACHE}/nx_tzdb/tz") |
|||
|
|||
set(NX_TZDB_DOWNLOAD_URL "https://git.crueter.xyz/misc/tzdb_to_nx/releases/download/${NX_TZDB_VERSION}/${NX_TZDB_VERSION}.zip") |
|||
|
|||
message(STATUS "Downloading time zone data from ${NX_TZDB_DOWNLOAD_URL}...") |
|||
file(DOWNLOAD ${NX_TZDB_DOWNLOAD_URL} ${NX_TZDB_ARCHIVE} |
|||
STATUS NX_TZDB_DOWNLOAD_STATUS) |
|||
|
|||
list(GET NX_TZDB_DOWNLOAD_STATUS 0 NX_TZDB_DOWNLOAD_STATUS_CODE) |
|||
if (NOT NX_TZDB_DOWNLOAD_STATUS_CODE EQUAL 0) |
|||
message(FATAL_ERROR "Time zone data download failed (status code ${NX_TZDB_DOWNLOAD_STATUS_CODE})") |
|||
endif() |
|||
|
|||
file(ARCHIVE_EXTRACT |
|||
INPUT |
|||
${NX_TZDB_ARCHIVE} |
|||
DESTINATION |
|||
${NX_TZDB_BASE_DIR}) |
|||
else() |
|||
message(STATUS "Downloading time zone data...") |
|||
AddJsonPackage(tzdb) |
|||
|
|||
set(NX_TZDB_BASE_DIR "${nx_tzdb_SOURCE_DIR}") |
|||
endif() |
|||
|
|||
set(NX_TZDB_TZ_DIR "${NX_TZDB_BASE_DIR}/zoneinfo") |
|||
|
|||
target_include_directories(nx_tzdb |
|||
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include |
|||
INTERFACE ${NX_TZDB_INCLUDE_DIR}) |
|||
|
|||
function(CreateHeader ZONE_PATH HEADER_NAME) |
|||
set(HEADER_PATH "${NX_TZDB_INCLUDE_DIR}/nx_tzdb/${HEADER_NAME}.h") |
|||
add_custom_command( |
|||
OUTPUT |
|||
${NX_TZDB_INCLUDE_DIR}/nx_tzdb/${HEADER_NAME}.h |
|||
COMMAND |
|||
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/NxTzdbCreateHeader.cmake |
|||
${ZONE_PATH} |
|||
${HEADER_NAME} |
|||
${NX_TZDB_INCLUDE_DIR} |
|||
${CMAKE_CURRENT_SOURCE_DIR} |
|||
DEPENDS |
|||
tzdb_template.h.in |
|||
NxTzdbCreateHeader.cmake) |
|||
|
|||
target_sources(nx_tzdb PRIVATE ${HEADER_PATH}) |
|||
endfunction() |
|||
|
|||
CreateHeader(${NX_TZDB_BASE_DIR} base) |
|||
CreateHeader(${NX_TZDB_TZ_DIR} zoneinfo) |
|||
CreateHeader(${NX_TZDB_TZ_DIR}/Africa africa) |
|||
CreateHeader(${NX_TZDB_TZ_DIR}/America america) |
|||
CreateHeader(${NX_TZDB_TZ_DIR}/America/Argentina america_argentina) |
|||
CreateHeader(${NX_TZDB_TZ_DIR}/America/Indiana america_indiana) |
|||
CreateHeader(${NX_TZDB_TZ_DIR}/America/Kentucky america_kentucky) |
|||
CreateHeader(${NX_TZDB_TZ_DIR}/America/North_Dakota america_north_dakota) |
|||
CreateHeader(${NX_TZDB_TZ_DIR}/Antarctica antarctica) |
|||
CreateHeader(${NX_TZDB_TZ_DIR}/Arctic arctic) |
|||
CreateHeader(${NX_TZDB_TZ_DIR}/Asia asia) |
|||
CreateHeader(${NX_TZDB_TZ_DIR}/Atlantic atlantic) |
|||
CreateHeader(${NX_TZDB_TZ_DIR}/Australia australia) |
|||
CreateHeader(${NX_TZDB_TZ_DIR}/Brazil brazil) |
|||
CreateHeader(${NX_TZDB_TZ_DIR}/Canada canada) |
|||
CreateHeader(${NX_TZDB_TZ_DIR}/Chile chile) |
|||
CreateHeader(${NX_TZDB_TZ_DIR}/Etc etc) |
|||
CreateHeader(${NX_TZDB_TZ_DIR}/Europe europe) |
|||
CreateHeader(${NX_TZDB_TZ_DIR}/Indian indian) |
|||
CreateHeader(${NX_TZDB_TZ_DIR}/Mexico mexico) |
|||
CreateHeader(${NX_TZDB_TZ_DIR}/Pacific pacific) |
|||
CreateHeader(${NX_TZDB_TZ_DIR}/US us) |
|||
@ -1,8 +0,0 @@ |
|||
# SPDX-FileCopyrightText: 2023 yuzu Emulator Project |
|||
# SPDX-License-Identifier: GPL-2.0-or-later |
|||
|
|||
# CMake does not have a way to list the files in a specific directory, |
|||
# so we need this script to do that for us in a platform-agnostic fashion |
|||
|
|||
file(GLOB FILE_LIST LIST_DIRECTORIES false RELATIVE ${CMAKE_SOURCE_DIR} "*") |
|||
execute_process(COMMAND ${CMAKE_COMMAND} -E echo "${FILE_LIST};") |
|||
@ -1,50 +0,0 @@ |
|||
# 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) |
|||
|
|||
if (NOT FILE_LIST) |
|||
message(FATAL_ERROR "No timezone files found in directory ${ZONE_PATH}, did the download fail?") |
|||
endif() |
|||
|
|||
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 (NOT HEX_DATA) |
|||
break() |
|||
endif() |
|||
|
|||
string(APPEND FILE_DATA "0x${HEX_DATA},") |
|||
if (BREAK_LINE EQUAL 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}") |
|||
@ -1,27 +0,0 @@ |
|||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project |
|||
// SPDX-License-Identifier: GPL-2.0-or-later |
|||
|
|||
#pragma once |
|||
|
|||
#include "nx_tzdb/africa.h" |
|||
#include "nx_tzdb/america.h" |
|||
#include "nx_tzdb/america_argentina.h" |
|||
#include "nx_tzdb/america_indiana.h" |
|||
#include "nx_tzdb/america_kentucky.h" |
|||
#include "nx_tzdb/america_north_dakota.h" |
|||
#include "nx_tzdb/antarctica.h" |
|||
#include "nx_tzdb/arctic.h" |
|||
#include "nx_tzdb/asia.h" |
|||
#include "nx_tzdb/atlantic.h" |
|||
#include "nx_tzdb/australia.h" |
|||
#include "nx_tzdb/base.h" |
|||
#include "nx_tzdb/brazil.h" |
|||
#include "nx_tzdb/canada.h" |
|||
#include "nx_tzdb/chile.h" |
|||
#include "nx_tzdb/etc.h" |
|||
#include "nx_tzdb/europe.h" |
|||
#include "nx_tzdb/indian.h" |
|||
#include "nx_tzdb/mexico.h" |
|||
#include "nx_tzdb/pacific.h" |
|||
#include "nx_tzdb/us.h" |
|||
#include "nx_tzdb/zoneinfo.h" |
|||
@ -1,18 +0,0 @@ |
|||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project |
|||
// SPDX-License-Identifier: GPL-2.0-or-later |
|||
|
|||
#pragma once |
|||
|
|||
#include <cstdint> |
|||
#include <map> |
|||
#include <vector> |
|||
|
|||
namespace NxTzdb { |
|||
|
|||
// clang-format off |
|||
const static std::map<const char*, const std::vector<uint8_t>> @DIRECTORY_NAME@ = |
|||
{ |
|||
@FILE_DATA@}; |
|||
// clang-format on |
|||
|
|||
} // namespace NxTzdb |
|||
@ -1,86 +0,0 @@ |
|||
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|||
|
|||
#include <vector>
|
|||
|
|||
#include "common/swap.h"
|
|||
#include "core/file_sys/system_archive/time_zone_binary.h"
|
|||
#include "core/file_sys/vfs/vfs_vector.h"
|
|||
|
|||
#include "nx_tzdb.h"
|
|||
|
|||
namespace FileSys::SystemArchive { |
|||
|
|||
const static std::map<std::string, const std::map<const char*, const std::vector<u8>>&> |
|||
tzdb_zoneinfo_dirs = {{"Africa", NxTzdb::africa}, |
|||
{"America", NxTzdb::america}, |
|||
{"Antarctica", NxTzdb::antarctica}, |
|||
{"Arctic", NxTzdb::arctic}, |
|||
{"Asia", NxTzdb::asia}, |
|||
{"Atlantic", NxTzdb::atlantic}, |
|||
{"Australia", NxTzdb::australia}, |
|||
{"Brazil", NxTzdb::brazil}, |
|||
{"Canada", NxTzdb::canada}, |
|||
{"Chile", NxTzdb::chile}, |
|||
{"Etc", NxTzdb::etc}, |
|||
{"Europe", NxTzdb::europe}, |
|||
{"Indian", NxTzdb::indian}, |
|||
{"Mexico", NxTzdb::mexico}, |
|||
{"Pacific", NxTzdb::pacific}, |
|||
{"US", NxTzdb::us}}; |
|||
|
|||
const static std::map<std::string, const std::map<const char*, const std::vector<u8>>&> |
|||
tzdb_america_dirs = {{"Argentina", NxTzdb::america_argentina}, |
|||
{"Indiana", NxTzdb::america_indiana}, |
|||
{"Kentucky", NxTzdb::america_kentucky}, |
|||
{"North_Dakota", NxTzdb::america_north_dakota}}; |
|||
|
|||
static void GenerateFiles(std::vector<VirtualFile>& directory, |
|||
const std::map<const char*, const std::vector<u8>>& files) { |
|||
for (const auto& [filename, data] : files) { |
|||
const auto data_copy{data}; |
|||
const std::string filename_copy{filename}; |
|||
VirtualFile file{ |
|||
std::make_shared<VectorVfsFile>(std::move(data_copy), std::move(filename_copy))}; |
|||
directory.push_back(file); |
|||
} |
|||
} |
|||
|
|||
static std::vector<VirtualFile> GenerateZoneinfoFiles() { |
|||
std::vector<VirtualFile> zoneinfo_files; |
|||
GenerateFiles(zoneinfo_files, NxTzdb::zoneinfo); |
|||
return zoneinfo_files; |
|||
} |
|||
|
|||
VirtualDir TimeZoneBinary() { |
|||
std::vector<VirtualDir> america_sub_dirs; |
|||
for (const auto& [dir_name, files] : tzdb_america_dirs) { |
|||
std::vector<VirtualFile> vfs_files; |
|||
GenerateFiles(vfs_files, files); |
|||
america_sub_dirs.push_back(std::make_shared<VectorVfsDirectory>( |
|||
std::move(vfs_files), std::vector<VirtualDir>{}, dir_name)); |
|||
} |
|||
|
|||
std::vector<VirtualDir> zoneinfo_sub_dirs; |
|||
for (const auto& [dir_name, files] : tzdb_zoneinfo_dirs) { |
|||
std::vector<VirtualFile> vfs_files; |
|||
GenerateFiles(vfs_files, files); |
|||
if (dir_name == "America") { |
|||
zoneinfo_sub_dirs.push_back(std::make_shared<VectorVfsDirectory>( |
|||
std::move(vfs_files), std::move(america_sub_dirs), dir_name)); |
|||
} else { |
|||
zoneinfo_sub_dirs.push_back(std::make_shared<VectorVfsDirectory>( |
|||
std::move(vfs_files), std::vector<VirtualDir>{}, dir_name)); |
|||
} |
|||
} |
|||
|
|||
std::vector<VirtualDir> zoneinfo_dir{std::make_shared<VectorVfsDirectory>( |
|||
GenerateZoneinfoFiles(), std::move(zoneinfo_sub_dirs), "zoneinfo")}; |
|||
std::vector<VirtualFile> root_files; |
|||
GenerateFiles(root_files, NxTzdb::base); |
|||
|
|||
return std::make_shared<VectorVfsDirectory>(std::move(root_files), std::move(zoneinfo_dir), |
|||
"data"); |
|||
} |
|||
|
|||
} // namespace FileSys::SystemArchive
|
|||
@ -1,12 +0,0 @@ |
|||
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project |
|||
// SPDX-License-Identifier: GPL-2.0-or-later |
|||
|
|||
#pragma once |
|||
|
|||
#include "core/file_sys/vfs/vfs_types.h" |
|||
|
|||
namespace FileSys::SystemArchive { |
|||
|
|||
VirtualDir TimeZoneBinary(); |
|||
|
|||
} // namespace FileSys::SystemArchive |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue