Skip to content

Commit 39fc3dd

Browse files
authored
[Static SDK for Linux] Add a sanity check (#446)
* [Static SDK for Linux] Add a sanity check. Build a simple Hello World program after building the SDK, to check that the SDK actually works. * [Static SDK for Linux] Tweak at-desk build script slightly. Add support for `i386` as the output of `arch`. * [Static SDK for Linux] Fix typo. This now successfully builds and runs a Hello World program as part of the Static SDK build.
1 parent a60f16d commit 39fc3dd

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

swift-ci/sdks/static-linux/build

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ case $(arch) in
2222
arm64|aarch64)
2323
OS_ARCH_SUFFIX=-aarch64
2424
;;
25-
amd64|x86_64)
25+
i386|amd64|x86_64)
2626
OS_ARCH_SUFFIX=
2727
;;
2828
*)
@@ -32,7 +32,7 @@ case $(arch) in
3232
esac
3333

3434
# Build the Docker image
35-
$DOCKER build --build-arg OS_ARCH_SUFFIX=$OS_ARCH_SUFFIX -t static-swift-linux .
35+
$DOCKER build $DOCKER_EXTRA_ARGS --build-arg OS_ARCH_SUFFIX=$OS_ARCH_SUFFIX -t static-swift-linux .
3636

3737
# Check-out the sources
3838
scripts/fetch-source.sh --clone-with-ssh --source-dir source
@@ -43,5 +43,6 @@ mkdir -p products
4343
$DOCKER run -it --rm \
4444
-v ./source:/source \
4545
-v ./products:/products \
46+
-m 10G \
4647
static-swift-linux \
4748
/scripts/build.sh --source-dir /source --products-dir /products

swift-ci/sdks/static-linux/scripts/build.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,3 +926,27 @@ quiet_pushd "${build_dir}"
926926
mkdir -p "${products_dir}"
927927
tar cvzf "${products_dir}/${bundle}.tar.gz" "${bundle}"
928928
quiet_popd
929+
930+
header "Install SDK"
931+
swift sdk install "${products_dir}/${bundle}.tar.gz"
932+
933+
header "Build Hello World"
934+
quiet_pushd "${build_dir}"
935+
mkdir -p hello-world
936+
cd hello-world
937+
swift package init --type executable
938+
for arch in $archs; do
939+
swift build --swift-sdk ${arch}-swift-linux-musl
940+
done
941+
quiet_popd
942+
943+
header "Run Hello World"
944+
quiet_pushd "${build_dir}/hello-world"
945+
native_arch=$(uname -p)
946+
native_binary=.build/${native_arch}-swift-linux-musl/debug/hello-world
947+
if [[ -x "${native_binary}" ]]; then
948+
"${native_binary}"
949+
else
950+
echo "No binary for ${native_arch}"
951+
fi
952+
quiet_popd

0 commit comments

Comments
 (0)