forked from EarthOS-SMC/EarthOS_kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·63 lines (62 loc) · 1.1 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
#!/bin/bash
reduce=`cat reduce`
if [[ "$2" == '' ]]; then
compiler="./compiler"
else
compiler="$2"
fi
auto="$3"
cd "$(dirname $BASH_SOURCE)"
if ! [ -d "$compiler" ]; then
echo "Error: PowerSlash compiler not found. Did you run sync.sh?"
exit 1
fi
cd "$compiler"
if ! [ -f "compile.sh" ]; then
echo "Error: Couldn't find compiler script."
exit 2
fi
if [ -f "include" ]; then
"Error: 'include' file exists, it should be a directory."
exit 4
fi
if [ -d "include" ]; then
rm -rf include
fi
ln -s .. include
chmod +x compile.sh
if [[ "$1" == '' ]]; then
name=main
ext=pwsl
else
n="$1"
name1=""
name2=""
i=0
while (( i < ${#n} )); do
i=$((i+1))
if [[ "${n:$((i-1)):1}" == "." ]]; then
name1="$name2"
name2=""
else
name2="${name2}${n:$((i-1)):1}"
fi
done
if [[ "$name1" == "" ]]; then
name1="$name2"
name2=""
fi
name="$name1"
ext="$name2"
fi
if ! [ -f "../${name}.$ext" ]; then
echo "Error: ${name}.${ext}: No such file."
exit 3
fi
echo "Compiling ${name}.$ext"
./compile.sh "../${name}.$ext" "$reduce" "" "$auto"
sv=$?
if (( $sv != 0 )); then
exit $sv
fi
mv ./output/${name}.smc ../image