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

add presubmit_build.sh that passes a flag to swiftpm if it is a stock toolchain #723

Merged
merged 2 commits into from
Dec 18, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions docker/presubmit_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

set -exuo pipefail

sudo apt-get install -y docker.io

# Sets 'swift_tf_url' to the public url corresponding to
# 'swift_tf_bigstore_gfile', if it exists.
if [[ ! -z ${swift_tf_bigstore_gfile+x} ]]; then
export swift_tf_url="${swift_tf_bigstore_gfile/\/bigstore/https://storage.googleapis.com}"
case "$swift_tf_url" in
*stock*) STOCK_TOOLCHAIN=YES ;;
*) ;;
esac
fi

# Help debug the job's disk space.
df -h

# Move docker images into /tmpfs, where there is more space.
sudo /etc/init.d/docker stop
sudo mv /var/lib/docker /tmpfs/
sudo ln -s /tmpfs/docker /var/lib/docker
sudo /etc/init.d/docker start

# Help debug the job's disk space.
df -h

cd github/swift-models
sudo -E docker build -t built-img -f docker/Dockerfile --build-arg swift_tf_url .

# SwiftPM-based build.
docker run built-img /bin/bash -c "
swift build ${STOCK_TOOLCHAIN:+"-D -Xswiftc -D TENSORFLOW_USE_STANDARD_TOOLCHAIN"} ;
swift test ${STOCK_TOOLCHAIN:+"-D -Xswiftc -D TENSORFLOW_USE_STANDARD_TOOLCHAIN"} ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there might be an extra -D in both of these. Should it just be "-Xswiftc -D TENSORFLOW_USE_STANDARD_TOOLCHAIN"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. And there should also be another -Xswiftc, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just the one is needed if you smoosh the last two together into "-Xswiftc -DTENSORFLOW_USE_STANDARD_TOOLCHAIN". That works for me at the command line.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I tried what you have now with the two of them, and that also works well.

"

# CMake-based build.
sudo docker run built-img /bin/bash -c "
set -e;
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;
cmake --build /BinaryCache/tensorflow-swift-models --verbose;
"