Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Commit fda0214

Browse files
author
marcrasi
authored
add presubmit_build.sh that passes a flag to swiftpm if it is a stock toolchain (#723)
* add presubmit_build.sh that passes a flag to swiftpm if it is a stock toolchain * address comment
1 parent 244a235 commit fda0214

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

docker/presubmit_build.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
set -exuo pipefail
4+
5+
sudo apt-get install -y docker.io
6+
7+
# Sets 'swift_tf_url' to the public url corresponding to
8+
# 'swift_tf_bigstore_gfile', if it exists.
9+
if [[ ! -z ${swift_tf_bigstore_gfile+x} ]]; then
10+
export swift_tf_url="${swift_tf_bigstore_gfile/\/bigstore/https://storage.googleapis.com}"
11+
case "$swift_tf_url" in
12+
*stock*) STOCK_TOOLCHAIN=YES ;;
13+
*) ;;
14+
esac
15+
fi
16+
17+
# Help debug the job's disk space.
18+
df -h
19+
20+
# Move docker images into /tmpfs, where there is more space.
21+
sudo /etc/init.d/docker stop
22+
sudo mv /var/lib/docker /tmpfs/
23+
sudo ln -s /tmpfs/docker /var/lib/docker
24+
sudo /etc/init.d/docker start
25+
26+
# Help debug the job's disk space.
27+
df -h
28+
29+
cd github/swift-models
30+
sudo -E docker build -t built-img -f docker/Dockerfile --build-arg swift_tf_url .
31+
32+
# SwiftPM-based build.
33+
docker run built-img /bin/bash -c "
34+
swift build ${STOCK_TOOLCHAIN:+"-Xswiftc -D -Xswiftc TENSORFLOW_USE_STANDARD_TOOLCHAIN"} ;
35+
swift test ${STOCK_TOOLCHAIN:+"-Xswiftc -D -Xswiftc TENSORFLOW_USE_STANDARD_TOOLCHAIN"} ;
36+
"
37+
38+
# CMake-based build.
39+
sudo docker run built-img /bin/bash -c "
40+
set -e;
41+
cmake -B /BinaryCache/tensorflow-swift-models -D CMAKE_BUILD_TYPE=Release -D CMAKE_Swift_COMPILER=/swift-tensorflow-toolchain/usr/bin/swiftc -G Ninja -S /swift-models;
42+
cmake --build /BinaryCache/tensorflow-swift-models --verbose;
43+
"

0 commit comments

Comments
 (0)