-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbuild_macos_plugin.sh
More file actions
executable file
·73 lines (63 loc) · 2.23 KB
/
build_macos_plugin.sh
File metadata and controls
executable file
·73 lines (63 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash -ex
CONFIGURATION=${CONFIGURATION:-"release"}
PRODUCT=${PRODUCT:-"SkipRunner"}
SKIPCMD=skip
ARTIFACT=${SKIPCMD}
ARTIFACTBUNDLE="${ARTIFACT}.artifactbundle"
PLUGIN_ZIP="${ARTIFACT}-macos.zip"
ARTIFACT_BUILD_DIR=.build/artifactbundle-macos
# now make the final release build for both architectures
swift build --arch arm64 --arch x86_64 --configuration ${CONFIGURATION} --product ${PRODUCT}
# try to back up any old artifactbundle folder
mv -f ${ARTIFACT_BUILD_DIR}/${ARTIFACTBUNDLE} ${ARTIFACT_BUILD_DIR}/${ARTIFACTBUNDLE}.bk.`date +%s` || true
mkdir -p ${ARTIFACT_BUILD_DIR}/${ARTIFACTBUNDLE}/macos
# the secret --arch flag emits to the (undocumented) "apple" build folder
cp -av .build/apple/Products/${CONFIGURATION}/${PRODUCT} ${ARTIFACT_BUILD_DIR}/${ARTIFACTBUNDLE}/macos/${SKIPCMD}
cd ${ARTIFACT_BUILD_DIR}
TOOLNAME="skip"
BINDIR="${ARTIFACTBUNDLE}"/bin
mkdir -p "${BINDIR}"
# make a shell script that launches the right binary
# note: logic duplicated in build_macos_plugin.sh and build_linux_plugin.sh
cat > ${BINDIR}/${TOOLNAME} << "EOF"
#!/bin/bash
# This script invokes the tool named after the script
# in the appropriate OS and architecture sub-folder
set -e
SCRIPTPATH="$(realpath "${BASH_SOURCE[0]}")"
TOOLNAME="$(basename "${SCRIPTPATH}")"
TOOLPATH="$(dirname "${SCRIPTPATH}")"
OS="$(uname -s)"
if [ "${OS}" = "Darwin" ]; then
PROGRAM="${TOOLPATH}"/../macos/"${TOOLNAME}"
/usr/bin/xattr -c "${PROGRAM}"
else
ARCH="$(uname -m)"
PROGRAM="${TOOLPATH}"/../"${ARCH}"-swift-linux-musl/"${TOOLNAME}"
fi
"${PROGRAM}" "${@}"
EOF
chmod +x ${BINDIR}/${TOOLNAME}
cat > ${ARTIFACTBUNDLE}/info.json << EOF
{
"schemaVersion": "1.0",
"artifacts": {
"${SKIPCMD}": {
"type": "executable",
"version": "${SKIP_VERSION}",
"variants": [
{
"path": "macos/${SKIPCMD}",
"supportedTriples": ["x86_64-apple-macosx", "arm64-apple-macosx"]
}
]
}
}
}
EOF
du -skh "${ARTIFACTBUNDLE}"
# sync file times to git date for build reproducability
#find ${ARTIFACTBUNDLE} -exec touch -d "${GITDATE:0:19}" {} \;
zip -9 -q --symlinks -r ${PLUGIN_ZIP} ${ARTIFACTBUNDLE}
unzip -l "${PLUGIN_ZIP}"
du -skh "${PLUGIN_ZIP}"