From 02e3415e7295f2492503417b6f66b4ae0dad4101 Mon Sep 17 00:00:00 2001 From: Erica Z Date: Tue, 5 Nov 2024 09:49:14 +0100 Subject: [PATCH] Revert "use cargo to compile blueprints" This reverts commit 630b44b352dd08eea48a3388d474bf708077c6a0. --- build.rs | 42 +++++------------------------------------- meson.build | 2 ++ resources/meson.build | 24 ++++++++++++++++++++++++ src/mpv/wait_event.rs | 34 ---------------------------------- 4 files changed, 31 insertions(+), 71 deletions(-) create mode 100644 resources/meson.build delete mode 100644 src/mpv/wait_event.rs diff --git a/build.rs b/build.rs index 8844633..e0c2784 100644 --- a/build.rs +++ b/build.rs @@ -1,53 +1,21 @@ -use std::path::PathBuf; - fn main() { - std::env::var("MESON_BUILD_ROOT").expect("build this through meson please!!"); - let out_path = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap()); - - // compile blueprints - { - let mut command = std::process::Command::new("blueprint-compiler"); - - command - .arg("batch-compile") - .arg(out_path.join("resources")) - .arg("resources"); - - for source in [ - "play_queue.blp", - "play_queue_song.blp", - "playbar.blp", - "setup.blp", - "window.blp", - ] { - command.arg(format!("resources/{source}")); - } - - let output = command.output().unwrap(); - assert!( - output.status.success(), - "blueprint-compiler failed with exit status {} and stdout:\n{}", - output.status, - String::from_utf8_lossy(&output.stdout) - ); - - println!("cargo::rerun-if-changed=resources"); - } - + let meson_build_root = + std::env::var("MESON_BUILD_ROOT").expect("build this through meson please!!"); glib_build_tools::compile_resources( - &[PathBuf::from("resources"), out_path.join("resources")], + &["resources", &format!("{meson_build_root}/resources")], "resources/audrey.gresource.xml", "audrey.gresource", ); println!("cargo::rerun-if-changed=resources/audrey.gresource.xml"); // TODO: consider using meson to pass include paths - println!("cargo::rustc-link-lib=mpv"); + println!("cargo:rustc-link-lib=mpv"); let bindings = bindgen::Builder::default() .header("src/mpv/wrapper.h") .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) .generate() .expect("could not generate bindings for mpv"); + let out_path = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap()); bindings .write_to_file(out_path.join("mpv_ffi.rs")) .expect("could not write mpv bindings"); diff --git a/meson.build b/meson.build index 432b7bc..70d92fd 100644 --- a/meson.build +++ b/meson.build @@ -38,6 +38,7 @@ add_project_arguments( subdir('data') subdir('po') +subdir('resources') subdir('src') if get_option('buildtype') == 'debug' @@ -59,6 +60,7 @@ custom_target( 'cargo-build', build_by_default: true, build_always_stale: true, + depends: blueprints, input: config_rs, console: true, # means nothing (always stale and uncopied), we can't cp since env: drops the /bin/sh wrapper diff --git a/resources/meson.build b/resources/meson.build new file mode 100644 index 0000000..57c1863 --- /dev/null +++ b/resources/meson.build @@ -0,0 +1,24 @@ +blueprints = custom_target( + 'blueprints', + input: files( + 'play_queue.blp', + 'play_queue_song.blp', + 'playbar.blp', + 'setup.blp', + 'window.blp', + ), + output: [ + 'play_queue.ui', + 'play_queue_song.ui', + 'playbar.ui', + 'setup.ui', + 'window.ui', + ], + command: [ + find_program('blueprint-compiler'), + 'batch-compile', + '@OUTDIR@', + '@CURRENT_SOURCE_DIR@', + '@INPUT@', + ], +) diff --git a/src/mpv/wait_event.rs b/src/mpv/wait_event.rs deleted file mode 100644 index 1f00309..0000000 --- a/src/mpv/wait_event.rs +++ /dev/null @@ -1,34 +0,0 @@ -use std::future::Future; -use std::task::Waker; - -pub struct WaitEvent<'a>(&'a Handle); - -impl Future for WaitEvent { - type Output = Event; - - fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - // set wakeup before polling, don't miss any wakeup events - { - let waker = self.0.wakeup.lock(); - match waker.as_mut() { - None => *waker = cx.waker().clone(), - Some(waker) if !cx.waker().will_wake(waker) => *waker = cx.waker().clone, - _ => {} - } - } - - match self.0.wait_event_timeout(0.0) { - Some(event) => Poll::Ready(event), - None => Poll::Pending, - } - } -} - -pub(super) extern "C" fn callback(d: *mut c_void) { - let d = d as *const Mutex>; - let waker = unsafe { &*d }; - let waker = waker.lock().unwrap(); - if let Some(waker) = waker.take() { - waker.wake(); - } -}