Skip to content

Commit 4563c3b

Browse files
committed
Dev: add Swift6 support
1 parent 61f8042 commit 4563c3b

File tree

9 files changed

+30
-15
lines changed

9 files changed

+30
-15
lines changed

src/bash/generate-destination-json.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ cat <<JSON > $SELF_DIR/$TARGET.json
1818
"-I$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/$TRIPLE"
1919
],
2020
"extra-swiftc-flags": [
21-
"-Xfrontend", "-experimental-disable-objc-attr",
21+
"-use-ld=lld",
2222
"-resource-dir", "$SWIFT_ANDROID_HOME/toolchain/usr/lib/swift-$SWIFT_ANDROID_ARCH",
2323
"-tools-directory", "$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin",
2424
"-I$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include",

src/bash/swift-build.sh

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,20 @@
55
SELF_DIR=$(dirname $0)
66
SELF_DIR=$SELF_DIR/src/bash
77

8-
xcode_toolchain=$(dirname $(dirname $(dirname $(xcrun --find swift))))
8+
XCODE_TOOLCHAIN=/Library/Developer/Toolchains/swift-6.0.3-RELEASE.xctoolchain
9+
10+
if [ ! -d "$XCODE_TOOLCHAIN" ]; then
11+
echo "Toolchain not found at $XCODE_TOOLCHAIN"
12+
echo "Please install the Swift 6.0.3 toolchain from https://www.swift.org/install/macos"
13+
exit 1
14+
fi
915

1016
export BUILD_ANDROID=1
1117
ANDROID_API_LEVEL="${SWIFT_ANDROID_API_LEVEL:=24}"
1218

1319
export CC="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang"
1420
export CXX="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++"
1521

16-
# swiftc dont know about CC/CXX so tell correct compiler path for him in more brutal way
17-
export PATH="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin:$PATH"
18-
19-
export SWIFT_EXEC=$SWIFT_ANDROID_HOME/toolchain/usr/bin/swiftc
20-
export SWIFT_EXEC_MANIFEST=$xcode_toolchain/usr/bin/swiftc
21-
export SWIFTPM_CUSTOM_LIBS_DIR=$xcode_toolchain/usr/lib/swift/pm
22-
2322
if [ ! -n "${SWIFT_ANDROID_ARCH+defined}" ] || [ "$SWIFT_ANDROID_ARCH" == "aarch64" ]
2423
then
2524
export SWIFT_ANDROID_ARCH=aarch64
@@ -52,9 +51,9 @@ fi
5251
include=-I.build/jniLibs/include
5352
libs=-L.build/jniLibs/$ABI
5453

55-
flags="-Xcc $include -Xswiftc $include -Xswiftc $libs -Xmanifest -DTARGET_ANDROID"
54+
flags="-Xcc $include -Xswiftc $include -Xswiftc $libs -Xbuild-tools-swiftc -DTARGET_ANDROID"
5655

5756
$SELF_DIR/generate-destination-json.sh
58-
$SWIFT_ANDROID_HOME/toolchain/usr/bin/swift-build --destination=$SELF_DIR/$TARGET.json $flags "$@"
57+
$XCODE_TOOLCHAIN/usr/bin/swift-build --destination=$SELF_DIR/$TARGET.json $flags "$@"
5958

6059
exit $?

src/python/run_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
self_dir = os.path.dirname(__file__)
8-
swift_build = os.path.join(self_dir, "swift-build")
8+
swift_build = os.path.join(self_dir, "swift-android-build")
99

1010

1111
def push(dst, name, skip_push_stdlib, skip_push_external, skip_push_resources, device=None):

src/python/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def setup(cls, configuration):
139139
@memoized
140140
def triple(cls):
141141
arch = os.environ.get("SWIFT_ANDROID_ARCH")
142-
level = os.environ.get("SWIFT_ANDROID_API_LEVEL")
142+
level = os.environ.get("SWIFT_ANDROID_API_LEVEL", "24")
143143

144144
if arch == "aarch64" or arch is None:
145145
return "aarch64-unknown-linux-android{}".format(level)

swift-android

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4+
SCRIPT_NAME="swift-android-$1"
5+
6+
if [[ -z "$1" ]]; then
7+
echo "Usage: swift-android <command>"
8+
exit 1
9+
fi
10+
11+
EXECUTABLE="$SCRIPT_DIR/$SCRIPT_NAME"
12+
13+
if [[ -x "$EXECUTABLE" ]]; then
14+
exec "$EXECUTABLE" "${@:2}"
15+
else
16+
echo "Error: Command '$SCRIPT_NAME' not found in '$SCRIPT_DIR' or not executable."
17+
exit 1
18+
fi
File renamed without changes.
File renamed without changes.

swift-install

Lines changed: 0 additions & 1 deletion
This file was deleted.

swift-update-package-resolved

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)