From 03e8d9aca73f3c6da2acc2c7e88a452bdf515c3b Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Thu, 15 Jun 2023 23:03:54 -0400 Subject: [PATCH 01/11] nx_tzdb: Correct Antarctica spelling --- externals/nx_tzdb/CMakeLists.txt | 2 +- externals/nx_tzdb/include/nx_tzdb.h | 2 +- src/core/file_sys/system_archive/time_zone_binary.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/externals/nx_tzdb/CMakeLists.txt b/externals/nx_tzdb/CMakeLists.txt index 2f625c108e..119ffe8d67 100644 --- a/externals/nx_tzdb/CMakeLists.txt +++ b/externals/nx_tzdb/CMakeLists.txt @@ -49,7 +49,7 @@ CreateHeader(${NX_TZDB_DIR}/zoneinfo/America/Argentina america_argentina) CreateHeader(${NX_TZDB_DIR}/zoneinfo/America/Indiana america_indiana) CreateHeader(${NX_TZDB_DIR}/zoneinfo/America/Kentucky america_kentucky) CreateHeader(${NX_TZDB_DIR}/zoneinfo/America/North_Dakota america_north_dakota) -CreateHeader(${NX_TZDB_DIR}/zoneinfo/Antartica antartica) +CreateHeader(${NX_TZDB_DIR}/zoneinfo/Antarctica antarctica) CreateHeader(${NX_TZDB_DIR}/zoneinfo/Arctic arctic) CreateHeader(${NX_TZDB_DIR}/zoneinfo/Asia asia) CreateHeader(${NX_TZDB_DIR}/zoneinfo/Atlantic atlantic) diff --git a/externals/nx_tzdb/include/nx_tzdb.h b/externals/nx_tzdb/include/nx_tzdb.h index d7b1e43046..1f7c6069ae 100644 --- a/externals/nx_tzdb/include/nx_tzdb.h +++ b/externals/nx_tzdb/include/nx_tzdb.h @@ -9,7 +9,7 @@ #include "nx_tzdb/america_indiana.h" #include "nx_tzdb/america_kentucky.h" #include "nx_tzdb/america_north_dakota.h" -#include "nx_tzdb/antartica.h" +#include "nx_tzdb/antarctica.h" #include "nx_tzdb/arctic.h" #include "nx_tzdb/asia.h" #include "nx_tzdb/atlantic.h" diff --git a/src/core/file_sys/system_archive/time_zone_binary.cpp b/src/core/file_sys/system_archive/time_zone_binary.cpp index ceb0b41c67..7c17bbefa5 100644 --- a/src/core/file_sys/system_archive/time_zone_binary.cpp +++ b/src/core/file_sys/system_archive/time_zone_binary.cpp @@ -15,7 +15,7 @@ namespace FileSys::SystemArchive { const static std::map>&> tzdb_zoneinfo_dirs = {{"Africa", NxTzdb::africa}, {"America", NxTzdb::america}, - {"Antartica", NxTzdb::antartica}, + {"Antarctica", NxTzdb::antarctica}, {"Arctic", NxTzdb::arctic}, {"Asia", NxTzdb::asia}, {"Atlantic", NxTzdb::atlantic}, From 8d8f850bd6d32e3f7b0cbbf40d771d49f6f22b1a Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Thu, 15 Jun 2023 23:05:41 -0400 Subject: [PATCH 02/11] time_zone_manager: Compare to the correct boolean Reference implementation does not compare the booleans as we had them. Use the correct ones as in the reference. Also adds an assert. I have been made aware of a crash here and am not able to reproduce currently. --- src/core/hle/service/time/time_zone_manager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/hle/service/time/time_zone_manager.cpp b/src/core/hle/service/time/time_zone_manager.cpp index e1728c06d5..63aacd19f1 100644 --- a/src/core/hle/service/time/time_zone_manager.cpp +++ b/src/core/hle/service/time/time_zone_manager.cpp @@ -849,8 +849,9 @@ static Result CreateCalendarTime(s64 time, int gmt_offset, CalendarTimeInternal& static Result ToCalendarTimeInternal(const TimeZoneRule& rules, s64 time, CalendarTimeInternal& calendar_time, CalendarAdditionalInfo& calendar_additional_info) { - if ((rules.go_ahead && time < rules.ats[0]) || - (rules.go_back && time > rules.ats[rules.time_count - 1])) { + ASSERT(rules.go_ahead ? rules.time_count > 0 : true); + if ((rules.go_back && time < rules.ats[0]) || + (rules.go_ahead && time > rules.ats[rules.time_count - 1])) { s64 seconds{}; if (time < rules.ats[0]) { seconds = rules.ats[0] - time; From cdc73498e3863c1ac60dc08db24661be79b1b426 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Fri, 16 Jun 2023 04:00:19 -0400 Subject: [PATCH 03/11] nx_tzdb: Support submoduling tzdb_to_nx Fix for flatpak having no internet access during CMake configure. --- externals/nx_tzdb/CMakeLists.txt | 39 +++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/externals/nx_tzdb/CMakeLists.txt b/externals/nx_tzdb/CMakeLists.txt index 119ffe8d67..d7e69a2efb 100644 --- a/externals/nx_tzdb/CMakeLists.txt +++ b/externals/nx_tzdb/CMakeLists.txt @@ -1,24 +1,47 @@ # SPDX-FileCopyrightText: 2023 yuzu Emulator Project # SPDX-License-Identifier: GPL-2.0-or-later -set(NX_TZDB_VERSION "220816") -set(NX_TZDB_DOWNLOAD_URL "https://github.com/lat9nq/tzdb_to_nx/releases/download/${NX_TZDB_VERSION}/${NX_TZDB_VERSION}.zip") - -set(NX_TZDB_ARCHIVE "${CMAKE_CURRENT_BINARY_DIR}/${NX_TZDB_VERSION}.zip") -set(NX_TZDB_DIR "${CMAKE_CURRENT_BINARY_DIR}/nx_tzdb") - set(NX_TZDB_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/include") -if (NOT EXISTS ${NX_TZDB_ARCHIVE}) +add_library(nx_tzdb INTERFACE) + +find_program(GIT git) +find_program(GNU_MAKE make) +find_program(GNU_DATE date) + +set(CAN_BUILD_NX_TZDB true) + +if ("${GIT}" STREQUAL "GIT-NOTFOUND") + message("git program not found") + set(CAN_BUILD_NX_TZDB false) +endif() +if ("${GNU_MAKE}" STREQUAL "GNU_MAKE-NOTFOUND") + message("GNU make program not found") + set(CAN_BUILD_NX_TZDB false) +endif() +if ("${GNU_DATE}" STREQUAL "GNU_DATE-NOTFOUND") + message("GNU date program not found") + set(CAN_BUILD_NX_TZDB false) +endif() + +if (NOT ${CAN_BUILD_NX_TZDB} AND NOT EXISTS ${NX_TZDB_ARCHIVE}) + set(NX_TZDB_VERSION "220816") + set(NX_TZDB_DOWNLOAD_URL "https://github.com/lat9nq/tzdb_to_nx/releases/download/${NX_TZDB_VERSION}/${NX_TZDB_VERSION}.zip") + + set(NX_TZDB_ARCHIVE "${CMAKE_CURRENT_BINARY_DIR}/${NX_TZDB_VERSION}.zip") + set(NX_TZDB_DIR "${CMAKE_CURRENT_BINARY_DIR}/nx_tzdb" CACHE PATH "Path to Switch-style time zone data") + file(DOWNLOAD ${NX_TZDB_DOWNLOAD_URL} ${NX_TZDB_ARCHIVE}) file(ARCHIVE_EXTRACT INPUT ${NX_TZDB_ARCHIVE} DESTINATION ${NX_TZDB_DIR}) +elseif (${CAN_BUILD_NX_TZDB}) + add_subdirectory(tzdb_to_nx) + add_dependencies(nx_tzdb x80e) endif() -add_library(nx_tzdb INTERFACE) target_include_directories(nx_tzdb INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include INTERFACE ${NX_TZDB_INCLUDE_DIR}) From b23c358e3d837bc4aab1444d23dd1d5915a79777 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Fri, 16 Jun 2023 04:15:19 -0400 Subject: [PATCH 04/11] externals: submodule tzdb_to_nx Fix for Flatpak being unable to download during CMake configure. --- .gitmodules | 3 +++ externals/nx_tzdb/tzdb_to_nx | 1 + 2 files changed, 4 insertions(+) create mode 160000 externals/nx_tzdb/tzdb_to_nx diff --git a/.gitmodules b/.gitmodules index 95eae81097..89f2ad924f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -52,3 +52,6 @@ [submodule "libadrenotools"] path = externals/libadrenotools url = https://github.com/bylaws/libadrenotools +[submodule "tzdb_to_nx"] + path = externals/nx_tzdb/tzdb_to_nx + url = https://github.com/lat9nq/tzdb_to_nx.git diff --git a/externals/nx_tzdb/tzdb_to_nx b/externals/nx_tzdb/tzdb_to_nx new file mode 160000 index 0000000000..34df65eff2 --- /dev/null +++ b/externals/nx_tzdb/tzdb_to_nx @@ -0,0 +1 @@ +Subproject commit 34df65eff295c2bd9ee9e6a077d662486d5cabb3 From e9701a3cda5907a2789457bc93771d87915920d4 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Fri, 16 Jun 2023 04:32:31 -0400 Subject: [PATCH 05/11] cmake: Add option to always download time zone data --- CMakeLists.txt | 2 ++ externals/nx_tzdb/CMakeLists.txt | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d03bbf94e..6d3146c9ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,8 @@ option(YUZU_CHECK_SUBMODULES "Check if submodules are present" ON) option(YUZU_ENABLE_LTO "Enable link-time optimization" OFF) +option(YUZU_DOWNLOAD_TIME_ZONE_DATA "Always download time zone binaries" OFF) + CMAKE_DEPENDENT_OPTION(YUZU_USE_FASTER_LD "Check if a faster linker is available" ON "NOT WIN32" OFF) # On Android, fetch and compile libcxx before doing anything else diff --git a/externals/nx_tzdb/CMakeLists.txt b/externals/nx_tzdb/CMakeLists.txt index d7e69a2efb..c15110fd6b 100644 --- a/externals/nx_tzdb/CMakeLists.txt +++ b/externals/nx_tzdb/CMakeLists.txt @@ -24,11 +24,12 @@ if ("${GNU_DATE}" STREQUAL "GNU_DATE-NOTFOUND") set(CAN_BUILD_NX_TZDB false) endif() -if (NOT ${CAN_BUILD_NX_TZDB} AND NOT EXISTS ${NX_TZDB_ARCHIVE}) - set(NX_TZDB_VERSION "220816") +set(NX_TZDB_VERSION "220816") +set(NX_TZDB_ARCHIVE "${CMAKE_CURRENT_BINARY_DIR}/${NX_TZDB_VERSION}.zip") + +if ((NOT ${CAN_BUILD_NX_TZDB} OR ${YUZU_DOWNLOAD_TIME_ZONE_DATA}) AND NOT EXISTS ${NX_TZDB_ARCHIVE}) set(NX_TZDB_DOWNLOAD_URL "https://github.com/lat9nq/tzdb_to_nx/releases/download/${NX_TZDB_VERSION}/${NX_TZDB_VERSION}.zip") - set(NX_TZDB_ARCHIVE "${CMAKE_CURRENT_BINARY_DIR}/${NX_TZDB_VERSION}.zip") set(NX_TZDB_DIR "${CMAKE_CURRENT_BINARY_DIR}/nx_tzdb" CACHE PATH "Path to Switch-style time zone data") file(DOWNLOAD ${NX_TZDB_DOWNLOAD_URL} ${NX_TZDB_ARCHIVE}) From 7ffb96f474ec970823111d6274c495df95081a66 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Fri, 16 Jun 2023 01:03:46 -0400 Subject: [PATCH 06/11] cmake: Extra time zone data download checks Extra sanitization for Windows hosts, and fail loudly when the download fails. cmake: Fix status code reading --- externals/nx_tzdb/CMakeLists.txt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/externals/nx_tzdb/CMakeLists.txt b/externals/nx_tzdb/CMakeLists.txt index c15110fd6b..67599faf46 100644 --- a/externals/nx_tzdb/CMakeLists.txt +++ b/externals/nx_tzdb/CMakeLists.txt @@ -12,27 +12,35 @@ find_program(GNU_DATE date) set(CAN_BUILD_NX_TZDB true) if ("${GIT}" STREQUAL "GIT-NOTFOUND") - message("git program not found") set(CAN_BUILD_NX_TZDB false) endif() if ("${GNU_MAKE}" STREQUAL "GNU_MAKE-NOTFOUND") - message("GNU make program not found") set(CAN_BUILD_NX_TZDB false) endif() if ("${GNU_DATE}" STREQUAL "GNU_DATE-NOTFOUND") - message("GNU date program not found") + set(CAN_BUILD_NX_TZDB false) +endif() +if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") + # tzdb_to_nx currently requires a posix-compliant host set(CAN_BUILD_NX_TZDB false) endif() set(NX_TZDB_VERSION "220816") set(NX_TZDB_ARCHIVE "${CMAKE_CURRENT_BINARY_DIR}/${NX_TZDB_VERSION}.zip") +set(NX_TZDB_DIR "${CMAKE_CURRENT_BINARY_DIR}/nx_tzdb") + if ((NOT ${CAN_BUILD_NX_TZDB} OR ${YUZU_DOWNLOAD_TIME_ZONE_DATA}) AND NOT EXISTS ${NX_TZDB_ARCHIVE}) set(NX_TZDB_DOWNLOAD_URL "https://github.com/lat9nq/tzdb_to_nx/releases/download/${NX_TZDB_VERSION}/${NX_TZDB_VERSION}.zip") - set(NX_TZDB_DIR "${CMAKE_CURRENT_BINARY_DIR}/nx_tzdb" CACHE PATH "Path to Switch-style time zone data") + 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}" STREQUAL "0") + message(FATAL_ERROR "Time zone data download failed (status code ${NX_TZDB_DOWNLOAD_STATUS_CODE})") + endif() - file(DOWNLOAD ${NX_TZDB_DOWNLOAD_URL} ${NX_TZDB_ARCHIVE}) file(ARCHIVE_EXTRACT INPUT ${NX_TZDB_ARCHIVE} From d35c9899020acdedf4ea7c23a5986fc2e2ceedeb Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Fri, 16 Jun 2023 05:07:30 -0400 Subject: [PATCH 07/11] cmake: Use non-conflicting variable names --- externals/nx_tzdb/CMakeLists.txt | 52 +++++++++++++++++--------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/externals/nx_tzdb/CMakeLists.txt b/externals/nx_tzdb/CMakeLists.txt index 67599faf46..1ec72d4182 100644 --- a/externals/nx_tzdb/CMakeLists.txt +++ b/externals/nx_tzdb/CMakeLists.txt @@ -28,7 +28,7 @@ endif() set(NX_TZDB_VERSION "220816") set(NX_TZDB_ARCHIVE "${CMAKE_CURRENT_BINARY_DIR}/${NX_TZDB_VERSION}.zip") -set(NX_TZDB_DIR "${CMAKE_CURRENT_BINARY_DIR}/nx_tzdb") +set(NX_TZDB_ROMFS_DIR "${CMAKE_CURRENT_BINARY_DIR}/nx_tzdb") if ((NOT ${CAN_BUILD_NX_TZDB} OR ${YUZU_DOWNLOAD_TIME_ZONE_DATA}) AND NOT EXISTS ${NX_TZDB_ARCHIVE}) set(NX_TZDB_DOWNLOAD_URL "https://github.com/lat9nq/tzdb_to_nx/releases/download/${NX_TZDB_VERSION}/${NX_TZDB_VERSION}.zip") @@ -45,10 +45,12 @@ if ((NOT ${CAN_BUILD_NX_TZDB} OR ${YUZU_DOWNLOAD_TIME_ZONE_DATA}) AND NOT EXISTS INPUT ${NX_TZDB_ARCHIVE} DESTINATION - ${NX_TZDB_DIR}) -elseif (${CAN_BUILD_NX_TZDB}) + ${NX_TZDB_ROMFS_DIR}) +elseif (${CAN_BUILD_NX_TZDB} AND NOT ${YUZU_DOWNLOAD_TIME_ZONE_DATA}) add_subdirectory(tzdb_to_nx) add_dependencies(nx_tzdb x80e) + + set(NX_TZDB_ROMFS_DIR "${NX_TZDB_DIR}") endif() target_include_directories(nx_tzdb @@ -73,25 +75,25 @@ function(CreateHeader ZONE_PATH HEADER_NAME) target_sources(nx_tzdb PRIVATE ${HEADER_PATH}) endfunction() -CreateHeader(${NX_TZDB_DIR} base) -CreateHeader(${NX_TZDB_DIR}/zoneinfo zoneinfo) -CreateHeader(${NX_TZDB_DIR}/zoneinfo/Africa africa) -CreateHeader(${NX_TZDB_DIR}/zoneinfo/America america) -CreateHeader(${NX_TZDB_DIR}/zoneinfo/America/Argentina america_argentina) -CreateHeader(${NX_TZDB_DIR}/zoneinfo/America/Indiana america_indiana) -CreateHeader(${NX_TZDB_DIR}/zoneinfo/America/Kentucky america_kentucky) -CreateHeader(${NX_TZDB_DIR}/zoneinfo/America/North_Dakota america_north_dakota) -CreateHeader(${NX_TZDB_DIR}/zoneinfo/Antarctica antarctica) -CreateHeader(${NX_TZDB_DIR}/zoneinfo/Arctic arctic) -CreateHeader(${NX_TZDB_DIR}/zoneinfo/Asia asia) -CreateHeader(${NX_TZDB_DIR}/zoneinfo/Atlantic atlantic) -CreateHeader(${NX_TZDB_DIR}/zoneinfo/Australia australia) -CreateHeader(${NX_TZDB_DIR}/zoneinfo/Brazil brazil) -CreateHeader(${NX_TZDB_DIR}/zoneinfo/Canada canada) -CreateHeader(${NX_TZDB_DIR}/zoneinfo/Chile chile) -CreateHeader(${NX_TZDB_DIR}/zoneinfo/Etc etc) -CreateHeader(${NX_TZDB_DIR}/zoneinfo/Europe europe) -CreateHeader(${NX_TZDB_DIR}/zoneinfo/Indian indian) -CreateHeader(${NX_TZDB_DIR}/zoneinfo/Mexico mexico) -CreateHeader(${NX_TZDB_DIR}/zoneinfo/Pacific pacific) -CreateHeader(${NX_TZDB_DIR}/zoneinfo/US us) +CreateHeader(${NX_TZDB_ROMFS_DIR} base) +CreateHeader(${NX_TZDB_ROMFS_DIR}/zoneinfo zoneinfo) +CreateHeader(${NX_TZDB_ROMFS_DIR}/zoneinfo/Africa africa) +CreateHeader(${NX_TZDB_ROMFS_DIR}/zoneinfo/America america) +CreateHeader(${NX_TZDB_ROMFS_DIR}/zoneinfo/America/Argentina america_argentina) +CreateHeader(${NX_TZDB_ROMFS_DIR}/zoneinfo/America/Indiana america_indiana) +CreateHeader(${NX_TZDB_ROMFS_DIR}/zoneinfo/America/Kentucky america_kentucky) +CreateHeader(${NX_TZDB_ROMFS_DIR}/zoneinfo/America/North_Dakota america_north_dakota) +CreateHeader(${NX_TZDB_ROMFS_DIR}/zoneinfo/Antarctica antarctica) +CreateHeader(${NX_TZDB_ROMFS_DIR}/zoneinfo/Arctic arctic) +CreateHeader(${NX_TZDB_ROMFS_DIR}/zoneinfo/Asia asia) +CreateHeader(${NX_TZDB_ROMFS_DIR}/zoneinfo/Atlantic atlantic) +CreateHeader(${NX_TZDB_ROMFS_DIR}/zoneinfo/Australia australia) +CreateHeader(${NX_TZDB_ROMFS_DIR}/zoneinfo/Brazil brazil) +CreateHeader(${NX_TZDB_ROMFS_DIR}/zoneinfo/Canada canada) +CreateHeader(${NX_TZDB_ROMFS_DIR}/zoneinfo/Chile chile) +CreateHeader(${NX_TZDB_ROMFS_DIR}/zoneinfo/Etc etc) +CreateHeader(${NX_TZDB_ROMFS_DIR}/zoneinfo/Europe europe) +CreateHeader(${NX_TZDB_ROMFS_DIR}/zoneinfo/Indian indian) +CreateHeader(${NX_TZDB_ROMFS_DIR}/zoneinfo/Mexico mexico) +CreateHeader(${NX_TZDB_ROMFS_DIR}/zoneinfo/Pacific pacific) +CreateHeader(${NX_TZDB_ROMFS_DIR}/zoneinfo/US us) From d9e2824c4e64b5bcfe3acbeaafdfe278320087d2 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Fri, 16 Jun 2023 05:32:11 -0400 Subject: [PATCH 08/11] cmake: Check for target is Windows MinGW has issues building tzdb2nx due to the headers being Windows specific. Download for this toolchain as well. --- externals/nx_tzdb/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externals/nx_tzdb/CMakeLists.txt b/externals/nx_tzdb/CMakeLists.txt index 1ec72d4182..db00e9d40b 100644 --- a/externals/nx_tzdb/CMakeLists.txt +++ b/externals/nx_tzdb/CMakeLists.txt @@ -20,7 +20,7 @@ endif() if ("${GNU_DATE}" STREQUAL "GNU_DATE-NOTFOUND") set(CAN_BUILD_NX_TZDB false) endif() -if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") +if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") # tzdb_to_nx currently requires a posix-compliant host set(CAN_BUILD_NX_TZDB false) endif() From 1fa16bc5943b997c28b2832b2f19a77eb689895b Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Fri, 16 Jun 2023 05:38:33 -0400 Subject: [PATCH 09/11] cmake: Add warn about cross compiling, disable android --- externals/nx_tzdb/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/externals/nx_tzdb/CMakeLists.txt b/externals/nx_tzdb/CMakeLists.txt index db00e9d40b..8429f82e58 100644 --- a/externals/nx_tzdb/CMakeLists.txt +++ b/externals/nx_tzdb/CMakeLists.txt @@ -20,8 +20,10 @@ endif() if ("${GNU_DATE}" STREQUAL "GNU_DATE-NOTFOUND") set(CAN_BUILD_NX_TZDB false) endif() -if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") +if ("${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() From 4cbdce17b69f4ab1f8da29c6718bec09e11b8125 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sat, 17 Jun 2023 01:35:35 -0400 Subject: [PATCH 10/11] nx_tzdb: Directly reference variables in if statements Addresses review feedback. --- externals/nx_tzdb/CMakeLists.txt | 14 +++++++------- externals/nx_tzdb/NxTzdbCreateHeader.cmake | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/externals/nx_tzdb/CMakeLists.txt b/externals/nx_tzdb/CMakeLists.txt index 8429f82e58..d5a1c6317b 100644 --- a/externals/nx_tzdb/CMakeLists.txt +++ b/externals/nx_tzdb/CMakeLists.txt @@ -11,16 +11,16 @@ find_program(GNU_DATE date) set(CAN_BUILD_NX_TZDB true) -if ("${GIT}" STREQUAL "GIT-NOTFOUND") +if (NOT GIT) set(CAN_BUILD_NX_TZDB false) endif() -if ("${GNU_MAKE}" STREQUAL "GNU_MAKE-NOTFOUND") +if (NOT GNU_MAKE) set(CAN_BUILD_NX_TZDB false) endif() -if ("${GNU_DATE}" STREQUAL "GNU_DATE-NOTFOUND") +if (NOT GNU_DATE) set(CAN_BUILD_NX_TZDB false) endif() -if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" OR ANDROID) +if (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 @@ -32,14 +32,14 @@ set(NX_TZDB_ARCHIVE "${CMAKE_CURRENT_BINARY_DIR}/${NX_TZDB_VERSION}.zip") set(NX_TZDB_ROMFS_DIR "${CMAKE_CURRENT_BINARY_DIR}/nx_tzdb") -if ((NOT ${CAN_BUILD_NX_TZDB} OR ${YUZU_DOWNLOAD_TIME_ZONE_DATA}) AND NOT EXISTS ${NX_TZDB_ARCHIVE}) +if ((NOT CAN_BUILD_NX_TZDB OR YUZU_DOWNLOAD_TIME_ZONE_DATA) AND NOT EXISTS ${NX_TZDB_ARCHIVE}) set(NX_TZDB_DOWNLOAD_URL "https://github.com/lat9nq/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}" STREQUAL "0") + 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() @@ -48,7 +48,7 @@ if ((NOT ${CAN_BUILD_NX_TZDB} OR ${YUZU_DOWNLOAD_TIME_ZONE_DATA}) AND NOT EXISTS ${NX_TZDB_ARCHIVE} DESTINATION ${NX_TZDB_ROMFS_DIR}) -elseif (${CAN_BUILD_NX_TZDB} AND NOT ${YUZU_DOWNLOAD_TIME_ZONE_DATA}) +elseif (CAN_BUILD_NX_TZDB AND NOT YUZU_DOWNLOAD_TIME_ZONE_DATA) add_subdirectory(tzdb_to_nx) add_dependencies(nx_tzdb x80e) diff --git a/externals/nx_tzdb/NxTzdbCreateHeader.cmake b/externals/nx_tzdb/NxTzdbCreateHeader.cmake index 69166aa5bc..8c29e1167b 100644 --- a/externals/nx_tzdb/NxTzdbCreateHeader.cmake +++ b/externals/nx_tzdb/NxTzdbCreateHeader.cmake @@ -15,7 +15,7 @@ set(DIRECTORY_NAME ${HEADER_NAME}) set(FILE_DATA "") foreach(ZONE_FILE ${FILE_LIST}) - if ("${ZONE_FILE}" STREQUAL "\n") + if (ZONE_FILE STREQUAL "\n") continue() endif() @@ -26,13 +26,13 @@ foreach(ZONE_FILE ${FILE_LIST}) 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 "") + string(SUBSTRING "${ZONE_DATA}" "${I}" 2 HEX_DATA) + if (NOT HEX_DATA) break() endif() string(APPEND FILE_DATA "0x${HEX_DATA},") - if ("${BREAK_LINE}" STREQUAL "0") + if (BREAK_LINE EQUAL 0) string(APPEND FILE_DATA "\n") else() string(APPEND FILE_DATA " ") From b99c4dd568fa12a833eeae25caeb9c0b1887465b Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sat, 17 Jun 2023 20:53:39 -0400 Subject: [PATCH 11/11] time_zone_service: Always write time zone rule data Switch firmware will initialize this data even if the given parameters are invalid. We should do the same. --- src/core/hle/service/time/time_zone_service.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/core/hle/service/time/time_zone_service.cpp b/src/core/hle/service/time/time_zone_service.cpp index e8273e152a..8171c82a5b 100644 --- a/src/core/hle/service/time/time_zone_service.cpp +++ b/src/core/hle/service/time/time_zone_service.cpp @@ -112,20 +112,14 @@ void ITimeZoneService::LoadTimeZoneRule(HLERequestContext& ctx) { LOG_DEBUG(Service_Time, "called, location_name={}", location_name); TimeZone::TimeZoneRule time_zone_rule{}; - if (const Result result{ - time_zone_content_manager.LoadTimeZoneRule(time_zone_rule, location_name)}; - result != ResultSuccess) { - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(result); - return; - } + const Result result{time_zone_content_manager.LoadTimeZoneRule(time_zone_rule, location_name)}; std::vector time_zone_rule_outbuffer(sizeof(TimeZone::TimeZoneRule)); std::memcpy(time_zone_rule_outbuffer.data(), &time_zone_rule, sizeof(TimeZone::TimeZoneRule)); ctx.WriteBuffer(time_zone_rule_outbuffer); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); + rb.Push(result); } void ITimeZoneService::ToCalendarTime(HLERequestContext& ctx) {