2017-07-01 02:43:00 +02:00
|
|
|
TERMUX_PKG_HOMEPAGE=https://github.com/ldc-developers/ldc
|
|
|
|
TERMUX_PKG_DESCRIPTION="D programming language compiler, built with LLVM"
|
2019-01-21 13:53:58 +01:00
|
|
|
TERMUX_PKG_LICENSE="BSD 3-Clause"
|
2018-06-13 02:15:26 +02:00
|
|
|
TERMUX_PKG_VERSION=()
|
2018-12-17 08:01:31 +01:00
|
|
|
TERMUX_PKG_VERSION+=(1.13.0)
|
|
|
|
TERMUX_PKG_VERSION+=(7.0.1) # LLVM version
|
|
|
|
TERMUX_PKG_VERSION+=(2.083.1) # TOOLS version
|
|
|
|
TERMUX_PKG_VERSION+=(1.12.1) # DUB version
|
2018-06-13 02:15:26 +02:00
|
|
|
|
|
|
|
TERMUX_PKG_SRCURL=(https://github.com/ldc-developers/ldc/releases/download/v${TERMUX_PKG_VERSION}/ldc-${TERMUX_PKG_VERSION}-src.tar.gz
|
|
|
|
https://github.com/ldc-developers/llvm/releases/download/ldc-v${TERMUX_PKG_VERSION[1]}/llvm-${TERMUX_PKG_VERSION[1]}.src.tar.xz
|
|
|
|
https://github.com/dlang/tools/archive/v${TERMUX_PKG_VERSION[2]}.tar.gz
|
2018-08-20 19:21:27 +02:00
|
|
|
https://github.com/dlang/dub/archive/v${TERMUX_PKG_VERSION[3]}.tar.gz
|
|
|
|
https://github.com/ldc-developers/ldc/releases/download/v${TERMUX_PKG_VERSION}/ldc2-${TERMUX_PKG_VERSION}-linux-x86_64.tar.xz)
|
2018-12-17 08:01:31 +01:00
|
|
|
TERMUX_PKG_SHA256=(4b2fd3eb90fb6debc0ae6d70406bc78fcb531a0f20806640e626d4822e87b2e0
|
|
|
|
5b01afd896b534f4d6a0ff0073d9f1b09625b37b0a752259a1caf857c56c0fc3
|
|
|
|
78d90dcda6b82d3eda69c30fa2308a8c8f1a3bce574d637806ca1af3c7f65888
|
|
|
|
bd17cf67784f2ea0a2e0298761c662c80fddf6700c065f6689eb353e2144c987
|
|
|
|
3692974b6dc6c81280c0321371b400101006f28bafb890f089b1d357dadbcbf1)
|
2017-07-01 02:43:00 +02:00
|
|
|
TERMUX_PKG_DEPENDS="clang"
|
|
|
|
TERMUX_PKG_HOSTBUILD=true
|
|
|
|
TERMUX_PKG_FORCE_CMAKE=yes
|
|
|
|
#These CMake args are only used to configure a patched LLVM
|
|
|
|
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
|
|
|
|
-DLLVM_ENABLE_PIC=ON
|
|
|
|
-DLLVM_BUILD_TOOLS=OFF
|
|
|
|
-DLLVM_BUILD_UTILS=OFF
|
2017-09-13 15:44:02 +02:00
|
|
|
-DLLVM_TABLEGEN=$TERMUX_PKG_HOSTBUILD_DIR/bin/llvm-tblgen
|
2018-10-14 23:12:36 +02:00
|
|
|
-DPYTHON_EXECUTABLE=`which python3`
|
2017-09-13 15:44:02 +02:00
|
|
|
"
|
2017-07-01 02:43:00 +02:00
|
|
|
TERMUX_PKG_KEEP_STATIC_LIBRARIES=true
|
|
|
|
TERMUX_PKG_NO_DEVELSPLIT=yes
|
|
|
|
TERMUX_PKG_MAINTAINER="Joakim @joakim-noah"
|
|
|
|
|
2019-02-08 10:37:29 +01:00
|
|
|
termux_step_post_extract_package() {
|
2018-06-13 02:15:26 +02:00
|
|
|
mv llvm-${TERMUX_PKG_VERSION[1]}.src llvm
|
|
|
|
mv tools-${TERMUX_PKG_VERSION[2]} rdmd
|
|
|
|
mv dub-${TERMUX_PKG_VERSION[3]} dub
|
2017-07-01 02:43:00 +02:00
|
|
|
|
2018-10-14 17:45:41 +02:00
|
|
|
export LLVM_TRIPLE=${TERMUX_HOST_PLATFORM/-/--}
|
2018-08-20 19:21:27 +02:00
|
|
|
if [ $TERMUX_ARCH = arm ]; then LLVM_TRIPLE=${LLVM_TRIPLE/arm-/armv7a-}; fi
|
2017-10-31 19:10:15 +01:00
|
|
|
sed $TERMUX_PKG_BUILDER_DIR/llvm-config.in \
|
2018-06-13 02:15:26 +02:00
|
|
|
-e "s|@LLVM_VERSION@|${TERMUX_PKG_VERSION[1]}|g" \
|
2017-10-31 19:10:15 +01:00
|
|
|
-e "s|@LLVM_BUILD_DIR@|$TERMUX_PKG_BUILDDIR/llvm|g" \
|
|
|
|
-e "s|@TERMUX_PKG_SRCDIR@|$TERMUX_PKG_SRCDIR|g" \
|
2018-08-20 19:21:27 +02:00
|
|
|
-e "s|@LLVM_DEFAULT_TARGET_TRIPLE@|$LLVM_TRIPLE|g" \
|
|
|
|
-e "s|@LLVM_TARGETS@|ARM AArch64 X86|g" > $TERMUX_PKG_BUILDDIR/llvm-config
|
2017-10-31 19:10:15 +01:00
|
|
|
chmod 755 $TERMUX_PKG_BUILDDIR/llvm-config
|
2017-07-01 02:43:00 +02:00
|
|
|
}
|
|
|
|
|
2019-02-08 10:37:29 +01:00
|
|
|
termux_step_host_build() {
|
2017-07-01 02:43:00 +02:00
|
|
|
termux_setup_cmake
|
2017-10-31 19:10:15 +01:00
|
|
|
termux_setup_ninja
|
|
|
|
cmake -GNinja $TERMUX_PKG_SRCDIR/llvm \
|
2017-07-01 02:43:00 +02:00
|
|
|
-DLLVM_BUILD_TOOLS=OFF \
|
2018-04-30 11:47:35 +02:00
|
|
|
-DLLVM_BUILD_UTILS=OFF \
|
|
|
|
-DCOMPILER_RT_INCLUDE_TESTS=OFF
|
2018-03-05 15:00:00 +01:00
|
|
|
ninja -j $TERMUX_MAKE_PROCESSES llvm-tblgen
|
2017-07-01 02:43:00 +02:00
|
|
|
}
|
|
|
|
|
2019-02-08 10:37:29 +01:00
|
|
|
termux_step_pre_configure() {
|
2018-08-20 19:21:27 +02:00
|
|
|
local LLVM_TARGET_ARCH
|
|
|
|
if [ $TERMUX_ARCH = "arm" ]; then
|
|
|
|
LLVM_TARGET_ARCH=ARM
|
|
|
|
elif [ $TERMUX_ARCH = "aarch64" ]; then
|
|
|
|
LLVM_TARGET_ARCH=AArch64
|
|
|
|
elif [ $TERMUX_ARCH = "i686" ]; then
|
|
|
|
LLVM_TARGET_ARCH=X86
|
|
|
|
elif [ $TERMUX_ARCH = "x86_64" ]; then
|
|
|
|
LLVM_TARGET_ARCH=X86
|
|
|
|
else
|
|
|
|
termux_error_exit "Invalid arch: $TERMUX_ARCH"
|
|
|
|
fi
|
|
|
|
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DLLVM_DEFAULT_TARGET_TRIPLE=${LLVM_TRIPLE}"
|
|
|
|
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DLLVM_TARGET_ARCH=${LLVM_TARGET_ARCH} -DLLVM_TARGETS_TO_BUILD=AArch64;ARM;X86"
|
2017-07-01 02:43:00 +02:00
|
|
|
|
|
|
|
# CPPFLAGS adds the system llvm to the include path, which causes
|
|
|
|
# conflicts with the local patched llvm when compiling ldc
|
|
|
|
CPPFLAGS=""
|
|
|
|
|
|
|
|
OLD_TERMUX_PKG_SRCDIR=$TERMUX_PKG_SRCDIR
|
|
|
|
TERMUX_PKG_SRCDIR=$TERMUX_PKG_SRCDIR/llvm
|
|
|
|
|
|
|
|
OLD_TERMUX_PKG_BUILDDIR=$TERMUX_PKG_BUILDDIR
|
|
|
|
TERMUX_PKG_BUILDDIR=$TERMUX_PKG_BUILDDIR/llvm
|
|
|
|
mkdir "$TERMUX_PKG_BUILDDIR"
|
|
|
|
}
|
|
|
|
|
2019-02-08 10:37:29 +01:00
|
|
|
termux_step_post_configure() {
|
2017-07-01 02:43:00 +02:00
|
|
|
TERMUX_PKG_SRCDIR=$OLD_TERMUX_PKG_SRCDIR
|
|
|
|
TERMUX_PKG_BUILDDIR=$OLD_TERMUX_PKG_BUILDDIR
|
|
|
|
cd "$TERMUX_PKG_BUILDDIR"
|
|
|
|
|
2017-10-31 19:10:15 +01:00
|
|
|
mv llvm-config llvm/bin
|
2018-08-20 19:21:27 +02:00
|
|
|
|
|
|
|
export LDC_FLAGS="-mtriple=$LLVM_TRIPLE"
|
|
|
|
if [ $TERMUX_ARCH = arm ]; then LDC_FLAGS="$LDC_FLAGS;-mcpu=cortex-a8"; fi
|
|
|
|
|
|
|
|
export LDC_PATH=$TERMUX_PKG_SRCDIR/ldc2-$TERMUX_PKG_VERSION-linux-x86_64
|
|
|
|
|
|
|
|
# Couldn't use -DD_COMPILER_FLAGS_ENV_INIT=\"${LDC_FLAGS//;/ }\"" because of the space
|
|
|
|
TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" -DD_FLAGS=$LDC_FLAGS \
|
|
|
|
-DLLVM_CONFIG=$TERMUX_PKG_BUILDDIR/llvm/bin/llvm-config \
|
|
|
|
-DD_COMPILER=$LDC_PATH/bin/ldmd2"
|
|
|
|
|
2017-07-01 02:43:00 +02:00
|
|
|
termux_step_configure_cmake
|
|
|
|
}
|
|
|
|
|
2019-02-08 10:37:29 +01:00
|
|
|
termux_step_make() {
|
2018-08-20 19:21:27 +02:00
|
|
|
$LDC_PATH/bin/ldc-build-runtime --ninja -j $TERMUX_MAKE_PROCESSES \
|
|
|
|
--dFlags="$LDC_FLAGS" --cFlags="$CFLAGS -I$TERMUX_PREFIX/include" \
|
|
|
|
--targetSystem="Android;Linux;UNIX" --ldcSrcDir="$TERMUX_PKG_SRCDIR"
|
|
|
|
|
2017-07-01 02:43:00 +02:00
|
|
|
cd llvm
|
2018-08-20 19:21:27 +02:00
|
|
|
if test -f build.ninja; then
|
|
|
|
ninja -j $TERMUX_MAKE_PROCESSES
|
2017-07-01 02:43:00 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
cd ..
|
2018-08-20 19:21:27 +02:00
|
|
|
export DFLAGS="${LDC_FLAGS//;/ }"
|
|
|
|
|
|
|
|
if test -f build.ninja; then
|
|
|
|
ninja -j $TERMUX_MAKE_PROCESSES ldc2 ldmd2 ldc-build-runtime
|
2017-07-01 02:43:00 +02:00
|
|
|
fi
|
2017-09-06 21:16:04 +02:00
|
|
|
|
|
|
|
# Build the rdmd scripting wrapper and the dub package manager
|
2018-08-20 19:21:27 +02:00
|
|
|
DMD=$LDC_PATH/bin/ldmd2
|
|
|
|
D_FLAGS="-w -de -O"
|
|
|
|
D_LDFLAGS="-fuse-ld=bfd -L$TERMUX_PKG_BUILDDIR/ldc-build-runtime.tmp/lib -lphobos2-ldc -ldruntime-ldc -Wl,--gc-sections -ldl -lm -fPIE -pie -Wl,-z,nocopyreloc ${LDFLAGS}"
|
|
|
|
if [ $TERMUX_ARCH = arm ]; then D_LDFLAGS="$D_LDFLAGS -Wl,--fix-cortex-a8"; fi
|
|
|
|
|
2017-09-06 21:16:04 +02:00
|
|
|
$DMD $D_FLAGS -c $TERMUX_PKG_SRCDIR/rdmd/rdmd.d -of=$TERMUX_PKG_BUILDDIR/bin/rdmd.o
|
|
|
|
$CC $TERMUX_PKG_BUILDDIR/bin/rdmd.o $D_LDFLAGS -o $TERMUX_PKG_BUILDDIR/bin/rdmd
|
|
|
|
|
|
|
|
cd $TERMUX_PKG_SRCDIR/dub
|
|
|
|
$DMD $D_FLAGS -version=DubUseCurl -Isource -c @build-files.txt -of=$TERMUX_PKG_BUILDDIR/bin/dub.o
|
|
|
|
$CC $TERMUX_PKG_BUILDDIR/bin/dub.o $D_LDFLAGS -o $TERMUX_PKG_BUILDDIR/bin/dub
|
2017-07-01 02:43:00 +02:00
|
|
|
}
|
|
|
|
|
2019-02-08 10:37:29 +01:00
|
|
|
termux_step_make_install() {
|
2017-09-13 09:26:46 +02:00
|
|
|
cp bin/{dub,ldc-build-runtime,ldc2,ldmd2,rdmd} $TERMUX_PREFIX/bin
|
2018-08-20 19:21:27 +02:00
|
|
|
cp $TERMUX_PKG_BUILDDIR/ldc-build-runtime.tmp/lib/lib{druntime,phobos2}*.a $TERMUX_PREFIX/lib
|
2017-07-01 02:43:00 +02:00
|
|
|
sed -i "/runtime\/druntime\/src/d" bin/ldc2.conf
|
2018-01-06 14:39:35 +01:00
|
|
|
sed -i "/runtime\/jit-rt\/d/d" bin/ldc2.conf
|
2017-07-01 02:43:00 +02:00
|
|
|
sed -i "s|$TERMUX_PKG_SRCDIR/runtime/phobos|%%ldcbinarypath%%/../include/d|" bin/ldc2.conf
|
|
|
|
sed "s|$TERMUX_PKG_BUILDDIR/lib|%%ldcbinarypath%%/../lib|" bin/ldc2.conf > $TERMUX_PREFIX/etc/ldc2.conf
|
|
|
|
|
|
|
|
rm -Rf $TERMUX_PREFIX/include/d
|
|
|
|
mkdir $TERMUX_PREFIX/include/d
|
|
|
|
cp -r $TERMUX_PKG_SRCDIR/runtime/druntime/src/{core,etc,ldc,object.d} $TERMUX_PREFIX/include/d
|
2018-08-20 19:21:27 +02:00
|
|
|
cp $LDC_PATH/import/ldc/gccbuiltins_{aarch64,arm,x86}.di $TERMUX_PREFIX/include/d/ldc
|
2017-07-01 02:43:00 +02:00
|
|
|
cp -r $TERMUX_PKG_SRCDIR/runtime/phobos/etc/c $TERMUX_PREFIX/include/d/etc
|
|
|
|
rm -Rf $TERMUX_PREFIX/include/d/etc/c/zlib
|
|
|
|
cp -r $TERMUX_PKG_SRCDIR/runtime/phobos/std $TERMUX_PREFIX/include/d
|
|
|
|
|
|
|
|
rm -Rf $TERMUX_PREFIX/share/ldc
|
|
|
|
mkdir $TERMUX_PREFIX/share/ldc
|
2018-12-17 08:01:31 +01:00
|
|
|
cp -r $TERMUX_PKG_SRCDIR/{LICENSE,README,packaging/bash_completion.d} $TERMUX_PREFIX/share/ldc
|
2017-07-01 02:43:00 +02:00
|
|
|
}
|