-
-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathbuild.sh
executable file
·36 lines (32 loc) · 869 Bytes
/
build.sh
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
32
33
34
35
36
#!/bin/bash
# build and pack a rust lambda library
# https://aws.amazon.com/blogs/opensource/rust-runtime-for-aws-lambda/
set -eo pipefail
mkdir -p target/lambda
export CARGO_TARGET_DIR=$PWD/target/lambda
(
if [[ $# -gt 0 ]]; then
yum install -y "$@"
fi
# source cargo
. $HOME/.cargo/env
cargo build ${CARGO_FLAGS:-} --release
) 1>&2
function package() {
file="$1"
strip "$file"
rm "$file.zip" > 2&>/dev/null || true
# note: would use printf "@ $(basename $file)\n@=bootstrap" | zipnote -w "$file.zip"
# if not for https://bugs.launchpad.net/ubuntu/+source/zip/+bug/519611
mv "$file" bootstrap
zip "$file.zip" bootstrap
rm bootstrap
}
cd "$CARGO_TARGET_DIR"/release
(
if [ -z "$BIN" ]; then
find -maxdepth 1 -executable -type f -exec package {} \;
else
package "$BIN"
fi
) 1>&2