Skip to content

Instantly share code, notes, and snippets.

@erica
Forked from ankitspd/faketoolchain.sh
Created August 3, 2016 18:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erica/3fef770d0dc510b49b627167a7d29cf7 to your computer and use it in GitHub Desktop.
Save erica/3fef770d0dc510b49b627167a7d29cf7 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e
NINJA_RELEASE_ASSERT_DIR="${HOME}/Documents/workspaces/xcode/github/apple/build/Ninja-ReleaseAssert"
SOURCE_ROOT="${HOME}/Documents/workspaces/xcode/github/apple"
echo "Updating sources (except SwiftPM)"
${SOURCE_ROOT}/swift/utils/update-checkout --skip-repository swiftpm
echo "Done updating sources"
echo "Building lldb llbuld llvm swiftpm"
${SOURCE_ROOT}/swift/utils/build-script -R --lldb --llbuild --lldb-use-system-debugserver --swiftpm
echo "Done building"
echo "Start copying to toolchain"
if [ -z "${CONFIGURATION}" ]; then
CONFIGURATION=debug
fi
# Create the development toolchain.
rm -rf ${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain
mkdir -p ${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain/usr/bin
if ! /usr/libexec/PlistBuddy -c "Add CFBundleIdentifier string 'swift-dev'" "${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain/Info.plist" > /dev/null; then
echo "error: unable to create Info.plist"
exit 1
fi
if ! /usr/libexec/PlistBuddy -c "Add CompatibilityVersion integer 1" "${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain/Info.plist" > /dev/null; then
echo "error: unable to create Info.plist"
exit 1
fi
# Install the `swift` provided binaries.
rsync -ar \
--link-dest ${NINJA_RELEASE_ASSERT_DIR}/swift-macosx-x86_64/bin/ \
${NINJA_RELEASE_ASSERT_DIR}/swift-macosx-x86_64/bin/swift \
${NINJA_RELEASE_ASSERT_DIR}/swift-macosx-x86_64/bin/swiftc \
${NINJA_RELEASE_ASSERT_DIR}/swift-macosx-x86_64/bin/swift-demangle \
${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain/usr/bin
# Install the `swiftpm` provided binaries.
rsync -ar \
--link-dest ${NINJA_RELEASE_ASSERT_DIR}/swiftpm-macosx-x86_64/${CONFIGURATION}/ \
${NINJA_RELEASE_ASSERT_DIR}/swiftpm-macosx-x86_64/${CONFIGURATION}/swift-build \
${NINJA_RELEASE_ASSERT_DIR}/swiftpm-macosx-x86_64/${CONFIGURATION}/swift-package \
${NINJA_RELEASE_ASSERT_DIR}/swiftpm-macosx-x86_64/${CONFIGURATION}/swift-test \
${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain/usr/bin/
# Install the `llbuild` provided binaries.
rsync -ar \
--link-dest ${NINJA_RELEASE_ASSERT_DIR}/llbuild-macosx-x86_64/bin/ \
${NINJA_RELEASE_ASSERT_DIR}/llbuild-macosx-x86_64/bin/swift-build-tool \
${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain/usr/bin/
# Install fake versions of `lldb` and `lldb-mi`.
rsync -ar \
--link-dest ${NINJA_RELEASE_ASSERT_DIR}/llbuild-macosx-x86_64/bin/ \
$(which false) \
${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain/usr/bin/lldb
rsync -ar \
--link-dest ${NINJA_RELEASE_ASSERT_DIR}/llbuild-macosx-x86_64/bin/ \
$(which false) \
${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain/usr/bin/lldb-mi
# Install the `swiftpm` runtime libraries.
mkdir -p ${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain/usr/lib/swift/pm/
rsync -ar \
--link-dest ${NINJA_RELEASE_ASSERT_DIR}/swiftpm-macosx-x86_64/${CONFIGURATION}/ \
${NINJA_RELEASE_ASSERT_DIR}/swiftpm-macosx-x86_64/${CONFIGURATION}/libPackageDescription.dylib \
${NINJA_RELEASE_ASSERT_DIR}/swiftpm-macosx-x86_64/${CONFIGURATION}/PackageDescription.swiftmodule \
${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain/usr/lib/swift/pm/
# Install the `clang` runtime data.
rsync -ar \
--link-dest ${NINJA_RELEASE_ASSERT_DIR}/llvm-macosx-x86_64/lib/libclang.dylib \
${NINJA_RELEASE_ASSERT_DIR}/llvm-macosx-x86_64/lib/libclang.dylib \
${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain/usr/lib/
# Install the standard libraries.
mkdir -p ${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain/usr/lib/swift/macosx/
rsync -a \
--link-dest ${NINJA_RELEASE_ASSERT_DIR}/swift-macosx-x86_64/lib/swift/macosx/ \
$(ls ${NINJA_RELEASE_ASSERT_DIR}/swift-macosx-x86_64/lib/swift/macosx/*.dylib | \
grep -v SwiftPrivate | \
grep -v StdlibUnittest | \
grep -v SwiftReflectionTest | \
grep -v SwiftExperimental) \
${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain/usr/lib/swift/macosx/
rsync -a \
--link-dest ${NINJA_RELEASE_ASSERT_DIR}/swift-macosx-x86_64/lib/swift/macosx/x86_64/ \
$(ls ${NINJA_RELEASE_ASSERT_DIR}/swift-macosx-x86_64/lib/swift/macosx/x86_64/*.swiftdoc | \
grep -v SwiftPrivate | \
grep -v StdlibUnittest | \
grep -v SwiftReflectionTest | \
grep -v SwiftExperimental) \
${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain/usr/lib/swift/macosx/x86_64/
rsync -a \
--link-dest ${NINJA_RELEASE_ASSERT_DIR}/swift-macosx-x86_64/lib/swift/macosx/x86_64/ \
$(ls ${NINJA_RELEASE_ASSERT_DIR}/swift-macosx-x86_64/lib/swift/macosx/x86_64/*.swiftmodule | \
grep -v SwiftPrivate | \
grep -v StdlibUnittest | \
grep -v SwiftReflectionTest | \
grep -v SwiftExperimental) \
${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain/usr/lib/swift/macosx/x86_64/
rsync -a \
--link-dest ${NINJA_RELEASE_ASSERT_DIR}/swift-macosx-x86_64/lib/swift/macosx/x86_64/ \
$(ls ${NINJA_RELEASE_ASSERT_DIR}/swift-macosx-x86_64/lib/swift/macosx/x86_64/*.apinotesc | \
grep -v SwiftPrivate | \
grep -v StdlibUnittest | \
grep -v SwiftReflectionTest | \
grep -v SwiftExperimental) \
${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain/usr/lib/swift/macosx/x86_64/
rsync -ar \
--link-dest ${NINJA_RELEASE_ASSERT_DIR}/swift-macosx-x86_64/lib/sourcekitd.framework/ \
${NINJA_RELEASE_ASSERT_DIR}/swift-macosx-x86_64/lib/sourcekitd.framework/ \
${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain/usr/lib/sourcekitd.framework/
# Install the `clang` symlink.
rsync -ar \
${NINJA_RELEASE_ASSERT_DIR}/swift-macosx-x86_64/lib/swift/clang \
${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain/usr/lib/swift/clang
rsync -ar \
--link-dest ${NINJA_RELEASE_ASSERT_DIR}/swift-macosx-x86_64/lib/swift/shims/ \
${NINJA_RELEASE_ASSERT_DIR}/swift-macosx-x86_64/lib/swift/shims/ \
${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain/usr/lib/swift/shims/
rsync -a \
--link-dest ${NINJA_RELEASE_ASSERT_DIR}/swift-macosx-x86_64/lib/ \
${NINJA_RELEASE_ASSERT_DIR}/swift-macosx-x86_64/lib/lib*Demangle.dylib \
${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain/usr/lib/
# Copy over `swift-stdlib-tool`.
cp $(xcrun --find swift-stdlib-tool) \
${NINJA_RELEASE_ASSERT_DIR}/swift-dev.xctoolchain/usr/bin/
echo "Copying done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment