Skip to content

Commit

Permalink
build: attempt to use bash for SWIFTFLAGS (tensorflow#1173)
Browse files Browse the repository at this point in the history
Unify the handling of SWIFTFLAGS for stock and non-stock toolchains.
Unfortunately, docker cannot pass along environment variables (outside
of `ARGS`).  We could pass the values through `ARGS` by creating a new
base and switching between the base determined by the toolchain we are
using.  Alternatively, we can create a file to pass along the state,
which I have opted to use here.
  • Loading branch information
compnerd authored Dec 30, 2020
1 parent a57bc85 commit 5538f39
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,26 @@ RUN git clone https://github.com/tensorflow/swift-models.git
RUN git clone https://github.com/fastai/fastai_dev.git
RUN git clone https://github.com/deepmind/open_spiel.git

RUN if test x"$TENSORFLOW_USE_STANDARD_TOOLCHAIN" = x"YES" ; then \
echo "-Xswiftc -DTENSORFLOW_USE_STANDARD_TOOLCHAIN -Xcc -I/swift-tensorflow-toolchain/usr/lib/swift -Xlinker -L/swift-tensorflow-toolchain/usr/lib/swift/linux" > /.swiftflags ; \
else \
echo "-Xcc -I/swift-tensorflow-toolchain/usr/lib/swift -Xlinker -L/swift-tensorflow-toolchain/usr/lib/swift/linux" > /.swiftflags ; \
fi

WORKDIR /swift-models

RUN /swift-tensorflow-toolchain/usr/bin/swift build \
$([ "$TENSORFLOW_USE_STANDARD_TOOLCHAIN" = "YES" ] && echo "-Xswiftc -DTENSORFLOW_USE_STANDARD_TOOLCHAIN -Xcc -I/swift-tensorflow-toolchain/usr/lib/swift -Xlinker -L/swift-tensorflow-toolchain/usr/lib/swift/linux")
RUN /swift-tensorflow-toolchain/usr/bin/swift build $(cat /.swiftflags)
# Swift Numerics in release mode does not currently build, which prevents the use of swift-models
# RUN /swift-tensorflow-toolchain/usr/bin/swift build -c release \
# $([ "$TENSORFLOW_USE_STANDARD_TOOLCHAIN" = "YES" ] && echo "-Xswiftc -DTENSORFLOW_USE_STANDARD_TOOLCHAIN -Xcc -I/swift-tensorflow-toolchain/usr/lib/swift -Xlinker -L/swift-tensorflow-toolchain/usr/lib/swift/linux")
# RUN /swift-tensorflow-toolchain/usr/bin/swift build -c release $(cat /.swiftflags)

WORKDIR /fastai_dev/swift/FastaiNotebook_11_imagenette

RUN /swift-tensorflow-toolchain/usr/bin/swift build
RUN /swift-tensorflow-toolchain/usr/bin/swift build -c release
RUN /swift-tensorflow-toolchain/usr/bin/swift build $(cat /.swiftflags)
RUN /swift-tensorflow-toolchain/usr/bin/swift build -c release $(cat /.swiftflags)

WORKDIR /open_spiel
RUN rm -f Package.resolved
RUN /swift-tensorflow-toolchain/usr/bin/swift test
RUN /swift-tensorflow-toolchain/usr/bin/swift test $(cat /.swiftflags)

WORKDIR /swift-apis
# TODO: move into bash scripts...
Expand All @@ -103,4 +107,4 @@ RUN python3 Utilities/benchmark_compile.py /swift-tensorflow-toolchain/usr/bin/s

# Run SwiftPM tests
RUN rm -f /swift-tensorflow-toolchain/usr/lib/swift/tensorflow/module.modulemap
RUN /swift-tensorflow-toolchain/usr/bin/swift test -Xcc -I/swift-tensorflow-toolchain/usr/lib/swift -Xlinker -L/swift-tensorflow-toolchain/usr/lib/swift/linux
RUN /swift-tensorflow-toolchain/usr/bin/swift test $(cat /.swiftflags)

0 comments on commit 5538f39

Please sign in to comment.