From 1523885d803810fe556f0a2a107b08b98069a99a Mon Sep 17 00:00:00 2001 From: Vladislav Nepogodin Date: Sat, 25 Mar 2023 15:38:10 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20compile=20gresource=20with=20car?= =?UTF-8?q?go=20instead=20of=20depending=20on=20meson?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-aux/cargo.py | 1 - build.rs | 24 ++++++++++++++++++++++++ meson.build | 10 ---------- src/meson.build | 3 +-- 4 files changed, 25 insertions(+), 13 deletions(-) create mode 100644 build.rs diff --git a/build-aux/cargo.py b/build-aux/cargo.py index 77ca8a3..547bcc9 100755 --- a/build-aux/cargo.py +++ b/build-aux/cargo.py @@ -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") diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..b02e6e4 --- /dev/null +++ b/build.rs @@ -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); + } +} diff --git a/meson.build b/meson.build index 1ef23ae..b72ff59 100644 --- a/meson.build +++ b/meson.build @@ -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() diff --git a/src/meson.build b/src/meson.build index 31fa543..90112a8 100644 --- a/src/meson.build +++ b/src/meson.build @@ -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,