Skip to content

Commit f1c5029

Browse files
committed
build: Add meson build
This simplifies the installation of necessary data files for the thumbnailer to work, working around this long-standing RFE: rust-lang/cargo#2729 Ideally, meson would also be used to compile the binary instead of Cargo, but meson doesn't easily support external crates: mesonbuild/meson#2173
1 parent 6c17c41 commit f1c5029

File tree

3 files changed

+61
-12
lines changed

3 files changed

+61
-12
lines changed

README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@ The RPMs can be downloaded from the [bign-handheld-thumbnailer COPR](https://cop
2525

2626
### Manual
2727

28-
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`.
29-
30-
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`.
31-
32-
1. Compile the project with `cargo build --release`
33-
2. Copy the compiled binary to /usr/bin (e.g. `sudo cp target/release/bign-handheld-thumbnailer /usr/bin/`)
34-
3. Copy `bign-handheld-thumbnailer-3ds.xml` to `/usr/share/mime/packages/` to install the needed mime type definition system-wide
35-
4. Run `sudo update-mime-database /usr/share/mime` so the system-wide mime type database is updated based on the newly-added configuration
36-
5. Copy the `bign-handheld-thumbnailer.thumbnailer` file to `~/.local/share/thumbnailers` (user-install) or `/usr/share/thumbnailers` (system-install)
37-
6. At this point thumbnails should be working, you likely will want to restart the file explorer or clear the cached thumbnails
28+
You will need a Rust development environment and meson installed to
29+
install the binaries and data files:
30+
```
31+
meson setup _build -Dprefix=/usr
32+
ninja -C _build install
33+
```
34+
35+
At this point thumbnails should be working, you likely will want to restart the file explorer or clear the cached thumbnails
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[Thumbnailer Entry]
2-
TryExec=/usr/bin/bign-handheld-thumbnailer
3-
Exec=/usr/bin/bign-handheld-thumbnailer -s %s %i %o
2+
TryExec=@bindir@/bign-handheld-thumbnailer
3+
Exec=@bindir@/bign-handheld-thumbnailer -s %s %i %o
44
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;

meson.build

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
project('bign-handheld-thumbnailer', 'rust',
2+
version: '1.0.0',
3+
license: 'GPL-2.0-or-later',
4+
meson_version: '>= 0.64.0')
5+
6+
gnome = import('gnome')
7+
8+
prefix = get_option('prefix')
9+
bindir = prefix / get_option('bindir')
10+
thumbnailers_dir = prefix / get_option('datadir') / 'thumbnailers'
11+
12+
cargo_bin = find_program('cargo')
13+
cargo_opt = [ '--manifest-path', meson.project_source_root() / 'Cargo.toml' ]
14+
cargo_opt += [ '--target-dir', meson.project_build_root() / 'src' ]
15+
cargo_env = [ 'CARGO_HOME=' + meson.project_build_root() / 'cargo-home' ]
16+
17+
if get_option('buildtype') == 'release'
18+
cargo_opt += [ '--release' ]
19+
rust_target = 'release'
20+
else
21+
rust_target = 'debug'
22+
endif
23+
24+
cargo_build = custom_target(
25+
'cargo-build',
26+
build_by_default: true,
27+
build_always_stale: true,
28+
output: meson.project_name(),
29+
console: true,
30+
install: true,
31+
install_dir: get_option('bindir'),
32+
command: [
33+
'env', cargo_env,
34+
cargo_bin, 'build',
35+
cargo_opt, '&&', 'cp', 'src' / rust_target / meson.project_name(), '@OUTPUT@',
36+
]
37+
)
38+
39+
configure_file(input : meson.project_name() + '.thumbnailer.in',
40+
output : meson.project_name() + '.thumbnailer',
41+
configuration : {'bindir' : bindir},
42+
install_dir : thumbnailers_dir)
43+
44+
install_data(
45+
'bign-handheld-thumbnailer-3ds.xml',
46+
install_dir: get_option('datadir') / 'mime/packages',
47+
)
48+
49+
gnome.post_install(
50+
update_mime_database: true
51+
)

0 commit comments

Comments
 (0)