From e0f7a5e9f6d1765c78a8f135059b7233d0caa289 Mon Sep 17 00:00:00 2001 From: Kieran Coldron Date: Wed, 21 Nov 2018 02:17:47 +0000 Subject: [PATCH] Add package: nim Co-Authored-By: Epictek Update packages/nim/build.sh Co-Authored-By: Epictek Update packages/nim/build.sh Co-Authored-By: Epictek Remove duplicated line --- packages/nim/build.sh | 54 ++++++++++++++++++++ packages/nim/installer.ini.patch | 22 ++++++++ packages/nim/osproc.nim.patch | 11 ++++ packages/nim/posix.nim.patch.beforehostbuild | 11 ++++ 4 files changed, 98 insertions(+) create mode 100644 packages/nim/build.sh create mode 100644 packages/nim/installer.ini.patch create mode 100644 packages/nim/osproc.nim.patch create mode 100644 packages/nim/posix.nim.patch.beforehostbuild diff --git a/packages/nim/build.sh b/packages/nim/build.sh new file mode 100644 index 000000000..3f63ddb36 --- /dev/null +++ b/packages/nim/build.sh @@ -0,0 +1,54 @@ +TERMUX_PKG_HOMEPAGE=https://nim-lang.org/ +TERMUX_PKG_DESCRIPTION="Nim programming language compiler" +TERMUX_PKG_VERSION=0.19.0 +TERMUX_PKG_SRCURL=https://nim-lang.org/download/nim-$TERMUX_PKG_VERSION.tar.xz +TERMUX_PKG_SHA256=a1996347253c590de42f6e36e33bd1d5ec7479c0aa013769b92deef802df3c2e +TERMUX_PKG_HOSTBUILD=yes +TERMUX_PKG_BUILD_IN_SRC=yes +TERMUX_PKG_DEPENDS="git, clang, libandroid-glob" + +termux_step_host_build() { + cp ../src/* -r ./ + make -j $TERMUX_MAKE_PROCESSES CC=gcc LD=gcc +} + +termux_step_make() { + if [ $TERMUX_ARCH = "x86_64" ]; then + export NIM_ARCH=amd64 + elif [ $TERMUX_ARCH = "i686" ]; then + export NIM_ARCH=i386 + elif [ $TERMUX_ARCH = "aarch64" ]; then + # -Oz breaks aarch64 build + CFLAGS+=" -Os" + export NIM_ARCH=arm64 + else + export NIM_ARCH=arm + fi + LDFLAGS+=" -landroid-glob" + sed -i "s%\@CC\@%${CC}%g" config/nim.cfg + sed -i "s%\@CFLAGS\@%${CFLAGS}%g" config/nim.cfg + sed -i "s%\@LDFLAGS\@%${LDFLAGS}%g" config/nim.cfg + sed -i "s%\@CPPFLAGS\@%${CPPFLAGS}%g" config/nim.cfg + + find -name "stdlib_osproc.c" | xargs -n 1 sed -i 's',"/system/bin/sh\"\,\ 14","/data/data/com.termux/files/usr/bin/sh\"\,\ 38",'g' + PATH=$TERMUX_PKG_HOSTBUILD_DIR/bin:$PATH + + if [ $NIM_ARCH = "amd64" ]; then + sed -i 's/arm64/amd64/g' makefile + fi + export CFLAGS=" $CPPFLAGS $CFLAGS -w -fno-strict-aliasing" + make LD=$CC uos=linux mycpu=$NIM_ARCH myos=android -j $TERMUX_MAKE_PROCESSES useShPath=$TERMUX_PREFIX/bin/sh + cp config/nim.cfg ../host-build/config + + nim --opt:size --define:termux -d:release --os:android --cpu:$NIM_ARCH -t:-I/data/data/com.termux/files/usr/include -l:"-L/data/data/com.termux/files/usr/lib -landroid-glob" c koch.nim + cd dist/nimble/src + nim --define:termux -d:release --os:android --cpu:$NIM_ARCH -t:-I/data/data/com.termux/files/usr/include -l:"-L/data/data/com.termux/files/usr/lib -landroid-glob" c nimble.nim +} +termux_step_make_install() { + ./install.sh $TERMUX_PREFIX/lib + cp koch $TERMUX_PREFIX/lib/nim/bin + cp dist/nimble/src/nimble $TERMUX_PREFIX/lib/nim/bin + ln -sf $TERMUX_PREFIX/lib/nim/bin/nim $TERMUX_PREFIX/bin/ + ln -sf $TERMUX_PREFIX/lib/nim/bin/koch $TERMUX_PREFIX/bin/ + ln -sf $TERMUX_PREFIX/lib/nim/bin/nimble $TERMUX_PREFIX/bin/ +} diff --git a/packages/nim/installer.ini.patch b/packages/nim/installer.ini.patch new file mode 100644 index 000000000..212917442 --- /dev/null +++ b/packages/nim/installer.ini.patch @@ -0,0 +1,22 @@ +--- ./compiler/installer.a.ini 2018-11-20 22:15:41.349488361 +0000 ++++ ./compiler/installer.ini 2018-11-20 22:14:38.431003964 +0000 +@@ -5,17 +5,8 @@ + Name: "Nim" + Version: "$version" + Platforms: """ +- windows: i386;amd64 +- linux: i386;amd64;powerpc64;arm;sparc;mips;mipsel;mips64;mips64el;powerpc;powerpc64el;arm64;riscv64 +- macosx: i386;amd64;powerpc64 +- solaris: i386;amd64;sparc;sparc64 +- freebsd: i386;amd64 +- netbsd: i386;amd64 +- openbsd: i386;amd64 +- dragonfly: i386;amd64 +- haiku: i386;amd64 +- android: i386;arm;arm64 +- nintendoswitch: arm64 ++ linux: i386;amd64;arm;arm64 ++ android: i386;amd64;arm;arm64 + """ + + Authors: "Andreas Rumpf" diff --git a/packages/nim/osproc.nim.patch b/packages/nim/osproc.nim.patch new file mode 100644 index 000000000..4cae6dada --- /dev/null +++ b/packages/nim/osproc.nim.patch @@ -0,0 +1,11 @@ +--- ./lib/pure/osproc.a.nim 2018-11-20 22:10:39.892888610 +0000 ++++ ./lib/pure/osproc.nim 2018-11-20 22:11:48.031167863 +0000 +@@ -792,7 +792,7 @@ + if poEvalCommand in options: + const useShPath {.strdefine.} = + when not defined(android): "/bin/sh" +- else: "/system/bin/sh" ++ else: "@TERMUX_PREFIX@/bin/sh" + sysCommand = useShPath + sysArgsRaw = @[sysCommand, "-c", command] + assert args.len == 0, "`args` has to be empty when using poEvalCommand." diff --git a/packages/nim/posix.nim.patch.beforehostbuild b/packages/nim/posix.nim.patch.beforehostbuild new file mode 100644 index 000000000..f49c61202 --- /dev/null +++ b/packages/nim/posix.nim.patch.beforehostbuild @@ -0,0 +1,11 @@ +--- ./lib/posix/posix.a.nim 2018-11-20 22:08:36.965187234 +0000 ++++ ./lib/posix/posix.nim 2018-11-20 22:07:25.911639450 +0000 +@@ -92,7 +92,7 @@ + + # Platform specific stuff + +-when defined(linux) and defined(amd64): ++when defined(linux) and defined(amd64) and not defined(android): + include posix_linux_amd64 + elif defined(nintendoswitch): + include posix_nintendoswitch