Skip to content

Commit

Permalink
Simple meson build (#754)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alecaddd authored Sep 19, 2024
1 parent f686b55 commit 0c267a2
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 5 deletions.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
29 changes: 29 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -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,
)
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
option('offline', type : 'boolean', value : false)
5 changes: 5 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -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";
5 changes: 5 additions & 0 deletions src/config.rs.in
Original file line number Diff line number Diff line change
@@ -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@;
8 changes: 4 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
* You should have received a copy of the GNU General Public License along with
* Akira. If not, see <https://www.gnu.org/ licenses/>.
*/
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();
Expand Down
48 changes: 48 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -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@',
]
)

0 comments on commit 0c267a2

Please sign in to comment.