Skip to content

Commit bf90727

Browse files
committed
android: start adding a stub target in the build script; doesn't work at all yet
1 parent e8a15c6 commit bf90727

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

lib/Basic/Platform.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) {
5858
return "watchos";
5959
}
6060

61+
if (triple.isAndroid()) {
62+
return "android";
63+
}
64+
6165
if (triple.isMacOSX())
6266
return "macosx";
6367

utils/build-script-impl

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ KNOWN_SETTINGS=(
172172
swift-enable-ast-verifier "1" "If enabled, and the assertions are enabled, the built Swift compiler will run the AST verifier every time it is invoked"
173173
swift-enable-target-linux "1" "Enable compiler support for targeting Linux"
174174
swift-enable-target-freebsd "1" "Enable compiler support for targeting FreeBSD"
175+
swift-enable-target-android "1" "Enable compiler support for targeting Android"
175176
swift-runtime-enable-dtrace "0" "Enable runtime dtrace support"
176177
swift-runtime-enable-leak-checker "0" "Enable leaks checking routines in the runtime"
177178
use-gold-linker "" "Enable using the gold linker"
@@ -404,6 +405,39 @@ function set_deployment_target_based_options() {
404405
)
405406
fi
406407

408+
;;
409+
android-*)
410+
case ${deployment_target} in
411+
android-armv7)
412+
llvm_host_triple="arm-linux-androideabi"
413+
llvm_target_arch="ARM"
414+
cmark_cmake_options=(
415+
-DCMAKE_C_FLAGS="$(cmark_c_flags $deployment_target)"
416+
-DCMAKE_CXX_FLAGS="$(cmark_c_flags $deployment_target)"
417+
-DCMAKE_SYSROOT:PATH="FIXME THE SYSROOT"
418+
)
419+
swift_cmake_options=(
420+
-DSWIFT_HOST_VARIANT_ARCH="armv7"
421+
)
422+
;;
423+
*)
424+
echo "Unknown deployment target"
425+
exit 1
426+
;;
427+
esac
428+
native_llvm_build=$(build_directory linux-x86_64 llvm)
429+
llvm_cmake_options=(
430+
-DCMAKE_OSX_SYSROOT:PATH="FIXME THE SYSROOT"
431+
-DLLVM_HOST_TRIPLE:STRING="${llvm_host_triple}"
432+
)
433+
434+
if [[ "${llvm_target_arch}" ]] ; then
435+
llvm_cmake_options=(
436+
"${llvm_cmake_options[@]}"
437+
-DLLVM_TARGET_ARCH="${llvm_target_arch}"
438+
)
439+
fi
440+
407441
;;
408442
*)
409443
echo "Unknown compiler deployment target: $deployment_target"
@@ -771,7 +805,8 @@ for t in ${CROSS_COMPILE_TOOLS_DEPLOYMENT_TARGETS} ; do
771805
iphonesimulator-i386 | iphonesimulator-x86_64 | \
772806
iphoneos-arm64 | iphoneos-armv7 | \
773807
appletvos-arm64 | appletvsimulator-x86_64 | \
774-
watchos-armv7k | watchsimulator-i386)
808+
watchos-armv7k | watchsimulator-i386 | \
809+
android-armv7 )
775810
CROSS_TOOLS_DEPLOYMENT_TARGETS=(
776811
"${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
777812
"${t}"
@@ -810,6 +845,7 @@ case "$(uname -s)" in
810845
Linux)
811846
STDLIB_DEPLOYMENT_TARGETS=(
812847
"linux-x86_64"
848+
"android-armv7"
813849
)
814850
;;
815851

@@ -954,6 +990,10 @@ for deployment_target in "${STDLIB_DEPLOYMENT_TARGETS[@]}"; do
954990
build_for_this_target=$(not $SKIP_BUILD_WATCHOS_SIMULATOR)
955991
test_this_target=$(not $SKIP_TEST_WATCHOS_SIMULATOR)
956992
;;
993+
android-*)
994+
build_for_this_target=1
995+
test_this_target=1
996+
;;
957997
*)
958998
echo "Unknown compiler deployment target: $deployment_target"
959999
exit 1
@@ -1184,6 +1224,9 @@ function common_cross_c_flags() {
11841224
watchos-armv7k)
11851225
echo "-arch armv7k -mwatchos-version-min=${DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
11861226
;;
1227+
android-armv7)
1228+
echo "-arch armv7"
1229+
;;
11871230
esac
11881231
}
11891232

@@ -1844,7 +1887,7 @@ for deployment_target in "${STDLIB_DEPLOYMENT_TARGETS[@]}"; do
18441887
linux-* | freebsd-* | macosx-*)
18451888
# OK, we can run tests directly.
18461889
;;
1847-
iphoneos-* | iphonesimulator-* | appletvos-* | appletvsimulator-* | watchos-* | watchsimulator-*)
1890+
iphoneos-* | iphonesimulator-* | appletvos-* | appletvsimulator-* | watchos-* | watchsimulator-* | android-* )
18481891
# FIXME: remove this
18491892
# echo "Don't know how to run tests for $deployment_target"
18501893
continue

0 commit comments

Comments
 (0)