👷 compile gresource with cargo instead of depending on meson

This commit is contained in:
Vladislav Nepogodin 2023-03-25 15:38:10 +04:00
parent 7ebcbb6cf5
commit 1523885d80
No known key found for this signature in database
GPG Key ID: B62C3D10C54D5DA9
4 changed files with 25 additions and 13 deletions

View File

@ -15,7 +15,6 @@ args = parser.parse_args()
environ["CARGO_TARGET_DIR"] = path.join(args.build_root, "target")
environ["CARGO_HOME"] = path.join(args.build_root, "cargo-home")
environ["OUT_DIR"] = path.join(args.build_root, "target")
cargo_toml_path = path.join(args.source_root, "Cargo.toml")

24
build.rs Normal file
View File

@ -0,0 +1,24 @@
use std::process::{self, Command};
use std::{env, fs};
fn main() {
for i in fs::read_dir("data").unwrap() {
println!("cargo:rerun-if-changed={}", i.unwrap().path().display());
}
for i in fs::read_dir("ui").unwrap() {
println!("cargo:rerun-if-changed={}", i.unwrap().path().display());
}
let out_dir = env::var("OUT_DIR").unwrap();
let status = Command::new("glib-compile-resources")
.arg(&format!("--target={}/cachyos-welcome.gresource", out_dir))
.arg("cachyos-welcome.gresource.xml")
.status()
.unwrap();
if !status.success() {
eprintln!("glib-compile-resources failed with exit status {}", status);
process::exit(1);
}
}

View File

@ -16,8 +16,6 @@ dependency('glib-2.0', version: '>= 2.66')
dependency('gio-2.0', version: '>= 2.66')
dependency('gtk+-3.0', version: '>= 3.24.33')
glib_compile_resources = find_program('glib-compile-resources', required: true)
glib_compile_schemas = find_program('glib-compile-schemas', required: true)
desktop_file_validate = find_program('desktop-file-validate', required: false)
appstream_util = find_program('appstream-util', required: false)
cargo = find_program('cargo', required: true)
@ -37,14 +35,6 @@ datadir = prefix / get_option('datadir')
pkgdatadir = datadir / meson.project_name()
iconsdir = datadir / 'icons'
resources = gnome.compile_resources(
'cachyos-welcome',
'cachyos-welcome.gresource.xml',
gresource_bundle: true,
source_dir: meson.current_build_dir(),
install: false,
)
if get_option('profile') == 'development'
profile = 'Devel'
vcs_tag = run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip()

View File

@ -31,14 +31,13 @@ else
message('Building in debug mode')
endif
cargo_env = [ 'CARGO_HOME=' + cargo_home, 'OUT_DIR=' + meson.project_build_root() ]
cargo_env = [ 'CARGO_HOME=' + cargo_home ]
cargo_build = custom_target(
'cargo-build',
build_by_default: true,
build_always_stale: true,
output: meson.project_name(),
depends: resources,
console: true,
install: true,
install_dir: bindir,