forked from xtremekforever/swift-armv7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswift-define
73 lines (68 loc) · 3.69 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
# Version
SWIFT_VERSION=swift-5.10-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-debian11.xctoolchain}"
XCTOOLCHAIN_SDK="${XCTOOLCHAIN_SDK:=/tmp/cross-toolchain/debian-bullseye.sdk}"
STAGING_DIR="${STAGING_DIR:=$SRC_ROOT/bullseye-armv7}"
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
WORKSPACE_DIR=$SRC_ROOT/workspace
LLVM_SRCDIR=$WORKSPACE_DIR/llvm-project
SWIFT_SRCDIR=$WORKSPACE_DIR/swift
SWIFT_BUILDDIR=$WORKSPACE_DIR/build/swift-linux-$SWIFT_TARGET_ARCH
SWIFT_INSTALL_PREFIX=$WORKSPACE_DIR/build/swift-linux-$SWIFT_TARGET_ARCH-install/
SWIFTPM_DESTINATION_FILE=$WORKSPACE_DIR/build/$SWIFT_TARGET_NAME-toolchain.json
DEPLOYABLE_INSTALLDIR=$WORKSPACE_DIR/build/swift-linux-$SWIFT_TARGET_ARCH-deployable-install/
INSTALL_TAR=$WORKSPACE_DIR/build/swift-$SWIFT_TARGET_ARCH.tar.gz
PREBUILT_XCTOOLCHAIN=$SRC_ROOT/downloads/${SWIFT_VERSION}-osx.pkg
# Compilation flags
EXTRA_INCLUDE_FLAGS="-I${STAGING_DIR}/usr/include"
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/9"
LINK_FLAGS="--sysroot=${STAGING_DIR} -target ${SWIFT_TARGET_NAME} ${EXTRA_FLAGS} -latomic"
ASM_FLAGS="--sysroot=${STAGING_DIR} -target ${SWIFT_TARGET_NAME}"
SWIFT_COMPONENTS="autolink-driver;compiler;clang-resource-dir-symlink;swift-remote-mirror;parser-lib;license;sourcekit-inproc;stdlib;sdk-overlay"
LLVM_COMPONENTS="IndexStore;clang;clang-resource-headers;compiler-rt;clangd;lld;LTO;clang-features-file"
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/9 \
-Xcc -I${STAGING_DIR}/usr/include \
-Xcc -I${STAGING_DIR}/usr/lib/gcc/arm-linux-gnueabihf/9/include \
-L${STAGING_DIR}/lib \
-L${STAGING_DIR}/usr/lib \
-L${STAGING_DIR}/usr/lib/swift/linux \
-L${STAGING_DIR}/usr/lib/gcc/arm-linux-gnueabihf/9 \
-sdk ${STAGING_DIR} \
"
EXTRA_CMAKE_OPTIONS=" \
-DCMAKE_C_FLAGS=\"${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}\" \
-DCMAKE_CXX_FLAGS=\"${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}\" \
-DCMAKE_C_LINK_FLAGS=\"${LINK_FLAGS}\" \
-DCMAKE_CXX_LINK_FLAGS=\"${LINK_FLAGS}\" \
-DCMAKE_ASM_FLAGS=\"${ASM_FLAGS}\" \
-DCMAKE_SYSROOT=\"$STAGING_DIR\" \
-DCMAKE_LINKER=/usr/bin/ld.lld \
-DSWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_PATH=${STAGING_DIR} \
-DSWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_LIBC_INCLUDE_DIRECTORY=${STAGING_DIR}/usr/include \
-DSWIFT_USE_LINKER=lld \
-DLLVM_USE_LINKER=lld \
-DZLIB_LIBRARY=${STAGING_DIR}/usr/lib/arm-linux-gnueabihf/libz.so \
-DZLIB_INCLUDE_DIR=${STAGING_DIR}/usr/include \
-DUUID_LIBRARY=${STAGING_DIR}/usr/lib/arm-linux-gnueabihf/libuuid.so \
-DSWIFT_PATH_TO_CMARK_BUILD=${SRC_ROOT}/downloads/build/Ninja-Release/cmark-linux-armv7 \
-DCMAKE_Swift_FLAGS_DEBUG="" \
-DCMAKE_Swift_FLAGS_RELEASE="" \
-DCMAKE_Swift_FLAGS_RELWITHDEBINFO="" \
"