Skip to content

Commit b230ce4

Browse files
authored
build system cleanup (#596)
* style: format meson.build with mesonlsp * build: check for libepoxy and xmllint - `epoxy` crate requires `libepoxy` - We have `preprocess="xml-stripblanks"` which requires `xmllint` from `libxml2` but compilation won't fail with this missing. * build: refactor build pipeline around Meson - drop non-meson resource generation - simplify redundant or unused meson code - simplify config.rs, template is no longer needed - parse gtk and adw name from Cargo.toml - make `buildscript` a crate for better IDE support - let Meson and directly Cargo call share target directory - run meson on Linux CI * dev: init justfile
1 parent 63c389a commit b230ce4

27 files changed

Lines changed: 336 additions & 393 deletions

.github/workflows/build_linux.yml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,28 @@ jobs:
2626
run: |
2727
apt-get update
2828
apt-get install -y git
29-
apt-get install -y --no-install-recommends build-essential curl gettext pkg-config libssl-dev libgtk-4-dev \
30-
libadwaita-1-dev libmpv-dev libgstreamer1.0-dev libgstreamer-plugins-bad1.0-dev \
31-
libgstreamer-plugins-base1.0-dev libgstreamer-plugins-extra1.0-dev gstreamer1.0-libav clang lld
29+
apt-get install -y --no-install-recommends \
30+
appstream \
31+
build-essential \
32+
clang \
33+
curl \
34+
desktop-file-utils \
35+
gettext \
36+
gstreamer1.0-libav \
37+
libxml2-utils \
38+
lld \
39+
meson \
40+
ninja-build \
41+
pkg-config \
42+
libadwaita-1-dev \
43+
libdbus-1-dev \
44+
libgstreamer1.0-dev \
45+
libgstreamer-plugins-bad1.0-dev \
46+
libgstreamer-plugins-base1.0-dev \
47+
libgstreamer-plugins-extra1.0-dev \
48+
libgtk-4-dev \
49+
libmpv-dev \
50+
libssl-dev
3251
3352
- name: Checkout
3453
uses: actions/checkout@v6
@@ -45,13 +64,14 @@ jobs:
4564
DANDANAPI_SECRET_KEY: ${{ secrets.DANDANAPI_SECRET_KEY }}
4665
run: |
4766
echo $DANDANAPI_SECRET_KEY > secret/key
48-
cargo build --release --locked
67+
meson setup build --prefix=/usr
68+
meson compile -C build
69+
meson install -C build --destdir "$PWD/artifact/tsukimi-${{ matrix.platform }}-linux"
70+
tar -czf tsukimi-${{ matrix.platform }}-linux.tar.gz -C artifact tsukimi-${{ matrix.platform }}-linux
4971
5072
- name: Upload artifact
5173
uses: actions/upload-artifact@v7
5274
with:
5375
name: tsukimi-${{ matrix.platform }}-linux
54-
path: |
55-
target/release/tsukimi
56-
target/i18n/locale
57-
resources/moe*.xml
76+
path: tsukimi-${{ matrix.platform }}-linux.tar.gz
77+
archive: false

Cargo.lock

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
[workspace]
2+
members = [
3+
".",
4+
"buildscript"
5+
]
6+
17
[package]
28
name = "tsukimi"
39
version = "26.5.3"
@@ -6,7 +12,6 @@ rust-version = "1.85"
612
description = "A simple Jellyfin Client written by GTK4-RS"
713
license = "GPL-3.0"
814

9-
1015
[dependencies]
1116
gtk = { version = "0.11", package = "gtk4", features = ["v4_22"] }
1217
adw = { version = "0.9", package = "libadwaita", features = ["v1_8"] }
@@ -56,8 +61,7 @@ futures-util = "0.3.31"
5661
cargo-husky = { version = "1", default-features = false, features = ["user-hooks"] }
5762

5863
[build-dependencies]
59-
embed-resource = "3.0"
60-
glib-build-tools = "0.22"
64+
tsukimi-buildscript = { path = "buildscript" }
6165

6266
[features]
6367
console = [] # Enable console logging

build.rs

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,28 @@
1-
#[path = "buildscript/resources.rs"]
2-
mod resources;
3-
4-
#[path = "buildscript/potfiles.rs"]
5-
mod potfiles;
6-
7-
#[path = "buildscript/gschema.rs"]
8-
mod gschema;
9-
10-
#[path = "buildscript/desktop.rs"]
11-
mod desktop;
12-
13-
#[path = "buildscript/metainfo.rs"]
14-
mod metainfo;
15-
16-
#[path = "buildscript/icons.rs"]
17-
mod icons;
18-
19-
#[cfg(any(target_os = "linux", target_os = "windows"))]
20-
#[path = "buildscript/gettext.rs"]
21-
mod gettext;
22-
231
#[cfg(windows)]
24-
#[path = "buildscript/windows.rs"]
25-
mod windows;
2+
use tsukimi_buildscript::{
3+
gettext,
4+
potfiles,
5+
resources,
6+
windows,
7+
};
268

279
fn main() {
28-
resources::compile();
29-
gschema::compile();
30-
desktop::generate();
31-
metainfo::generate();
32-
icons::copy();
10+
// These variables are passed by Meson, see src/config.rs.
11+
// We track them here to ensure Meson and direct Cargo calls can share the
12+
// same target directory safely.
13+
println!("cargo:rerun-if-env-changed=TSUKIMI_VERSION");
14+
println!("cargo:rerun-if-env-changed=TSUKIMI_LOCALEDIR");
15+
println!("cargo:rerun-if-env-changed=TSUKIMI_PKGDATADIR");
3316

34-
let translatable_files = potfiles::collect();
35-
potfiles::write(&translatable_files);
36-
37-
#[cfg(any(target_os = "linux", target_os = "windows"))]
17+
#[cfg(windows)]
3818
{
19+
resources::compile();
20+
21+
let translatable_files = potfiles::collect();
22+
potfiles::write(&translatable_files);
3923
gettext::update_pot(&translatable_files);
4024
gettext::compile_po();
41-
}
4225

43-
#[cfg(windows)]
44-
windows::embed_manifest();
26+
windows::embed_manifest();
27+
}
4528
}

buildscript/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "tsukimi-buildscript"
3+
version = "26.5.3"
4+
edition = "2024"
5+
6+
[dependencies]
7+
embed-resource = "3.0"
8+
glib-build-tools = "0.22"

buildscript/desktop.rs

Lines changed: 0 additions & 53 deletions
This file was deleted.

buildscript/gschema.rs

Lines changed: 0 additions & 24 deletions
This file was deleted.

buildscript/icons.rs

Lines changed: 0 additions & 16 deletions
This file was deleted.

buildscript/metainfo.rs

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::{
44
time::SystemTime,
55
};
66

7-
const LINGUAS: &str = include_str!("../po/LINGUAS");
7+
const LINGUAS: &str = include_str!("../../po/LINGUAS");
88

99
fn mtime(path: &str) -> Option<SystemTime> {
1010
std::fs::metadata(path).ok()?.modified().ok()
@@ -15,6 +15,7 @@ fn any_newer(sources: &[&str], target: &str) -> bool {
1515
Some(t) => t,
1616
None => return true,
1717
};
18+
1819
sources
1920
.iter()
2021
.any(|s| mtime(s).is_some_and(|t| t > target_time))
@@ -52,7 +53,6 @@ pub fn update_pot(files: &[String]) {
5253
&format!("--package-version={pkg_version}"),
5354
"--from-code=UTF-8",
5455
"--add-comments",
55-
// gettextrs function names
5656
"-kgettext",
5757
"-kngettext:1,2",
5858
"-kpgettext:1c,2",

0 commit comments

Comments
 (0)