-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathswift-define
75 lines (70 loc) · 3.55 KB
/
swift-define
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Version
SWIFT_VERSION=${SWIFT_VERSION:=swift-6.0.3-RELEASE}
SWIFT_TARGET_ARCH=${SWIFT_TARGET_ARCH:=armv7}
case ${SWIFT_TARGET_ARCH} in
armv6)
# The only version of armv6 supported is the RPI ARM1176JZF-S, which is only supported by Raspbian
# If you attempt to build for armv6 with a Ubuntu or Debian sysroot, binaries will fail to run!!!
EXTRA_FLAGS="-march=armv6z -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard"
;;
armv7)
EXTRA_FLAGS="-march=armv7-a -mfpu=neon -mfloat-abi=hard"
;;
*)
echo "Unsupported architecture $SWIFT_TARGET_ARCH!"
exit -1
;;
esac
SWIFT_TARGET_NAME=${SWIFT_TARGET_ARCH}-unknown-linux-gnueabihf
# Configurable
SRC_ROOT="${SRC_ROOT:=$(pwd)}"
XCTOOLCHAIN="${XCTOOLCHAIN:=$SRC_ROOT/build/$SWIFT_VERSION-armv7-debian12.xctoolchain}"
XCTOOLCHAIN_SDK="${XCTOOLCHAIN_SDK:=/tmp/cross-toolchain/debian-bookworm.sdk}"
STAGING_DIR="${STAGING_DIR:=$SRC_ROOT/sysroot-debian-bookworm}"
if [[ $OSTYPE == 'darwin'* ]]; then
SWIFT_NATIVE_PATH="${SWIFT_NATIVE_PATH:=$XCTOOLCHAIN/usr/bin}"
else
SWIFT_NATIVE_PATH="${SWIFT_NATIVE_PATH:=/usr/bin}"
fi
SWIFT_BUILD_CONFIGURATION="${SWIFT_BUILD_CONFIGURATION:=Release}"
SWIFTPM_CONFIGURATION="${SWIFTPM_CONFIGURATION:=release}"
SWIFT_PACKAGE_SRCDIR="${SWIFT_PACKAGE_SRCDIR:=$SRC_ROOT/swift-hello}"
SWIFT_PACKAGE_BUILDDIR="${SWIFT_PACKAGE_BUILDDIR:=$SWIFT_PACKAGE_SRCDIR/.build}"
if [ -d ${STAGING_DIR} ]; then
GCC_INSTALL_DIR=$(dirname $(find ${STAGING_DIR} -name crtbegin.o))
else
GCC_INSTALL_DIR=${STAGING_DIR}
fi
# Build Paths
LLVM_SRCDIR=$SRC_ROOT/downloads/llvm-project
LLVM_BUILDDIR=$SRC_ROOT/build/llvm-linux-$SWIFT_TARGET_ARCH
SWIFT_SRCDIR=$SRC_ROOT/downloads/swift
SWIFT_BUILDDIR=$SRC_ROOT/build/swift-linux-$SWIFT_TARGET_ARCH
SWIFT_INSTALL_PREFIX=$SRC_ROOT/build/swift-linux-$SWIFT_TARGET_ARCH-install
SYNTAX_SRCDIR=$SRC_ROOT/downloads/swift-syntax
STRING_PROCESSING_SRCDIR=$SRC_ROOT/downloads/swift-experimental-string-processing
LIBDISPATCH_SRCDIR=$SRC_ROOT/downloads/swift-corelibs-libdispatch
LIBDISPATCH_BUILDDIR=$SRC_ROOT/build/libdispatch-linux-$SWIFT_TARGET_ARCH
LIBDISPATCH_INSTALL_PREFIX=$SRC_ROOT/build/libdispatch-linux-$SWIFT_TARGET_ARCH-install
FOUNDATION_SRCDIR=$SRC_ROOT/downloads/swift-corelibs-foundation
FOUNDATION_BUILDDIR=$SRC_ROOT/build/foundation-linux-$SWIFT_TARGET_ARCH
FOUNDATION_INSTALL_PREFIX=$SRC_ROOT/build/foundation-linux-$SWIFT_TARGET_ARCH-install
XCTEST_SRCDIR=$SRC_ROOT/downloads/swift-corelibs-xctest
XCTEST_BUILDDIR=$SRC_ROOT/build/xctest-linux-$SWIFT_TARGET_ARCH
XCTEST_INSTALL_PREFIX=$SRC_ROOT/build/xctest-linux-$SWIFT_TARGET_ARCH-install
SWIFT_TESTING_SRCDIR=$SRC_ROOT/downloads/swift-testing
SWIFT_TESTING_BUILDDIR=$SRC_ROOT/build/swift-testing-linux-$SWIFT_TARGET_ARCH
SWIFT_TESTING_INSTALL_PREFIX=$SRC_ROOT/build/swift-testing-linux-$SWIFT_TARGET_ARCH-install
SWIFTPM_DESTINATION_FILE=$SRC_ROOT/build/$SWIFT_TARGET_NAME-toolchain.json
INSTALL_PREFIX=$SRC_ROOT/build/swift-install/usr
INSTALL_TAR=${INSTALL_TAR:=$SRC_ROOT/build/swift-$SWIFT_TARGET_ARCH-$SWIFT_VERSION.tar.gz}
PREBUILT_XCTOOLCHAIN=$SRC_ROOT/downloads/${SWIFT_VERSION}-osx.pkg
# Compilation flags
RUNTIME_FLAGS="-w -fuse-ld=lld --sysroot=${STAGING_DIR} --gcc-install-dir=${GCC_INSTALL_DIR} -target ${SWIFT_TARGET_NAME} ${EXTRA_FLAGS}"
LINK_FLAGS="--sysroot=${STAGING_DIR} --gcc-install-dir=${GCC_INSTALL_DIR} -target ${SWIFT_TARGET_NAME} ${EXTRA_FLAGS} -latomic"
ASM_FLAGS="--sysroot=${STAGING_DIR} -target ${SWIFT_TARGET_NAME}"
SWIFTC_FLAGS="-target ${SWIFT_TARGET_NAME} \
-use-ld=lld \
-resource-dir ${STAGING_DIR}/usr/lib/swift \
-sdk ${STAGING_DIR} \
"