summary refs log tree commit diff
path: root/build-aux/dist-vendor.sh
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2024-09-01 18:10:26 +0300
committerVika <vika@fireburn.ru>2024-09-04 19:51:50 +0300
commitf8d61d957d4a2d086f4b97f2e3d7d19d0bb35f13 (patch)
tree740988c295d5e3c53b93bd09bad0ce73211b2f40 /build-aux/dist-vendor.sh
parent7718901fb8346a75bd203f04e4303d0df007dcd1 (diff)
downloadbowl-f8d61d957d4a2d086f4b97f2e3d7d19d0bb35f13.tar.zst
Mesonify build
This took a while and had me scratching my head often. But I managed
to combine the best parts of Crane and Meson together, allowing me to
have blazing fast Nix builds.

This also adds initial scaffolding for gettext and other cool things.
Diffstat (limited to 'build-aux/dist-vendor.sh')
-rw-r--r--build-aux/dist-vendor.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/build-aux/dist-vendor.sh b/build-aux/dist-vendor.sh
new file mode 100644
index 0000000..c1430dc
--- /dev/null
+++ b/build-aux/dist-vendor.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+# Since Meson invokes this script as
+# "/bin/sh .../dist-vendor.sh DIST SOURCE_ROOT" we can't rely on bash features
+set -eu
+export DIST="$1"
+export SOURCE_ROOT="$2"
+
+cd "$SOURCE_ROOT"
+mkdir "$DIST"/.cargo
+
+# cargo-vendor-filterer can be found at https://github.com/coreos/cargo-vendor-filterer
+# It is also part of the Rust SDK extension.
+#
+# nixpkgs doesn't have it packaged though.
+if command -v cargo-vendor-filterer &>/dev/null; then
+    cargo vendor-filterer \
+          --platform=x86_64-unknown-linux-gnu \
+          --platform=aarch64-unknown-linux-gnu \
+          > "$DIST"/.cargo/config
+else
+    echo "WARNING: using normal cargo vendor"
+    cargo vendor > "$DIST"/.cargo/config
+fi
+
+# Remove vendored gettext sources, we'll be using system gettext.
+rm -f vendor/gettext-sys/gettext-*.tar.*
+
+# Don't combine the previous and this line with a pipe because we can't catch
+# errors with "set -o pipefail"
+sed -i 's/^directory = ".*"/directory = "vendor"/g' "$DIST/.cargo/config"
+
+# Move vendor into dist tarball directory
+mv vendor "$DIST"
+
+rm -r "$DIST"/*.nix "$DIST/pkgs"