Skip to content
  • Sponsor softprops/lambda-rust

  • Notifications You must be signed in to change notification settings
  • Fork 75

Commit a8d0021

Browse files
committedFeb 10, 2019
don't rename bin if its already named bootstrap. fixes #7
1 parent a1fef45 commit a8d0021

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed
 

‎build.sh

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@ function package() {
2020
rm "$file.zip" > 2&>/dev/null || true
2121
# note: would use printf "@ $(basename $file)\n@=bootstrap" | zipnote -w "$file.zip"
2222
# if not for https://bugs.launchpad.net/ubuntu/+source/zip/+bug/519611
23-
mv "$file" bootstrap
23+
if [ "$file" != ./bootstrap ] && [ "$file" != bootstrap ]; then
24+
mv "${file}" bootstrap
25+
fi
2426
zip "$file.zip" bootstrap
2527
rm bootstrap
2628
}
2729

2830
cd "$CARGO_TARGET_DIR"/release
2931
(
32+
export -f package
3033
if [ -z "$BIN" ]; then
31-
find -maxdepth 1 -executable -type f -exec package {} \;
34+
find -maxdepth 1 -executable -type f -exec bash -c 'package "$0"' {} \;
3235
else
3336
package "$BIN"
3437
fi

‎tests/test-func/Cargo.toml

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ version = "0.1.0"
44
authors = ["softprops <d.tangren@gmail.com>"]
55
edition = "2018"
66

7+
# users don't have to do this
8+
# but when they do, the builder packaging still work
9+
[[bin]]
10+
name = "bootstrap"
11+
path = "src/main.rs"
12+
713
[dependencies]
814
lambda_runtime = "0.1"
915
serde_json = "1.0"

‎tests/test.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,19 @@ DIST=$(cd $HERE/..; echo $PWD)
4646

4747
cd ${HERE}/test-func
4848

49+
# test packaing with a single binary
4950
function package_bin() {
5051
rm target/lambda/release/ > /dev/null 2>&1
5152
docker run --rm \
52-
-e BIN=test-func \
53+
-e BIN="$1" \
5354
-v ${PWD}:/code \
5455
-v ${HOME}/.cargo/registry:/root/.cargo/registry \
5556
-v ${HOME}/.cargo/git:/root/.cargo/git \
5657
softprops/lambda-rust && \
5758
ls target/lambda/release/test-func.zip > /dev/null 2>&1
5859
}
5960

61+
# test packaging all binaries
6062
function package_all() {
6163
rm target/lambda/release/ > /dev/null 2>&1
6264
docker run --rm \
@@ -68,7 +70,7 @@ function package_all() {
6870
}
6971

7072
# package tests
71-
assert_success "it packages single bin" package_bin
73+
assert_success "it packages single bin" package_bin bootstrap
7274

7375
assert_success "it packages all bins" package_all
7476

0 commit comments

Comments
 (0)