Skip to content

Instantly share code, notes, and snippets.

@mxcl
Last active April 21, 2023 17:13
Show Gist options
  • Select an option

  • Save mxcl/05ced0268bbd5db6ab0c to your computer and use it in GitHub Desktop.

Select an option

Save mxcl/05ced0268bbd5db6ab0c to your computer and use it in GitHub Desktop.

Revisions

  1. mxcl revised this gist May 11, 2016. 1 changed file with 24 additions and 5 deletions.
    29 changes: 24 additions & 5 deletions swift-self-build
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,6 @@ 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
    @@ -37,7 +36,10 @@ cd "$HOME/Desktop"
    --assertions \
    --no-swift-stdlib-assertions \
    --install-prefix="${TOOLCHAIN_PREFIX}/usr" \
    --lldb \
    --darwin-xcrun-toolchain=mxcl \
    -- \
    --lldb-use-system-debugserver \
    ${RECONFIGURE} \
    --skip-ios \
    --skip-tvos \
    @@ -54,7 +56,6 @@ cd "$HOME/Desktop"
    --skip-build-watchos \
    --skip-build-watchos-device \
    --skip-build-watchos-simulator \
    --skip-build-lldb \
    --skip-build-xctest \
    --skip-build-foundation \
    --skip-build-libdispatch \
    @@ -91,15 +92,21 @@ cd "$HOME/Desktop"
    --install-llbuild=1 \
    --install-swiftpm=1 \
    --install-destdir="/" \
    --install-lldb=1 \
    --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)
    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"')

    if [[ "$SWIFT_VERSION" == "3.0-dev" ]]; then
    SWIFT_VERSION="3.0.0-dev"
    fi

    VERSION="${SWIFT_VERSION}-${ALIAS}+${DATE}"

    cat > "${TOOLCHAIN_PREFIX}/Info.plist" <<EOF
    @@ -111,18 +118,30 @@ cat > "${TOOLCHAIN_PREFIX}/Info.plist" <<EOF
    <array>
    <string>${ALIAS}</string>
    </array>
    <key>CompatibilityVersion</key>
    <integer>2</integer>
    <key>CFBundleIdentifier</key>
    <string>org.swift.${SWIFT_VERSION}.${ALIAS}</string>
    <key>DisplayName</key>
    <string>Xcode Swift (${SWIFT_VERSION}.${ALIAS}+${DATE})</string>
    <string>Swift ${SWIFT_VERSION}.${ALIAS}+${DATE}</string>
    <key>ReportProblemURL</key>
    <string>https://bugs.swift.org/</string>
    <key>Version</key>
    <string>${DATE}</string>
    <key>OverrideEnvironment</key>
    <dict>
    <key>ENABLE_BITCODE</key>
    <false/>
    <key>SWIFT_DISABLE_REQUIRED_ARCLITE</key>
    <true/>
    <key>SWIFT_LINK_OBJC_RUNTIME</key>
    <true/>
    </dict>
    </dict>
    </plist>
    EOF

    # again, only way to trigger this otherwise is do a lenghy --installable-package step

    # again, only way to trigger this otherwise is do a lengthy --installable-package step

    cp "${SRCROOT}/swift/utils/swift-stdlib-tool-substitute" "${TOOLCHAIN_PREFIX}/usr/bin/swift-stdlib-tool"
  2. mxcl revised this gist Apr 18, 2016. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion swift-self-build
    Original file line number Diff line number Diff line change
    @@ -77,7 +77,6 @@ cd "$HOME/Desktop"
    --skip-test-tvos-host \
    --skip-test-watchos-simulator \
    --skip-test-watchos-host \
    --skip-test-validation \
    --skip-test-benchmarks \
    --skip-test-optimized \
    --swift-sdks=OSX \
  3. mxcl revised this gist Mar 29, 2016. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions swift-self-build
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    #!/bin/bash
    #
    # Faster toolchain build: skips as much as possible.
    #
    # To use this toolchain from the command line:"
    # export TOOLCHAINS=$(whoami)
    #
    @@ -16,9 +18,10 @@ 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
    if [[ $1 == "--reconfigure" ]]; then
    RECONFIGURE="--reconfigure"
    fi

    @@ -39,7 +42,6 @@ cd "$HOME/Desktop"
    --skip-ios \
    --skip-tvos \
    --skip-watchos \
    --skip-build-benchmarks \
    --skip-build-linux \
    --skip-build-freebsd \
    --skip-build-cygwin \
  4. mxcl revised this gist Mar 24, 2016. 1 changed file with 16 additions and 3 deletions.
    19 changes: 16 additions & 3 deletions swift-self-build
    Original file line number Diff line number Diff line change
    @@ -1,22 +1,31 @@
    #!/bin/bash
    #
    # To use this toolchain from the command line:"
    # export TOOLCHAINS=$(whoami)

    # we build to the same prefix every time because the alternative is a compelte rebuild everyday
    #
    # 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 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"

    "$HOME/src/swift/utils/build-script" \
    "$SRCROOT/swift/utils/build-script" \
    --release \
    --llvm \
    --llbuild \
    @@ -112,3 +121,7 @@ cat > "${TOOLCHAIN_PREFIX}/Info.plist" <<EOF
    </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"
  5. mxcl revised this gist Mar 24, 2016. 1 changed file with 12 additions and 21 deletions.
    33 changes: 12 additions & 21 deletions swift-self-build
    Original file line number Diff line number Diff line change
    @@ -1,30 +1,22 @@
    #!/bin/bash
    # To use this toolchain from the command line:"
    # export TOOLCHAINS=mxcl
    # export TOOLCHAINS=$(whoami)

    # we build to the same prefix every time because the alternative is a compelte rebuild everyday

    set -e
    trap "exit;" SIGINT SIGTERM

    ALIAS=mxcl
    DATE=$(date +%Y%m%d)
    VERSION="3.0.0-${ALIAS}+${DATE}"
    SRCROOT="$HOME/src"
    TOOLCHAIN_NAME="swift-${VERSION}.xctoolchain"
    ALIAS=$(whoami)
    TOOLCHAIN_NAME="swift-${ALIAS}.xctoolchain"
    TOOLCHAIN_PREFIX="$HOME/Library/Developer/Toolchains/${TOOLCHAIN_NAME}"

    if [ ! -d "${TOOLCHAIN_PREFIX}" ]; then
    echo "+++ reconfiguring"
    RECONFIGURE="--reconfigure"
    else
    echo "+++ NOT reconfiguring"
    fi

    export TOOLCHAINS=default

    # so if anything is put in the wrong place we will *see* it
    cd "$HOME/Desktop"

    "$SRCROOT/swift/utils/build-script" \
    "$HOME/src/swift/utils/build-script" \
    --release \
    --llvm \
    --llbuild \
    @@ -83,11 +75,6 @@ cd "$HOME/Desktop"
    --build-swift-stdlib-unittest-extra=0 \
    --build-swift-static-stdlib=1 \
    --compiler-vendor=apple \
    --darwin-toolchain-bundle_identifier="org.swift.${VERSION}" \
    --darwin-toolchain-display_name="Xcode Swift (${VERSION})" \
    --darwin-toolchain-name="swift-${VERSION}" \
    --darwin-toolchain-version="${DATE}" \
    --darwin-toolchain-alias="${ALIAS}" \
    --swift-install-components="compiler;clang-builtin-headers;stdlib;sdk-overlay;license;sourcekit-xpc-service" \
    --llvm-install-components="libclang;libclang-headers" \
    --install-swift=1 \
    @@ -101,6 +88,10 @@ cd "$HOME/Desktop"
    # 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">
    @@ -111,9 +102,9 @@ cat > "${TOOLCHAIN_PREFIX}/Info.plist" <<EOF
    <string>${ALIAS}</string>
    </array>
    <key>CFBundleIdentifier</key>
    <string>org.swift.${VERSION}</string>
    <string>org.swift.${SWIFT_VERSION}.${ALIAS}</string>
    <key>DisplayName</key>
    <string>Xcode Swift (${VERSION})</string>
    <string>Xcode Swift (${SWIFT_VERSION}.${ALIAS}+${DATE})</string>
    <key>ReportProblemURL</key>
    <string>https://bugs.swift.org/</string>
    <key>Version</key>
  6. mxcl revised this gist Mar 24, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion swift-self-build
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    set -e
    trap "exit;" SIGINT SIGTERM

    ALIAS=$(whoami)
    ALIAS=mxcl
    DATE=$(date +%Y%m%d)
    VERSION="3.0.0-${ALIAS}+${DATE}"
    SRCROOT="$HOME/src"
  7. mxcl revised this gist Mar 23, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion swift-self-build
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    set -e
    trap "exit;" SIGINT SIGTERM

    ALIAS=mxcl
    ALIAS=$(whoami)
    DATE=$(date +%Y%m%d)
    VERSION="3.0.0-${ALIAS}+${DATE}"
    SRCROOT="$HOME/src"
  8. mxcl revised this gist Mar 23, 2016. 1 changed file with 37 additions and 13 deletions.
    50 changes: 37 additions & 13 deletions swift-self-build
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,23 @@
    #!/bin/bash
    # To use this toolchain from the command line:"
    # export TOOLCHAINS=mxcl

    set -e
    trap "exit;" SIGINT SIGTERM

    ALIAS=mxcl
    VERSION="3.0.0-${ALIAS}+$(date +%Y%m%d)"
    DATE=$(date +%Y%m%d)
    VERSION="3.0.0-${ALIAS}+${DATE}"
    SRCROOT="$HOME/src"
    TOOLCHAIN_NAME="swift-${VERSION}.xctoolchain"
    TOOLCHAIN_PREFIX="${SRCROOT}/build/${TOOLCHAIN_NAME}"
    TOOLCHAIN_PREFIX="$HOME/Library/Developer/Toolchains/${TOOLCHAIN_NAME}"

    if [ ! -d "${TOOLCHAIN_PREFIX}" ]; then
    echo "+++ reconfiguring"
    RECONFIGURE="--reconfigure"
    else
    echo "+++ NOT reconfiguring"
    fi

    export TOOLCHAINS=default

    @@ -25,7 +34,7 @@ cd "$HOME/Desktop"
    --no-swift-stdlib-assertions \
    --install-prefix="${TOOLCHAIN_PREFIX}/usr" \
    -- \
    --reconfigure \
    ${RECONFIGURE} \
    --skip-ios \
    --skip-tvos \
    --skip-watchos \
    @@ -77,23 +86,38 @@ cd "$HOME/Desktop"
    --darwin-toolchain-bundle_identifier="org.swift.${VERSION}" \
    --darwin-toolchain-display_name="Xcode Swift (${VERSION})" \
    --darwin-toolchain-name="swift-${VERSION}" \
    --darwin-toolchain-version="${VERSION}" \
    --darwin-toolchain-version="${DATE}" \
    --darwin-toolchain-alias="${ALIAS}" \
    --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}" \
    --installable-package="${TOOLCHAIN_PREFIX}.tar.gz"
    --toolchain-prefix="${TOOLCHAIN_PREFIX}"

    DSTDIR="$HOME/Library/Developer/Toolchains"

    rm -rf "${DSTDIR}/${TOOLCHAIN_NAME}" # only one build per day thanks
    mv "${TOOLCHAIN_PREFIX}" "${DSTDIR}"
    rm -f "${DSTDIR}/swift-latest.xctoolchain"
    ln -s "${DSTDIR}/${TOOLCHAIN_NAME}" "${DSTDIR}/swift-latest.xctoolchain"
    # 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

    echo "+++ To use this toolchain from the command line:"
    echo " export TOOLCHAINS='${ALIAS}'"
    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.${VERSION}</string>
    <key>DisplayName</key>
    <string>Xcode Swift (${VERSION})</string>
    <key>ReportProblemURL</key>
    <string>https://bugs.swift.org/</string>
    <key>Version</key>
    <string>${DATE}</string>
    </dict>
    </plist>
    EOF
  9. mxcl revised this gist Mar 22, 2016. 1 changed file with 59 additions and 25 deletions.
    84 changes: 59 additions & 25 deletions swift-self-build
    Original file line number Diff line number Diff line change
    @@ -3,44 +3,75 @@
    set -e
    trap "exit;" SIGINT SIGTERM

    unset TOOLCHAINS

    ALIAS=mxcl
    VERSION="3.0.0-${ALIAS}+$(date +%Y%m%d)"
    PREFIX="$HOME/Library/Developer/Toolchains"
    SRCROOT="$HOME/src"
    TOOLCHAIN_NAME="swift-${VERSION}.xctoolchain"
    TOOLCHAIN_PREFIX="${SRCROOT}/build/${TOOLCHAIN_NAME}"


    export TOOLCHAINS=default

    # so if anything is put in the wrong place we will *see* it
    cd "$HOME/Desktop"

    # only one build per day thanks
    rm -fr "${PREFIX}/swift-${VERSION}.xctoolchain"
    rm -f "${PREFIX}/swift-latest.xctoolchain"

    ~/src/swift/utils/build-script \
    "$SRCROOT/swift/utils/build-script" \
    --release \
    --llvm \
    --lldb \
    --llbuild \
    --swiftpm \
    --build-subdir="${ALIAS}" \
    --assertions \
    --no-swift-stdlib-assertions \
    --install-prefix="${TOOLCHAIN_PREFIX}/usr" \
    -- \
    --skip-ios=1 \
    --skip-tvos=1 \
    --skip-watchos=1 \
    --skip-build-benchmarks=1 \
    --reconfigure \
    --skip-ios \
    --skip-tvos \
    --skip-watchos \
    --skip-build-benchmarks \
    --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-validation \
    --skip-test-benchmarks \
    --skip-test-optimized \
    --swift-sdks=OSX \
    --swift-enable-ast-verifier=0 \
    --build-swift-examples=0 \
    --build-swift-stdlib-unittest-extra=0 \
    --lldb-no-debugserver=1 \
    --lldb-build-type=Release \
    --skip-test-swift=1 \
    --skip-test-swiftpm=1 \
    --skip-test-llbuild=1 \
    --skip-test-lldb=1 \
    --skip-build-lldb=0 \
    --build-swift-static-stdlib=1 \
    --compiler-vendor=apple \
    --darwin-toolchain-bundle_identifier="org.swift.${VERSION}" \
    @@ -50,16 +81,19 @@ rm -f "${PREFIX}/swift-latest.xctoolchain"
    --darwin-toolchain-alias="${ALIAS}" \
    --swift-install-components="compiler;clang-builtin-headers;stdlib;sdk-overlay;license;sourcekit-xpc-service" \
    --llvm-install-components="libclang;libclang-headers" \
    --installable-package="${HOME}/Desktop/swift-${VERSION}.tar.gz" \
    --install-swift=1 \
    --install-lldb=1 \
    --install-llbuild=1 \
    --install-swiftpm=1 \
    --install-destdir="/" \
    --install-prefix="${PREFIX}/swift-${VERSION}.xctoolchain/usr" \
    --reconfigure
    --toolchain-prefix="${TOOLCHAIN_PREFIX}" \
    --installable-package="${TOOLCHAIN_PREFIX}.tar.gz"

    DSTDIR="$HOME/Library/Developer/Toolchains"

    ln -s "${PREFIX}/swift-${VERSION}.xctoolchain" "${PREFIX}/swift-latest.xctoolchain"
    rm -rf "${DSTDIR}/${TOOLCHAIN_NAME}" # only one build per day thanks
    mv "${TOOLCHAIN_PREFIX}" "${DSTDIR}"
    rm -f "${DSTDIR}/swift-latest.xctoolchain"
    ln -s "${DSTDIR}/${TOOLCHAIN_NAME}" "${DSTDIR}/swift-latest.xctoolchain"

    echo "+++ To use this toolchain from the command line:"
    echo " export TOOLCHAINS='${ALIAS}'"
  10. mxcl created this gist Mar 21, 2016.
    65 changes: 65 additions & 0 deletions swift-self-build
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,65 @@
    #!/bin/bash

    set -e
    trap "exit;" SIGINT SIGTERM

    unset TOOLCHAINS

    ALIAS=mxcl
    VERSION="3.0.0-${ALIAS}+$(date +%Y%m%d)"
    PREFIX="$HOME/Library/Developer/Toolchains"

    # so if anything is put in the wrong place we will *see* it
    cd "$HOME/Desktop"

    # only one build per day thanks
    rm -fr "${PREFIX}/swift-${VERSION}.xctoolchain"
    rm -f "${PREFIX}/swift-latest.xctoolchain"

    ~/src/swift/utils/build-script \
    --release \
    --llvm \
    --lldb \
    --llbuild \
    --swiftpm \
    --build-subdir="${ALIAS}" \
    --assertions \
    --no-swift-stdlib-assertions \
    -- \
    --skip-ios=1 \
    --skip-tvos=1 \
    --skip-watchos=1 \
    --skip-build-benchmarks=1 \
    --swift-sdks=OSX \
    --swift-enable-ast-verifier=0 \
    --build-swift-examples=0 \
    --build-swift-stdlib-unittest-extra=0 \
    --lldb-no-debugserver=1 \
    --lldb-build-type=Release \
    --skip-test-swift=1 \
    --skip-test-swiftpm=1 \
    --skip-test-llbuild=1 \
    --skip-test-lldb=1 \
    --skip-build-lldb=0 \
    --build-swift-static-stdlib=1 \
    --compiler-vendor=apple \
    --darwin-toolchain-bundle_identifier="org.swift.${VERSION}" \
    --darwin-toolchain-display_name="Xcode Swift (${VERSION})" \
    --darwin-toolchain-name="swift-${VERSION}" \
    --darwin-toolchain-version="${VERSION}" \
    --darwin-toolchain-alias="${ALIAS}" \
    --swift-install-components="compiler;clang-builtin-headers;stdlib;sdk-overlay;license;sourcekit-xpc-service" \
    --llvm-install-components="libclang;libclang-headers" \
    --installable-package="${HOME}/Desktop/swift-${VERSION}.tar.gz" \
    --install-swift=1 \
    --install-lldb=1 \
    --install-llbuild=1 \
    --install-swiftpm=1 \
    --install-destdir="/" \
    --install-prefix="${PREFIX}/swift-${VERSION}.xctoolchain/usr" \
    --reconfigure

    ln -s "${PREFIX}/swift-${VERSION}.xctoolchain" "${PREFIX}/swift-latest.xctoolchain"

    echo "+++ To use this toolchain from the command line:"
    echo " export TOOLCHAINS='${ALIAS}'"