Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Add meson build #3

Merged
merged 2 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
51 changes: 51 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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',
)

gnome.post_install(
update_mime_database: true
)
hadess marked this conversation as resolved.
Show resolved Hide resolved