Skip to content

Commit 34848e6

Browse files
committed
[build] Unify logic to skip building projects in build-script-impl
1 parent 8e09cd2 commit 34848e6

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed

utils/build-script-impl

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,10 +1041,14 @@ if [[ ! "${SKIP_BUILD_PLAYGROUNDSUPPORT}" && ! -d ${PLAYGROUNDSUPPORT_SOURCE_DIR
10411041
exit 1
10421042
fi
10431043

1044-
PRODUCTS=(cmark llvm)
1044+
# We cannot currently apply the normal rules of skipping here for LLVM. Even if
1045+
# we are skipping building LLVM, we still need to at least build several tools
1046+
# that swift relies on for building and testing. See the LLVM configure rules.
1047+
PRODUCTS=(llvm)
1048+
[[ "${SKIP_BUILD_CMARK}" ]] || PRODUCTS+=(cmark)
10451049
[[ "${SKIP_BUILD_LIBCXX}" ]] || PRODUCTS+=(libcxx)
10461050
[[ "${SKIP_BUILD_LIBICU}" ]] || PRODUCTS+=(libicu)
1047-
PRODUCTS+=(swift)
1051+
[[ "${SKIP_BUILD_SWIFT}" ]] || PRODUCTS+=(swift)
10481052
[[ "${SKIP_BUILD_LLDB}" ]] || PRODUCTS+=(lldb)
10491053
[[ "${SKIP_BUILD_LIBDISPATCH}" ]] || PRODUCTS+=(libdispatch)
10501054
[[ "${SKIP_BUILD_STATIC_LIBDISPATCH}" ]] || PRODUCTS+=(libdispatch_static)
@@ -1436,7 +1440,6 @@ for host in "${ALL_HOSTS[@]}"; do
14361440
-DCMAKE_BUILD_TYPE:STRING="${CMARK_BUILD_TYPE}"
14371441
"${cmark_cmake_options[@]}"
14381442
)
1439-
skip_build=${SKIP_BUILD_CMARK}
14401443
build_targets=(all)
14411444
;;
14421445

@@ -1761,7 +1764,6 @@ for host in "${ALL_HOSTS[@]}"; do
17611764
build_targets=("${build_targets[@]}"
17621765
"${SWIFT_BENCHMARK_TARGETS[@]}")
17631766
fi
1764-
skip_build=${SKIP_BUILD_SWIFT}
17651767
;;
17661768
lldb)
17671769
if [ ! -d "${LLDB_SOURCE_DIR}" ]; then
@@ -2228,48 +2230,46 @@ for host in "${ALL_HOSTS[@]}"; do
22282230
fi
22292231

22302232
# Build.
2231-
if [[ ! "${skip_build}" ]]; then
2232-
if [[ "${CMAKE_GENERATOR}" == "Xcode" ]] ; then
2233-
# Xcode generator uses "ALL_BUILD" instead of "all".
2234-
# Also, xcodebuild uses -target instead of bare names.
2235-
build_targets=("${build_targets[@]/all/ALL_BUILD}")
2236-
build_targets=("${build_targets[@]/#/${BUILD_TARGET_FLAG} }")
2237-
2238-
# Xcode can't restart itself if it turns out we need to reconfigure.
2239-
# Do an advance build to handle that.
2240-
call "${CMAKE_BUILD[@]}" "${build_dir}" $(cmake_config_opt ${product})
2241-
fi
2233+
if [[ "${CMAKE_GENERATOR}" == "Xcode" ]] ; then
2234+
# Xcode generator uses "ALL_BUILD" instead of "all".
2235+
# Also, xcodebuild uses -target instead of bare names.
2236+
build_targets=("${build_targets[@]/all/ALL_BUILD}")
2237+
build_targets=("${build_targets[@]/#/${BUILD_TARGET_FLAG} }")
2238+
2239+
# Xcode can't restart itself if it turns out we need to reconfigure.
2240+
# Do an advance build to handle that.
2241+
call "${CMAKE_BUILD[@]}" "${build_dir}" $(cmake_config_opt ${product})
2242+
fi
22422243

2243-
call "${CMAKE_BUILD[@]}" "${build_dir}" $(cmake_config_opt ${product}) -- "${BUILD_ARGS[@]}" ${build_targets[@]}
2244-
2245-
# When we are building LLVM copy over the compiler-rt
2246-
# builtins for iOS/tvOS/watchOS to ensure that Swift's
2247-
# stdlib can use compiler-rt builtins when targetting iOS/tvOS/watchOS.
2248-
if [[ "${product}" = "llvm" ]] && [[ "${BUILD_LLVM}" = "1" ]] && [[ "$(uname -s)" = "Darwin" ]]; then
2249-
HOST_CXX_DIR=$(dirname "${HOST_CXX}")
2250-
HOST_LIB_CLANG_DIR="${HOST_CXX_DIR}/../lib/clang"
2251-
DEST_LIB_CLANG_DIR="$(build_directory_bin ${host} llvm)/../lib/clang"
2252-
2253-
if [[ -d "${HOST_LIB_CLANG_DIR}" ]] && [[ -d "${DEST_LIB_CLANG_DIR}" ]]; then
2254-
DEST_CXX_BUILTINS_VERSION=$(ls "${DEST_LIB_CLANG_DIR}" | awk '{print $0}')
2255-
DEST_BUILTINS_DIR="$(build_directory_bin ${host} llvm)/../lib/clang/$DEST_CXX_BUILTINS_VERSION/lib/darwin"
2256-
2257-
if [[ -d "${DEST_BUILTINS_DIR}" ]]; then
2258-
for HOST_CXX_BUILTINS_PATH in "${HOST_LIB_CLANG_DIR}"/*; do
2259-
HOST_CXX_BUILTINS_DIR="${HOST_CXX_BUILTINS_PATH}/lib/darwin"
2260-
echo "copying compiler-rt embedded builtins from ${HOST_CXX_BUILTINS_DIR} into the local clang build directory ${DEST_BUILTINS_DIR}."
2261-
2262-
for OS in ios watchos tvos; do
2263-
LIB_NAME="libclang_rt.$OS.a"
2264-
HOST_LIB_PATH="$HOST_CXX_BUILTINS_DIR/$LIB_NAME"
2265-
if [[ -f "${HOST_LIB_PATH}" ]]; then
2266-
call cp "${HOST_LIB_PATH}" "${DEST_BUILTINS_DIR}/${LIB_NAME}"
2267-
elif [[ "${VERBOSE_BUILD}" ]]; then
2268-
echo "no file exists at ${HOST_LIB_PATH}"
2269-
fi
2270-
done
2244+
call "${CMAKE_BUILD[@]}" "${build_dir}" $(cmake_config_opt ${product}) -- "${BUILD_ARGS[@]}" ${build_targets[@]}
2245+
2246+
# When we are building LLVM copy over the compiler-rt
2247+
# builtins for iOS/tvOS/watchOS to ensure that Swift's
2248+
# stdlib can use compiler-rt builtins when targetting iOS/tvOS/watchOS.
2249+
if [[ "${product}" = "llvm" ]] && [[ "${BUILD_LLVM}" = "1" ]] && [[ "$(uname -s)" = "Darwin" ]]; then
2250+
HOST_CXX_DIR=$(dirname "${HOST_CXX}")
2251+
HOST_LIB_CLANG_DIR="${HOST_CXX_DIR}/../lib/clang"
2252+
DEST_LIB_CLANG_DIR="$(build_directory_bin ${host} llvm)/../lib/clang"
2253+
2254+
if [[ -d "${HOST_LIB_CLANG_DIR}" ]] && [[ -d "${DEST_LIB_CLANG_DIR}" ]]; then
2255+
DEST_CXX_BUILTINS_VERSION=$(ls "${DEST_LIB_CLANG_DIR}" | awk '{print $0}')
2256+
DEST_BUILTINS_DIR="$(build_directory_bin ${host} llvm)/../lib/clang/$DEST_CXX_BUILTINS_VERSION/lib/darwin"
2257+
2258+
if [[ -d "${DEST_BUILTINS_DIR}" ]]; then
2259+
for HOST_CXX_BUILTINS_PATH in "${HOST_LIB_CLANG_DIR}"/*; do
2260+
HOST_CXX_BUILTINS_DIR="${HOST_CXX_BUILTINS_PATH}/lib/darwin"
2261+
echo "copying compiler-rt embedded builtins from ${HOST_CXX_BUILTINS_DIR} into the local clang build directory ${DEST_BUILTINS_DIR}."
2262+
2263+
for OS in ios watchos tvos; do
2264+
LIB_NAME="libclang_rt.$OS.a"
2265+
HOST_LIB_PATH="$HOST_CXX_BUILTINS_DIR/$LIB_NAME"
2266+
if [[ -f "${HOST_LIB_PATH}" ]]; then
2267+
call cp "${HOST_LIB_PATH}" "${DEST_BUILTINS_DIR}/${LIB_NAME}"
2268+
elif [[ "${VERBOSE_BUILD}" ]]; then
2269+
echo "no file exists at ${HOST_LIB_PATH}"
2270+
fi
22712271
done
2272-
fi
2272+
done
22732273
fi
22742274
fi
22752275
fi

0 commit comments

Comments
 (0)