Overhaul Meson / Flatpak Building

This commit is contained in:
dav 2024-01-24 18:07:56 -08:00
parent 1b98054024
commit 6cde50daf3
21 changed files with 802 additions and 550 deletions

1042
burrow-gtk/Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -10,7 +10,7 @@ anyhow = "1.0"
relm4 = { features = ["libadwaita", "gnome_45"], git = "https://github.com/Relm4/Relm4" } relm4 = { features = ["libadwaita", "gnome_45"], git = "https://github.com/Relm4/Relm4" }
burrow = { version = "*", path = "../burrow/" } burrow = { version = "*", path = "../burrow/" }
tokio = { version = "1.35.0", features = ["time", "sync"] } tokio = { version = "1.35.0", features = ["time", "sync"] }
gettext-rs = "0.7.0" gettext-rs = { version = "0.7.0", features = ["gettext-system"] }
[build-dependencies] [build-dependencies]
anyhow = "1.0" anyhow = "1.0"

View file

@ -24,12 +24,24 @@
"RUST_LOG" : "burrow-gtk=debug" "RUST_LOG" : "burrow-gtk=debug"
} }
}, },
"cleanup" : [
"/include",
"/lib/pkgconfig",
"/man",
"/share/doc",
"/share/gtk-doc",
"/share/man",
"/share/pkgconfig",
"*.la",
"*.a"
],
"modules" : [ "modules" : [
{ {
"name" : "burrow-gtk", "name" : "burrow-gtk",
"builddir" : true, "builddir" : true,
"subdir" : "burrow-gtk", "subdir" : "burrow-gtk",
"buildsystem" : "meson", "buildsystem" : "meson",
"config-opts": ["--buildtype=debug"],
"sources" : [ "sources" : [
{ {
"type": "dir", "type": "dir",

View file

@ -41,6 +41,7 @@
"builddir" : true, "builddir" : true,
"subdir" : "burrow-gtk", "subdir" : "burrow-gtk",
"buildsystem" : "meson", "buildsystem" : "meson",
"config-opts": ["--buildtype=release"],
"sources" : [ "sources" : [
{ {
"type": "dir", "type": "dir",

View file

@ -1,7 +1,7 @@
[Desktop Entry] [Desktop Entry]
Name=Burrow Name=@APP_NAME_CAPITALIZED@
Exec=burrow-gtk Exec=@APP_NAME@
Icon=com.hackclub.burrow Icon=@APP_ID@
Terminal=false Terminal=false
Type=Application Type=Application
Categories=GTK;Network Categories=GTK;Network

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="@APP_NAME@">
<schema id="@APP_ID" path="@APP_IDPATH@">
</schema>
</schemalist>

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>@APP_ID@</id>
<metadata_license>CC0</metadata_license>
<project_license>GPL-3.0-or-later</project_license>
<name translatable="no">@APP_NAME_CAPITALIZED@</name>
<launchable type="desktop-id">@APP_ID@.desktop</launchable>
<description>
<p>No description</p>
</description>
<summary>
<p>No Summary</p>
</summary>
</component>

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>com.hackclub.burrow.desktop</id>
<project_license>GPL-3.0-or-later</project_license>
<description>
<p>No description</p>
</description>
</component>

View file

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="burrow-gtk">
<schema id="com.hackclub.burrow" path="/com/hackclub/burrow/">
</schema>
</schemalist>

View file

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before After
Before After

View file

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g color="#000" fill="#2e3436"><path d="M7.188 2.281c-.094.056-.192.125-.29.19L5.566 3.803a1.684 1.684 0 11-2.17 2.17L2.332 7.037c.506-.069 1.017-.136 1.2.026.242.214.139 1.031.155 1.656.213.088.427.171.657.219.04.008.085-.007.125 0 .337-.525.683-1.288 1-1.344.322-.057.905.562 1.406.937a3.67 3.67 0 00.656-.468c-.195-.595-.594-1.369-.437-1.657.158-.29 1.019-.37 1.625-.531.028-.183.062-.371.062-.562 0-.075-.027-.146-.031-.22-.587-.217-1.435-.385-1.562-.687-.128-.302.34-1.021.593-1.593a3.722 3.722 0 00-.593-.532zm3.875 3.25c-.165.475-.305 1.086-.47 1.563-.43.047-.84.14-1.218.312-.38-.322-.787-.773-1.156-1.093a5.562 5.562 0 00-.688.468c.177.46.453 1.001.625 1.469-.298.309-.531.67-.719 1.063-.494 0-1.102-.084-1.593-.094a5.68 5.68 0 00-.219.812c.435.24 1.006.468 1.438.72-.006.093-.032.185-.032.28 0 .333.049.66.125.97-.382.304-.898.63-1.28.937.015.044.04.083.058.127l.613.613c.417-.1.868-.223 1.266-.303.248.343.532.626.875.875-.027.135-.068.283-.104.428.174-.063.34-.155.482-.297l1.432-1.432a1.994 1.994 0 01.533-3.918c.919 0 1.684.623 1.918 1.467l1.338-1.338c.06-.06.11-.124.156-.191-.035-.062-.06-.13-.1-.188.096-.152.205-.31.315-.47.017-.348-.1-.7-.37-.971l-.177-.176c-.28.192-.561.387-.83.555-.345-.233-.746-.383-1.156-.5-.077-.507-.107-1.132-.187-1.625a5.44 5.44 0 00-.875-.063zm-9.247.608c-.087.068-.173.138-.254.205l.014.035z" style="marker:none" overflow="visible"/><path d="M8.707.293a1 1 0 00-1.415 0l-6.999 7a1 1 0 000 1.413l7 7.001a1 1 0 001.415 0l7-7a1 1 0 000-1.413zm-.708 2.121l5.587 5.587L8 13.586 2.414 7.999z" style="line-height:normal;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;text-transform:none;text-orientation:mixed;shape-padding:0;isolation:auto;mix-blend-mode:normal;marker:none" font-weight="400" font-family="sans-serif" overflow="visible"/></g></svg> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g color="#000" fill="#2e3436"><path d="M7.188 2.281c-.094.056-.192.125-.29.19L5.566 3.803a1.684 1.684 0 11-2.17 2.17L2.332 7.037c.506-.069 1.017-.136 1.2.026.242.214.139 1.031.155 1.656.213.088.427.171.657.219.04.008.085-.007.125 0 .337-.525.683-1.288 1-1.344.322-.057.905.562 1.406.937a3.67 3.67 0 00.656-.468c-.195-.595-.594-1.369-.437-1.657.158-.29 1.019-.37 1.625-.531.028-.183.062-.371.062-.562 0-.075-.027-.146-.031-.22-.587-.217-1.435-.385-1.562-.687-.128-.302.34-1.021.593-1.593a3.722 3.722 0 00-.593-.532zm3.875 3.25c-.165.475-.305 1.086-.47 1.563-.43.047-.84.14-1.218.312-.38-.322-.787-.773-1.156-1.093a5.562 5.562 0 00-.688.468c.177.46.453 1.001.625 1.469-.298.309-.531.67-.719 1.063-.494 0-1.102-.084-1.593-.094a5.68 5.68 0 00-.219.812c.435.24 1.006.468 1.438.72-.006.093-.032.185-.032.28 0 .333.049.66.125.97-.382.304-.898.63-1.28.937.015.044.04.083.058.127l.613.613c.417-.1.868-.223 1.266-.303.248.343.532.626.875.875-.027.135-.068.283-.104.428.174-.063.34-.155.482-.297l1.432-1.432a1.994 1.994 0 01.533-3.918c.919 0 1.684.623 1.918 1.467l1.338-1.338c.06-.06.11-.124.156-.191-.035-.062-.06-.13-.1-.188.096-.152.205-.31.315-.47.017-.348-.1-.7-.37-.971l-.177-.176c-.28.192-.561.387-.83.555-.345-.233-.746-.383-1.156-.5-.077-.507-.107-1.132-.187-1.625a5.44 5.44 0 00-.875-.063zm-9.247.608c-.087.068-.173.138-.254.205l.014.035z" style="marker:none" overflow="visible"/><path d="M8.707.293a1 1 0 00-1.415 0l-6.999 7a1 1 0 000 1.413l7 7.001a1 1 0 001.415 0l7-7a1 1 0 000-1.413zm-.708 2.121l5.587 5.587L8 13.586 2.414 7.999z" style="line-height:normal;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;text-transform:none;text-orientation:mixed;shape-padding:0;isolation:auto;mix-blend-mode:normal;marker:none" font-weight="400" font-family="sans-serif" overflow="visible"/></g></svg>

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 2 KiB

Before After
Before After

View file

@ -1,13 +0,0 @@
application_id = 'com.hackclub.burrow'
scalable_dir = join_paths('hicolor', 'scalable', 'apps')
install_data(
join_paths(scalable_dir, ('@0@.svg').format(application_id)),
install_dir: join_paths(get_option('datadir'), 'icons', scalable_dir)
)
symbolic_dir = join_paths('hicolor', 'symbolic', 'apps')
install_data(
join_paths(symbolic_dir, ('@0@-symbolic.svg').format(application_id)),
install_dir: join_paths(get_option('datadir'), 'icons', symbolic_dir)
)

View file

@ -1,39 +1,90 @@
# app.desktop.in.in
desktop_conf = configuration_data()
desktop_conf.set('APP_ID', app_id)
desktop_conf.set('APP_NAME', app_name)
desktop_conf.set('APP_NAME_CAPITALIZED', app_name_capitalized)
desktop_file_in = configure_file(
input: 'app.desktop.in.in',
output: '@BASENAME@',
configuration: desktop_conf,
)
desktop_file = i18n.merge_file( desktop_file = i18n.merge_file(
input: 'com.hackclub.burrow.desktop.in', input: desktop_file_in,
output: 'com.hackclub.burrow.desktop', output: app_id + '.desktop',
type: 'desktop', type: 'desktop',
po_dir: '../po', po_dir: '../po',
install: true, install: true,
install_dir: join_paths(get_option('datadir'), 'applications') install_dir: datadir / 'applications',
) )
desktop_utils = find_program('desktop-file-validate', required: false) if desktop_file_validate.found()
if desktop_utils.found() test(
test('Validate desktop file', desktop_utils, args: [desktop_file]) 'validate-desktop',
desktop_file_validate,
args: [desktop_file],
)
endif endif
appstream_file = i18n.merge_file( # app.gschema.xml.in
input: 'com.hackclub.burrow.appdata.xml.in', gschema_conf = configuration_data()
output: 'com.hackclub.burrow.appdata.xml', gschema_conf.set('APP_ID', app_id)
po_dir: '../po', gschema_conf.set('APP_NAME', app_name)
install: true, gschema_conf.set('APP_IDPATH', app_idpath)
install_dir: join_paths(get_option('datadir'), 'appdata') gschema_file = configure_file(
input: 'app.gschema.xml.in',
output: app_id + '.gschema.xml',
configuration: gschema_conf,
install: true,
install_dir: datadir / 'glib-2.0' / 'schemas',
)
if glib_compile_schemas.found()
test(
'validate-gschema',
glib_compile_schemas,
args: [
'--dry-run',
datadir / 'glib-2.0' / 'schemas',
],
)
endif
# app.metainfo.xml.in
appdata_conf = configuration_data()
appdata_conf.set('APP_ID', app_id)
appdata_conf.set('APP_NAME', app_name)
appdata_conf.set('APP_NAME_CAPITALIZED', app_name_capitalized)
appdata_file_in = configure_file(
input: 'app.metainfo.xml.in',
output: '@BASENAME@',
configuration: appdata_conf,
)
appdata_file = i18n.merge_file(
input: appdata_file_in,
output: app_id + '.metainfo.xml',
po_dir: '../po',
install: true,
install_dir: datadir / 'metainfo',
) )
appstream_util = find_program('appstream-util', required: false)
if appstream_util.found() if appstream_util.found()
test('Validate appstream file', appstream_util, args: ['validate', appstream_file]) test(
'validate-appdata',
appstream_util,
args: ['validate', '--nonet', appdata_file],
)
endif endif
install_data('com.hackclub.burrow.gschema.xml', install_data(
install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas') 'icons/hicolor/scalable/apps/' + app_name + '.svg',
install_dir: datadir / 'icons' / 'hicolor' / 'scalable' / 'apps',
rename: app_id + '.svg',
) )
compile_schemas = find_program('glib-compile-schemas', required: false) install_data(
if compile_schemas.found() 'icons/hicolor/symbolic/apps/' + app_name + '-symbolic.svg',
test('Validate schema file', install_dir: datadir / 'icons' / 'hicolor' / 'symbolic' / 'apps',
compile_schemas, rename: app_id + '-symbolic.svg',
args: ['--strict', '--dry-run', meson.current_source_dir()]) )
endif
subdir('icons')

View file

@ -3,4 +3,3 @@
<gresource prefix="/com/hackclub/burrow"> <gresource prefix="/com/hackclub/burrow">
</gresource> </gresource>
</gresources> </gresources>

View file

@ -1,28 +1,56 @@
project('burrow-gtk', 'rust', project(
version: '0.1.0', 'burrow-gtk',
meson_version: '>= 0.62.0', ['rust'],
default_options: [ 'warning_level=2', 'werror=false', ], version: '0.0.1',
meson_version: '>= 1.0',
) )
# Find Cargo
cargo_bin = find_program('cargo')
cargo_env = ['CARGO_HOME=' + meson.project_build_root()]
cargo_opt = ['--manifest-path', meson.project_source_root() / 'Cargo.toml']
cargo_opt += ['--target-dir', meson.project_build_root() / 'target']
# Config
prefix = get_option('prefix')
datadir = prefix / get_option('datadir')
localedir = prefix / get_option('localedir')
app_name = 'burrow-gtk'
app_name_capitalized = 'Burrow'
base_id = 'com.hackclub.burrow'
app_idpath = '/com/hackclub/' + app_name + '/'
if get_option('buildtype') == 'release'
cargo_opt += ['--release']
rust_target = 'release'
app_id = base_id
else
rust_target = 'debug'
app_id = base_id + '-' + 'devel'
endif
# Imports
i18n = import('i18n') i18n = import('i18n')
gnome = import('gnome') gnome = import('gnome')
# External Dependencies
dependency('gtk4', version: '>= 4.12')
dependency('libadwaita-1', version: '>= 1.4')
glib_compile_resources = find_program('glib-compile-resources', required: true) glib_compile_resources = find_program('glib-compile-resources', required: true)
glib_compile_schemas = find_program('glib-compile-schemas', required: true) glib_compile_schemas = find_program('glib-compile-schemas', required: true)
desktop_file_validate = find_program('desktop-file-validate', required: false) desktop_file_validate = find_program('desktop-file-validate', required: false)
appstream_util = find_program('appstream-util', required: false) appstream_util = find_program('appstream-util', required: false)
fc_cache = find_program('fc-cache', required: false) fc_cache = find_program('fc-cache', required: false)
update_mime_database = find_program('update-mime-database', required: false)
dependency('gtk4', version: '>= 4.12')
dependency('libadwaita-1', version: '>= 1.4')
# Our Sources
subdir('po') subdir('po')
subdir('data') subdir('data')
subdir('src') subdir('src')
# Gnome Post Install
gnome.post_install( gnome.post_install(
glib_compile_schemas: true, glib_compile_schemas: true,
gtk_update_icon_cache: true, gtk_update_icon_cache: true,
update_desktop_database: true, update_desktop_database: true,
) )

View file

@ -1,3 +1 @@
data/com.hackclub.Burrow.desktop.in data/app.desktop.in.in
data/com.hackclub.Burrow.appdata.xml.in
data/com.hackclub.Burrow.gschema.xml

View file

@ -1 +1 @@
i18n.gettext('burrow-gtk', preset: 'glib') i18n.gettext(app_name, preset: 'glib')

View file

@ -18,7 +18,7 @@ pub enum AppMsg {
impl App { impl App {
pub fn run() { pub fn run() {
let app = RelmApp::new("com.hackclub.burrow"); let app = RelmApp::new(config::ID);
Self::setup_gresources().unwrap(); Self::setup_gresources().unwrap();
Self::setup_i18n().unwrap(); Self::setup_i18n().unwrap();

View file

@ -21,7 +21,7 @@ impl SimpleComponent for SettingsScreen {
fn init( fn init(
init: Self::Init, init: Self::Init,
root: &Self::Root, root: Self::Root,
sender: ComponentSender<Self>, sender: ComponentSender<Self>,
) -> ComponentParts<Self> { ) -> ComponentParts<Self> {
let diag_group = settings::DiagGroup::builder() let diag_group = settings::DiagGroup::builder()

View file

@ -1,4 +1,8 @@
pub static VERSION: &str = @VERSION@; #[allow(unused)]
pub static GETTEXT_PACKAGE: &str = @GETTEXT_PACKAGE@; pub const ID: &str = @ID@;
pub static LOCALEDIR: &str = @LOCALEDIR@; #[allow(unused)]
pub static PKGDATADIR: &str = @PKGDATADIR@; pub const VERSION: &str = @VERSION@;
#[allow(unused)]
pub const LOCALEDIR: &str = @LOCALEDIR@;
#[allow(unused)]
pub const GETTEXT_PACKAGE: &str = @GETTEXT_PACKAGE@;

View file

@ -1,46 +1,34 @@
pkgdatadir = get_option('prefix') / get_option('datadir') / meson.project_name() # config.rs.in
global_conf = configuration_data() global_conf = configuration_data()
global_conf.set_quoted('ID', app_id)
global_conf.set_quoted('VERSION', meson.project_version()) global_conf.set_quoted('VERSION', meson.project_version())
global_conf.set_quoted('GETTEXT_PACKAGE', meson.project_name()) global_conf.set_quoted('LOCALEDIR', localedir)
global_conf.set_quoted('LOCALEDIR', get_option('prefix') / get_option('localedir')) global_conf.set_quoted('GETTEXT_PACKAGE', app_name)
global_conf.set_quoted('PKGDATADIR', pkgdatadir)
config = configure_file( config = configure_file(
input: 'config.rs.in', input: 'config.rs.in',
output: 'config.rs', output: 'config.rs',
configuration: global_conf configuration: global_conf,
) )
run_command( run_command(
'cp', 'cp',
meson.project_build_root() / 'src' / 'config.rs', meson.project_build_root() / 'src' / 'config.rs',
meson.project_source_root() / 'src' / 'config.rs', meson.project_source_root() / 'src',
check: true check: true,
) )
cargo_bin = find_program('cargo') # Cargo Build
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' ]
rust_target = 'release'
else
rust_target = 'debug'
endif
cargo_build = custom_target( cargo_build = custom_target(
'cargo-build', 'cargo-build',
build_by_default: true, build_by_default: true,
build_always_stale: true, build_always_stale: true,
output: meson.project_name(), output: meson.project_name(),
console: true, console: true,
install: true, install: true,
install_dir: get_option('bindir'), install_dir: get_option('bindir'),
command: [ command: [
'env', cargo_env, 'env', cargo_env,
cargo_bin, 'build', cargo_bin, 'build',
cargo_opt, '&&', 'cp', 'src' / rust_target / meson.project_name(), '@OUTPUT@', cargo_opt, '&&', 'cp', 'target' / rust_target / meson.project_name(), '@OUTPUT@',
] ]
) )