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

Commit 6dc2cce

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 - Currently, this is done only for manually-triggered runs based on an input condition. This allows users to download standard swift.org/download toolchains with TensorFlow and X10 installed.
1 parent eebf3c7 commit 6dc2cce

File tree

1 file changed

+99
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)