cargo fmt, and also pass argc/argv to c lib
This commit is contained in:
parent
66500f483c
commit
36b2cf989d
4 changed files with 11 additions and 11 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -9,7 +9,6 @@ dependencies = [
|
||||||
"glib-build-tools",
|
"glib-build-tools",
|
||||||
"gtk4",
|
"gtk4",
|
||||||
"libadwaita",
|
"libadwaita",
|
||||||
"libc",
|
|
||||||
"libsecret",
|
"libsecret",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
adw = { version = "0.7.0", package = "libadwaita", features = ["v1_6"] }
|
adw = { version = "0.7.0", package = "libadwaita", features = ["v1_6"] }
|
||||||
gtk = { version = "0.9.2", package = "gtk4", features = ["v4_16"] }
|
gtk = { version = "0.9.2", package = "gtk4", features = ["v4_16"] }
|
||||||
libc = "0.2.161"
|
|
||||||
libsecret = { version = "0.5.0", features = ["v0_21"] }
|
libsecret = { version = "0.5.0", features = ["v0_21"] }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|
5
build.rs
5
build.rs
|
@ -1,10 +1,7 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
let meson_build_root = std::env::var("MESON_BUILD_ROOT").unwrap();
|
let meson_build_root = std::env::var("MESON_BUILD_ROOT").unwrap();
|
||||||
glib_build_tools::compile_resources(
|
glib_build_tools::compile_resources(
|
||||||
&[
|
&["resources", &format!("{meson_build_root}/resources")],
|
||||||
"resources",
|
|
||||||
&format!("{meson_build_root}/resources"),
|
|
||||||
],
|
|
||||||
"resources/audrey.gresource.xml",
|
"resources/audrey.gresource.xml",
|
||||||
"audrey.gresource",
|
"audrey.gresource",
|
||||||
);
|
);
|
||||||
|
|
15
src/main.rs
15
src/main.rs
|
@ -8,14 +8,19 @@ extern crate libsecret;
|
||||||
#[link(name = "json-glib-1.0")]
|
#[link(name = "json-glib-1.0")]
|
||||||
#[link(name = "mpv")]
|
#[link(name = "mpv")]
|
||||||
#[link(name = "soup-3.0")]
|
#[link(name = "soup-3.0")]
|
||||||
extern {
|
extern "C" {
|
||||||
fn c_main(argc: libc::c_int, argv: *mut *mut libc::c_char) -> libc::c_int;
|
fn c_main(argc: std::ffi::c_int, argv: *const *const std::ffi::c_char) -> std::ffi::c_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
gio::resources_register_include!("audrey.gresource").expect("could not register resources");
|
gio::resources_register_include!("audrey.gresource").expect("could not register resources");
|
||||||
|
|
||||||
unsafe {
|
let args = std::env::args_os();
|
||||||
std::process::exit(c_main(0, std::ptr::null_mut()))
|
let argc = args.len();
|
||||||
}
|
let argv: Vec<std::ffi::CString> = args
|
||||||
|
.map(|arg| std::ffi::CString::new(std::ffi::OsStr::as_encoded_bytes(&arg)).unwrap())
|
||||||
|
.collect();
|
||||||
|
let argv: Vec<*const std::ffi::c_char> = argv.iter().map(|arg| arg.as_ptr()).collect();
|
||||||
|
|
||||||
|
unsafe { std::process::exit(c_main(argc as std::ffi::c_int, argv.as_ptr())) }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue