Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

Commit 5538f39

Browse files
authored
build: attempt to use bash for SWIFTFLAGS (#1173)
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.
1 parent a57bc85 commit 5538f39

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Dockerfile

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,26 @@ RUN git clone https://github.com/tensorflow/swift-models.git
7474
RUN git clone https://github.com/fastai/fastai_dev.git
7575
RUN git clone https://github.com/deepmind/open_spiel.git
7676

77+
RUN if test x"$TENSORFLOW_USE_STANDARD_TOOLCHAIN" = x"YES" ; then \
78+
echo "-Xswiftc -DTENSORFLOW_USE_STANDARD_TOOLCHAIN -Xcc -I/swift-tensorflow-toolchain/usr/lib/swift -Xlinker -L/swift-tensorflow-toolchain/usr/lib/swift/linux" > /.swiftflags ; \
79+
else \
80+
echo "-Xcc -I/swift-tensorflow-toolchain/usr/lib/swift -Xlinker -L/swift-tensorflow-toolchain/usr/lib/swift/linux" > /.swiftflags ; \
81+
fi
82+
7783
WORKDIR /swift-models
7884

79-
RUN /swift-tensorflow-toolchain/usr/bin/swift build \
80-
$([ "$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")
85+
RUN /swift-tensorflow-toolchain/usr/bin/swift build $(cat /.swiftflags)
8186
# Swift Numerics in release mode does not currently build, which prevents the use of swift-models
82-
# RUN /swift-tensorflow-toolchain/usr/bin/swift build -c release \
83-
# $([ "$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")
87+
# RUN /swift-tensorflow-toolchain/usr/bin/swift build -c release $(cat /.swiftflags)
8488

8589
WORKDIR /fastai_dev/swift/FastaiNotebook_11_imagenette
8690

87-
RUN /swift-tensorflow-toolchain/usr/bin/swift build
88-
RUN /swift-tensorflow-toolchain/usr/bin/swift build -c release
91+
RUN /swift-tensorflow-toolchain/usr/bin/swift build $(cat /.swiftflags)
92+
RUN /swift-tensorflow-toolchain/usr/bin/swift build -c release $(cat /.swiftflags)
8993

9094
WORKDIR /open_spiel
9195
RUN rm -f Package.resolved
92-
RUN /swift-tensorflow-toolchain/usr/bin/swift test
96+
RUN /swift-tensorflow-toolchain/usr/bin/swift test $(cat /.swiftflags)
9397

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

104108
# Run SwiftPM tests
105109
RUN rm -f /swift-tensorflow-toolchain/usr/lib/swift/tensorflow/module.modulemap
106-
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
110+
RUN /swift-tensorflow-toolchain/usr/bin/swift test $(cat /.swiftflags)

0 commit comments

Comments
 (0)