Skip to content

Instantly share code, notes, and snippets.

@czechboy0
Forked from mxcl/swift-self-build
Created May 2, 2016 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save czechboy0/a77feeb6363981b805c294a9a8644878 to your computer and use it in GitHub Desktop.
Save czechboy0/a77feeb6363981b805c294a9a8644878 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Faster toolchain build: skips as much as possible.
#
# To use this toolchain from the command line:"
# export TOOLCHAINS=$(whoami)
#
# we build to the same prefix every time (instead of building
# to a versioned prefix) because every time the prefix changes
# *everything* rebuilds.
set -e
trap "exit;" SIGINT SIGTERM
SRCROOT="$HOME/src"
ALIAS=$(whoami)
TOOLCHAIN_NAME="swift-${ALIAS}.xctoolchain"
TOOLCHAIN_PREFIX="$HOME/Library/Developer/Toolchains/${TOOLCHAIN_NAME}"
export MACOSX_DEPLOYMENT_TARGET=10.11
export TOOLCHAINS=default
if [[ $1 == "--reconfigure" ]]; then
RECONFIGURE="--reconfigure"
fi
# so if anything is put in the wrong place we will *see* it
cd "$HOME/Desktop"
"$SRCROOT/swift/utils/build-script" \
--release \
--llvm \
--llbuild \
--swiftpm \
--build-subdir="${ALIAS}" \
--assertions \
--no-swift-stdlib-assertions \
--install-prefix="${TOOLCHAIN_PREFIX}/usr" \
-- \
${RECONFIGURE} \
--skip-ios \
--skip-tvos \
--skip-watchos \
--skip-build-linux \
--skip-build-freebsd \
--skip-build-cygwin \
--skip-build-ios \
--skip-build-ios-device \
--skip-build-ios-simulator \
--skip-build-tvos \
--skip-build-tvos-device \
--skip-build-tvos-simulator \
--skip-build-watchos \
--skip-build-watchos-device \
--skip-build-watchos-simulator \
--skip-build-lldb \
--skip-build-xctest \
--skip-build-foundation \
--skip-build-libdispatch \
--skip-build-benchmarks \
--skip-test-cmark \
--skip-test-lldb \
--skip-test-swift \
--skip-test-llbuild \
--skip-test-swiftpm \
--skip-test-xctest \
--skip-test-foundation \
--skip-test-libdispatch \
--skip-test-linux \
--skip-test-freebsd \
--skip-test-cygwin \
--skip-test-osx \
--skip-test-ios-simulator \
--skip-test-ios-host \
--skip-test-tvos-simulator \
--skip-test-tvos-host \
--skip-test-watchos-simulator \
--skip-test-watchos-host \
--skip-test-benchmarks \
--skip-test-optimized \
--swift-sdks=OSX \
--swift-enable-ast-verifier=0 \
--build-swift-examples=0 \
--build-swift-stdlib-unittest-extra=0 \
--build-swift-static-stdlib=1 \
--compiler-vendor=apple \
--swift-install-components="compiler;clang-builtin-headers;stdlib;sdk-overlay;license;sourcekit-xpc-service" \
--llvm-install-components="libclang;libclang-headers" \
--install-swift=1 \
--install-llbuild=1 \
--install-swiftpm=1 \
--install-destdir="/" \
--toolchain-prefix="${TOOLCHAIN_PREFIX}"
# doing by hand as the only other way to trigger this
# is by specifying --installable-package, which tars
# all installed products and is super slow
DATE=$(date +%Y%m%d)
SWIFT_VERSION=$("${TOOLCHAIN_PREFIX}/usr/bin/swift" --version | ruby -e 'ARGF.read =~ /Swift version (\d+\.\d(\.\d+)?(-.*?)?) /; print "#{$1}\n"')
VERSION="${SWIFT_VERSION}-${ALIAS}+${DATE}"
cat > "${TOOLCHAIN_PREFIX}/Info.plist" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Aliases</key>
<array>
<string>${ALIAS}</string>
</array>
<key>CFBundleIdentifier</key>
<string>org.swift.${SWIFT_VERSION}.${ALIAS}</string>
<key>DisplayName</key>
<string>Xcode Swift (${SWIFT_VERSION}.${ALIAS}+${DATE})</string>
<key>ReportProblemURL</key>
<string>https://bugs.swift.org/</string>
<key>Version</key>
<string>${DATE}</string>
</dict>
</plist>
EOF
# again, only way to trigger this otherwise is do a lenghy --installable-package step
cp "${SRCROOT}/swift/utils/swift-stdlib-tool-substitute" "${TOOLCHAIN_PREFIX}/usr/bin/swift-stdlib-tool"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment