use cargo to compile blueprints
This commit is contained in:
parent
0e78318ddc
commit
630b44b352
4 changed files with 71 additions and 31 deletions
40
build.rs
40
build.rs
|
@ -1,20 +1,52 @@
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let meson_build_root =
|
|
||||||
std::env::var("MESON_BUILD_ROOT").expect("build this through meson please!!");
|
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 stderr:\n{}",
|
||||||
|
output.status,
|
||||||
|
String::from_utf8_lossy(&output.stderr)
|
||||||
|
);
|
||||||
|
|
||||||
|
println!("cargo::rerun-if-changed=resources");
|
||||||
|
}
|
||||||
|
|
||||||
glib_build_tools::compile_resources(
|
glib_build_tools::compile_resources(
|
||||||
&["resources", &format!("{meson_build_root}/resources")],
|
&[PathBuf::from("resources"), out_path.join("resources")],
|
||||||
"resources/audrey.gresource.xml",
|
"resources/audrey.gresource.xml",
|
||||||
"audrey.gresource",
|
"audrey.gresource",
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO: consider using meson to pass include paths
|
// 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()
|
let bindings = bindgen::Builder::default()
|
||||||
.header("src/mpv/wrapper.h")
|
.header("src/mpv/wrapper.h")
|
||||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
|
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
|
||||||
.generate()
|
.generate()
|
||||||
.expect("could not generate bindings for mpv");
|
.expect("could not generate bindings for mpv");
|
||||||
let out_path = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap());
|
|
||||||
bindings
|
bindings
|
||||||
.write_to_file(out_path.join("mpv_ffi.rs"))
|
.write_to_file(out_path.join("mpv_ffi.rs"))
|
||||||
.expect("could not write mpv bindings");
|
.expect("could not write mpv bindings");
|
||||||
|
|
|
@ -38,7 +38,6 @@ add_project_arguments(
|
||||||
|
|
||||||
subdir('data')
|
subdir('data')
|
||||||
subdir('po')
|
subdir('po')
|
||||||
subdir('resources')
|
|
||||||
subdir('src')
|
subdir('src')
|
||||||
|
|
||||||
if get_option('buildtype') == 'debug'
|
if get_option('buildtype') == 'debug'
|
||||||
|
@ -60,7 +59,6 @@ custom_target(
|
||||||
'cargo-build',
|
'cargo-build',
|
||||||
build_by_default: true,
|
build_by_default: true,
|
||||||
build_always_stale: true,
|
build_always_stale: true,
|
||||||
depends: blueprints,
|
|
||||||
input: config_rs,
|
input: config_rs,
|
||||||
console: true,
|
console: true,
|
||||||
# means nothing (always stale and uncopied), we can't cp since env: drops the /bin/sh wrapper
|
# means nothing (always stale and uncopied), we can't cp since env: drops the /bin/sh wrapper
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
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@',
|
|
||||||
],
|
|
||||||
)
|
|
34
src/mpv/wait_event.rs
Normal file
34
src/mpv/wait_event.rs
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
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<Self::Output> {
|
||||||
|
// 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<Option<Waker>>;
|
||||||
|
let waker = unsafe { &*d };
|
||||||
|
let waker = waker.lock().unwrap();
|
||||||
|
if let Some(waker) = waker.take() {
|
||||||
|
waker.wake();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue