Skip to content

Commit

Permalink
bump version 0.3.0
Browse files Browse the repository at this point in the history
Signed-off-by: dragonflylee <[email protected]>
  • Loading branch information
dragonflylee committed Sep 7, 2023
1 parent 411e9ad commit 4e40b02
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 61 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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: |
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -184,7 +180,6 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Cache xmake packages
uses: actions/cache@v3
with:
Expand Down
26 changes: 22 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,33 @@ 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)

# 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")
Expand Down Expand Up @@ -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}
)
Expand Down
5 changes: 2 additions & 3 deletions app/include/utils/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::atomic_bool> updating = std::make_shared<std::atomic_bool>(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 {
Expand Down
2 changes: 1 addition & 1 deletion app/src/activity/server_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion app/src/api/analytics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Analytics::Analytics() {
const auto ts = std::chrono::system_clock::now().time_since_epoch();
const auto sec = std::chrono::duration_cast<std::chrono::seconds>(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(); }); });
Expand Down
2 changes: 1 addition & 1 deletion app/src/api/http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions app/src/tab/setting_tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
16 changes: 8 additions & 8 deletions app/src/utils/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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<AppServer> AppConfig::getServers() const {
Expand Down
11 changes: 6 additions & 5 deletions app/src/utils/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down Expand Up @@ -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<std::string>();
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;
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions app/src/view/mpv_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

Expand Down
22 changes: 0 additions & 22 deletions cmake/deps.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion resources/xml/view/video_card.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

<brls:Box
axis="column"
height="20px"
height="50"
alignItems="center">
<brls:Label
wireframe="false"
Expand Down
1 change: 0 additions & 1 deletion xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,5 @@ target("Switchfin")
target:set("configvar", "VERSION_ALTER", string.match(cmakefile, "set%(VERSION_ALTER \"(%d)\"%)"))
target:set("configvar", "VERSION_BUILD", "$(shell git rev-list --count --all)")
target:add("defines", "BUILD_PACKAGE_NAME="..target:name())
target:add("defines", "BUILD_TAG_VERSION=v$(shell git describe --tags)")
target:add("defines", "BUILD_TAG_SHORT=$(shell git rev-parse --short HEAD)")
end)

0 comments on commit 4e40b02

Please sign in to comment.