-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·96 lines (87 loc) · 2.67 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
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env bash
set -eu -o pipefail
function find_compatible_gxx_ver(){
min_req=$1
default_gcc_version=$(g++ --version | awk '/g\+\+/{print $NF}')
if [ ${default_gcc_version%%.*} -lt $min_req ]; then
avail_vers=($(compgen -c g++- | grep -oP "(?<=g\+\+-)[0-9]+"))
if [ ${#avail_vers[@]} -gt 0 ]; then
max=${avail_vers[0]}
for ver in ${avail_vers[@]}
do
if [ $ver -gt $max ]; then
max=$ver
fi
done
if [ $max -ge $min_req ]; then
echo "g++-$max"
else
echo "NO VALID G++ VERSION FOUND, MINIMUM REQUIRED: $min_req , MAXIMUM FOUND: $max"
return 1
fi
else
echo "NO G++ VERSIONS FOUND"
return 1
fi
else
echo "g++"
fi
}
function find_compatible_gcc_ver(){
min_req=$1
default_gcc_version=$(gcc --version | awk '/gcc/{print $NF}')
if [ ${default_gcc_version%%.*} -lt $min_req ]; then
avail_vers=($(compgen -c gcc- | grep -oP "(?<=gcc-)[0-9]+"))
if [ ${#avail_vers[@]} -gt 0 ]; then
max=${avail_vers[0]}
for ver in ${avail_vers[@]}
do
if [ $ver -gt $max ]; then
max=$ver
fi
done
if [ $max -ge $min_req ]; then
echo "gcc-$max"
else
echo "NO VALID GCC VERSION FOUND, MINIMUM REQUIRED: $min_req , MAXIMUM FOUND: $max"
return 1
fi
else
echo "NO GCC VERSIONS FOUND"
return 1
fi
else
echo "gcc"
fi
}
if gcc=$(find_compatible_gcc_ver 10)
then
if gxx=$(find_compatible_gxx_ver 10)
then
:
else
echo "$gxx"
exit 1
fi
else
echo "$gcc"
exit 1
fi
if command -v RBuild &> /dev/null
then
RBuild --gcc_override=$gcc --gxx_override=$gxx --file=RBuild.json "$@"
elif command -v ./build/lin/release/bin/RBuild &> /dev/null
then
./build/lin/release/bin/RBuild --gcc_override=$gcc --gxx_override=$gxx --file=RBuild.json "$@"
else
echo Cannot find RBuild in path, using fallback build command
echo Building release...
mkdir -p build/lin/release/bin
if $gxx src/args.cpp src/json.cpp src/main.cpp src/project.cpp src/targets.cpp src/util.cpp src/drivers.cpp src/run.cpp -Iinclude -Werror=return-type -Werror=suggest-override -std=c++20 -fexceptions -O2 -lpthread -s -o build/lin/release/bin/RBuild
then
echo Release build successful
else
echo Release build failed
fi
fi
echo run ./install.sh to add to path or upgrade