Commit 5b2edc73 authored by Christopher Davis's avatar Christopher Davis Committed by Jordan Petridis

build: Build resources with meson instead of build.rs

Allows us to get rid of build.rs, which was only used to
compile resources. static_resource.rs is now created by
meson, and the meson path is used for include_bytes!.

Closes #55
parent 395e31ff
......@@ -20,3 +20,4 @@ repo/
# Files configured by meson
podcasts-gtk/src/config.rs
podcasts-gtk/src/static_resource.rs
......@@ -17,9 +17,6 @@ flatpak:
script:
- flatpak-builder --stop-at=${FLATPAK_MODULE} app ${MANIFEST_PATH}
# https://gitlab.gnome.org/World/podcasts/issues/55
# Force regeneration of gresources regardless of artifacts chage
- flatpak-builder --run app ${MANIFEST_PATH} glib-compile-resources --sourcedir=podcasts-gtk/resources/ podcasts-gtk/resources/resources.xml
# Build the flatpak repo
- flatpak-builder --run app ${MANIFEST_PATH} meson --prefix=/app ${CONFIGURE_ARGS} _build
......
......@@ -46,6 +46,7 @@ endif
application_id = 'org.gnome.Podcasts@0@'.format(profile)
i18n = import('i18n')
gnome = import('gnome')
subdir('podcasts-gtk/po')
podir = join_paths (meson.source_root (), 'podcasts-gtk', 'po')
......
[package]
authors = ["Jordan Petridis <jpetridis@gnome.com>"]
build = "build.rs"
name = "podcasts-gtk"
version = "0.1.0"
......
use std::process::Command;
fn main() {
// Rerun the build script when files in the resources folder are changed.
println!("cargo:rerun-if-changed=resources");
println!("cargo:rerun-if-changed=resources/*");
let out = Command::new("glib-compile-resources")
.args(&["--generate", "resources.xml"])
.current_dir("resources")
.status()
.expect("failed to generate resources");
assert!(out.success());
}
......@@ -58,4 +58,11 @@ configure_file(
install_dir: join_paths(datadir,'dbus-1', 'services')
)
podcasts_resources = gnome.compile_resources(
'resources',
'resources.xml',
gresource_bundle: true,
source_dir: meson.current_build_dir()
)
meson.add_install_script('../../scripts/compile-gschema.py')
......@@ -15,12 +15,29 @@ run_command(
check: true
)
# include_bytes! only takes a string literal
resource_conf = configuration_data()
resource_conf.set_quoted('RESOURCEFILE', podcasts_resources.full_path())
resource_rs = configure_file(
input: 'static_resource.rs.in',
output: 'static_resource.rs',
configuration: resource_conf
)
run_command(
'cp',
resource_rs,
meson.current_source_dir(),
check: true
)
cargo_release = custom_target('cargo-build',
build_always_stale: true,
output: ['gnome-podcasts'],
install: true,
install_dir: podcasts_bindir,
console: true,
depends: podcasts_resources,
command: [cargo_script,
'@SOURCE_ROOT@',
'@OUTPUT@',
......
......@@ -23,7 +23,7 @@ use glib::Bytes;
pub(crate) fn init() -> Result<(), Error> {
// load the gresource binary at build time and include/link it into the final
// binary.
let res_bytes = include_bytes!("../resources/resources.gresource");
let res_bytes = include_bytes!(@RESOURCEFILE@);
// Create Resource it will live as long the value lives.
let gbytes = Bytes::from_static(res_bytes.as_ref());
......
......@@ -12,9 +12,6 @@ export CONFIGURE_ARGS="-Dprofile=development"
# export RUNTIME_REPO="https://sdk.gnome.org/gnome-nightly.flatpakrepo"
flatpak-builder --stop-at=${FLATPAK_MODULE} --force-clean app ${MANIFEST_PATH}
# https://gitlab.gnome.org/World/podcasts/issues/55
# Force regeneration of gresources regardless of artifacts chage
flatpak-builder --run app ${MANIFEST_PATH} glib-compile-resources --sourcedir=podcasts-gtk/resources/ podcasts-gtk/resources/resources.xml
# Build the flatpak repo
flatpak-builder --run app ${MANIFEST_PATH} meson --prefix=/app ${CONFIGURE_ARGS} build
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment