Skip to content

Commit

Permalink
Merge pull request #3 from hadess/wip/hadess/meson-build
Browse files Browse the repository at this point in the history
build: Add meson build
  • Loading branch information
MateusRodCosta authored May 18, 2024
2 parents 841db8d + 03e1f92 commit 9717856
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 12 deletions.
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ The RPMs can be downloaded from the [bign-handheld-thumbnailer COPR](https://cop

### Manual

There are three pieces to get the thumbnailer running: a compiled `bign-handheld-thumbnailer` binary, the `bign-handheld-thumbnailer.thumbnailer` file and the needed mime type definitions from `bign-handheld-thumbnailer-3ds.xml`.

Due to nautilus using a sandbox to run thumbnailers it's needed to install the binary in a place where the sandbox can access it, such as `/usr/bin`.

1. Compile the project with `cargo build --release`
2. Copy the compiled binary to /usr/bin (e.g. `sudo cp target/release/bign-handheld-thumbnailer /usr/bin/`)
3. Copy `bign-handheld-thumbnailer-3ds.xml` to `/usr/share/mime/packages/` to install the needed mime type definition system-wide
4. Run `sudo update-mime-database /usr/share/mime` so the system-wide mime type database is updated based on the newly-added configuration
5. Copy the `bign-handheld-thumbnailer.thumbnailer` file to `~/.local/share/thumbnailers` (user-install) or `/usr/share/thumbnailers` (system-install)
6. At this point thumbnails should be working, you likely will want to restart the file explorer or clear the cached thumbnails
You will need a Rust development environment and meson installed to
install the binaries and data files:
```
meson setup _build -Dprefix=/usr
ninja -C _build install
```

At this point thumbnails should be working, you likely will want to restart the file explorer or clear the cached thumbnails
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[Thumbnailer Entry]
TryExec=/usr/bin/bign-handheld-thumbnailer
Exec=/usr/bin/bign-handheld-thumbnailer -s %s %i %o
TryExec=@bindir@/bign-handheld-thumbnailer
Exec=@bindir@/bign-handheld-thumbnailer -s %s %i %o
MimeType=application/x-nintendo-ds-rom;application/x-ctr-cia;application/x-ctr-smdh;application/x-ctr-3dsx;application/x-nintendo-3ds-executable;application/x-ctr-cxi;application/x-ctr-cci;application/x-nintendo-3ds-rom;
53 changes: 53 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
project('bign-handheld-thumbnailer', 'rust',
version: '1.0.0',
license: 'GPL-2.0-or-later',
meson_version: '>= 0.64.0')

gnome = import('gnome')

prefix = get_option('prefix')
bindir = prefix / get_option('bindir')
thumbnailers_dir = prefix / get_option('datadir') / 'thumbnailers'

cargo_bin = find_program('cargo')
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_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: meson.project_name(),
console: true,
install: true,
install_dir: get_option('bindir'),
command: [
'env', cargo_env,
cargo_bin, 'build',
cargo_opt, '&&', 'cp', 'src' / rust_target / meson.project_name(), '@OUTPUT@',
]
)

configure_file(input : meson.project_name() + '.thumbnailer.in',
output : meson.project_name() + '.thumbnailer',
configuration : {'bindir' : bindir},
install_dir : thumbnailers_dir)

install_data(
'bign-handheld-thumbnailer-3ds.xml',
install_dir: get_option('datadir') / 'mime/packages',
)

if get_option('update_mime_database')
gnome.post_install(
update_mime_database: true
)
endif
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
option('update_mime_database', type: 'boolean', value: true, description: 'Whether to run update-mime-database after installation')

0 comments on commit 9717856

Please sign in to comment.