From: Matthias Geiger <werdahias@riseup.net>
Date: Thu, 11 Jan 2024 18:19:47 +0100
Subject: Patch meson.build to allow building in debian

This patch allows building under debian by using a workaround to pass DEB_RUST_HOST
to meson to get the correct installation location.

Forwarded: not-needed
---
 glycin-loaders/meson.build     | 2 +-
 glycin-thumbnailer/meson.build | 2 +-
 libglycin/meson.build          | 2 +-
 meson.build                    | 1 -
 meson_options.txt              | 5 +++++
 5 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/glycin-loaders/meson.build b/glycin-loaders/meson.build
index 8e456ec..80ff0c4 100644
--- a/glycin-loaders/meson.build
+++ b/glycin-loaders/meson.build
@@ -103,7 +103,7 @@ foreach loader : get_option('loaders')
     output: loader,
     command: [
       'cp',
-      cargo_target_dir / rust_target / loader,
+      cargo_target_dir / get_option('host_arch') / 'release' / loader,
       '@OUTPUT@',
     ],
   )
diff --git a/glycin-thumbnailer/meson.build b/glycin-thumbnailer/meson.build
index 44c6fbb..28338e1 100644
--- a/glycin-thumbnailer/meson.build
+++ b/glycin-thumbnailer/meson.build
@@ -29,7 +29,7 @@ custom_target(
     output: 'glycin-thumbnailer',
     command: [
         'cp',
-        cargo_target_dir / rust_target / 'glycin-thumbnailer',
+        cargo_target_dir / get_option('host_arch') / 'release'/ 'glycin-thumbnailer',
         '@OUTPUT@',
     ],
 )
diff --git a/libglycin/meson.build b/libglycin/meson.build
index 209b641..81afe94 100644
--- a/libglycin/meson.build
+++ b/libglycin/meson.build
@@ -70,7 +70,7 @@ foreach package : packages
         endif
     endif
 
-    cargo_output = cargo_target_dir / rust_target / f'libglycin@suffix@.so'.replace('-', '_')
+    cargo_output = cargo_target_dir / get_option('host_arch') / 'release' / f'libglycin@suffix@.so'.replace('-', '_')
 
     # Build library with Rust
     libglycin = custom_target(
diff --git a/meson.build b/meson.build
index 1c36085..dd6a15f 100644
--- a/meson.build
+++ b/meson.build
@@ -29,7 +29,6 @@ cargo_bin = find_program('cargo')
 crate_version_bin = find_program(meson.project_source_root() / 'build-aux/crates-version.py')
 
 cargo_env = environment()
-cargo_env.set('CARGO_HOME', cargo_home)
 
 if get_option('libglycin') and get_option('libglycin-gtk4')
   # Let the libglycin-gtk4 build find the previously built libglycin
diff --git a/meson_options.txt b/meson_options.txt
index d2d368d..5967d4c 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -123,3 +123,8 @@ option(
   type: 'boolean',
   description: 'Build thumbnailer',
 )
+
+option(
+  'host_arch',
+  type: 'string',
+)
