diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e48c3c54..ea26d250 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -20,7 +20,7 @@ permissions: jobs: upload-release: - needs: [ build-msvc-x64, build-mingw64, build-switch, build-macos, build-snap ] + needs: [ build-msvc-x64, build-switch, build-macos ] runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') steps: @@ -43,7 +43,6 @@ jobs: - uses: actions/checkout@v3 with: submodules: recursive - fetch-depth: 0 - name: Update dependencies run: | for p in `curl -sL https://api.github.com/repos/${{ github.repository }}/releases/tags/switch-portlibs | grep browser_download_url | cut -d\" -f4`; do dkp-pacman --noconfirm -U $p; done @@ -54,7 +53,7 @@ jobs: git config --system --add safe.directory '*' - name: Build nro run: | - cmake -B build_switch -DPLATFORM_SWITCH=ON -DBUILTIN_NSP=ON + cmake -B build_switch -DPLATFORM_SWITCH=ON -DBUILTIN_NSP=ON -DVERSION_BUILD=${{ github.run_number }} make -C build_switch Switchfin.nro -j$(nproc) - name: Set outputs id: vars @@ -72,7 +71,6 @@ jobs: - uses: actions/checkout@v3 with: submodules: recursive - fetch-depth: 0 - name: Update gamepad mappings run: | BRLS_GLFW=library/borealis/library/lib/extern/glfw @@ -95,7 +93,6 @@ jobs: - uses: actions/checkout@v3 with: submodules: recursive - fetch-depth: 0 - name: Install deps run: | brew install create-dmg dylibbundler webp boost @@ -107,7 +104,7 @@ jobs: cmake -P $BRLS_GLFW/CMake/GenerateMappings.cmake $BRLS_GLFW/src/mappings.h.in $BRLS_GLFW/src/mappings.h - name: Build App run: | - cmake -B build -DPLATFORM_DESKTOP=ON -DUSE_BOOST_FILESYSTEM=ON -DCMAKE_BUILD_TYPE=Release + cmake -B build -DPLATFORM_DESKTOP=ON -DUSE_BOOST_FILESYSTEM=ON -DVERSION_BUILD=${{ github.run_number }} make -C build -j$(sysctl -n hw.ncpu) - name: Create DMG run: | @@ -140,7 +137,6 @@ jobs: - uses: actions/checkout@v3 with: submodules: recursive - fetch-depth: 0 - name: Install dependency run: | pacman -S --noconfirm --noprogressbar mingw-w64-x86_64-gcc mingw-w64-x86_64-make mingw-w64-x86_64-cmake git p7zip @@ -160,7 +156,7 @@ jobs: cmake -P $BRLS_GLFW/CMake/GenerateMappings.cmake $BRLS_GLFW/src/mappings.h.in $BRLS_GLFW/src/mappings.h - name: Build run: | - cmake -B build_mingw -G 'MinGW Makefiles' -DUSE_LIBROMFS=ON -DPLATFORM_DESKTOP=ON -DWIN32_TERMINAL=OFF -DUSE_SYSTEM_CURL=OFF + cmake -B build_mingw -G 'MinGW Makefiles' -DUSE_LIBROMFS=ON -DPLATFORM_DESKTOP=ON -DWIN32_TERMINAL=OFF -DUSE_SYSTEM_CURL=OFF -DVERSION_BUILD=${{ github.run_number }} mingw32-make -C build_mingw -j4 for i in {libwinpthread-1,zlib1}; do cp /mingw64/bin/$i.dll build_mingw; done @@ -184,7 +180,6 @@ jobs: - uses: actions/checkout@v3 with: submodules: recursive - fetch-depth: 0 - name: Cache xmake packages uses: actions/cache@v3 with: diff --git a/CMakeLists.txt b/CMakeLists.txt index 19dd0266..94369273 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,25 @@ if (MPV_NO_FB) list(APPEND APP_PLATFORM_OPTION -DMPV_NO_FB) endif() -include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/deps.cmake) +if (NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) +elseif (CMAKE_BUILD_TYPE STREQUAL Debug) + list(APPEND APP_PLATFORM_OPTION -D_DEBUG -D_GLIBCXX_ASSERTIONS) +endif() + +# Add git info +if (NOT DEFINED GIT_TAG_SHORT) + execute_process(COMMAND git rev-parse --short HEAD + TIMEOUT 5 OUTPUT_VARIABLE GIT_TAG_SHORT + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif () + +if (NOT DEFINED VERSION_BUILD) + execute_process(COMMAND git rev-list --count --all + TIMEOUT 5 OUTPUT_VARIABLE VERSION_BUILD + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif () +message(STATUS "git commit ${GIT_TAG_SHORT} build ${VERSION_BUILD}") # toolchain include(${BOREALIS_LIBRARY}/cmake/toolchain.cmake) @@ -38,7 +56,7 @@ include(${BOREALIS_LIBRARY}/cmake/toolchain.cmake) # project info project(Switchfin) set(VERSION_MAJOR "0") -set(VERSION_MINOR "2") +set(VERSION_MINOR "3") set(VERSION_ALTER "0") set(PROJECT_TITLEID "010ff000ffff0003") set(PROJECT_AUTHOR "dragonflylee") @@ -172,8 +190,8 @@ target_compile_options(${PROJECT_NAME} PRIVATE -ffunction-sections -fdata-sectio target_link_libraries(${PROJECT_NAME} PRIVATE borealis lunasvg ${APP_PLATFORM_LIB}) target_link_options(${PROJECT_NAME} PRIVATE ${APP_PLATFORM_LINK_OPTION}) target_compile_definitions(${PROJECT_NAME} PRIVATE - APP_VERSION=v${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_ALTER} - BUILD_TAG_VERSION=${GIT_TAG_VERSION} + APP_VERSION=${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_ALTER} + APP_BUILD=${VERSION_BUILD} BUILD_TAG_SHORT=${GIT_TAG_SHORT} BUILD_PACKAGE_NAME=${CMAKE_PROJECT_NAME} ) diff --git a/app/include/utils/config.hpp b/app/include/utils/config.hpp index ee7f2484..3bd3a193 100644 --- a/app/include/utils/config.hpp +++ b/app/include/utils/config.hpp @@ -13,14 +13,13 @@ class AppVersion { static std::string getVersion(); static std::string getPlatform(); static std::string getDeviceName(); + static std::string getPackageName(); + static std::string getCommit(); static bool needUpdate(std::string latestVersion); static void checkUpdate(int delay = 2000, bool showUpToDateDialog = false); inline static std::shared_ptr updating = std::make_shared(true); inline static std::string git_repo = "dragonflylee/switchfin"; - static std::string git_commit; - static std::string git_tag; - static std::string pkg_name; }; struct AppUser { diff --git a/app/src/activity/server_list.cpp b/app/src/activity/server_list.cpp index 7ff3a976..93229a6c 100644 --- a/app/src/activity/server_list.cpp +++ b/app/src/activity/server_list.cpp @@ -58,7 +58,7 @@ class ServerUserDataSource : public RecyclingGridDataSource { HTTP::Header header = { fmt::format("X-Emby-Authorization: MediaBrowser Client=\"{}\", Device=\"{}\", DeviceId=\"{}\", " "Version=\"{}\", Token=\"{}\"", - AppVersion::pkg_name, AppVersion::getDeviceName(), conf.getDevice(), AppVersion::getVersion(), + AppVersion::getPackageName(), AppVersion::getDeviceName(), conf.getDevice(), AppVersion::getVersion(), u.access_token)}; const long timeout = conf.getItem(AppConfig::REQUEST_TIMEOUT, default_timeout); try { diff --git a/app/src/api/analytics.cpp b/app/src/api/analytics.cpp index a3369703..8fe13fcc 100644 --- a/app/src/api/analytics.cpp +++ b/app/src/api/analytics.cpp @@ -29,7 +29,7 @@ Analytics::Analytics() { const auto ts = std::chrono::system_clock::now().time_since_epoch(); const auto sec = std::chrono::duration_cast(ts); - this->client_id = fmt::format("GA1.3.{}.{}", AppVersion::git_commit, sec.count()); + this->client_id = fmt::format("GA1.3.{}.{}", AppVersion::getCommit(), sec.count()); this->url = GA_URL + "?" + HTTP::encode_form({{"api_secret", GA_KEY}, {"measurement_id", GA_ID}}); this->ticker.setCallback([]() { brls::Threading::async([]() { Analytics::instance().send(); }); }); diff --git a/app/src/api/http.cpp b/app/src/api/http.cpp index 4e184e11..b4210917 100644 --- a/app/src/api/http.cpp +++ b/app/src/api/http.cpp @@ -26,7 +26,7 @@ class curl_status_code : public std::exception { std::string msg; }; -static std::string user_agent = fmt::format("{}/{}", AppVersion::pkg_name, AppVersion::getVersion()); +static std::string user_agent = fmt::format("{}/{}", AppVersion::getPackageName(), AppVersion::getVersion()); /// @brief curl context diff --git a/app/src/main.cpp b/app/src/main.cpp index 19db6c23..2f4a5e26 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -59,7 +59,7 @@ int main(int argc, char* argv[]) { // Return directly to the desktop when closing the application (only for NX) brls::Application::getPlatform()->exitToHomeMode(true); - brls::Application::createWindow(fmt::format("{} for {}", AppVersion::pkg_name, AppVersion::getPlatform())); + brls::Application::createWindow(fmt::format("{} for {}", AppVersion::getPackageName(), AppVersion::getPlatform())); // Have the application register an action on every activity that will quit when you press BUTTON_START brls::Application::setGlobalQuit(false); diff --git a/app/src/tab/setting_tab.cpp b/app/src/tab/setting_tab.cpp index c034afb9..c91a6a12 100644 --- a/app/src/tab/setting_tab.cpp +++ b/app/src/tab/setting_tab.cpp @@ -34,8 +34,8 @@ class SettingAbout : public brls::Box { SettingAbout() { this->inflateFromXMLRes("xml/view/setting_about.xml"); - this->labelTitle->setText(AppVersion::pkg_name); - this->labelVersion->setText(AppVersion::getVersion()); + this->labelTitle->setText(AppVersion::getPackageName()); + this->labelVersion->setText(fmt::format("v{}-{}", AppVersion::getVersion(), AppVersion::getCommit())); this->labelGithub->setText("https://github.com/" + AppVersion::git_repo); auto& mpv = MPVCore::instance(); diff --git a/app/src/utils/config.cpp b/app/src/utils/config.cpp index c6c5646f..5c0584b2 100644 --- a/app/src/utils/config.cpp +++ b/app/src/utils/config.cpp @@ -144,8 +144,8 @@ void AppConfig::init() { } } - brls::Logger::info( - "init {} {} device {} from {}", AppVersion::getPlatform(), AppVersion::getVersion(), this->device, path); + brls::Logger::info("init {} v{}-{} device {} from {}", AppVersion::getPlatform(), AppVersion::getVersion(), + AppVersion::getCommit(), this->device, path); } void AppConfig::save() { @@ -182,13 +182,13 @@ bool AppConfig::checkLogin() { std::string AppConfig::configDir() { #if __SWITCH__ - return fmt::format("sdmc:/switch/{}", AppVersion::pkg_name); + return fmt::format("sdmc:/switch/{}", AppVersion::getPackageName()); #elif _WIN32 - return fmt::format("{}\\{}", getenv("LOCALAPPDATA"), AppVersion::pkg_name); + return fmt::format("{}\\{}", getenv("LOCALAPPDATA"), AppVersion::getPackageName()); #elif __linux__ - return fmt::format("{}/.config/{}", getenv("HOME"), AppVersion::pkg_name); + return fmt::format("{}/.config/{}", getenv("HOME"), AppVersion::getPackageName()); #elif __APPLE__ - return fmt::format("{}/Library/Application Support/{}", getenv("HOME"), AppVersion::pkg_name); + return fmt::format("{}/Library/Application Support/{}", getenv("HOME"), AppVersion::getPackageName()); #endif } @@ -271,12 +271,12 @@ std::string AppConfig::getDevice(const std::string& token) { if (token.empty()) return fmt::format( "X-Emby-Authorization: MediaBrowser Client=\"{}\", Device=\"{}\", DeviceId=\"{}\", Version=\"{}\"", - AppVersion::pkg_name, AppVersion::getDeviceName(), this->device, AppVersion::getVersion()); + AppVersion::getPackageName(), AppVersion::getDeviceName(), this->device, AppVersion::getVersion()); else return fmt::format( "X-Emby-Authorization: MediaBrowser Client=\"{}\", Device=\"{}\", DeviceId=\"{}\", Version=\"{}\", " "Token=\"{}\"", - AppVersion::pkg_name, AppVersion::getDeviceName(), this->device, AppVersion::getVersion(), token); + AppVersion::getPackageName(), AppVersion::getDeviceName(), this->device, AppVersion::getVersion(), token); } const std::vector AppConfig::getServers() const { diff --git a/app/src/utils/version.cpp b/app/src/utils/version.cpp index 834a6baf..0a1aebb8 100644 --- a/app/src/utils/version.cpp +++ b/app/src/utils/version.cpp @@ -13,11 +13,11 @@ using namespace brls::literals; #define STR_IMPL(x) #x #define STR(x) STR_IMPL(x) -std::string AppVersion::git_commit = STR(BUILD_TAG_SHORT); -std::string AppVersion::git_tag = STR(BUILD_TAG_VERSION); -std::string AppVersion::pkg_name = STR(BUILD_PACKAGE_NAME); +std::string AppVersion::getVersion() { return STR(APP_VERSION); } -std::string AppVersion::getVersion() { return git_tag.empty() ? "dev-" + git_commit : git_tag; } +std::string AppVersion::getPackageName() { return STR(BUILD_PACKAGE_NAME); } + +std::string AppVersion::getCommit() { return STR(BUILD_TAG_SHORT); } std::string AppVersion::getPlatform() { #if __SWITCH__ @@ -63,7 +63,7 @@ void AppVersion::checkUpdate(int delay, bool showUpToDateDialog) { auto resp = HTTP::get(url, HTTP::Timeout{default_timeout}); nlohmann::json j = nlohmann::json::parse(resp); std::string latest_ver = j.at("tag_name").get(); - if (latest_ver.compare(git_tag) <= 0) { + if (latest_ver.compare(getVersion()) <= 0) { brls::Logger::info("App is up to date"); if (showUpToDateDialog) brls::sync([]() { Dialog::show("main/setting/others/up2date"_i18n); }); return; @@ -76,6 +76,7 @@ void AppVersion::checkUpdate(int delay, bool showUpToDateDialog) { AppVersion::updating->store(false); ThreadPool::instance().submit([latest_ver]() { std::string conf_dir = AppConfig::instance().configDir(); + std::string pkg_name = AppVersion::getPackageName(); std::string path = fmt::format("{}/{}_{}.nro", conf_dir, pkg_name, latest_ver); std::string url = fmt::format( "https://github.com/{}/releases/download/{}/Switchfin.nro", git_repo, latest_ver); diff --git a/app/src/view/mpv_core.cpp b/app/src/view/mpv_core.cpp index ac8329bc..81c88bc2 100644 --- a/app/src/view/mpv_core.cpp +++ b/app/src/view/mpv_core.cpp @@ -187,7 +187,7 @@ void MPVCore::init() { } mpv_free_node_contents(&node); - command_str("set audio-client-name {}", AppVersion::pkg_name); + command_str("set audio-client-name {}", AppVersion::getPackageName()); // set event callback mpv_set_wakeup_callback(mpv, on_wakeup, this); // set render callback @@ -760,7 +760,7 @@ double MPVCore::getPlaybackTime() { return this->playback_time; } void MPVCore::disableDimming(bool disable) { - brls::Application::getPlatform()->disableScreenDimming(disable, "Playing video", AppVersion::pkg_name); + brls::Application::getPlatform()->disableScreenDimming(disable, "Playing video", AppVersion::getPackageName()); brls::Application::setAutomaticDeactivation(!disable); } diff --git a/cmake/deps.cmake b/cmake/deps.cmake deleted file mode 100644 index 319ea47e..00000000 --- a/cmake/deps.cmake +++ /dev/null @@ -1,22 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -if (NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) -elseif (CMAKE_BUILD_TYPE STREQUAL Debug) - add_definitions(-D_DEBUG) - add_definitions(-D_GLIBCXX_ASSERTIONS) -endif() - -# Add git info -execute_process(COMMAND git describe --tags - TIMEOUT 5 OUTPUT_VARIABLE GIT_TAG_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE) -execute_process(COMMAND git rev-parse --short HEAD - TIMEOUT 5 OUTPUT_VARIABLE GIT_TAG_SHORT - OUTPUT_STRIP_TRAILING_WHITESPACE) -execute_process(COMMAND git rev-list --count --all - TIMEOUT 5 OUTPUT_VARIABLE VERSION_BUILD - OUTPUT_STRIP_TRAILING_WHITESPACE) - -message(STATUS "building from git tag ${GIT_TAG_VERSION}") -message(STATUS "building from git commit ${GIT_TAG_SHORT}") \ No newline at end of file diff --git a/resources/xml/view/video_card.xml b/resources/xml/view/video_card.xml index 096980fb..0b9814b0 100644 --- a/resources/xml/view/video_card.xml +++ b/resources/xml/view/video_card.xml @@ -50,7 +50,7 @@