summary refs log tree commit diff
path: root/build-aux/dist-vendor.sh
blob: d1fe13bc23cb20eb441faba1a5d6b39b7c1fa6fe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/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>, and 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/vendor"
          > "$DIST"/.cargo/config.toml
else
    echo "WARNING: using normal cargo vendor"
    cargo vendor "$DIST/vendor" > "$DIST"/.cargo/config.toml
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.toml"

rm -r "$DIST"/*.nix "$DIST/pkgs" "$DIST/.envrc"