-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.sh
executable file
·86 lines (71 loc) · 2.12 KB
/
build.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
#!/bin/sh
set -e
cd "$(dirname "$0")"
if [ -e nimenv.local ]; then
echo 'nimenv.local exists. You may use `nimenv build` instead of this script.'
#exit 1
fi
mkdir -p .nimenv/nim
mkdir -p .nimenv/deps
NIMHASH=905df2316262aa2cbacae067acf45fc05c2a71c8c6fde1f2a70c927ebafcfe8a
if ! [ -e .nimenv/nimhash -a \( "$(cat .nimenv/nimhash)" = "$NIMHASH" \) ]; then
echo "Downloading Nim http://nim-lang.org/download/nim-0.15.2.tar.xz (sha256: $NIMHASH)"
wget http://nim-lang.org/download/nim-0.15.2.tar.xz -O .nimenv/nim.tar.xz
if ! [ "$(sha256sum < .nimenv/nim.tar.xz)" = "$NIMHASH -" ]; then
echo "verification failed"
exit 1
fi
echo "Unpacking Nim..."
rm -r .nimenv/nim
mkdir -p .nimenv/nim
cd .nimenv/nim
tar xJf ../nim.tar.xz
mv nim-*/* .
echo "Building Nim..."
make -j$(getconf _NPROCESSORS_ONLN)
cd ../..
echo $NIMHASH > .nimenv/nimhash
fi
get_dep() {
set -e
cd .nimenv/deps
name="$1"
url="$2"
hash="$3"
srcpath="$4"
new=0
if ! [ -e "$name" ]; then
git clone --recursive "$url" "$name"
new=1
fi
if ! [ "$(cd "$name" && git rev-parse HEAD)" = "$hash" -a $new -eq 0 ]; then
cd "$name"
git fetch --all
git checkout -q "$hash"
git submodule update --init
cd ..
fi
cd ../..
echo "path: \".nimenv/deps/$name$srcpath\"" >> nim.cfg
}
echo "path: \".\"" > nim.cfg
get_dep collections https://github.com/zielmicha/collections.nim ab4ad35f0cab08e01a16cd54a0c16938a18ba10a ''
get_dep reactor https://github.com/zielmicha/reactor.nim b1875cd2c41f0c284e1e954350a4400a59a606db ''
echo 'debugger: "native"
# reactor.nim required pthreads
threads: "on"
verbosity: "0"
hint[Processing]: "off"
@if release:
gcc.options.always = "-w -fno-strict-overflow"
gcc.cpp.options.always = "-w -fno-strict-overflow"
clang.options.always = "-w -fno-strict-overflow"
clang.cpp.options.always = "-w -fno-strict-overflow"
passC:"-ffunction-sections -fdata-sections -flto -fPIE -fstack-protector-strong -D_FORTIFY_SOURCE=2"
passL:"-Wl,--gc-sections -flto -fPIE"
obj_checks: on
field_checks: on
bound_checks: on
@end' >> nim.cfg
mkdir -p bin
ln -sf ../.nimenv/nim/bin/nim bin/nim