Skip to content

[build-script] Only build XCTest once #1506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 48 additions & 29 deletions utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -1879,15 +1879,25 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
continue
;;
xctest)
XCTEST_BUILD_DIR=$(build_directory ${deployment_target} xctest)
if [[ "$(uname -s)" == "Darwin" ]] ; then
set -x
xcodebuild -project "${XCTEST_SOURCE_DIR}"/XCTest.xcodeproj -scheme SwiftXCTest SKIP_INSTALL=NO DEPLOYMENT_LOCATION=YES DSTROOT="${build_dir}" INSTALL_PATH="/"
xcodebuild \
-project "${XCTEST_SOURCE_DIR}"/XCTest.xcodeproj \
-scheme SwiftXCTest \
SKIP_INSTALL=NO \
DEPLOYMENT_LOCATION=YES \
DSTROOT="${XCTEST_BUILD_DIR}" \
INSTALL_PATH="/"
{ set +x; } 2>/dev/null
else
SWIFTC_BIN="$(build_directory_bin ${deployment_target} swift)/swiftc"
SWIFT_BUILD_PATH="$(build_directory ${deployment_target} swift)"
set -x
"${XCTEST_SOURCE_DIR}"/build_script.py --swiftc="${SWIFTC_BIN}" --build-dir="${build_dir}" --swift-build-dir="${SWIFT_BUILD_PATH}" --arch="${SWIFT_HOST_VARIANT_ARCH}"
# FIXME: Use XCTEST_BUILD_TYPE (which is never properly
# set) to build either --debug or --release.
"${XCTEST_SOURCE_DIR}"/build_script.py \
--swiftc="${SWIFTC_BIN}" \
--build-dir="${XCTEST_BUILD_DIR}"
{ set +x; } 2>/dev/null
fi

Expand Down Expand Up @@ -2135,15 +2145,17 @@ for deployment_target in "${STDLIB_DEPLOYMENT_TARGETS[@]}"; do
echo "--- Running tests for ${product} ---"
if [[ "$(uname -s)" == "Darwin" ]] ; then
set -x
xcodebuild -project "${XCTEST_SOURCE_DIR}"/XCTest.xcodeproj -scheme SwiftXCTestFunctionalTests
xcodebuild \
-project "${XCTEST_SOURCE_DIR}"/XCTest.xcodeproj \
-scheme SwiftXCTestFunctionalTests
{ set +x; } 2>/dev/null
else
SWIFTC_BIN="$(build_directory_bin ${deployment_target} swift)/swiftc"
SWIFT_BUILD_PATH="$(build_directory ${deployment_target} swift)"
XCTEST_BUILD_DIR=$(build_directory ${deployment_target} xctest)
set -x
# FIXME: This re-builds swift-corelibs-xctest. Instead, 'build_script.py' should take
# a top-level 'test' command that only tests an already built XCTest.
"${XCTEST_SOURCE_DIR}"/build_script.py --swiftc="${SWIFTC_BIN}" --build-dir="${build_dir}" --swift-build-dir="${SWIFT_BUILD_PATH}" --arch="${SWIFT_HOST_VARIANT_ARCH}" --test
"${XCTEST_SOURCE_DIR}"/build_script.py test \
--swiftc="${SWIFTC_BIN}" \
"${XCTEST_BUILD_DIR}"
{ set +x; } 2>/dev/null
fi
echo "--- Finished tests for ${product} ---"
Expand Down Expand Up @@ -2293,31 +2305,38 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
if [[ -z "${INSTALL_XCTEST}" ]] ; then
continue
fi
if [[ $(uname -s) == "Linux" ]]; then
LIB_TARGET="linux"
ARCH_FLAG="--arch=\"${SWIFT_HOST_VARIANT_ARCH}\""
fi
if [[ $(uname -s) == "FreeBSD" ]]; then
LIB_TARGET="freebsd"
ARCH_FLAG="--arch=\"${SWIFT_HOST_VARIANT_ARCH}\""
fi
if [[ $(uname -s) == "CYGWIN_NT-10.0" ]]; then
LIB_TARGET="windows"
fi
if [[ $(uname -s) == "Darwin" ]]; then
LIB_TARGET="macosx"
ARCH_FLAG=""
if [[ -z "${INSTALL_DESTDIR}" ]] ; then
echo "error: --install-destdir is required"
exit 1
fi
XCTEST_INSTALL_PREFIX="${INSTALL_DESTDIR}"/"${INSTALL_PREFIX}"/lib/swift/"${LIB_TARGET}"
case "$(uname -s)" in
Linux)
LIB_TARGET="linux"
;;
FreeBSD)
LIB_TARGET="freebsd"
;;
CYGWIN_NT-10.0)
LIB_TARGET="windows"
;;
*)
echo "error: --install-xctest is not supported on this platform"
exit 1
;;
esac

echo "--- Installing ${product} ---"
XCTEST_BUILD_DIR=$(build_directory ${deployment_target} xctest)
XCTEST_INSTALL_PREFIX="${INSTALL_DESTDIR}/${INSTALL_PREFIX}/lib/swift/${LIB_TARGET}"
# Note that installing directly to /usr/lib/swift usually
# requires root permissions.
set -x
"${XCTEST_SOURCE_DIR}"/build_script.py --swiftc="${SWIFTC_BIN}" \
--build-dir="${build_dir}" \
--library-install-path="${XCTEST_INSTALL_PREFIX}" \
--module-install-path="${XCTEST_INSTALL_PREFIX}"/"${SWIFT_HOST_VARIANT_ARCH}" \
--swift-build-dir="${SWIFT_BUILD_PATH}" ${ARCH_FLAG}
"${XCTEST_SOURCE_DIR}"/build_script.py install \
--library-install-path="${XCTEST_INSTALL_PREFIX}" \
--module-install-path="${XCTEST_INSTALL_PREFIX}"/"${SWIFT_HOST_VARIANT_ARCH}" \
"${XCTEST_BUILD_DIR}"
{ set +x; } 2>/dev/null

# As XCTest installation is self-contained, we break early here.
continue
;;
Expand Down