diff --git a/README.md b/README.md index 90f9dbf6..2dbe9428 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,29 @@ Akira is a native Linux Design application built in Rust. Akira focuses on offer ## 🛠 Compile -You can install Akira by compiling it from the source +You can install Akira by compiling it from the source directly via `cargo` or with the `meson` build system. + +``` +git clone https://github.com/akiraux/Akira +cd Akira +``` + +### Build with meson for release development + +``` +meson setup build +cd build +ninja +ninja install +src/akira +``` + +### Build with cargo for quick local development + +``` +cargo build +cargo run +``` ### Install Dependencies diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..3adc4ecf --- /dev/null +++ b/meson.build @@ -0,0 +1,29 @@ +project('com.github.akiraux.akira', 'rust', + version: '0.1.0', + meson_version: '>= 0.59.0', + default_options: [ 'warning_level=2', 'werror=false', ], +) + +exec_name = 'akira' + +i18n = import('i18n') +gnome = import('gnome') + +pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name()) + +conf = configuration_data() +conf.set_quoted('APP_ID', meson.project_name()) +conf.set('APP_ID_UNQUOTED', meson.project_name()) +conf.set_quoted('SLASHED_APP_ID', '/' + meson.project_name().replace('.', '/') + '/') +conf.set('EXEC_NAME', exec_name) +conf.set_quoted('GETTEXT_PACKAGE', meson.project_name()) +conf.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir'))) +conf.set_quoted('PKGDATADIR', pkgdatadir) + +subdir('src') + +gnome.post_install( + glib_compile_schemas: true, + gtk_update_icon_cache: true, + update_desktop_database: true, +) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..b648c92e --- /dev/null +++ b/meson_options.txt @@ -0,0 +1 @@ +option('offline', type : 'boolean', value : false) diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 00000000..e4de2d31 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,5 @@ +pub static APP_ID: &str = "com.github.akiraux.akira"; +pub static SLASHED_APP_ID: &str = "/com/github/akiraux/akira/"; +pub static GETTEXT_PACKAGE: &str = "com.github.akiraux.akira"; +pub static LOCALEDIR: &str = "/usr/local/share/locale"; +pub static PKGDATADIR: &str = "/usr/local/share/com.github.akiraux.akira"; diff --git a/src/config.rs.in b/src/config.rs.in new file mode 100644 index 00000000..336fe903 --- /dev/null +++ b/src/config.rs.in @@ -0,0 +1,5 @@ +pub static APP_ID: &str = @APP_ID@; +pub static SLASHED_APP_ID: &str = @SLASHED_APP_ID@; +pub static GETTEXT_PACKAGE: &str = @GETTEXT_PACKAGE@; +pub static LOCALEDIR: &str = @LOCALEDIR@; +pub static PKGDATADIR: &str = @PKGDATADIR@; diff --git a/src/main.rs b/src/main.rs index 24af03e8..9670dd5b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,15 +14,15 @@ * You should have received a copy of the GNU General Public License along with * Akira. If not, see . */ +mod config; +mod window; + +use config::APP_ID; use gtk::prelude::*; use gtk::{glib, Application}; -mod window; - use self::window::AppWindow; -const APP_ID: &str = "com.github.akiraux.akira"; - fn main() -> glib::ExitCode { // Create a new application let app = Application::builder().application_id(APP_ID).build(); diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 00000000..9fbff997 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,48 @@ +gnome = import('gnome') + +configure_file( + 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'), + check: true +) + +cargo_bin = find_program('cargo') +cargo_opt = [ '--manifest-path', meson.project_source_root() / 'Cargo.toml' ] +cargo_opt += [ '--target-dir', meson.project_build_root() / 'src' ] +if get_option('offline') + cargo_opt += [ '--offline' ] + cargo_env = [ 'CARGO_HOME=' + meson.project_source_root() / 'cargo' ] +else + cargo_env = [ 'CARGO_HOME=' + meson.project_build_root() / 'cargo-home' ] +endif + +if get_option('buildtype') == 'release' + cargo_opt += [ '--release' ] + rust_target = 'release' +else + rust_target = 'debug' +endif + +cargo_build = custom_target( + 'cargo-build', + build_by_default: true, + build_always_stale: true, + output: exec_name, + console: true, + install: true, + install_dir: get_option('bindir'), + command: [ + 'env', cargo_env, + cargo_bin, 'build', + cargo_opt, '&&', 'cp', 'src' / rust_target / exec_name, '@OUTPUT@', + ] +)