Skip to content

Instantly share code, notes, and snippets.

@philipturner
Created May 14, 2022 22:35
Show Gist options
  • Save philipturner/b585c5899e846c05eefffff81559a9a6 to your computer and use it in GitHub Desktop.
Save philipturner/b585c5899e846c05eefffff81559a9a6 to your computer and use it in GitHub Desktop.
# Prepare for building S4TF
# Ensure this is your toolchain's bundle identifier. The one hard-coded is for
# May 4, 2022. That may not be your toolchain.
export TOOLCHAINS="org.swift.57202205041a"
# I plan to upgrade to v2.9.0-rc2 soon, so you may need to change this part of
# the script soon.
tensorflow_version="2.8.0"
# What ever directory this script is in, should contain the unzipped "Library"
# folder.
DESTDIR=${PWD}/Library/tensorflow-${tensorflow_version}
# Build S4TF
# Run `git clone https://github.com/s4tf/s4tf` if you haven't done so already.
# Otherwise, the "s4tf" directory won't exist.
cd s4tf
swift build -Xswiftc -DTENSORFLOW_USE_STANDARD_TOOLCHAIN \
-Xcc -I${DESTDIR}/usr/include -Xlinker -L${DESTDIR}/usr/lib
cp ${DESTDIR}/usr/lib/libx10.dylib .build/$(uname -m)-apple-macosx/debug/libx10.dylib
swift test -Xswiftc -DTENSORFLOW_USE_STANDARD_TOOLCHAIN \
-Xcc -I${DESTDIR}/usr/include -Xlinker -L${DESTDIR}/usr/lib
# Same with `export TOOLCHAINS`: make sure it matches your toolchain.
export DYLD_LIBRARY_PATH="/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-05-04-a.xctoolchain/usr/lib/swift/macosx"
/Applications/Xcode.app/Contents/Developer/usr/bin/xctest \
.build/$(uname -m)-apple-macosx/debug/TensorFlowPackageTests.xctest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment