forked from kiss-community/repo
cbindgen: trim build directories from binary
This commit is contained in:
parent
980a355925
commit
31bf9188d9
|
@ -1,27 +1,26 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
#
|
#
|
||||||
# Seeing as this is the only rust package in the
|
# Seeing as this is the only rust package in the repositories (other than rust
|
||||||
# repositories (other than rust itself), this will
|
# itself), this will also serve as a reference to writing network-free rust
|
||||||
# also serve as a reference to writing network-free
|
# based packages.
|
||||||
# rust-based packages.
|
|
||||||
|
|
||||||
# Set the CARGO_HOME variable to the current directory
|
# Set the CARGO_HOME variable to the current directory to prevent cargo from
|
||||||
# to prevent cargo from touching '$HOME/.cargo'. This
|
# touching '$HOME/.cargo'. This keeps the build contained to the package
|
||||||
# keeps the build contained to the package manager's
|
# manager's domain.
|
||||||
# domain.
|
|
||||||
export CARGO_HOME=$PWD
|
export CARGO_HOME=$PWD
|
||||||
|
|
||||||
# Extract each crate and generate a checksum file.
|
# Instruct the compiler to trim absolute paths in resulting binaries and instead
|
||||||
# This effectively mimics 'cargo vendor' without the
|
# change them to relative paths ($PWD/... ./...).
|
||||||
# network requirement.
|
export RUSTFLAGS="$RUSTFLAGS --remap-path-prefix=$PWD=."
|
||||||
#
|
|
||||||
# This allows the package manager to cache each crate
|
# Extract each crate and generate a checksum file. This effectively mimics
|
||||||
# and handle them as regular sources.
|
# 'cargo vendor' without the network requirement. This allows the package
|
||||||
|
# manager to cache each crate and handle them as regular sources.
|
||||||
(
|
(
|
||||||
cd vendor
|
cd vendor
|
||||||
|
|
||||||
# Download link for this crate 404s. Mirror link saves
|
# Download link for this crate 404s. Mirror link saves the file as
|
||||||
# the file as 'download' so it must be renamed.
|
# 'download' so it must be renamed.
|
||||||
mv -f download wasi-0.9.0+wasi-snapshot-preview1.crate
|
mv -f download wasi-0.9.0+wasi-snapshot-preview1.crate
|
||||||
|
|
||||||
for crate in *.crate; do
|
for crate in *.crate; do
|
||||||
|
@ -36,14 +35,12 @@ export CARGO_HOME=$PWD
|
||||||
done
|
done
|
||||||
)
|
)
|
||||||
|
|
||||||
# Cargo reads a "global" configuration file from $CARGO_HOME,
|
# Cargo reads a "global" configuration file from $CARGO_HOME, as we've set it to
|
||||||
# as we've set it to $PWD this is where we'll be storing the
|
# $PWD this is where we'll be storing the vendor config.
|
||||||
# vendor config.
|
|
||||||
mkdir -p .cargo
|
mkdir -p .cargo
|
||||||
|
|
||||||
# Create the configuration file to tell cargo to look in the
|
# Create the configuration file to tell cargo to look in the 'vendor' directory
|
||||||
# 'vendor' directory for the already downloaded sources
|
# for the already downloaded sources rather than crates.io (over network).
|
||||||
# rather than crates.io (over network).
|
|
||||||
cat <<EOF > .cargo/config
|
cat <<EOF > .cargo/config
|
||||||
[source.crates-io]
|
[source.crates-io]
|
||||||
replace-with = "vendored-sources"
|
replace-with = "vendored-sources"
|
||||||
|
@ -52,9 +49,8 @@ replace-with = "vendored-sources"
|
||||||
directory = "vendor"
|
directory = "vendor"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Use the '--frozen' flag to tell cargo to skip the network
|
# Use the '--frozen' flag to tell cargo to skip the network and use whatever
|
||||||
# and use whatever dependencies are in the Cargo.[toml|lock]
|
# dependencies are in the Cargo.[toml|lock] files.
|
||||||
# files.
|
|
||||||
cargo build --release --frozen
|
cargo build --release --frozen
|
||||||
|
|
||||||
mkdir -p "$1/usr/bin"
|
mkdir -p "$1/usr/bin"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user