Skip to content

Commit 24d191d

Browse files
committed
[build] Verify a host is supported when setting build options
By verifying that the host is supported before doing any operations, we can assume that the host value is properly formed, meaning we can simplify the logic to set values based on the host. Follow-up commits will do exactly that.
1 parent 22a0445 commit 24d191d

File tree

1 file changed

+36
-8
lines changed

1 file changed

+36
-8
lines changed

utils/build-script-impl

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,40 @@ function should_execute_host_actions_for_phase() {
397397
fi
398398
}
399399

400+
function verify_host_is_supported() {
401+
local host="$1"
402+
case ${host} in
403+
freebsd-x86_64 \
404+
| cygwin-x86_64 \
405+
| haiku-x86_64 \
406+
| linux-x86_64 \
407+
| linux-i686 \
408+
| linux-armv6 \
409+
| linux-armv7 \
410+
| linux-aarch64 \
411+
| linux-powerpc64 \
412+
| linux-powerpc64le \
413+
| linux-s390x \
414+
| macosx-x86_64 \
415+
| iphonesimulator-i386 \
416+
| iphonesimulator-x86_64 \
417+
| iphoneos-armv7 \
418+
| iphoneos-armv7s \
419+
| iphoneos-arm64 \
420+
| appletvsimulator-x86_64 \
421+
| appletvos-arm64 \
422+
| watchsimulator-i386 \
423+
| watchos-armv7k \
424+
| android-armv7 \
425+
| android-aarch64)
426+
;;
427+
*)
428+
echo "Unknown host tools target: ${host}"
429+
exit 1
430+
;;
431+
esac
432+
}
433+
400434
function set_build_options_for_host() {
401435
llvm_cmake_options=()
402436
swift_cmake_options=()
@@ -411,6 +445,8 @@ function set_build_options_for_host() {
411445
# Hosts which can be cross-compiled must specify:
412446
# SWIFT_HOST_TRIPLE and llvm_target_arch (as well as usual HOST_VARIANT flags)
413447

448+
verify_host_is_supported $host
449+
414450
case ${host} in
415451
freebsd-x86_64)
416452
SWIFT_HOST_VARIANT="freebsd"
@@ -555,10 +591,6 @@ function set_build_options_for_host() {
555591
SWIFT_HOST_VARIANT_ARCH="armv7k"
556592
cmake_osx_deployment_target=""
557593
;;
558-
*)
559-
echo "Unknown host for swift tools: ${host}"
560-
exit 1
561-
;;
562594
esac
563595

564596
if [[ "${DARWIN_SDK_DEPLOYMENT_TARGETS}" != "" ]]; then
@@ -638,10 +670,6 @@ function set_build_options_for_host() {
638670
;;
639671
esac
640672
;;
641-
*)
642-
echo "Unknown host tools target: ${host}"
643-
exit 1
644-
;;
645673
esac
646674

647675

0 commit comments

Comments
 (0)