Skip to content

Commit 4faf1b7

Browse files
committed
Enable static linking for examples
1 parent 1400a06 commit 4faf1b7

File tree

13 files changed

+11
-29
lines changed

13 files changed

+11
-29
lines changed

Examples/CloudFunctions/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.2
1+
// swift-tools-version:5.3
22

33
import PackageDescription
44

Examples/CloudFunctions/scripts/build-and-package.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ echo "-------------------------------------------------------------------------"
4141
echo "Building \"$executable\" SCF"
4242
echo "-------------------------------------------------------------------------"
4343
docker run --rm -v "$workspace":/workspace -w /workspace/Examples/CloudFunctions builder \
44-
bash -cl "swift build --product $executable -c release"
44+
bash -cl "swift build --product $executable -c release -Xswiftc -static-executable"
4545
echo "done"
4646

4747
echo "-------------------------------------------------------------------------"

Examples/CloudFunctions/scripts/deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ read -p "COS bucket to upload (name-appid, eg: examplebucket-1250000000): " cos_
3333
read -p "COS bucket region (eg: ap-beijing): " cos_region
3434
cos_region=${cos_region:-ap-beijing} # default for easy testing
3535

36-
coscmd -b "$cos_bucket" -r "$cos_region" upload ".build/scf/$executable/cloud-function.zip" "$executable.zip"
36+
coscmd -b "$cos_bucket" -r "$cos_region" upload ".build/scf/$executable.zip" "$executable.zip"
3737

3838
echo "-------------------------------------------------------------------------"
3939
echo "Updating SCF function to use \"$executable\""

Examples/CloudFunctions/scripts/package.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ target=".build/scf/$executable"
3434
rm -rf "$target"
3535
mkdir -p "$target"
3636

37-
cp ".build/release/$executable" "$target/"
38-
# add the target deps based on ldd
39-
ldd ".build/release/$executable" | grep swift | awk '{print $3}' | xargs cp -Lv -t "$target"
40-
37+
cp ".build/release/$executable" "$target/bootstrap"
4138
cd "$target"
42-
ln -s "$executable" "bootstrap"
43-
zip --symlinks cloud-function.zip *
39+
zip ../$executable.zip *

Examples/CloudFunctions/scripts/serverless/APIGateway/serverless.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ inputs:
44
name: apigateway-swift-scf
55
src:
66
src: ../../../.build/scf/APIGateway
7-
exclude:
8-
- cloud-function.zip
97
runtime: CustomRuntime
108
region: ap-beijing
119
description: Swift SCF demo for APIGateway

Examples/CloudFunctions/scripts/serverless/Benchmark/serverless.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ inputs:
44
name: benchmark-swift-scf
55
src:
66
src: ../../../.build/scf/Benchmark
7-
exclude:
8-
- cloud-function.zip
97
runtime: CustomRuntime
108
region: ap-beijing
119
description: Swift SCF demo for benchmark

Examples/CloudFunctions/scripts/serverless/CurrencyExchange/serverless.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ inputs:
44
name: currency-swift-scf
55
src:
66
src: ../../../.build/scf/CurrencyExchange
7-
exclude:
8-
- cloud-function.zip
97
runtime: CustomRuntime
108
region: ap-beijing
119
description: Swift SCF demo (currency exchange)

Examples/CloudFunctions/scripts/serverless/ErrorHandling/serverless.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ inputs:
44
name: errorhandling-swift-scf
55
src:
66
src: ../../../.build/scf/ErrorHandling
7-
exclude:
8-
- cloud-function.zip
97
runtime: CustomRuntime
108
region: ap-beijing
119
description: Swift SCF demo (error handling)

Examples/CloudFunctions/scripts/serverless/HelloWorld/serverless.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ inputs:
44
name: helloworld-swift-scf
55
src:
66
src: ../../../.build/scf/HelloWorld
7-
exclude:
8-
- cloud-function.zip
97
runtime: CustomRuntime
108
region: ap-beijing
119
description: Swift SCF demo (hello world)

Examples/LocalDebugging/MyCloudFunction/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.2
1+
// swift-tools-version:5.3
22

33
import PackageDescription
44

Examples/LocalDebugging/MyCloudFunction/scripts/deploy.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ echo "-------------------------------------------------------------------------"
4646
echo "Building \"$executable\" SCF"
4747
echo "-------------------------------------------------------------------------"
4848
docker run --rm -v `pwd`/../../..:/workspace -w /workspace/Examples/LocalDebugging/MyCloudFunction builder \
49-
bash -cl "swift build --product $executable -c release"
49+
bash -cl "swift build --product $executable -c release -Xswiftc -static-executable"
5050
echo "done"
5151

5252
echo "-------------------------------------------------------------------------"
@@ -59,7 +59,7 @@ echo "done"
5959
echo "-------------------------------------------------------------------------"
6060
echo "Uploading \"$executable\" function to COS"
6161
echo "-------------------------------------------------------------------------"
62-
coscmd -b "$cos_bucket" -r "$cos_region" upload ".build/scf/$executable/cloud-function.zip" "$executable.zip"
62+
coscmd -b "$cos_bucket" -r "$cos_region" upload ".build/scf/$executable.zip" "$executable.zip"
6363

6464
echo "-------------------------------------------------------------------------"
6565
echo "Updating \"$function_name\" to the latest \"$executable\""

Examples/LocalDebugging/MyCloudFunction/scripts/package.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ target=".build/scf/$executable"
3434
rm -rf "$target"
3535
mkdir -p "$target"
3636

37-
cp ".build/release/$executable" "$target/"
38-
# add the target deps based on ldd
39-
ldd ".build/release/$executable" | grep swift | awk '{print $3}' | xargs cp -Lv -t "$target"
40-
37+
cp ".build/release/$executable" "$target/bootstrap"
4138
cd "$target"
42-
ln -s "$executable" "bootstrap"
43-
zip --symlinks cloud-function.zip *
39+
zip ../$executable.zip *

Examples/LocalDebugging/Shared/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.2
1+
// swift-tools-version:5.3
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription

0 commit comments

Comments
 (0)