-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathdx.sh
99 lines (82 loc) · 2.22 KB
/
dx.sh
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#! /bin/bash
export SRCFILE=nim-$VERSION.tar.xz
export BINFILE=nim-$VERSION-${OS}_$ARCH.tar
echo "Building Nim $VERSION for $ARCH on $OS"
set -e
# Setup PCRE
wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
tar xvzf pcre-8.43.tar.gz
cd pcre-8.43
./configure --host=`$CC -dumpmachine`
make
cd ..
# Extract and enter source
tar -xJf /io/$SRCFILE
cd nim-$VERSION
# Compile
case $ARCH in
arm64) cpu="aarch64";;
armv6 | armv7) cpu="arm" ;;
*) cpu="$ARCH" ;;
esac
export LD=$CC
cp config/nim.cfg config/nim.cfg~
cp -f build.sh build.sh~
if [[ $CC == *"gcc" ]]; then
export COMPILER="gcc"
elif [[ $CC == *"clang" ]]; then
export COMPILER="clang"
else
echo "Unknown compiler $CC"
exit
fi
echo -d:usePcreHeader >> config/nim.cfg
echo --$COMPILER.exe:\"$CC\" >> config/nim.cfg
echo --$COMPILER.linkerexe:\"$CC\" >> config/nim.cfg
echo --$COMPILER.options.always:\"-w -I/work/pcre-8.43\" >> config/nim.cfg
if [[ "$OS" == "android" ]]; then
cd /work
wget https://raw.githubusercontent.com/termux/termux-packages/master/packages/libandroid-glob/glob.c
wget https://raw.githubusercontent.com/termux/termux-packages/master/packages/libandroid-glob/glob.h
$CC -c -I. glob.c
cd -
sed -i 's/ -lrt//' build.sh
sed -i 's/ -ldl//' build.sh
sed -i 's/ -landroid-glob//' build.sh
mkdir -p /system/bin
ln -sf /bin/sh /system/bin/sh
export LDFLAGS="-static /work/glob.o"
else
export LDFLAGS="-static"
fi
echo --$COMPILER.options.linker:\"/work/pcre-8.43/.libs/libpcre.a $LDFLAGS\" >> config/nim.cfg
./build.sh --cpu $cpu --os $OS
./bin/nim c koch
./koch boot -d:release
cp config/nim.cfg ~/.
if [[ "$OS" == "android" ]]; then
sed -i 's/-static/-ldl -pie/' config/nim.cfg
else
sed -i 's/-static/-ldl/' config/nim.cfg
fi
./koch tools -d:release
# Cleanup
mv -f config/nim.cfg~ config/nim.cfg
mv -f build.sh~ build.sh
find -name *.o | xargs rm -f
find -name nimcache | xargs rm -rf
rm -f compiler/nim0
rm -f compiler/nim1
rm -f compiler/nim
rm -f /io/$BINFILE.xz
# Create XZ
cd ..
tar cf $BINFILE nim-$VERSION
xz -9fc $BINFILE > /io/$BINFILE.xz
# Test binaries
cd nim-$VERSION
mv -f ~/nim.cfg config/.
./bin/nim c koch.nim
#./koch docs
export NIM_EXE_NOT_IN_PATH=NOT_IN_PATH
./koch tests --nim:./bin/nim cat megatest || echo "Failed megatest"