mirror of
https://github.com/apple/swift.git
synced 2026-06-27 12:25:55 +02:00
046fb4128e
This script improves several things: * Previous it was incredilby easy to accidently mis-use the script. For example running `build-toolchain -n` would set `BUNDLE_PREFIX` to `-n`. The new implementation of command line argument parsing is less fragile and easier to extend. * Provides `--help` (or `-h`) output. * Prints the value of several environment variables before running `build-script`. * Shows the invocation of `build-script`. The accepted order of command line arguments has not changed to avoid breaking existing users of the script.
123 lines
3.3 KiB
Bash
Executable File
123 lines
3.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# utils/build-toolchain - documents process for building a toolchain
|
|
#
|
|
# This source file is part of the Swift.org open source project
|
|
#
|
|
# Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
|
|
# Licensed under Apache License v2.0 with Runtime Library Exception
|
|
#
|
|
# See https://swift.org/LICENSE.txt for license information
|
|
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
|
|
function usage() {
|
|
echo "$0 <bundle_prefix> [OPTIONS]"
|
|
echo ""
|
|
echo "<bundle_prefix> - Prefix to use for bundle name"
|
|
echo ""
|
|
echo "OPTIONS"
|
|
echo ""
|
|
echo "-h --help"
|
|
echo "Show help information."
|
|
echo ""
|
|
echo "-n --dry-run"
|
|
echo "Do a dry run."
|
|
echo ""
|
|
if [[ "$(uname -s)" == "Linux" ]] ; then
|
|
echo "-t --test"
|
|
echo "Run tests."
|
|
echo ""
|
|
fi
|
|
}
|
|
|
|
cd "$(dirname $0)/.." || exit
|
|
SRC_DIR=$PWD
|
|
|
|
# Set defaults
|
|
DRY_RUN=
|
|
BUNDLE_PREFIX=
|
|
case $(uname -s) in
|
|
Darwin)
|
|
SWIFT_PACKAGE=buildbot_osx_package
|
|
;;
|
|
Linux)
|
|
SWIFT_PACKAGE=buildbot_linux,no_test
|
|
;;
|
|
*)
|
|
echo "Unrecognised platform $(uname -s)"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
# Process command line arguments
|
|
FIRST_ARG_PROCESSED=0
|
|
while [ $# -ne 0 ]; do
|
|
case "$1" in
|
|
-n|--dry-run)
|
|
DRY_RUN="-n"
|
|
;;
|
|
-t|--test)
|
|
if [ "$(uname -s)" == "Linux" ]; then
|
|
SWIFT_PACKAGE=buildbot_linux
|
|
else
|
|
echo "--test is not supported on \"$(uname -s)\". See --help"
|
|
exit 1
|
|
fi
|
|
;;
|
|
-h|--help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
*)
|
|
if [ ${FIRST_ARG_PROCESSED} -eq 0 ]; then
|
|
# This is the bundle prefix
|
|
BUNDLE_PREFIX="$1"
|
|
else
|
|
echo "Unrecognised argument \"$1\""
|
|
exit 1
|
|
fi
|
|
;;
|
|
esac
|
|
FIRST_ARG_PROCESSED=1
|
|
shift
|
|
done
|
|
|
|
if [ -z "${BUNDLE_PREFIX}" ]; then
|
|
echo "Bundle prefix cannot be empty. See $0 --help"
|
|
exit 1
|
|
fi
|
|
|
|
# Report the commands being run
|
|
set -x
|
|
YEAR=$(date +"%Y")
|
|
MONTH=$(date +"%m")
|
|
DAY=$(date +"%d")
|
|
TOOLCHAIN_VERSION="swift-LOCAL-${YEAR}-${MONTH}-${DAY}-a"
|
|
ARCHIVE="${TOOLCHAIN_VERSION}-osx.tar.gz"
|
|
SYM_ARCHIVE="${TOOLCHAIN_VERSION}-osx-symbols.tar.gz"
|
|
BUNDLE_PREFIX=${BUNDLE_PREFIX:?Please specify a bundle prefix}
|
|
BUNDLE_IDENTIFIER="${BUNDLE_PREFIX}.${YEAR}${MONTH}${DAY}"
|
|
DISPLAY_NAME_SHORT="Local Swift Development Snapshot"
|
|
DISPLAY_NAME="${DISPLAY_NAME_SHORT} ${YEAR}-${MONTH}-${DAY}"
|
|
TOOLCHAIN_NAME="${TOOLCHAIN_VERSION}"
|
|
|
|
SWIFT_INSTALLABLE_PACKAGE="${SRC_DIR}/${ARCHIVE}"
|
|
SWIFT_INSTALL_DIR="${SRC_DIR}/swift-nightly-install"
|
|
SWIFT_INSTALL_SYMROOT="${SRC_DIR}/swift-nightly-symroot"
|
|
SWIFT_TOOLCHAIN_DIR="/Library/Developer/Toolchains/${TOOLCHAIN_NAME}.xctoolchain"
|
|
SYMBOLS_PACKAGE="${SRC_DIR}/${SYM_ARCHIVE}"
|
|
DRY_RUN="${DRY_RUN}"
|
|
|
|
./utils/build-script ${DRY_RUN} --preset="${SWIFT_PACKAGE}" \
|
|
install_destdir="${SWIFT_INSTALL_DIR}" \
|
|
installable_package="${SWIFT_INSTALLABLE_PACKAGE}" \
|
|
install_toolchain_dir="${SWIFT_TOOLCHAIN_DIR}" \
|
|
install_symroot="${SWIFT_INSTALL_SYMROOT}" \
|
|
symbols_package="${SYMBOLS_PACKAGE}" \
|
|
darwin_toolchain_bundle_identifier="${BUNDLE_IDENTIFIER}" \
|
|
darwin_toolchain_display_name="${DISPLAY_NAME}" \
|
|
darwin_toolchain_display_name_short="${DISPLAY_NAME_SHORT}" \
|
|
darwin_toolchain_xctoolchain_name="${TOOLCHAIN_NAME}" \
|
|
darwin_toolchain_version="${TOOLCHAIN_VERSION}" \
|
|
darwin_toolchain_alias="Local"
|