Skip to content

Commit

Permalink
ci: update cmake files
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonflylee committed Jun 29, 2023
1 parent cf4f68f commit 74b9df6
Show file tree
Hide file tree
Showing 14 changed files with 317 additions and 124 deletions.
119 changes: 87 additions & 32 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ permissions:
contents: write

jobs:
release:
needs: [ build-win-x64, build-switch, build-macos ]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
- name: Release and Upload Assets
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
name: ${{ github.ref_name }}
generate_release_notes: true
files: '*/*'
body: |
![download](https://img.shields.io/github/downloads/${{ github.repository }}/${{ github.ref_name }}/total?label=Downloads)
build-switch:
runs-on: ubuntu-latest
container:
Expand All @@ -16,7 +31,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 1
fetch-depth: 0
- name: Build dependencies
if: ${{ github.ref_name == '0.1.0' }}
run: |
Expand All @@ -32,58 +47,98 @@ jobs:
- name: Update dependencies
if: ${{ github.ref_name != '0.1.0' }}
run: |
dkp-pacman --noconfirm -U https://github.com/${{ github.repository }}/releases/download/0.1.0/switch-libass-0.17.1-1-any.pkg.tar.zst
dkp-pacman --noconfirm -U https://github.com/${{ github.repository }}/releases/download/0.1.0/switch-ffmpeg-4.4.4-1-any.pkg.tar.zst
dkp-pacman --noconfirm -U https://github.com/${{ github.repository }}/releases/download/0.1.0/switch-libmpv-0.35.1-1-any.pkg.tar.zst
dkp-pacman --noconfirm -U https://github.com/${{ github.repository }}/releases/download/switch-portlibs/switch-libass-0.17.1-1-any.pkg.tar.zst
dkp-pacman --noconfirm -U https://github.com/${{ github.repository }}/releases/download/switch-portlibs/switch-ffmpeg-4.4.4-1-any.pkg.tar.zst
dkp-pacman --noconfirm -U https://github.com/${{ github.repository }}/releases/download/switch-portlibs/switch-libmpv-0.35.1-1-any.pkg.tar.zst
- name: Build nro
run: |
cmake -B switch -DPLATFORM_SWITCH=ON
make -C switch Switchfin.nro -j$(nproc)
cmake -E tar c Switchfin-NintendoSwitch.zip switch/Switchfin.nro
- name: Release and Upload Assets
- name: Upload Assets
uses: actions/upload-artifact@v3
with:
name: switch-${{ github.ref_name }}
path: Switchfin-NintendoSwitch.zip
- name: Upload dependencies
uses: softprops/action-gh-release@v1
if: ${{ github.ref_name == '0.1.0' }}
with:
name: ${{ github.ref_name }}
files: |
Switchfin-NintendoSwitch.zip
scripts/switch/*/*.pkg.tar.zst
tag_name: switch-portlibs
prerelease: true
files: scripts/switch/*/*.pkg.tar.zst
body: |
![download](https://img.shields.io/github/downloads/${{ github.repository }}/switch-portlibs/total?label=Downloads)
build-linux:
build-snap:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 1
fetch-depth: 0
- name: Update gamepad mappings
run: |
BRLS_GLFW="library/borealis/library/lib/extern/glfw"
cmake -P ${BRLS_GLFW}/CMake/GenerateMappings.cmake ${BRLS_GLFW}/src/mappings.h.in ${BRLS_GLFW}/src/mappings.h
- name: Build snap
uses: snapcore/action-build@v1
id: snapcraft
- name: Release and Upload Assets
uses: softprops/action-gh-release@v1
run: |
docker run --rm --tty -v $PWD:/data -w /data/scripts --privileged diddledani/snapcraft:core20
- name: Upload Assets
uses: actions/upload-artifact@v3
with:
name: ${{ github.ref_name }}
files: ${{ steps.snapcraft.outputs.snap }}
name: snap-${{ github.ref_name }}
path: scripts/*.snap

build-flatpak:
runs-on: ubuntu-latest
container:
image: bilelmoussaoui/flatpak-github-actions:freedesktop-22.08
options: --privileged
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Update gamepad mappings
run: |
dnf -y install cmake
BRLS_GLFW="library/borealis/library/lib/extern/glfw"
cmake -P ${BRLS_GLFW}/CMake/GenerateMappings.cmake ${BRLS_GLFW}/src/mappings.h.in ${BRLS_GLFW}/src/mappings.h
- name: Build flatpak
uses: flatpak/flatpak-github-actions/[email protected]
with:
bundle: switchfin-Linux-${{ github.ref_name }}.flatpak
manifest-path: scripts/flatpak.yaml
cache-key: flatpak-builder-${{ github.ref_name }}
- name: Upload Assets
uses: actions/upload-artifact@v3
with:
name: flatpak-${{ github.ref_name }}
path: switchfin-Linux-${{ github.ref_name }}.flatpak

build-macos:
runs-on: macos-11
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 1
fetch-depth: 0
- name: Install deps
run: |
brew install create-dmg dylibbundler webp
brew tap xfangfang/wiliwili
brew install -v mpv-wiliwili
- name: Build
- name: Update gamepad mappings
run: |
BRLS_GLFW="library/borealis/library/lib/extern/glfw/"
BRLS_GLFW="library/borealis/library/lib/extern/glfw"
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 -DCMAKE_BUILD_TYPE=Release
make -C build -j$(sysctl -n hw.ncpu)
- name: Create DMG
run: |
mkdir -p dist
mv build/Switchfin.app dist/
cp README.md dist
Expand All @@ -92,13 +147,13 @@ jobs:
--icon "README.md" 400 100 --hide-extension "Switchfin.app" \
--app-drop-link 600 185 --volicon ./scripts/dmg.icns \
--volname "Switchfin" Switchfin-macOS.dmg "dist/"
- name: Release and Upload Assets
uses: softprops/action-gh-release@v1
- name: Upload Assets
uses: actions/upload-artifact@v3
with:
name: ${{ github.ref_name }}
files: Switchfin-macOS.dmg
name: macos-${{ github.ref_name }}
path: Switchfin-*.dmg

build-windows:
build-win-x64:
runs-on: windows-2022
steps:
- name: Setup Windows 10 SDK
Expand All @@ -112,7 +167,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 1
fetch-depth: 0
- name: Cache xmake packages
uses: actions/cache@v3
with:
Expand All @@ -128,8 +183,8 @@ jobs:
xmake build -y
cd build\windows\x64\release
7z a "$env:GITHUB_WORKSPACE\Switchfin-Win64.zip" *
- name: Release and Upload Assets
uses: softprops/action-gh-release@v1
- name: Upload Assets
uses: actions/upload-artifact@v3
with:
name: ${{ github.ref_name }}
files: Switchfin-Win64.zip
name: windows-${{ github.ref_name }}
path: Switchfin-Win64.zip
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ settings.json
ffmpeg-*
mpv-*
/*.json
/script/switch/*/src
/parts/*
/prime/*
/stage/*
/scripts/switch/*/src
/scripts/parts/*
/scripts/prime/*
/scripts/stage/*
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/deps.cmake)

# toolchain
if (PLATFORM_DESKTOP)
message("building for Desktop")
message(STATUS "building for Desktop")
set(TARGET_PLATFORM desktop CACHE STRING "")
message("Build Type: ${CMAKE_BUILD_TYPE}")
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -g2 -ggdb -Wall")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
elseif (PLATFORM_SWITCH)
message("building for SWITCH")
message("Build Type: ${CMAKE_BUILD_TYPE}")
message(STATUS "building for SWITCH")
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
set(CMAKE_USE_SYSTEM_ENVIRONMENT_PATH OFF)
file(TO_CMAKE_PATH "$ENV{DEVKITPRO}" DEVKITPRO)
if (NOT IS_DIRECTORY ${DEVKITPRO})
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Switchfin is third-party PC player for Jellyfin that provides a native user interface to browse and play movies and series.
<br>

[![latest release](https://img.shields.io/github/release/dragonflylee/switchfin)](https://github.com/dragonflylee/switchfin/releases) ![download](https://img.shields.io/github/downloads/dragonflylee/switchfin/total) ![NS](https://img.shields.io/badge/-Nintendo%20Switch-e4000f?style=flat&logo=Nintendo%20Switch) ![MS](https://img.shields.io/badge/-Windows%2010-357ec7?style=flat&logo=Windows) ![mac](https://img.shields.io/badge/-macOS%2010.15-black?style=flat&logo=Apple) ![Linux](https://img.shields.io/badge/-Linux-lightgrey?style=flat&logo=Linux)
[![build](https://github.com/dragonflylee/switchfin/actions/workflows/build.yaml/badge.svg)](https://github.com/dragonflylee/switchfin/actions/workflows/build.yaml) [![release](https://img.shields.io/github/release/dragonflylee/switchfin)](https://github.com/dragonflylee/switchfin/releases) ![download](https://img.shields.io/github/downloads/dragonflylee/switchfin/total) ![NS](https://img.shields.io/badge/-Nintendo%20Switch-e4000f?style=flat&logo=Nintendo%20Switch) ![MS](https://img.shields.io/badge/-Windows%2010-357ec7?style=flat&logo=Windows) ![mac](https://img.shields.io/badge/-macOS%2010.15-black?style=flat&logo=Apple) ![Linux](https://img.shields.io/badge/-Linux-lightgrey?style=flat&logo=Linux)

**This project is in its early stages so expect bugs.**

Expand Down
5 changes: 2 additions & 3 deletions app/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ int main(int argc, char* argv[]) {
#ifdef __SWITCH__
appletInitializeGamePlayRecording();
#endif
int c = -1;
// We recommend to use INFO for real apps
while ((c = getopt(argc, argv, "v")) != -1) {
if (c == 'v') brls::Logger::setLogLevel(brls::LogLevel::LOG_DEBUG);
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-v") == 0) brls::Logger::setLogLevel(brls::LogLevel::LOG_DEBUG);
}

// Load cookies and settings
Expand Down
8 changes: 7 additions & 1 deletion app/src/utils/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
#endif

#include <fstream>
#ifdef USE_BOOST_FILESYSTEM
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
#else
#include <filesystem>
namespace fs = std::filesystem;
#endif
#include <set>
#include <borealis.hpp>
#include <borealis/core/cache_helper.hpp>
Expand Down Expand Up @@ -135,7 +141,7 @@ void AppConfig::init() {

void AppConfig::save() {
try {
std::filesystem::create_directories(this->configDir());
fs::create_directories(this->configDir());
std::ofstream f(this->configDir() + "/config.json");
if (f.is_open()) {
nlohmann::json j(*this);
Expand Down
11 changes: 10 additions & 1 deletion cmake/FindMPV.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@ endif (PKG_CONFIG_FOUND)

# Used for macOS
# brew tap xfangfang/wiliwili && brew install mpv-wiliwili
set(HOMEBREW_MPV /usr/local/opt/mpv-wiliwili)
if (APPLE)
execute_process(COMMAND brew --prefix mpv-wiliwili
TIMEOUT 5
OUTPUT_VARIABLE HOMEBREW_MPV
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (NOT HOMEBREW_MPV)
message(AUTHOR_WARNING "You can install mpv-wiliwili to reduce the size of dependencies, this is very useful when used with dylibbundler to package as a standalone app:\nbrew tap xfangfang/wiliwili && brew install mpv-wiliwili\nPlease refer to: https://github.com/xfangfang/wiliwili/discussions/151 for more information")
endif()
endif ()

#
### Look for the include files.
Expand Down
2 changes: 1 addition & 1 deletion cmake/deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ 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)
message("Build Type: ${CMAKE_BUILD_TYPE}")
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
endif()

if (CMAKE_BUILD_TYPE STREQUAL Debug)
Expand Down
3 changes: 2 additions & 1 deletion resources/i18n/zh-Hans/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"subtitle": "字幕",
"audio": "音轨",
"common": "通用",
"speed": "倍速"
"speed": "倍速",
"quality": "画质"
},
"setting": {
"quit_hint": "即将退出应用, 设置内容将在下次启动后生效",
Expand Down
Loading

0 comments on commit 74b9df6

Please sign in to comment.