-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.sh
executable file
·83 lines (71 loc) · 1.89 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
#!/usr/bin/env bash
# kdevelop build mode
if [ ! -z "${BUILD+x}" ]
then
FAST=1
# no log spam
set -euo pipefail
else
set -euxo pipefail
fi
OPTFLAG="-O -release"
#OPTFLAG=""
JFLAG=""
if [ \! -z ${FAST+x} ]
then
OPTFLAG=""
JFLAG="-j8"
fi
. ./find-llvm-config.sh
FLAGS="$JFLAG -I$($LLVM_CONFIG --includedir) -L-L$($LLVM_CONFIG --libdir)"
TAG=v0.7.1
NEAT=.cache/bootstrap/"$TAG"/neat-"$TAG"-gcc/neat
if [ ! -f "$NEAT" ]
then
echo "Downloading bootstrap compiler $TAG..."
TARGET=.cache/bootstrap/"$TAG"
rm -rf "$TARGET"
mkdir -p "$TARGET"
pushd "$TARGET"
FILE=neat-"$TAG"-gcc.zip
curl -L https://github.com/Neat-Lang/neat/releases/download/"$TAG"/"$FILE" --output "$FILE"
unzip "$FILE"
cd neat-"$TAG"-gcc
echo "Building bootstrap compiler $TAG..."
./build.sh
popd
fi
mkdir -p build
echo "Building stage 1..."
FLAGS="$FLAGS -version=LLVMBackend"
FLAGS="$FLAGS -file-id-output build/fileIdPins"
# see generation.md
NEXT=compiler$(($($NEAT -print-generation) + 1))
$NEAT $FLAGS -backend=c -macro-backend=c -next-generation -P$NEXT:src -j src/main.nt \
-version=firstpass -o build/neat_stage1
cat build/fileIdPins -<<EOF > build/neat.ini
-syspackage compiler:src
-running-compiler-version=$TAG
EOF
rm build/fileIdPins
NEAT=build/neat_stage1
# store compiler source next to compiler
rm -rf build/src
cp -R src build/
echo "Building stage 2..."
FLAGS="$FLAGS -version=LLVMBackend"
# see generation.md
$NEAT $FLAGS -backend=llvm -macro-backend=c -Pcompiler:src -j src/main.nt \
-o build/neat_stage2
NEAT=build/neat_stage2
echo "Building stage 3..."
$NEAT $FLAGS $OPTFLAG -backend=llvm -macro-backend=llvm -Pcompiler:src -j src/main.nt \
-o build/neat_stage3
NEAT=build/neat_stage3
cp -f $NEAT build/neat
rm build/neat_stage*
cat build/fileIdPins -<<EOF > build/neat.ini
-syspackage compiler:src
-running-compiler-version=$TAG
EOF
rm build/fileIdPins