Skip to content

Commit

Permalink
feat: adjust directory structure of program
Browse files Browse the repository at this point in the history
fix: missing icons on Windows
CI: disable MacOS Linux and MSVC
  • Loading branch information
Kosette committed Apr 1, 2024
1 parent caf6ae9 commit 1116def
Show file tree
Hide file tree
Showing 12 changed files with 163 additions and 192 deletions.
28 changes: 19 additions & 9 deletions .github/workflows/build_gnu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
push:
branches:
- 'feature/win'
schedule:
- cron: '50 5 * * *'
# schedule:
# - cron: '50 5 * * *'

env:
CARGO_TERM_COLOR: always
Expand All @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
include:
- arch-name: x86_64-windows-gnu
- arch: x86_64-windows-gnu
os: windows-latest
target: x86_64-pc-windows-gnu
artifact: tsukimi.exe
Expand All @@ -40,16 +40,26 @@ jobs:
- name: Build ${{matrix.target}}
run: |
$env:Path = "C:\msys64\usr\bin;C:\msys64\mingw64\bin;C:\msys64\mingw64\lib;C:\msys64\mingw64\include;" + $env:Path;
cargo build --release --locked
mkdir C:/artifacts
cp target/release/${{matrix.artifact}} C:/artifacts/
cd C:/msys64/mingw64/bin
cp *.dll C:/artifacts/
cargo build --release --locked --target ${{matrix.target}}
mkdir artifact && cd artifact
mkdir tsukimi-windows-gnu-amd64/ && cd tsukimi-windows-gnu-amd64/ && mkdir bin/ && mkdir share/ && mkdir lib/
cp ../../target/${{matrix.target}}/release/${{ matrix.artifact }} bin/
cp C:/msys64/mingw64/bin/*.dll bin/
cp -recurse C:/msys64/mingw64/lib/gdk-pixbuf-2.0 lib/
remove-item lib/gdk-pixbuf-2.0/2.10.0/loaders/* -exclude "*svg.dll"
cp -recurse C:/msys64/mingw64/share/glib-2.0 share/
get-childitem -recurse -path share/glib-2.0/* -exclude "*gschemas.compiled*"|remove-item -recurse
cp -recurse C:/msys64/mingw64/share/icons share/
remove-item -recurse share/icons/hicolor && remove-item -recurse share/icons/Adwaita/scalable && remove-item -recurse share/icons/Adwaita/cursors
remove-item -recurse share/icons/Adwaita/16x16 && remove-item -recurse share/icons/Adwaita/symbolic-up-to-32
gci -directory -recurse .|where-object {$_.getfilesysteminfos().count -eq 0}|remove-item -recurse
cd ..
compress-archive -path ./* -destinationpath ./tsukimi-${{matrix.arch}}.zip
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: tsukimi-${{matrix.arch-name}}
path: C:/artifacts/*
path: artifact/*.zip
compression-level: 5
retention-days: 3
10 changes: 5 additions & 5 deletions .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: feature/win - Linux CI
on:
workflow_dispatch:
push:
branches:
- 'feature/win'
schedule:
- cron: '45 5 * * *'
# push:
# branches:
# - 'feature/win'
# schedule:
# - cron: '45 5 * * *'

jobs:
build-release:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/build_macos.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: feature/win - MacOS CI
on:
workflow_dispatch:
push:
branches:
- 'feature/win'
schedule:
- cron: '55 5 * * *'
# push:
# branches:
# - 'feature/win'
# schedule:
# - cron: '55 5 * * *'

env:
CARGO_TERM_COLOR: always
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/build_msvc.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: feature/win - Windows MSVC CI
on:
workflow_dispatch:
push:
branches:
- 'feature/win'
schedule:
- cron: '5 6 * * *'
# push:
# branches:
# - 'feature/win'
# schedule:
# - cron: '5 6 * * *'

env:
CARGO_TERM_COLOR: always
Expand Down
118 changes: 64 additions & 54 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
matrix:
include:
# x86_64-windows-msvc
- arch: x86_64-windows-msvc
os: windows-latest
target: x86_64-pc-windows-msvc
artifact: tsukimi.exe
ext: .exe
# - arch: x86_64-windows-msvc
# os: windows-latest
# target: x86_64-pc-windows-msvc
# artifact: tsukimi.exe
# ext: .exe
# x86_64-windows-gnu
- arch: x86_64-windows-gnu
os: windows-latest
Expand All @@ -34,35 +34,35 @@ jobs:
artifact: tsukimi
ext:
# x86_64-apple-darwin
- arch: x86_64-apple-darwin
os: macos-latest
target: x86_64-apple-darwin
artifact: tsukimi
ext:
# - arch: x86_64-apple-darwin
# os: macos-latest
# target: x86_64-apple-darwin
# artifact: tsukimi
# ext:

runs-on: ${{matrix.os}}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build ${{ matrix.target }}
if: ${{ matrix.target == 'x86_64-pc-windows-msvc' }}
run: |
rustup default stable-msvc
py -3.12 -m pip install --user pipx
py -3.12 -m pipx ensurepath
pipx install gvsbuild
$env:Path = "C:\gtk-build\gtk\x64\release\lib\pkgconfig;C:\gtk-build\gtk\x64\release\bin;C:\msys64\usr\bin;C:\msys64\mingw64\bin;C:\msys64\mingw64\lib;C:\msys64\mingw64\include;" + $env:Path
$env:LIB = "C:\gtk-build\gtk\x64\release\lib;C:\msys64\mingw64\lib;" + $env:LIB
$env:INCLUDE = "C:\gtk-build\gtk\x64\release\include;C:\gtk-build\gtk\x64\release\include\cairo;C:\gtk-build\gtk\x64\release\include\glib-2.0;C:\gtk-build\gtk\x64\release\include\gobject-introspection-1.0;C:\gtk-build\gtk\x64\release\lib\glib-2.0\include;C:\msys64\mingw64\include;" + $env:INCLUDE
$env:PKG_CONFIG_PATH = "C:\gtk-build\gtk\x64\release\lib\pkgconfig;" + $env:PKG_CONFIG_PATH
gvsbuild build gtk4 libadwaita adwaita-icon-theme
cargo build --release --locked --target ${{ matrix.target }}
mkdir artifact
cp target/${{matrix.target}}/release/${{ matrix.artifact }} artifact/tsukimi-${{ matrix.arch }}${{ matrix.ext }}
cp C:\gtk-build\gtk\x64\release\bin\*.dll artifact/
compress-archive -path artifact/* -destination artifact/tsukimi-${{matrix.arch}}.zip
# - name: Build ${{ matrix.target }}
# if: ${{ matrix.target == 'x86_64-pc-windows-msvc' }}
# run: |
# rustup default stable-msvc
# py -3.12 -m pip install --user pipx
# py -3.12 -m pipx ensurepath
# pipx install gvsbuild
# $env:Path = "C:\gtk-build\gtk\x64\release\lib\pkgconfig;C:\gtk-build\gtk\x64\release\bin;C:\msys64\usr\bin;C:\msys64\mingw64\bin;C:\msys64\mingw64\lib;C:\msys64\mingw64\include;" + $env:Path
# $env:LIB = "C:\gtk-build\gtk\x64\release\lib;C:\msys64\mingw64\lib;" + $env:LIB
# $env:INCLUDE = "C:\gtk-build\gtk\x64\release\include;C:\gtk-build\gtk\x64\release\include\cairo;C:\gtk-build\gtk\x64\release\include\glib-2.0;C:\gtk-build\gtk\x64\release\include\gobject-introspection-1.0;C:\gtk-build\gtk\x64\release\lib\glib-2.0\include;C:\msys64\mingw64\include;" + $env:INCLUDE
# $env:PKG_CONFIG_PATH = "C:\gtk-build\gtk\x64\release\lib\pkgconfig;" + $env:PKG_CONFIG_PATH
# gvsbuild build gtk4 libadwaita adwaita-icon-theme
# cargo build --release --locked --target ${{ matrix.target }}
# mkdir artifact
# cp target/${{matrix.target}}/release/${{ matrix.artifact }} artifact/tsukimi-${{ matrix.arch }}${{ matrix.ext }}
# cp C:\gtk-build\gtk\x64\release\bin\*.dll artifact/
# compress-archive -path artifact/* -destination artifact/tsukimi-${{matrix.arch}}.zip

- name: Build ${{ matrix.target }}
if: ${{ matrix.target == 'x86_64-pc-windows-gnu' }}
Expand All @@ -77,10 +77,20 @@ jobs:
run: |
$env:Path = "C:\msys64\mingw64\bin;C:\msys64\mingw64\lib;C:\msys64\mingw64\include;" + $env:Path;
cargo build --release --locked --target ${{ matrix.target }}
mkdir artifact/
cp target/${{matrix.target}}/release/${{ matrix.artifact }} artifact/tsukimi-${{ matrix.arch }}${{ matrix.ext }}
cp C:/msys64/mingw64/bin/*.dll artifact
compress-archive -path artifact/* -destination artifact/tsukimi-${{matrix.arch}}.zip
mkdir artifact && cd artifact
mkdir tsukimi-windows-gnu-amd64/ && cd tsukimi-windows-gnu-amd64/ && mkdir bin/ && mkdir share/ && mkdir lib/
cp ../../target/${{matrix.target}}/release/${{ matrix.artifact }} bin/
cp C:/msys64/mingw64/bin/*.dll bin/
cp -recurse C:/msys64/mingw64/lib/gdk-pixbuf-2.0 lib/
remove-item lib/gdk-pixbuf-2.0/2.10.0/loaders/* -exclude "*svg.dll"
cp -recurse C:/msys64/mingw64/share/glib-2.0 share/
get-childitem -recurse -path share/glib-2.0/* -exclude "*gschemas.compiled*"|remove-item -recurse
cp -recurse C:/msys64/mingw64/share/icons share/
remove-item -recurse share/icons/hicolor && remove-item -recurse share/icons/Adwaita/scalable && remove-item -recurse share/icons/Adwaita/cursors
remove-item -recurse share/icons/Adwaita/16x16 && remove-item -recurse share/icons/Adwaita/symbolic-up-to-32
gci -directory -recurse .|where-object {$_.getfilesysteminfos().count -eq 0}|remove-item -recurse
cd ..
compress-archive -path ./* -destinationpath ./tsukimi-${{matrix.arch}}.zip
- name: Build ${{matrix.target}}
if: ${{matrix.target == 'x86_64-unknown-linux-gnu'}}
Expand All @@ -92,17 +102,17 @@ jobs:
cd artifact
tar -czf tsukimi-${{matrix.arch}}.tar.gz tsukimi
- name: Build ${{matrix.target}}
if: ${{matrix.target == 'x86_64-apple-darwin'}}
run: |
brew install gtk4
brew install libadwaita
rustup target add ${{matrix.target}}
cargo build --release --locked --target ${{matrix.target}}
mkdir artifact
cp target/${{matrix.target}}/release/${{matrix.artifact}} artifact/
cd artifact/
tar -czf tsukimi-${{matrix.arch}}.tar.gz ./*
# - name: Build ${{matrix.target}}
# if: ${{matrix.target == 'x86_64-apple-darwin'}}
# run: |
# brew install gtk4
# brew install libadwaita
# rustup target add ${{matrix.target}}
# cargo build --release --locked --target ${{matrix.target}}
# mkdir artifact
# cp target/${{matrix.target}}/release/${{matrix.artifact}} artifact/
# cd artifact/
# tar -czf tsukimi-${{matrix.arch}}.tar.gz ./*

- name: Upload artifact
uses: actions/upload-artifact@v4
Expand All @@ -128,23 +138,23 @@ jobs:
- name: Download artifacts
uses: actions/download-artifact@v4

- name: Package MacOS x86_64
run: |
tar -xzf tsukimi-x86_64-apple-darwin/tsukimi-x86_64-apple-darwin.tar.gz
mkdir -p Tsukimi.app/Contents/MacOS
mkdir -p Tsukimi.app/Contents/Resources
cp share/macos/Info.plist Tsukimi.app/Contents/
cp share/macos/AppIcon.icns Tsukimi.app/Contents/Resources/
mv tsukimi Tsukimi.app/Contents/MacOS/
tar -czf tsukimi-x86_64-apple-darwin.tar.gz Tsukimi.app/
# - name: Package MacOS x86_64
# run: |
# tar -xzf tsukimi-x86_64-apple-darwin/tsukimi-x86_64-apple-darwin.tar.gz
# mkdir -p Tsukimi.app/Contents/MacOS
# mkdir -p Tsukimi.app/Contents/Resources
# cp share/macos/Info.plist Tsukimi.app/Contents/
# cp share/macos/AppIcon.icns Tsukimi.app/Contents/Resources/
# mv tsukimi Tsukimi.app/Contents/MacOS/
# tar -czf tsukimi-x86_64-apple-darwin.tar.gz Tsukimi.app/

- name: Package Windows GNU
run: |
mv tsukimi-x86_64-windows-gnu/*.zip .
- name: Package Windows MSVC
run: |
mv tsukimi-x86_64-windows-msvc/*.zip .
# - name: Package Windows MSVC
# run: |
# mv tsukimi-x86_64-windows-msvc/*.zip .

- name: Package Linux GNU
run: |
Expand Down
64 changes: 35 additions & 29 deletions src/ui/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use reqwest;
use serde::{Deserialize, Serialize};
#[cfg(any(target_os = "windows", target_os = "macos"))]
use std::env;
use std::fs;
use std::{fs, path::PathBuf};
use toml;

#[derive(Debug, Serialize, Deserialize, Default)]
Expand Down Expand Up @@ -112,15 +112,7 @@ impl MPVClient {
}

fn get_proxy_info() -> String {
#[cfg(unix)]
let config_path = dirs::home_dir().unwrap().join(".config/tsukimi.toml");

#[cfg(windows)]
let config_path = env::current_dir()
.unwrap()
.join("config")
.join("tsukimi.toml");

let config_path = Dir::get_config_path();
let data = std::fs::read_to_string(&config_path).unwrap();
let config: Config = toml::from_str(&data).unwrap();
return config.proxy;
Expand All @@ -135,14 +127,7 @@ fn default_mpv() -> String {
}

fn mpv() -> String {
#[cfg(unix)]
let config_path = dirs::home_dir().unwrap().join(".config/tsukimi.toml");

#[cfg(windows)]
let config_path = env::current_dir()
.unwrap()
.join("config")
.join("tsukimi.toml");
let config_path = Dir::get_config_path();

let data = std::fs::read_to_string(&config_path).unwrap();
let config: Config = toml::from_str(&data).unwrap();
Expand All @@ -169,17 +154,7 @@ pub fn get_server_info() -> ServerInfo {
access_token: String::new(),
port: String::new(),
};
#[cfg(unix)]
let path = dirs::home_dir()
.unwrap()
.join(".config")
.join("tsukimi.toml");

#[cfg(windows)]
let path = env::current_dir()
.unwrap()
.join("config")
.join("tsukimi.toml");
let path = Dir::get_config_path();

if path.exists() {
let data = fs::read_to_string(path).expect("read config file failed");
Expand All @@ -192,3 +167,34 @@ pub fn get_server_info() -> ServerInfo {

server_info
}

pub struct Dir;

impl Dir {
pub fn get_cache_dir() -> PathBuf {
#[cfg(unix)]
let pathbuf = dirs::home_dir().unwrap().join(".local/share/tsukimi");

#[cfg(windows)]
let pathbuf = env::current_dir().unwrap().parent().unwrap().join("cache");

return pathbuf;
}

pub fn get_config_path() -> PathBuf {
#[cfg(unix)]
let path = dirs::home_dir()
.unwrap()
.join(".config")
.join("tsukimi.toml");

#[cfg(windows)]
let path = env::current_dir()
.unwrap()
.parent()
.unwrap()
.join("config")
.join("tsukimi.toml");
return path;
}
}
Loading

0 comments on commit 1116def

Please sign in to comment.