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

Commit f1cf159

Browse files
committed
Add GitHub workflow for building+installing into toolchain via CMake.
Add GitHub Actions workflow for: - Downloading and installing a swift.org/download macOS development snapshot - Building tensorflow/swift-apis via CMake - Installing tensorflow/swift-apis into the toolchain via CMake - Repackaging the toolchain into a .pkg - Publishing the toolchain .pkg artifact This allows users to download standard swift.org/download toolchains with TensorFlow and X10 installed.
1 parent eebf3c7 commit f1cf159

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: macOS (CMake toolchain)
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
jobs:
8+
build:
9+
runs-on: macos-latest
10+
11+
env:
12+
# Hardcoded date selecting the latest toolchain from https://swift.org/download/#snapshots.
13+
# Update this to build with a newer toolchain.
14+
toolchain-date: 2021-01-04
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- name: Set environment variables
20+
run: |
21+
TOOLCHAIN_DATE=${{ env.toolchain-date }}
22+
# TOOLCHAIN_SHORT_DATE: TOOLCHAIN_DATE with hypens removed. Used for toolchain identifier and version.
23+
TOOLCHAIN_SHORT_DATE="${TOOLCHAIN_DATE//-/}"
24+
TOOLCHAIN_NAME=swift-DEVELOPMENT-SNAPSHOT-${TOOLCHAIN_DATE}-a
25+
echo "TOOLCHAIN_DATE=${TOOLCHAIN_DATE}" >> $GITHUB_ENV
26+
echo "TOOLCHAIN_SHORT_DATE=${TOOLCHAIN_SHORT_DATE}" >> $GITHUB_ENV
27+
echo "TOOLCHAIN_NAME=${TOOLCHAIN_NAME}" >> $GITHUB_ENV
28+
echo "SOURCE_TOOLCHAIN_LOCATION=$HOME/Library/Developer/Toolchains/${TOOLCHAIN_NAME}.xctoolchain" >> $GITHUB_ENV
29+
echo "DEST_TOOLCHAIN_LOCATION=/tmp/destination-toolchain/Library/Developer/Toolchains/${TOOLCHAIN_NAME}.xctoolchain" >> $GITHUB_ENV
30+
31+
- name: Install Ninja
32+
run: |
33+
brew install ninja
34+
35+
- name: Install swift.org toolchain
36+
run: |
37+
curl -sOL https://swift.org/builds/development/xcode/${TOOLCHAIN_NAME}/${TOOLCHAIN_NAME}-osx.pkg
38+
xattr -dr com.apple.quarantine ${TOOLCHAIN_NAME}-osx.pkg
39+
# Install "source" toolchain. This toolchain is used to build tensorflow/swift-apis.
40+
installer -pkg ${TOOLCHAIN_NAME}-osx.pkg -target CurrentUserHomeDirectory
41+
# Install "destination" toolchain. tensorflow/swift-apis is installed into this toolchain.
42+
mkdir /tmp/destination-toolchain
43+
sudo installer -pkg ${TOOLCHAIN_NAME}-osx.pkg -target /tmp/destination-toolchain
44+
rm -rf ${TOOLCHAIN_NAME}-osx.pkg
45+
46+
- name: Install pre-built TensorFlow and X10 libraries
47+
run: |
48+
curl -sL https://artprodeus21.artifacts.visualstudio.com/A8fd008a0-56bc-482c-ba46-67f9425510be/3133d6ab-80a8-4996-ac4f-03df25cd3224/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2NvbXBuZXJkL3Byb2plY3RJZC8zMTMzZDZhYi04MGE4LTQ5OTYtYWM0Zi0wM2RmMjVjZDMyMjQvYnVpbGRJZC80NTU3NC9hcnRpZmFjdE5hbWUvdGVuc29yZmxvdy1kYXJ3aW4teDY00/content?format=zip -o tensorflow-darwin-x64.zip
49+
unzip tensorflow-darwin-x64.zip
50+
mv tensorflow-darwin-x64/Library/tensorflow-2.4.0 ~/Library/
51+
52+
- name: Build tensorflow/swift-apis via CMake
53+
run: |
54+
echo $(TOOLCHAINS=org.swift.${TOOLCHAIN_SHORT_DATE}a xcrun -f swiftc)
55+
cmake \
56+
-B build \
57+
-D BUILD_SHARED_LIBS=YES \
58+
-D CMAKE_BUILD_TYPE=Release \
59+
-D CMAKE_INSTALL_PREFIX=${DEST_TOOLCHAIN_LOCATION}/usr \
60+
-D CMAKE_Swift_COMPILER=$(TOOLCHAINS=org.swift.${TOOLCHAIN_SHORT_DATE}a xcrun -f swiftc) \
61+
-D CMAKE_OSX_DEPLOYMENT_TARGET=10.9 \
62+
-D TENSORFLOW_USE_STANDARD_TOOLCHAIN=YES \
63+
-D X10_LIBRARY=${HOME}/Library/tensorflow-2.4.0/usr/lib/libx10.dylib \
64+
-D X10_INCLUDE_DIRS=${HOME}/Library/tensorflow-2.4.0/usr/include \
65+
-D BUILD_TESTING=NO \
66+
-G Ninja \
67+
-S ${PWD}
68+
69+
- name: Install tensorflow/swift-apis into toolchain
70+
run: |
71+
cmake --build build --target install
72+
73+
- name: Build toolchain package installer
74+
run: |
75+
TOOLCHAIN_ROOT_LOCATION="/Library/Developer/Toolchains/${TOOLCHAIN_NAME}.xctoolchain"
76+
TF_TOOLCHAIN_NAME="swift-tensorflow-DEVELOPMENT-SNAPSHOT-${TOOLCHAIN_DATE}-a"
77+
pkgbuild --identifier org.tensorflow-${TOOLCHAIN_SHORT_DATE} \
78+
--install-location ${TOOLCHAIN_ROOT_LOCATION} \
79+
--version 5.0.${TOOLCHAIN_SHORT_DATE} \
80+
--root ${DEST_TOOLCHAIN_LOCATION} \
81+
${TF_TOOLCHAIN_NAME}-osx.pkg
82+
83+
- name: Upload toolchain package installer
84+
uses: actions/upload-artifact@v2
85+
with:
86+
name: swift-tensorflow-DEVELOPMENT-SNAPSHOT-${{ env.toolchain-date }}-a-osx.pkg
87+
path: '*.pkg'

0 commit comments

Comments
 (0)