diff --git a/.github/workflows/build_presets.yml b/.github/workflows/build_presets.yml index 22dd0b8..31f9452 100644 --- a/.github/workflows/build_presets.yml +++ b/.github/workflows/build_presets.yml @@ -8,7 +8,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - preset: [MinSizeRel] + preset: [Release] runs-on: ${{ matrix.os }} container: devkitpro/devkita64:latest diff --git a/CMakePresets.json b/CMakePresets.json index 008d505..9fed1a8 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -16,19 +16,19 @@ "name": "Release", "displayName": "Release", "inherits":["core"], - "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" } + "cacheVariables": { + "CMAKE_BUILD_TYPE": "MinSizeRel", + "ENABLE_NETWORK_INSTALL": false + } }, { - "name": "RelWithDebInfo", - "displayName": "RelWithDebInfo", + "name": "ReleaseWithInstall", + "displayName": "ReleaseWithInstall", "inherits":["core"], - "cacheVariables": { "CMAKE_BUILD_TYPE":"RelWithDebInfo" } - }, - { - "name": "MinSizeRel", - "displayName": "MinSizeRel", - "inherits":["core"], - "cacheVariables": { "CMAKE_BUILD_TYPE":"MinSizeRel" } + "cacheVariables": { + "CMAKE_BUILD_TYPE": "MinSizeRel", + "ENABLE_NETWORK_INSTALL": true + } }, { "name": "Debug", @@ -44,13 +44,8 @@ "jobs": 16 }, { - "name": "RelWithDebInfo", - "configurePreset": "RelWithDebInfo", - "jobs": 16 - }, - { - "name": "MinSizeRel", - "configurePreset": "MinSizeRel", + "name": "ReleaseWithInstall", + "configurePreset": "ReleaseWithInstall", "jobs": 16 }, { diff --git a/build_release.sh b/build_release.sh index 9550c7e..9345287 100644 --- a/build_release.sh +++ b/build_release.sh @@ -8,13 +8,13 @@ build_preset() { cmake --build --preset $1 } -build_preset MinSizeRel +build_preset Release rm -rf out # --- SWITCH --- # mkdir -p out/switch/sphaira/ -cp -r build/MinSizeRel/*.nro out/switch/sphaira/sphaira.nro +cp -r build/Release/*.nro out/switch/sphaira/sphaira.nro pushd out zip -r9 sphaira.zip switch popd diff --git a/sphaira/CMakeLists.txt b/sphaira/CMakeLists.txt index 9528332..61a96c5 100644 --- a/sphaira/CMakeLists.txt +++ b/sphaira/CMakeLists.txt @@ -111,6 +111,7 @@ target_compile_definitions(sphaira PRIVATE -DAPP_VERSION="${sphaira_VERSION}" -DAPP_VERSION_HASH="${sphaira_VERSION_HASH}" -DCURL_NO_OLDIES=1 + -DENABLE_NETWORK_INSTALL=$ ) target_compile_options(sphaira PRIVATE diff --git a/sphaira/source/dumper.cpp b/sphaira/source/dumper.cpp index c9849cc..32a98b6 100644 --- a/sphaira/source/dumper.cpp +++ b/sphaira/source/dumper.cpp @@ -30,10 +30,13 @@ struct DumpLocationEntry { constexpr DumpLocationEntry DUMP_LOCATIONS[]{ { DumpLocationType_SdCard, "microSD card (/dumps/)" }, +#if ENABLE_NETWORK_INSTALL { DumpLocationType_UsbS2S, "USB transfer (Switch 2 Switch)" }, +#endif { DumpLocationType_DevNull, "/dev/null (Speed Test)" }, }; +#if ENABLE_NETWORK_INSTALL struct UsbTest final : usb::upload::Usb, yati::source::Stream { UsbTest(ui::ProgressBox* pbox, BaseSource* source) : Usb{UINT64_MAX} { m_pbox = pbox; @@ -97,6 +100,7 @@ private: s64 m_progress{}; s64 m_pull_offset{}; }; +#endif Result DumpToFile(ui::ProgressBox* pbox, fs::Fs* fs, const fs::FsPath& root, BaseSource* source, std::span paths) { const auto is_file_based_emummc = App::IsFileBaseEmummc(); @@ -150,6 +154,7 @@ Result DumpToStdio(ui::ProgressBox* pbox, const location::StdioEntry& loc, BaseS return DumpToFile(pbox, &fs, loc.mount, source, paths); } +#if ENABLE_NETWORK_INSTALL Result DumpToUsbS2SStream(ui::ProgressBox* pbox, UsbTest* usb, std::span paths) { auto source = usb->GetSource(); @@ -239,6 +244,7 @@ Result DumpToUsbS2S(ui::ProgressBox* pbox, BaseSource* source, std::span paths) { for (auto path : paths) { @@ -357,7 +363,9 @@ void Dump(const std::shared_ptr& source, const DumpLocation& locatio } else if (location.entry.type == DumpLocationType_SdCard) { R_TRY(DumpToFileNative(pbox, source.get(), paths)); } else if (location.entry.type == DumpLocationType_UsbS2S) { + #if ENABLE_NETWORK_INSTALL R_TRY(DumpToUsbS2S(pbox, source.get(), paths)); + #endif } else if (location.entry.type == DumpLocationType_DevNull) { R_TRY(DumpToDevNull(pbox, source.get(), paths)); } diff --git a/sphaira/source/ftpsrv_helper.cpp b/sphaira/source/ftpsrv_helper.cpp index 52c83f1..1eb5ec3 100644 --- a/sphaira/source/ftpsrv_helper.cpp +++ b/sphaira/source/ftpsrv_helper.cpp @@ -14,6 +14,7 @@ namespace sphaira::ftpsrv { namespace { +#if ENABLE_NETWORK_INSTALL struct InstallSharedData { Mutex mutex; std::deque queued_files; @@ -26,6 +27,7 @@ struct InstallSharedData { bool in_progress; bool enabled; }; +#endif const char* INI_PATH = "/config/ftpsrv/config.ini"; constexpr int THREAD_PRIO = PRIO_PREEMPTIVE; @@ -35,7 +37,6 @@ std::atomic_bool g_should_exit = false; bool g_is_running{false}; Thread g_thread; Mutex g_mutex{}; -InstallSharedData g_shared_data{}; void ftp_log_callback(enum FTP_API_LOG_TYPE type, const char* msg) { sphaira::App::NotifyFlashLed(); @@ -45,6 +46,9 @@ void ftp_progress_callback(void) { sphaira::App::NotifyFlashLed(); } +#if ENABLE_NETWORK_INSTALL +InstallSharedData g_shared_data{}; + const char* SUPPORTED_EXT[] = { ".nsp", ".xci", ".nsz", ".xcz", }; @@ -273,6 +277,7 @@ FtpVfs g_vfs_install = { .rmdir = vfs_install_rmdir, .rename = vfs_install_rename, }; +#endif void loop(void* arg) { log_write("[FTP] loop entered\n"); @@ -348,6 +353,7 @@ bool Init() { g_ftpsrv_config.anon = true; } +#if ENABLE_NETWORK_INSTALL const VfsNxCustomPath custom = { .name = "install", .user = NULL, @@ -355,6 +361,9 @@ bool Init() { }; vfs_nx_init(&custom, mount_devices, save_writable, mount_bis); +#else + vfs_nx_init(NULL, mount_devices, save_writable, mount_bis); +#endif Result rc; if (R_FAILED(rc = threadCreate(&g_thread, loop, nullptr, nullptr, 1024*16, THREAD_PRIO, THREAD_CORE))) { @@ -396,6 +405,7 @@ void Exit() { log_write("[FTP] exitied\n"); } +#if ENABLE_NETWORK_INSTALL void InitInstallMode(OnInstallStart on_start, OnInstallWrite on_write, OnInstallClose on_close) { SCOPED_MUTEX(&g_shared_data.mutex); g_shared_data.on_start = on_start; @@ -408,6 +418,7 @@ void DisableInstallMode() { SCOPED_MUTEX(&g_shared_data.mutex); g_shared_data.enabled = false; } +#endif unsigned GetPort() { SCOPED_MUTEX(&g_mutex); diff --git a/sphaira/source/haze_helper.cpp b/sphaira/source/haze_helper.cpp index edc8db1..3361883 100644 --- a/sphaira/source/haze_helper.cpp +++ b/sphaira/source/haze_helper.cpp @@ -12,6 +12,7 @@ namespace sphaira::haze { namespace { +#if ENABLE_NETWORK_INSTALL struct InstallSharedData { Mutex mutex; std::string current_file; @@ -24,12 +25,15 @@ struct InstallSharedData { bool in_progress; bool enabled; }; +#endif constexpr int THREAD_PRIO = PRIO_PREEMPTIVE; constexpr int THREAD_CORE = 2; std::atomic_bool g_should_exit = false; bool g_is_running{false}; Mutex g_mutex{}; + +#if ENABLE_NETWORK_INSTALL InstallSharedData g_shared_data{}; const char* SUPPORTED_EXT[] = { @@ -54,6 +58,7 @@ void on_thing() { } } } +#endif struct FsProxyBase : ::haze::FileSystemProxyImpl { FsProxyBase(const char* name, const char* display_name) : m_name{name}, m_display_name{display_name} { @@ -406,6 +411,7 @@ struct FsDevNullProxy final : FsProxyVfs { } }; +#if ENABLE_NETWORK_INSTALL struct FsInstallProxy final : FsProxyVfs { using FsProxyVfs::FsProxyVfs; @@ -531,6 +537,7 @@ struct FsInstallProxy final : FsProxyVfs { return false; } }; +#endif ::haze::FsEntries g_fs_entries{}; @@ -575,7 +582,9 @@ bool Init() { g_fs_entries.emplace_back(std::make_shared(std::make_unique(FsImageDirectoryId_Nand), "image_nand", "Image nand")); g_fs_entries.emplace_back(std::make_shared(std::make_unique(FsImageDirectoryId_Sd), "image_sd", "Image sd")); g_fs_entries.emplace_back(std::make_shared("DevNull", "DevNull (Speed Test)")); +#if ENABLE_NETWORK_INSTALL g_fs_entries.emplace_back(std::make_shared("install", "Install (NSP, XCI, NSZ, XCZ)")); +#endif g_should_exit = false; if (!::haze::Initialize(haze_callback, THREAD_PRIO, THREAD_CORE, g_fs_entries)) { @@ -600,6 +609,7 @@ void Exit() { log_write("[MTP] exitied\n"); } +#if ENABLE_NETWORK_INSTALL void InitInstallMode(OnInstallStart on_start, OnInstallWrite on_write, OnInstallClose on_close) { SCOPED_MUTEX(&g_shared_data.mutex); g_shared_data.on_start = on_start; @@ -612,5 +622,6 @@ void DisableInstallMode() { SCOPED_MUTEX(&g_shared_data.mutex); g_shared_data.enabled = false; } +#endif } // namespace sphaira::haze diff --git a/sphaira/source/ui/menus/ftp_menu.cpp b/sphaira/source/ui/menus/ftp_menu.cpp index 9872dd5..fe14e02 100644 --- a/sphaira/source/ui/menus/ftp_menu.cpp +++ b/sphaira/source/ui/menus/ftp_menu.cpp @@ -1,3 +1,5 @@ +#if ENABLE_NETWORK_INSTALL + #include "ui/menus/ftp_menu.hpp" #include "app.hpp" #include "defines.hpp" @@ -101,3 +103,5 @@ void Menu::OnDisableInstallMode() { } } // namespace sphaira::ui::menu::ftp + +#endif diff --git a/sphaira/source/ui/menus/install_stream_menu_base.cpp b/sphaira/source/ui/menus/install_stream_menu_base.cpp index 33fc770..9ae302d 100644 --- a/sphaira/source/ui/menus/install_stream_menu_base.cpp +++ b/sphaira/source/ui/menus/install_stream_menu_base.cpp @@ -1,3 +1,5 @@ +#if ENABLE_NETWORK_INSTALL + #include "ui/menus/install_stream_menu_base.hpp" #include "yati/yati.hpp" #include "app.hpp" @@ -273,3 +275,5 @@ void Menu::OnInstallClose() { } } // namespace sphaira::ui::menu::stream + +#endif diff --git a/sphaira/source/ui/menus/main_menu.cpp b/sphaira/source/ui/menus/main_menu.cpp index b782ab1..1d1f6d0 100644 --- a/sphaira/source/ui/menus/main_menu.cpp +++ b/sphaira/source/ui/menus/main_menu.cpp @@ -54,9 +54,11 @@ const MiscMenuEntry MISC_MENU_ENTRIES[] = { { .name = "Saves", .title = "Saves", .func = MiscMenuFuncGenerator, .flag = MiscMenuFlag_Shortcut }, { .name = "Themezer", .title = "Themezer", .func = MiscMenuFuncGenerator, .flag = MiscMenuFlag_Shortcut }, { .name = "GitHub", .title = "GitHub", .func = MiscMenuFuncGenerator, .flag = MiscMenuFlag_Shortcut }, +#if ENABLE_NETWORK_INSTALL { .name = "FTP", .title = "FTP Install", .func = MiscMenuFuncGenerator, .flag = MiscMenuFlag_Install }, { .name = "MTP", .title = "MTP Install", .func = MiscMenuFuncGenerator, .flag = MiscMenuFlag_Install }, { .name = "USB", .title = "USB Install", .func = MiscMenuFuncGenerator, .flag = MiscMenuFlag_Install }, +#endif { .name = "GameCard", .title = "GameCard", .func = MiscMenuFuncGenerator, .flag = MiscMenuFlag_Shortcut }, { .name = "IRS", .title = "IRS (Infrared Joycon Camera)", .func = MiscMenuFuncGenerator, .flag = MiscMenuFlag_Shortcut }, }; diff --git a/sphaira/source/ui/menus/mtp_menu.cpp b/sphaira/source/ui/menus/mtp_menu.cpp index be64f99..aa3086f 100644 --- a/sphaira/source/ui/menus/mtp_menu.cpp +++ b/sphaira/source/ui/menus/mtp_menu.cpp @@ -1,3 +1,5 @@ +#if ENABLE_NETWORK_INSTALL + #include "ui/menus/mtp_menu.hpp" #include "usb/usbds.hpp" #include "app.hpp" @@ -57,3 +59,5 @@ void Menu::OnDisableInstallMode() { } } // namespace sphaira::ui::menu::mtp + +#endif diff --git a/sphaira/source/ui/menus/usb_menu.cpp b/sphaira/source/ui/menus/usb_menu.cpp index ac4a7aa..90c4c8a 100644 --- a/sphaira/source/ui/menus/usb_menu.cpp +++ b/sphaira/source/ui/menus/usb_menu.cpp @@ -1,3 +1,5 @@ +#if ENABLE_NETWORK_INSTALL + #include "ui/menus/usb_menu.hpp" #include "yati/yati.hpp" #include "app.hpp" @@ -189,3 +191,5 @@ void Menu::ThreadFunction() { } } // namespace sphaira::ui::menu::usb + +#endif diff --git a/sphaira/source/usb/base.cpp b/sphaira/source/usb/base.cpp index 5f732ab..1040948 100644 --- a/sphaira/source/usb/base.cpp +++ b/sphaira/source/usb/base.cpp @@ -16,6 +16,8 @@ // The USB transfer code was taken from Haze (part of Atmosphere). +#if ENABLE_NETWORK_INSTALL + #include "usb/base.hpp" #include "log.hpp" #include "defines.hpp" @@ -98,3 +100,5 @@ Result Base::TransferAll(bool read, void *data, u32 size, u64 timeout) { } } // namespace sphaira::usb + +#endif diff --git a/sphaira/source/usb/usb_uploader.cpp b/sphaira/source/usb/usb_uploader.cpp index 93d3018..27c5409 100644 --- a/sphaira/source/usb/usb_uploader.cpp +++ b/sphaira/source/usb/usb_uploader.cpp @@ -1,4 +1,5 @@ // The USB protocol was taken from Tinfoil, by Adubbz. +#if ENABLE_NETWORK_INSTALL #include "usb/usb_uploader.hpp" #include "usb/tinfoil.hpp" @@ -109,3 +110,5 @@ Result Usb::FileRangeCmd(u64 data_size) { } } // namespace sphaira::usb::upload + +#endif diff --git a/sphaira/source/usb/usbds.cpp b/sphaira/source/usb/usbds.cpp index 40fe262..e2584e7 100644 --- a/sphaira/source/usb/usbds.cpp +++ b/sphaira/source/usb/usbds.cpp @@ -1,3 +1,5 @@ +#if ENABLE_NETWORK_INSTALL + #include "usb/usbds.hpp" #include "log.hpp" #include "defines.hpp" @@ -342,3 +344,5 @@ Result UsbDs::GetTransferResult(UsbSessionEndpoint ep, u32 urb_id, u32 *out_requ } } // namespace sphaira::usb + +#endif diff --git a/sphaira/source/usb/usbhs.cpp b/sphaira/source/usb/usbhs.cpp index db3b156..599e8e0 100644 --- a/sphaira/source/usb/usbhs.cpp +++ b/sphaira/source/usb/usbhs.cpp @@ -1,3 +1,5 @@ +#if ENABLE_NETWORK_INSTALL + #include "usb/usbhs.hpp" #include "log.hpp" #include "defines.hpp" @@ -200,3 +202,5 @@ Result UsbHs::GetTransferResult(UsbSessionEndpoint ep, u32 xfer_id, u32 *out_req } } // namespace sphaira::usb + +#endif diff --git a/sphaira/source/yati/source/usb.cpp b/sphaira/source/yati/source/usb.cpp index ceb1b84..8d25773 100644 --- a/sphaira/source/yati/source/usb.cpp +++ b/sphaira/source/yati/source/usb.cpp @@ -1,4 +1,5 @@ // The USB protocol was taken from Tinfoil, by Adubbz. +#if ENABLE_NETWORK_INSTALL #include "yati/source/usb.hpp" #include "usb/tinfoil.hpp" @@ -97,3 +98,5 @@ Result Usb::Read(void* buf, s64 off, s64 size, u64* bytes_read) { } } // namespace sphaira::yati::source + +#endif