Commit 1a5e9054 authored by Felix Häcker's avatar Felix Häcker

Update meson build configuration; Devel app id is now de.haeckerfelix.Shortwave.Devel

parent 45fa01f5
......@@ -516,6 +516,23 @@ dependencies = [
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gettext-rs"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gettext-sys 0.19.9 (registry+https://github.com/rust-lang/crates.io-index)",
"locale_config 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gettext-sys"
version = "0.19.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gio"
version = "0.7.0"
......@@ -923,6 +940,16 @@ dependencies = [
"vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "locale_config"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "lock_api"
version = "0.1.5"
......@@ -1699,6 +1726,7 @@ dependencies = [
"diesel 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"diesel_migrations 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gdk 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gettext-rs 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"gio 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glib 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -2254,6 +2282,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abddb55a898d32925f3148bd281174a68eeb68bbfd9a5938a57b18f506ee4ef7"
"checksum get_if_addrs-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d04f9fb746cf36b191c00f3ede8bde9c8e64f9f4b05ae2694a9ccf5e3f5ab48"
"checksum getrandom 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "cd8e190892c840661957ba9f32dacfb3eb405e657f9f9f60485605f0bb37d6f8"
"checksum gettext-rs 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a668364fec5934bb278781a431e1200acb8ad41a25e149f97206a4b4cc81fca5"
"checksum gettext-sys 0.19.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e034c4ba5bb796730a6cc5eb0d654c16885006a7c3d6c6603581ed809434f153"
"checksum gio 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6261b5d34c30c2d59f879e643704cf54cb44731f3a2038000b68790c03e360e3"
"checksum gio-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "778b856a70a32e2cc5dd5cc7fa1b0c4b6df924fdf5c82984bc28f30565657cfe"
"checksum glib 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "91a70db179515473b57aaff8b879167f1f8460bc5523e97beacf6d1026a8b99d"
......@@ -2288,6 +2318,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum libhandy 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7195919b261667e13240c14004c3fdc1a07a77ee865a9e0da5c2a4e134171c25"
"checksum libhandy-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "17019593005fd387b0d2f6e5b29533796e3206e9f433dbf74846a609ceeb5fbf"
"checksum libsqlite3-sys 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd6457c70bbff456d9fe49deaba35ec47c3e598bf8d7950ff0575ceb7a8a6ad1"
"checksum locale_config 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "73ac19ebe45489e5d53b4346d8b90bb3dd03275c5fdf2ce22a982516d86b535c"
"checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c"
"checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff"
"checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc"
......
......@@ -2,7 +2,6 @@
name = "shortwave"
version = "0.1.0"
authors = ["Felix Häcker <haeckerfelix@gnome.org>"]
build = "build.rs"
edition = "2018"
[dependencies]
......@@ -37,3 +36,4 @@ diesel_migrations = "1.4.0"
xdg = "2.2.0"
soup = { git="https://gitlab.gnome.org/haecker-felix/soup-rs", features = ["futures"] }
indexmap = { git = "https://github.com/bluss/indexmap.git", rev = "380e55c6a330b03f554f59ebd01c075bf396dd47" }
gettext-rs= { version = "0.4", features = ["gettext-system"] }
......@@ -2,24 +2,25 @@
export MESON_BUILD_ROOT="$1"
export MESON_SOURCE_ROOT="$2"
export SHORTWAVE_OUTPUT="$3"
export SHORTWAVE_LOCALEDIR="$4"
export SHORTWAVE_PROFILE="$5"
export APP_OUTPUT="$3"
export APP_LOCALEDIR="$4"
export APP_PROFILE="$5"
export CARGO_TARGET_DIR="$MESON_BUILD_ROOT"/target
export CARGO_HOME="$CARGO_TARGET_DIR"/cargo-home
echo "** Rust version:"
echo "** RUST VERSION **"
rustc --version
if test "$SHORTWAVE_PROFILE" != "Devel"
if test "$APP_PROFILE" != "development"
then
echo "** RELEASE MODE **"
cargo build --manifest-path \
"$MESON_SOURCE_ROOT"/Cargo.toml --release && \
cp "$CARGO_TARGET_DIR"/release/shortwave $SHORTWAVE_OUTPUT
cp "$CARGO_TARGET_DIR"/release/shortwave $APP_OUTPUT
else
echo "** DEBUG MODE **"
cargo build --manifest-path \
"$MESON_SOURCE_ROOT"/Cargo.toml && \
cp "$CARGO_TARGET_DIR"/debug/shortwave $SHORTWAVE_OUTPUT
cp "$CARGO_TARGET_DIR"/debug/shortwave $APP_OUTPUT
fi
{
"app-id" : "de.haeckerfelix.ShortwaveDevel",
"app-id" : "de.haeckerfelix.Shortwave.Devel",
"runtime" : "org.gnome.Platform",
"runtime-version" : "master",
"sdk" : "org.gnome.Sdk",
......
#!/bin/sh
export DIST="$1"
export SOURCE_ROOT="$2"
cd "$SOURCE_ROOT"
mkdir "$DIST"/.cargo
cargo vendor | sed 's/^directory = ".*"/directory = "vendor"/g' > $DIST/.cargo/config
# Move vendor into dist tarball directory
mv vendor "$DIST"
#!/bin/sh
find ../src -name "*.rs"
find ../data/gtk -name "*.ui"
#!/usr/bin/env python3
from os import environ, path
from subprocess import call
prefix = environ.get('MESON_INSTALL_PREFIX', '/usr/local')
datadir = path.join(prefix, 'share')
destdir = environ.get('DESTDIR', '')
# Package managers set this so we don't need to run
if not destdir:
print('Updating icon cache...')
call(['gtk-update-icon-cache', '-qtf', path.join(datadir, 'icons', 'hicolor')])
print('Updating desktop database...')
call(['update-desktop-database', '-q', path.join(datadir, 'applications')])
print('Compiling GSettings schemas...')
call(['glib-compile-schemas', path.join(datadir, 'glib-2.0', 'schemas')])
#!/usr/bin/env python3
import os
import subprocess
install_prefix = os.environ['MESON_INSTALL_PREFIX']
icondir = os.path.join(install_prefix, 'share', 'icons', 'hicolor')
schemadir = os.path.join(install_prefix, 'share', 'glib-2.0', 'schemas')
if not os.environ.get('DESTDIR'):
print('Update icon cache...')
subprocess.call(['gtk-update-icon-cache', '-f', '-t', icondir])
print('Compiling gsettings schemas...')
subprocess.call(['glib-compile-schemas', schemadir])
#!/bin/bash
current=$(cat meson.build | grep -Eo "version: '(.*)'" | grep -Eo "[0-9]+\.[0-9]+.[0-9]+")
mayor=$(echo $current | cut -d"." -f1)
minor=$(echo $current | cut -d"." -f2)
rev=$(echo $current | cut -d"." -f3)
case $1 in
"mayor")
next=$(echo $(($mayor + 1)).0.0)
;;
"minor")
next=$(echo $mayor.$(($minor + 1)).0)
;;
*)
next=$(echo $mayor.$minor.$(($rev + 1)))
;;
esac
sed -i "s/$current/$next/" meson.build
sed -i "s/$current/$next/" Cargo.toml
sed -i "s/version=\"$current\".*/version=\"$next\" date=\"$(date +%Y-%m-%d)\"\/>/" data/de.haeckerfelix.Shortwave.appdata.xml
cargo check
git commit -av
git tag -s $next
ninja -C _build release
#git push --tags
use std::process::Command;
fn main() {
// Rerun the build script when files in the resources folder are changed.
println!("cargo:rerun-if-changed=data");
println!("cargo:rerun-if-changed=data/*");
println!("Run glib-compile-resources...");
let out = Command::new("glib-compile-resources")
.args(&["--generate", "resources.xml"])
.current_dir("data")
.status()
.expect("failed to generate resources");
assert!(out.success());
}
......@@ -2,14 +2,14 @@ scalable_dir = join_paths('hicolor', 'scalable', 'apps')
install_data(
join_paths(scalable_dir, 'de.haeckerfelix.Shortwave.svg'),
install_dir: join_paths(shortwave_datadir, 'icons', scalable_dir),
rename: '@0@.svg'.format(application_id)
install_dir: join_paths(datadir, 'icons', scalable_dir),
rename: '@0@.svg'.format(app_id)
)
symbolic_dir = join_paths('hicolor', 'symbolic', 'apps')
install_data(
join_paths(symbolic_dir, 'de.haeckerfelix.Shortwave-symbolic.svg'),
install_dir: join_paths(shortwave_datadir, 'icons', symbolic_dir),
rename: '@0@-symbolic.svg'.format(application_id)
install_dir: join_paths(datadir, 'icons', symbolic_dir),
rename: '@0@-symbolic.svg'.format(app_id)
)
gnome = import('gnome')
# Icons #
subdir('icons')
# Desktop file
# Desktop file #
desktop_conf = configuration_data()
desktop_conf.set('icon', application_id)
desktop_file = i18n.merge_file (
type: 'desktop',
desktop_conf.set('icon', app_id)
desktop_file = i18n.merge_file(
input: configure_file(
input: files('de.haeckerfelix.Shortwave.desktop.in.in'),
output: 'de.haeckerfelix.Shortwave.desktop.in',
input: files('de.haeckerfelix.Shortwave.desktop.in'),
output: 'de.haeckerfelix.Shortwave.desktop',
configuration: desktop_conf
),
output: '@0@.desktop'.format(application_id),
po_dir: podir,
output: '@0@.desktop'.format(app_id),
type: 'desktop',
po_dir: '../po',
install: true,
install_dir: join_paths (shortwave_datadir, 'applications')
install_dir: join_paths(datadir, 'applications')
)
# Validate Desktop file
desktop_file_validate = find_program('desktop-file-validate', required: false)
if desktop_file_validate.found()
test(
'validate-desktop',
desktop_file_validate,
args: [
desktop_file.full_path()
]
# Validate desktop file #
desktop_utils = find_program('desktop-file-validate', required: false)
if desktop_utils.found()
test('Validate desktop file', desktop_utils,
args: [desktop_file]
)
endif
# Appdata
# Appstream metadata #
appdata_conf = configuration_data()
appdata_conf.set('appid', application_id)
appdata_file = i18n.merge_file (
appdata_conf.set('appid', app_id)
appstream_file = i18n.merge_file(
input: configure_file(
input: files('de.haeckerfelix.Shortwave.appdata.xml.in.in'),
output: 'de.haeckerfelix.Shortwave.appdata.xml.in',
input: files('de.haeckerfelix.Shortwave.appdata.xml.in'),
output: 'de.haeckerfelix.Shortwave.appdata.xml',
configuration: appdata_conf
),
output: '@0@.appdata.xml'.format(application_id),
po_dir: podir,
output: '@0@.appdata.xml'.format(app_id),
po_dir: '../po',
install: true,
install_dir: join_paths (shortwave_datadir, 'metainfo')
install_dir: join_paths(datadir, 'appdata')
)
# Validate Appdata
# Validate appstream metadata #
appstream_util = find_program('appstream-util', required: false)
if appstream_util.found()
test(
'validate-appdata', appstream_util,
args: [
'validate-relax', '--nonet', appdata_file.full_path()
]
test('Validate appstream file', appstream_util,
args: ['validate', appstream_file]
)
endif
# dbus service
# DBUS service
service_conf = configuration_data()
service_conf.set('appid', application_id)
service_conf.set('bindir', shortwave_bindir)
service_conf.set('appid', app_id)
service_conf.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
configure_file(
input: 'de.haeckerfelix.Shortwave.service.in',
output: '@0@.service'.format(application_id),
output: '@0@.service'.format(app_id),
configuration: service_conf,
install_dir: join_paths(shortwave_datadir,'dbus-1', 'services')
install_dir: join_paths(datadir,'dbus-1', 'services')
)
# Gschema file #
install_data('de.haeckerfelix.Shortwave.gschema.xml',
install_dir: join_paths(datadir, 'glib-2.0/schemas')
)
# gschema
install_data('de.haeckerfelix.Shortwave.gschema.xml', install_dir: join_paths(shortwave_datadir, 'glib-2.0', 'schemas'))
# Validate gschema file #
compile_schemas = find_program('glib-compile-schemas', required: false)
if compile_schemas.found()
test('Validate schema file', compile_schemas,
args: ['--strict', '--dry-run', meson.current_source_dir()]
)
endif
# Adatped from GNOME Social by Christopher Davis (GPLv3)
# https://gitlab.gnome.org/BrainBlasted/Social/blob/7e8f36b5e1b96fd64d152de995e15171a823836c/meson.build
project(
'shortwave', 'rust',
version: '7.99.0',
license: 'GPLv3',
project('shortwave',
version: '7.99.0',
meson_version: '>= 0.50.0',
license: 'GPLv3',
)
shortwave_version = meson.project_version()
version_array = shortwave_version.split('.')
shortwave_major_version = version_array[0].to_int()
shortwave_minor_version = version_array[1].to_int()
shortwave_version_micro = version_array[2].to_int()
shortwave_prefix = get_option('prefix')
shortwave_bindir = join_paths(shortwave_prefix, get_option('bindir'))
shortwave_localedir = join_paths(shortwave_prefix, get_option('localedir'))
shortwave_datadir = get_option('datadir')
shortwave_pkgdatadir = join_paths(shortwave_datadir, meson.project_name())
shortwave_icondir = join_paths(shortwave_datadir, 'icons')
if get_option('profile') == 'development'
profile = 'Devel'
name_suffix = ' (Devel)'
vcs_tag = run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip()
if vcs_tag == ''
version_suffix = '-devel'
else
version_suffix = '-@0@'.format (vcs_tag)
endif
else
profile = ''
name_suffix = ''
version_suffix = ''
# Initialize project variables
name = 'Shortwave'
app_id = 'de.haeckerfelix.Shortwave'
profile = get_option('profile')
vcs_tag = run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip()
localedir = join_paths(get_option('prefix'), get_option('localedir'))
datadir = get_option('datadir')
# Change app id for development builds
if profile == 'development'
app_id = '@0@.Devel'.format(app_id)
endif
application_id = 'de.haeckerfelix.Shortwave@0@'.format(profile)
application_name = 'Shortwave'
i18n = import('i18n')
gnome = import('gnome')
podir = join_paths (meson.source_root (), 'po')
subdir('po')
subdir('data')
cargo = find_program('cargo', required: false)
gresource = find_program('glib-compile-resources', required: false)
cargo_vendor = find_program('cargo-vendor', required: false)
cargo_script = find_program('build-aux/cargo.sh')
grabber = find_program('build-aux/grabber.sh')
subdir('src')
subdir('po')
meson.add_dist_script(
'build-aux/dist-vendor.sh',
join_paths(meson.build_root(), 'meson-dist', meson.project_name() + '-' + shortwave_version),
meson.source_root()
)
meson.add_install_script('build-aux/meson_post_install.py')
# Postinstall script (Update icon cache, gsettings, ...)
meson.add_install_script('build-aux/meson/postinstall.py')
......@@ -85,7 +85,7 @@ impl App {
storefront,
});
glib::set_application_name(&format!("{}{}", config::NAME, config::NAME_SUFFIX));
glib::set_application_name(&config::NAME);
glib::set_prgname(Some("shortwave"));
gtk::Window::set_default_icon_name(config::APP_ID);
......@@ -95,9 +95,8 @@ impl App {
}
pub fn run(&self, app: Rc<Self>) {
info!("{}{} ({})", config::NAME, config::NAME_SUFFIX, config::APP_ID);
info!("{} ({}) ({})", config::NAME, config::APP_ID, config::VCS_TAG);
info!("Version: {} ({})", config::VERSION, config::PROFILE);
info!("Datadir: {}", config::PKGDATADIR);
let a = app.clone();
let receiver = self.receiver.borrow_mut().take().unwrap();
......@@ -216,13 +215,19 @@ impl App {
}
fn show_about_dialog(window: gtk::ApplicationWindow) {
let vcs_tag = config::VCS_TAG;
let version_suffix: String = match config::PROFILE {
"development" => format!("\n(Development Commit {})", vcs_tag).to_string(),
_ => "".to_string(),
};
let dialog = gtk::AboutDialog::new();
dialog.set_program_name(config::NAME);
dialog.set_logo_icon_name(Some(config::APP_ID));
dialog.set_comments(Some("A web radio client"));
dialog.set_copyright(Some("© 2019 Felix Häcker"));
dialog.set_license_type(gtk::License::Gpl30);
dialog.set_version(Some(format!("{}{}", config::VERSION, config::NAME_SUFFIX).as_str()));
dialog.set_version(Some(format!("{}{}", config::VERSION, version_suffix).as_str()));
dialog.set_transient_for(Some(&window));
dialog.set_modal(true);
......
pub static APP_ID: &'static str = @APP_ID@;
pub static PKGDATADIR: &'static str = @PKGDATADIR@;
pub static PROFILE: &'static str = @PROFILE@;
pub static NAME_SUFFIX: &'static str = @NAME_SUFFIX@;
pub static NAME: &'static str = @NAME@;
pub static APP_ID: &'static str = @APP_ID@;
pub static VERSION: &'static str = @VERSION@;
pub static PROFILE: &'static str = @PROFILE@;
pub static VCS_TAG: &'static str = @VCS_TAG@;
pub static LOCALEDIR: &'static str = @LOCALEDIR@;
......@@ -15,6 +15,7 @@ extern crate matches;
extern crate diesel;
#[macro_use]
extern crate diesel_migrations;
use gettextrs::*;
mod api;
mod audio;
......@@ -42,6 +43,11 @@ fn main() {
// Initialize Gstreamer
gstreamer::init().expect("Failed to initialize Gstreamer");
// Setup translations
setlocale(LocaleCategory::LcAll, "");
bindtextdomain("demo", config::LOCALEDIR);
textdomain("shortwave");
// Run app itself
let app = App::new();
app.run(app.clone());
......
global_conf = configuration_data()
global_conf.set_quoted('APP_ID', application_id)
global_conf.set_quoted('PKGDATADIR', join_paths(shortwave_prefix, shortwave_pkgdatadir))
global_conf.set_quoted('PROFILE', profile)
global_conf.set_quoted('NAME_SUFFIX', name_suffix)
global_conf.set_quoted('NAME', application_name)
global_conf.set_quoted('VERSION', shortwave_version + version_suffix)
config = configure_file(
conf = configuration_data()
conf.set_quoted('NAME', name)
conf.set_quoted('APP_ID', app_id)
conf.set_quoted('VERSION', meson.project_version())
conf.set_quoted('PROFILE', profile)
conf.set_quoted('VCS_TAG', vcs_tag)
conf.set_quoted('LOCALEDIR', localedir)
configure_file(
input: 'config.rs.in',
output: 'config.rs',
configuration: global_conf
configuration: conf
)
c = run_command(grabber)
sources = c.stdout().strip().split('\n')
# Copy the configuration into src for Cargo
run_command(
'cp',
join_paths(meson.build_root(), 'src', 'config.rs'),
......@@ -22,17 +19,72 @@ run_command(
check: true
)
cargo_release = custom_target('cargo-build',
build_by_default: true,
input: [sources],
output: ['shortwave'],
console: true,
install: true,
install_dir: shortwave_bindir,
command: [cargo_script,
meson.build_root(),
meson.source_root(),
'@OUTPUT@',
shortwave_localedir,
profile])
sources = files(
'api/client.rs',
'api/mod.rs',
'api/object.rs',
'api/station.rs',
'api/station_request.rs',
'api/station_url.rs',
'audio/controller/gtk_controller.rs',
'audio/controller/mod.rs',
'audio/controller/mpris_controller.rs',
'audio/gstreamer_backend.rs',
'audio/mod.rs',
'audio/playback_state.rs',
'audio/player.rs',
'audio/song.rs',
'database/connection.rs',
'database/gradio_db.rs',
'database/library.rs',
'database/mod.rs',
'database/queries.rs',
'database/schema.rs',
'discover/pages/mod.rs',
'discover/pages/search.rs',
'discover/mod.rs',
'discover/storefront.rs',
'discover/tile_button.rs',
'model/mod.rs',
'model/object_wrapper.rs',
'model/song_model.rs',
'ui/mod.rs',
'ui/notification.rs',
'ui/song_listbox.rs',
'ui/song_row.rs',
'ui/station_dialog.rs',
'ui/station_flowbox.rs',
'ui/station_row.rs',
'ui/window.rs',
'app.rs',
'config.rs',
'main.rs',
'path.rs',
'static_resource.rs',
'utils.rs'
)
cargo_script = find_program(join_paths(meson.source_root(), 'build-aux/cargo.sh'))
cargo_release = custom_target(
'cargo-build',
build_by_default: true,
input: sources,
output: meson.project_name(),
console: true,
install: true,
install_dir: get_option('bindir'),
command: [
cargo_script,
meson.build_root(),
meson.source_root(),
'@OUTPUT@',
localedir,
profile
]
)
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