[swift-build-dev] Building custom toolchain

Hi all,

I'm trying to build a custom toolchain, but it is failing with error:

--- Installing swift ---
+ env DESTDIR=// /usr/local/bin/cmake --build
/Users/bhargavg/Documents/workspaces/xcode/github/apple/build/bhargavg/swift-macosx-x86_64
-- install
ninja: error: unknown target 'install'
swift/utils/build-script: fatal error: command terminated with a non-zero
exit status 1, aborting

Script to build toolchain:

#!/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/Documents/workspaces/xcode/github/apple/"

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"

"$SRCROOT/swift/utils/build-script" \
        --release \
        --llvm \
        --llbuild \
        --swiftpm \
        --build-subdir="${ALIAS}" \
        --assertions \
        --no-swift-stdlib-assertions \
        --install-prefix="${TOOLCHAIN_PREFIX}/usr" \
        --lldb \
        --darwin-xcrun-toolchain=mxcl \
        -- \
        --lldb-use-system-debugserver \
        ${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-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 \
        --stdlib-deployment-targets=macosx-x86_64 \
        --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="/" \
        --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)
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
<?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&quot;&gt;
<plist version="1.0">
<dict>
  <key>Aliases</key>
  <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>Swift ${SWIFT_VERSION}.${ALIAS}+${DATE}</string>
  <key>ReportProblemURL</key>
  <string>Issues · apple/swift · GitHub;
  <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 lengthy
--installable-package step

cp "${SRCROOT}/swift/utils/swift-stdlib-tool-substitute"
"${TOOLCHAIN_PREFIX}/usr/bin/swift-stdlib-tool"

You can find the script at:

Regards,
Bhargav Gurlanka

FWIW, this:
  This is the script I currently use on OS X to get a working "swift-dev.xctoolchain" out of a built Swift. It isn't designed to work for anyone but me, but it should be easy to adapt. I always run this after every build, and then use `TOOLCHAINS=swift-dev swift build` (etc) to use the development compiler. · GitHub
is the script I currently use on OS X to get a working "swift-dev.xctoolchain" out of a built Swift. It isn't designed to work for anyone but me, but it should be easy to adapt.

I always run this after every build, and then use `TOOLCHAINS=swift-dev swift build` (etc) to use the development compiler.

My "toolchain-based build process" proposal will hopefully make this a no-op.

- Daniel

···

On Jun 2, 2016, at 3:12 AM, bhargav gurlanka via swift-build-dev <swift-build-dev@swift.org> wrote:

Hi all,

I'm trying to build a custom toolchain, but it is failing with error:

--- Installing swift ---
+ env DESTDIR=// /usr/local/bin/cmake --build /Users/bhargavg/Documents/workspaces/xcode/github/apple/build/bhargavg/swift-macosx-x86_64 -- install
ninja: error: unknown target 'install'
swift/utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting

Script to build toolchain:

#!/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/Documents/workspaces/xcode/github/apple/"

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"

"$SRCROOT/swift/utils/build-script" \
        --release \
        --llvm \
        --llbuild \
        --swiftpm \
        --build-subdir="${ALIAS}" \
        --assertions \
        --no-swift-stdlib-assertions \
        --install-prefix="${TOOLCHAIN_PREFIX}/usr" \
        --lldb \
        --darwin-xcrun-toolchain=mxcl \
        -- \
        --lldb-use-system-debugserver \
        ${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-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 \
        --stdlib-deployment-targets=macosx-x86_64 \
        --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="/" \
        --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)
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
<?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&quot;&gt;
<plist version="1.0">
<dict>
  <key>Aliases</key>
  <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>Swift ${SWIFT_VERSION}.${ALIAS}+${DATE}</string>
  <key>ReportProblemURL</key>
  <string>Issues · apple/swift · GitHub;
  <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 lengthy --installable-package step

cp "${SRCROOT}/swift/utils/swift-stdlib-tool-substitute" "${TOOLCHAIN_PREFIX}/usr/bin/swift-stdlib-tool"

You can find the script at: swift-self-build · GitHub

Regards,
Bhargav Gurlanka

_______________________________________________
swift-build-dev mailing list
swift-build-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-build-dev

I always run this after every build

If I understand you correctly, you first build swift and then run this
script to create the toolchain right?

Are you using the `build-toolchain` script to build swift? I've tried doing
it sometime back and it included the testing also, which took a long time
to complete. Is there a way to quicken the build (by disabling tests,
incremental build, etc.,)?

Regards,
Bhargav Gurlanka

···

On 2 June 2016 at 23:06, Daniel Dunbar <daniel_dunbar@apple.com> wrote:

FWIW, this:
  This is the script I currently use on OS X to get a working "swift-dev.xctoolchain" out of a built Swift. It isn't designed to work for anyone but me, but it should be easy to adapt. I always run this after every build, and then use `TOOLCHAINS=swift-dev swift build` (etc) to use the development compiler. · GitHub
is the script I currently use on OS X to get a working
"swift-dev.xctoolchain" out of a built Swift. It isn't designed to work for
anyone but me, but it should be easy to adapt.

I always run this after every build, and then use `TOOLCHAINS=swift-dev
swift build` (etc) to use the development compiler.

My "toolchain-based build process" proposal will hopefully make this a
no-op.

- Daniel

On Jun 2, 2016, at 3:12 AM, bhargav gurlanka via swift-build-dev < > swift-build-dev@swift.org> wrote:

Hi all,

I'm trying to build a custom toolchain, but it is failing with error:

--- Installing swift ---
+ env DESTDIR=// /usr/local/bin/cmake --build
/Users/bhargavg/Documents/workspaces/xcode/github/apple/build/bhargavg/swift-macosx-x86_64
-- install
ninja: error: unknown target 'install'
swift/utils/build-script: fatal error: command terminated with a non-zero
exit status 1, aborting

Script to build toolchain:

#!/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/Documents/workspaces/xcode/github/apple/"

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"

"$SRCROOT/swift/utils/build-script" \
        --release \
        --llvm \
        --llbuild \
        --swiftpm \
        --build-subdir="${ALIAS}" \
        --assertions \
        --no-swift-stdlib-assertions \
        --install-prefix="${TOOLCHAIN_PREFIX}/usr" \
        --lldb \
        --darwin-xcrun-toolchain=mxcl \
        -- \
        --lldb-use-system-debugserver \
        ${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-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 \
        --stdlib-deployment-targets=macosx-x86_64 \
        --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="/" \
        --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)
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
<?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&quot;&gt;
<plist version="1.0">
<dict>
  <key>Aliases</key>
  <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>Swift ${SWIFT_VERSION}.${ALIAS}+${DATE}</string>
  <key>ReportProblemURL</key>
  <string>Issues · apple/swift · GitHub;
  <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 lengthy --installable-package step

cp "${SRCROOT}/swift/utils/swift-stdlib-tool-substitute" "${TOOLCHAIN_PREFIX}/usr/bin/swift-stdlib-tool"

You can find the script at:
swift-self-build · GitHub

Regards,
Bhargav Gurlanka

_______________________________________________
swift-build-dev mailing list
swift-build-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-build-dev

> I always run this after every build

If I understand you correctly, you first build swift and then run this script to create the toolchain right?

Are you using the `build-toolchain` script to build swift? I've tried doing it sometime back and it included the testing also, which took a long time to complete. Is there a way to quicken the build (by disabling tests, incremental build, etc.,)?

No, part of the reason I developed that script is because I wanted to make a toolchain out of the build-script invocation I use for incremental development, which is this:
  ~/public/swift-project/swift/utils/build-script -R --llbuild --swiftpm

That works fine for iterative development, my "null" builds are about 5s. I run that with "--tests" if I want to also run all the tests (but often for my local iterative SwiftPM development I am just running the SwiftPM tests).

- Daniel

···

On Jun 2, 2016, at 10:59 AM, bhargav gurlanka <bhargav.grlnk@gmail.com> wrote:

Regards,
Bhargav Gurlanka

On 2 June 2016 at 23:06, Daniel Dunbar <daniel_dunbar@apple.com <mailto:daniel_dunbar@apple.com>> wrote:
FWIW, this:
  This is the script I currently use on OS X to get a working "swift-dev.xctoolchain" out of a built Swift. It isn't designed to work for anyone but me, but it should be easy to adapt. I always run this after every build, and then use `TOOLCHAINS=swift-dev swift build` (etc) to use the development compiler. · GitHub
is the script I currently use on OS X to get a working "swift-dev.xctoolchain" out of a built Swift. It isn't designed to work for anyone but me, but it should be easy to adapt.

I always run this after every build, and then use `TOOLCHAINS=swift-dev swift build` (etc) to use the development compiler.

My "toolchain-based build process" proposal will hopefully make this a no-op.

- Daniel

On Jun 2, 2016, at 3:12 AM, bhargav gurlanka via swift-build-dev <swift-build-dev@swift.org <mailto:swift-build-dev@swift.org>> wrote:

Hi all,

I'm trying to build a custom toolchain, but it is failing with error:

--- Installing swift ---
+ env DESTDIR=// /usr/local/bin/cmake --build /Users/bhargavg/Documents/workspaces/xcode/github/apple/build/bhargavg/swift-macosx-x86_64 -- install
ninja: error: unknown target 'install'
swift/utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting

Script to build toolchain:

#!/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/Documents/workspaces/xcode/github/apple/"

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"

"$SRCROOT/swift/utils/build-script" \
        --release \
        --llvm \
        --llbuild \
        --swiftpm \
        --build-subdir="${ALIAS}" \
        --assertions \
        --no-swift-stdlib-assertions \
        --install-prefix="${TOOLCHAIN_PREFIX}/usr" \
        --lldb \
        --darwin-xcrun-toolchain=mxcl \
        -- \
        --lldb-use-system-debugserver \
        ${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-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 \
        --stdlib-deployment-targets=macosx-x86_64 \
        --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="/" \
        --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)
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
<?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&quot;&gt;
<plist version="1.0">
<dict>
  <key>Aliases</key>
  <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>Swift ${SWIFT_VERSION}.${ALIAS}+${DATE}</string>
  <key>ReportProblemURL</key>
  <string>Issues · apple/swift · GitHub;
  <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 lengthy --installable-package step

cp "${SRCROOT}/swift/utils/swift-stdlib-tool-substitute" "${TOOLCHAIN_PREFIX}/usr/bin/swift-stdlib-tool"

You can find the script at: swift-self-build · GitHub

Regards,
Bhargav Gurlanka

_______________________________________________
swift-build-dev mailing list
swift-build-dev@swift.org <mailto:swift-build-dev@swift.org>
https://lists.swift.org/mailman/listinfo/swift-build-dev

Hi Daniel,

Thanks a lot for sharing your script. I tried to run it and noticed there's no libPackageDescription.dylib and PackageDescription.swiftmodule seems to be missing or I might be doing something wrong on my end. I tried to build both with ./utils/build-script -R --llbuild --swiftpm and normal ./utils/build-toolchain, and in neither one the swiftpm has those libraries. Was wondering if you have that issue or know of a way to create the toolchain with already built swift?

Thanks,
Mani