-
Notifications
You must be signed in to change notification settings - Fork 3
/
swift-define
62 lines (58 loc) · 3.3 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
# Version
SWIFT_VERSION=${SWIFT_VERSION:=swift-5.10.1-RELEASE}
SWIFT_TARGET_ARCH=armv7
SWIFT_TARGET_NAME=armv7-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/downloads/sysroot}"
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}"
# Build Paths
LLVM_SRCDIR=$SRC_ROOT/downloads/llvm-project
LLVM_BUILDDIR=$SRC_ROOT/build/llvm-linux-$SWIFT_TARGET_ARCH
LLVM_INSTALL_PREFIX=$SRC_ROOT/build/llvm-install
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
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
SWIFTPM_DESTINATION_FILE=$SRC_ROOT/build/$SWIFT_TARGET_NAME-toolchain.json
INSTALL_PREFIX=$SRC_ROOT/build/swift-install/usr
INSTALL_TAR=$SRC_ROOT/build/swift-$SWIFT_TARGET_ARCH-$SWIFT_VERSION.tar.gz
PREBUILT_XCTOOLCHAIN=$SRC_ROOT/downloads/${SWIFT_VERSION}-osx.pkg
# Compilation flags
EXTRA_INCLUDE_FLAGS="-I${STAGING_DIR}/usr/include -I${STAGING_DIR}/usr/include/c++/12 -I${STAGING_DIR}/usr/include/arm-linux-gnueabihf/c++/12"
EXTRA_FLAGS="-march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard"
RUNTIME_FLAGS="-w -fuse-ld=lld --sysroot=${STAGING_DIR} -target ${SWIFT_TARGET_NAME} ${EXTRA_FLAGS} -B${STAGING_DIR}/usr/lib -B${STAGING_DIR}/lib -B${STAGING_DIR}/usr/lib/arm-linux-gnueabihf -B${STAGING_DIR}/lib/arm-linux-gnueabihf -B${STAGING_DIR}/usr/lib/gcc/arm-linux-gnueabihf/12"
LINK_FLAGS="--sysroot=${STAGING_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 \
-Xclang-linker -B${STAGING_DIR}/usr/lib \
-Xclang-linker -B${STAGING_DIR}/usr/lib/gcc/arm-linux-gnueabihf/12 \
-Xcc -I${STAGING_DIR}/usr/include \
-Xcc -I${STAGING_DIR}/usr/lib/gcc/arm-linux-gnueabihf/12/include \
-L${STAGING_DIR}/lib \
-L${STAGING_DIR}/usr/lib \
-L${STAGING_DIR}/usr/lib/swift \
-L${STAGING_DIR}/usr/lib/swift/linux \
-L${STAGING_DIR}/usr/lib/gcc/arm-linux-gnueabihf/12 \
-sdk ${STAGING_DIR} \
"