let cargo build the resources

This commit is contained in:
Erica Z 2024-10-29 11:46:58 +01:00
parent 824a68956a
commit 66500f483c
20 changed files with 52 additions and 53 deletions

10
Cargo.lock generated
View file

@ -6,6 +6,7 @@ version = 3
name = "audrey"
version = "0.1.0"
dependencies = [
"glib-build-tools",
"gtk4",
"libadwaita",
"libc",
@ -307,6 +308,15 @@ dependencies = [
"smallvec",
]
[[package]]
name = "glib-build-tools"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7029c2651d9b5d5a3eea93ec8a1995665c6d3a69ce9bf6042ad9064d134736d8"
dependencies = [
"gio 0.20.4",
]
[[package]]
name = "glib-macros"
version = "0.19.9"

View file

@ -8,3 +8,6 @@ adw = { version = "0.7.0", package = "libadwaita", features = ["v1_6"] }
gtk = { version = "0.9.2", package = "gtk4", features = ["v4_16"] }
libc = "0.2.161"
libsecret = { version = "0.5.0", features = ["v0_21"] }
[build-dependencies]
glib-build-tools = "0.20.0"

11
build.rs Normal file
View file

@ -0,0 +1,11 @@
fn main() {
let meson_build_root = std::env::var("MESON_BUILD_ROOT").unwrap();
glib_build_tools::compile_resources(
&[
"resources",
&format!("{meson_build_root}/resources"),
],
"resources/audrey.gresource.xml",
"audrey.gresource",
);
}

View file

@ -37,8 +37,9 @@ add_project_arguments(
)
subdir('data')
subdir('src')
subdir('po')
subdir('resources')
subdir('src')
cargo = find_program('cargo')
# TODO: cargo release build
@ -46,12 +47,16 @@ custom_target(
'cargo-build',
build_by_default: true,
build_always_stale: true,
depends: audrey_c,
depends: [
audrey_c,
blueprints,
],
output: meson.project_name(),
command: [
'env',
'CARGO_HOME=' + meson.project_build_root() / 'cargo-home',
'RUSTFLAGS=-L ' + fs.parent(audrey_c.full_path()),
'MESON_BUILD_ROOT=' + meson.project_build_root(),
cargo,
'build',
'--manifest-path', meson.project_source_root() / 'Cargo.toml',

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/eu/callcc/audrey">
<file>style.css</file>
<file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
<file preprocess="xml-stripblanks">play_queue.ui</file>
<file preprocess="xml-stripblanks">play_queue_song.ui</file>
<file preprocess="xml-stripblanks">playbar.ui</file>
<file preprocess="xml-stripblanks">setup.ui</file>
<file preprocess="xml-stripblanks">window.ui</file>
</gresource>
</gresources>

View file

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/eu/callcc/audrey">
<file>style.css</file>
<file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
<file preprocess="xml-stripblanks">ui/play_queue.ui</file>
<file preprocess="xml-stripblanks">ui/play_queue_song.ui</file>
<file preprocess="xml-stripblanks">ui/playbar.ui</file>
<file preprocess="xml-stripblanks">ui/setup.ui</file>
<file preprocess="xml-stripblanks">ui/window.ui</file>
</gresource>
</gresources>

View file

@ -1,5 +1,6 @@
use gtk::gio;
extern crate adw;
extern crate gtk;
extern crate libsecret;
#[link(name = "audrey")]
@ -9,12 +10,12 @@ extern crate libsecret;
#[link(name = "soup-3.0")]
extern {
fn c_main(argc: libc::c_int, argv: *mut *mut libc::c_char) -> libc::c_int;
fn audrey_get_resource() -> *mut ();
}
fn main() {
gio::resources_register_include!("audrey.gresource").expect("could not register resources");
unsafe {
audrey_get_resource();
std::process::exit(c_main(0, std::ptr::null_mut()))
}
}

View file

@ -21,37 +21,6 @@ audrey_deps = [
dependency('mpv', version: '>= 2.3'),
]
subdir('ui')
audrey_sources += gnome.compile_resources(
'audrey-resources',
'audrey.gresource.xml',
c_name: 'audrey',
dependencies: blueprints,
# this is a huge hack, as by default only src/ui to the 'blueprints' dep
# and ../src is passed, which means the ui/xyz.ui prefix will not be found
# anywhere, as src/ui already has the ui in the path.
# the reason we have to put blp in its own ui folder, is because:
# - blueprint-compiler batch-compile outputs in the same directory structure,
# i.e. if you pass ui/x.blp outdir foo, it will create foo/ui/x.ui,
# - meson doesn't support output:[] with dir/ prefix
# .. which means, all the files are always dirty; meson will try find 'src/x.ui'
# as an output for dirty tracking, but blp is outputting src/ui/x.ui
# because of the directory structure.
# using manual blueprint-compiler invocations to put the output in the
# 'correct' tracked place doesn't work either,
# since then it will be in this dir and not in ui/ and so all the ui/ prefixes
# in gresources won't find it, and we can't put it in a ui/ output from the
# current dir due to the above and meson not letting you.
#so since we use ui/ prefix, we need a meson.build in ui/ and then this hack
# to ensure compile sees the ui/ prefix starting from this src/ dir still,
# despite the dependency normally doing this for you
# note that the 'documented' way to use blp is with outdir:[.] which is
# fundamentally broken as then nothing is tracked except the dirs existence, which
# is racy as the dependency is satistfied before anything is compiled
extra_args: ['--sourcedir', 'src'],
)
audrey_c = static_library(
'audrey',
audrey_sources,

View file

@ -1056,7 +1056,7 @@ ui_play_queue_song_class_init (UiPlayQueueSongClass * klass,
#line 4 "../src/ui/play_queue.vala"
g_object_class_install_property (G_OBJECT_CLASS (klass), UI_PLAY_QUEUE_SONG_SONG_PROPERTY, ui_play_queue_song_properties[UI_PLAY_QUEUE_SONG_SONG_PROPERTY] = g_param_spec_object ("song", "song", "song", TYPE_PLAYBIN_SONG, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
#line 4 "../src/ui/play_queue.vala"
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/eu/callcc/audrey/ui/play_queue_song.ui");
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/eu/callcc/audrey/play_queue_song.ui");
#line 4 "../src/ui/play_queue.vala"
gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "format_duration", G_CALLBACK(ui_play_queue_song_format_duration));
#line 4 "../src/ui/play_queue.vala"
@ -1633,7 +1633,7 @@ ui_play_queue_class_init (UiPlayQueueClass * klass,
#line 115 "../src/ui/play_queue.vala"
g_object_class_install_property (G_OBJECT_CLASS (klass), UI_PLAY_QUEUE_CAN_CLEAR_ALL_PROPERTY, ui_play_queue_properties[UI_PLAY_QUEUE_CAN_CLEAR_ALL_PROPERTY] = g_param_spec_boolean ("can-clear-all", "can-clear-all", "can-clear-all", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
#line 115 "../src/ui/play_queue.vala"
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/eu/callcc/audrey/ui/play_queue.ui");
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/eu/callcc/audrey/play_queue.ui");
#line 115 "../src/ui/play_queue.vala"
gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_song_list_setup", G_CALLBACK(_ui_play_queue_on_song_list_setup_gtk_signal_list_item_factory_setup));
#line 115 "../src/ui/play_queue.vala"

View file

@ -950,7 +950,7 @@ ui_playbar_class_init (UiPlaybarClass * klass,
#line 2 "../src/ui/playbar.vala"
g_object_class_install_property (G_OBJECT_CLASS (klass), UI_PLAYBAR_VOLUME_PROPERTY, ui_playbar_properties[UI_PLAYBAR_VOLUME_PROPERTY] = g_param_spec_int ("volume", "volume", "volume", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
#line 2 "../src/ui/playbar.vala"
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/eu/callcc/audrey/ui/playbar.ui");
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/eu/callcc/audrey/playbar.ui");
#line 2 "../src/ui/playbar.vala"
gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "format_timestamp", G_CALLBACK(ui_playbar_format_timestamp));
#line 2 "../src/ui/playbar.vala"

View file

@ -1268,7 +1268,7 @@ ui_setup_class_init (UiSetupClass * klass,
#line 20 "../src/ui/setup.vala"
g_object_class_install_property (G_OBJECT_CLASS (klass), UI_SETUP_PASSWORD_PROPERTY, ui_setup_properties[UI_SETUP_PASSWORD_PROPERTY] = g_param_spec_string ("password", "password", "password", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
#line 20 "../src/ui/setup.vala"
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/eu/callcc/audrey/ui/setup.ui");
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/eu/callcc/audrey/setup.ui");
#line 20 "../src/ui/setup.vala"
ui_setup_signals[UI_SETUP_CONNECTED_SIGNAL] = g_signal_new ("connected", UI_TYPE_SETUP, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, SUBSONIC_TYPE_CLIENT);
#line 34 "../src/ui/setup.vala"

View file

@ -1376,7 +1376,7 @@ ui_window_class_init (UiWindowClass * klass,
#line 2 "../src/ui/window.vala"
g_object_class_install_property (G_OBJECT_CLASS (klass), UI_WINDOW_CAN_CLICK_SHUFFLE_ALL_PROPERTY, ui_window_properties[UI_WINDOW_CAN_CLICK_SHUFFLE_ALL_PROPERTY] = g_param_spec_boolean ("can-click-shuffle-all", "can-click-shuffle-all", "can-click-shuffle-all", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
#line 2 "../src/ui/window.vala"
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/eu/callcc/audrey/ui/window.ui");
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/eu/callcc/audrey/window.ui");
#line 2 "../src/ui/window.vala"
gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "play_queue", FALSE, G_STRUCT_OFFSET (UiWindow, play_queue));
#line 2 "../src/ui/window.vala"