Skip to content

Commit

Permalink
feat: modernize build system
Browse files Browse the repository at this point in the history
  • Loading branch information
bragefuglseth committed Sep 17, 2023
1 parent b9c5f31 commit 789fb90
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 124 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ jobs:
- uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v6
with:
bundle: fretboard.flatpak
manifest-path: dev.bragefuglseth.Fretboard.json
manifest-path: dev.bragefuglseth.Fretboard.Devel.json
run-tests: true
cache-key: flatpak-builder-${{ github.sha }}
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ serde_json = "1.0.99"

[dependencies.adw]
package = "libadwaita"
version = "0.5.2"
version = "0.5"
features = ["v1_4"]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Name=Fretboard
Comment=Look up guitar chords
Exec=fretboard
Icon=dev.bragefuglseth.Fretboard
Icon=@icon@
Terminal=false
Type=Application
Categories=GTK;Education;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2023 Brage Fuglseth -->
<component type="desktop-application">
<id>dev.bragefuglseth.Fretboard.desktop</id>
<id>@app-id@</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0-or-later</project_license>
<name>Fretboard</name>
Expand All @@ -17,7 +17,7 @@
practice, learn, and master your favorite songs!
</p>
</description>
<translation type="gettext">fretboard</translation>
<translation type="gettext">@gettext-package@</translation>
<keywords>
<keyword>guitar</keyword>
<keyword>chords</keyword>
Expand Down Expand Up @@ -45,7 +45,7 @@
<image>https://raw.githubusercontent.com/bragefuglseth/fretboard/main/data/screenshots/screenshot-4.png</image>
</screenshot>
</screenshots>
<launchable type="desktop-id">dev.bragefuglseth.Fretboard.desktop</launchable>
<launchable type="desktop-id">@app-id@.desktop</launchable>
<url type="homepage">https://github.com/bragefuglseth/fretboard</url>
<url type="bugtracker">https://github.com/bragefuglseth/fretboard/issues</url>
<url type="contribute">https://github.com/bragefuglseth/fretboard#contributing</url>
Expand Down
File renamed without changes
10 changes: 4 additions & 6 deletions data/icons/meson.build
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
scalable_dir = join_paths('hicolor', 'scalable', 'apps')
install_data(
join_paths(scalable_dir, ('@[email protected]').format(application_id)),
install_dir: join_paths(get_option('datadir'), 'icons', scalable_dir)
'@[email protected]'.format(application_id),
install_dir: iconsdir / 'hicolor' / 'scalable' / 'apps'
)

symbolic_dir = join_paths('hicolor', 'symbolic', 'apps')
install_data(
join_paths(symbolic_dir, ('@[email protected]').format(base_id)),
install_dir: join_paths(get_option('datadir'), 'icons', symbolic_dir),
'@[email protected]'.format(base_id),
install_dir: iconsdir / 'hicolor' / 'symbolic' / 'apps',
rename: '@[email protected]'.format(application_id)
)
48 changes: 30 additions & 18 deletions data/meson.build
Original file line number Diff line number Diff line change
@@ -1,39 +1,51 @@
desktop_conf = configuration_data()
desktop_conf.set('icon', application_id)
desktop_file = i18n.merge_file(
input: 'dev.bragefuglseth.Fretboard.desktop.in',
output: 'dev.bragefuglseth.Fretboard.desktop',
type: 'desktop',
po_dir: '../po',
install: true,
install_dir: join_paths(get_option('datadir'), 'applications')
type: 'desktop',
input: configure_file(
input: '@[email protected]'.format(base_id),
output: '@BASENAME@',
configuration: desktop_conf
),
output: '@[email protected]'.format(application_id),
po_dir: podir,
install: true,
install_dir: datadir / 'applications'
)

desktop_utils = find_program('desktop-file-validate', required: false)
if desktop_utils.found()
test('Validate desktop file', desktop_utils, args: [desktop_file])
endif

appdata_conf = configuration_data()
appdata_conf.set('app-id', application_id)
appdata_conf.set('gettext-package', gettext_package)
appstream_file = i18n.merge_file(
input: 'dev.bragefuglseth.Fretboard.appdata.xml.in',
output: 'dev.bragefuglseth.Fretboard.appdata.xml',
po_dir: '../po',
install: true,
install_dir: join_paths(get_option('datadir'), 'appdata')
input: configure_file(
input:'@[email protected]'.format(base_id),
output: '@BASENAME@',
configuration: appdata_conf
),
output: '@[email protected]'.format(application_id),
po_dir: podir,
install: true,
install_dir: datadir / 'appdata'
)

appstream_util = find_program('appstream-util', required: false)
if appstream_util.found()
test('Validate appstream file', appstream_util, args: ['validate-relax', appstream_file])
endif
appstreamcli = find_program('appstreamcli', required: false, disabler: true)
test('Validate appstream file', appstreamcli,
args: ['validate', '--no-net', '--explain', appstream_file])

install_data('dev.bragefuglseth.Fretboard.gschema.xml',
install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas')
install_dir: datadir / 'glib-2.0/schemas'
)

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()])
compile_schemas,
args: ['--strict', '--dry-run', meson.current_source_dir()])
endif

subdir('icons')
9 changes: 0 additions & 9 deletions dev.bragefuglseth.Fretboard.Devel.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@
],
"build-options" : {
"append-path" : "/usr/lib/sdk/rust-stable/bin",
"prepend-path": "/usr/lib/sdk/llvm16/bin",
"prepend-ld-library-path": "/usr/lib/sdk/llvm16/lib",
"build-args": [
"--share=network"
],
"env" : {
"RUST_BACKTRACE" : "1",
"RUST_LOG" : "fretboard=debug"
}
},
"cleanup" : [
"/include",
Expand Down
68 changes: 0 additions & 68 deletions dev.bragefuglseth.Fretboard.json

This file was deleted.

19 changes: 14 additions & 5 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
project('fretboard', 'rust',
version: '2.0',
meson_version: '>= 0.62.0',
default_options: [ 'warning_level=2', 'werror=false', ],
project('fretboard',
'rust',
version: '2.0',
license: 'GPL-3.0-or-later',
meson_version: '>= 0.62.0',
)

i18n = import('i18n')
Expand All @@ -11,6 +12,14 @@ base_id = 'dev.bragefuglseth.Fretboard'

version = meson.project_version()

prefix = get_option('prefix')
localedir = prefix / get_option('localedir')
datadir = prefix / get_option('datadir')
pkgdatadir = datadir / meson.project_name()
iconsdir = datadir / 'icons'
podir = meson.project_source_root() / 'po'
gettext_package = meson.project_name()

if get_option('profile') == 'development'
profile = 'Devel'
vcs_tag = run_command('git', 'rev-parse', '--short', 'HEAD', check: false).stdout().strip()
Expand All @@ -29,7 +38,7 @@ endif
meson.add_dist_script(
'build-aux/dist-vendor.sh',
meson.project_source_root(),
meson.project_build_root() / 'meson-dist' / '@0@-@1@'.format(meson.project_name(), meson.project_version()),
meson.project_build_root() / 'meson-dist' / meson.project_name() + '-' + meson.project_version(),
)

subdir('data')
Expand Down
19 changes: 9 additions & 10 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
gnome = import('gnome')

blueprints = custom_target('blueprints',
Expand Down Expand Up @@ -27,21 +26,21 @@ gnome.compile_resources('fretboard',
conf = configuration_data()
conf.set_quoted('APP_ID', application_id)
conf.set_quoted('VERSION', version + version_suffix)
conf.set_quoted('GETTEXT_PACKAGE', 'fretboard')
conf.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
conf.set_quoted('GETTEXT_PACKAGE', gettext_package)
conf.set_quoted('LOCALEDIR', localedir)
conf.set_quoted('PKGDATADIR', pkgdatadir)

configure_file(
input: 'config.rs.in',
output: 'config.rs',
configuration: conf
input: 'config.rs.in',
output: 'config.rs',
configuration: conf
)

# Copy the config.rs output to the source directory.
run_command(
'cp',
join_paths(meson.project_build_root(), 'src', 'config.rs'),
join_paths(meson.project_source_root(), 'src', 'config.rs'),
meson.project_build_root() / 'src' / 'config.rs',
meson.project_source_root() / 'src' / 'config.rs',
check: true
)

Expand All @@ -50,8 +49,8 @@ cargo_opt = [ '--manifest-path', meson.project_source_root() / 'Cargo.toml' ]
cargo_opt += [ '--target-dir', meson.project_build_root() / 'src' ]
cargo_env = [ 'CARGO_HOME=' + meson.project_build_root() / 'cargo-home' ]

if get_option('buildtype') == 'release'
cargo_options += [ '--release' ]
if get_option('profile') == 'default'
cargo_opt += [ '--release' ]
rust_target = 'release'
else
rust_target = 'debug'
Expand Down
4 changes: 2 additions & 2 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,15 +558,15 @@ impl FretboardWindow {

fn chord_data_path() -> PathBuf {
let mut path = glib::user_data_dir();
path.push("dev.bragefuglseth.Fretboard");
path.push(APP_ID);
std::fs::create_dir_all(&path).expect("able to create directory");
path.push("chord.json");
path
}

fn bookmarks_data_path() -> PathBuf {
let mut path = glib::user_data_dir();
path.push("dev.bragefuglseth.Fretboard");
path.push(APP_ID);
std::fs::create_dir_all(&path).expect("able to create directory");
path.push("bookmarks.json");
path
Expand Down

0 comments on commit 789fb90

Please sign in to comment.