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 https://gitlab.gnome.org/World/podcasts/issues/55
This commit is contained in:
parent
395e31ff85
commit
5b2edc73ec
1
.gitignore
vendored
1
.gitignore
vendored
@ -20,3 +20,4 @@ repo/
|
|||||||
|
|
||||||
# Files configured by meson
|
# Files configured by meson
|
||||||
podcasts-gtk/src/config.rs
|
podcasts-gtk/src/config.rs
|
||||||
|
podcasts-gtk/src/static_resource.rs
|
||||||
|
|||||||
@ -17,9 +17,6 @@ flatpak:
|
|||||||
|
|
||||||
script:
|
script:
|
||||||
- flatpak-builder --stop-at=${FLATPAK_MODULE} app ${MANIFEST_PATH}
|
- 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
|
# Build the flatpak repo
|
||||||
- flatpak-builder --run app ${MANIFEST_PATH} meson --prefix=/app ${CONFIGURE_ARGS} _build
|
- 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)
|
application_id = 'org.gnome.Podcasts@0@'.format(profile)
|
||||||
i18n = import('i18n')
|
i18n = import('i18n')
|
||||||
|
gnome = import('gnome')
|
||||||
|
|
||||||
subdir('podcasts-gtk/po')
|
subdir('podcasts-gtk/po')
|
||||||
podir = join_paths (meson.source_root (), 'podcasts-gtk', 'po')
|
podir = join_paths (meson.source_root (), 'podcasts-gtk', 'po')
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
authors = ["Jordan Petridis <jpetridis@gnome.com>"]
|
authors = ["Jordan Petridis <jpetridis@gnome.com>"]
|
||||||
build = "build.rs"
|
|
||||||
name = "podcasts-gtk"
|
name = "podcasts-gtk"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +0,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')
|
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')
|
meson.add_install_script('../../scripts/compile-gschema.py')
|
||||||
|
|||||||
@ -15,12 +15,29 @@ run_command(
|
|||||||
check: true
|
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',
|
cargo_release = custom_target('cargo-build',
|
||||||
build_always_stale: true,
|
build_always_stale: true,
|
||||||
output: ['gnome-podcasts'],
|
output: ['gnome-podcasts'],
|
||||||
install: true,
|
install: true,
|
||||||
install_dir: podcasts_bindir,
|
install_dir: podcasts_bindir,
|
||||||
console: true,
|
console: true,
|
||||||
|
depends: podcasts_resources,
|
||||||
command: [cargo_script,
|
command: [cargo_script,
|
||||||
'@SOURCE_ROOT@',
|
'@SOURCE_ROOT@',
|
||||||
'@OUTPUT@',
|
'@OUTPUT@',
|
||||||
|
|||||||
@ -23,7 +23,7 @@ use glib::Bytes;
|
|||||||
pub(crate) fn init() -> Result<(), Error> {
|
pub(crate) fn init() -> Result<(), Error> {
|
||||||
// load the gresource binary at build time and include/link it into the final
|
// load the gresource binary at build time and include/link it into the final
|
||||||
// binary.
|
// 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.
|
// Create Resource it will live as long the value lives.
|
||||||
let gbytes = Bytes::from_static(res_bytes.as_ref());
|
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"
|
# export RUNTIME_REPO="https://sdk.gnome.org/gnome-nightly.flatpakrepo"
|
||||||
|
|
||||||
flatpak-builder --stop-at=${FLATPAK_MODULE} --force-clean app ${MANIFEST_PATH}
|
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
|
# Build the flatpak repo
|
||||||
flatpak-builder --run app ${MANIFEST_PATH} meson --prefix=/app ${CONFIGURE_ARGS} build
|
flatpak-builder --run app ${MANIFEST_PATH} meson --prefix=/app ${CONFIGURE_ARGS} build
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user