-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-examples.sh
44 lines (36 loc) · 1.33 KB
/
build-examples.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
#!/bin/bash
function printLine {
num=$(( 100-${#1} ))
echo -n "$1"
v=$(printf "%0*s\r" "${num}" " ")
echo -n "${v// / }"
}
mkdir -p build
rm -r build/*
declare -i fileID=0
for inputFile in $(find ./src -type f \( -iname "*.c" \))
do
printLine "Running: C Pre-Processor : $inputFile -> ./build/$fileID.i"
if [[ "$1" == "enabled" ]]; then
./src/objectSystem/customPreProcessor.sh $inputFile ./build/$fileID.i
else
gcc -E $inputFile > ./build/$fileID.i
fi
printLine "Running: GCC Compiler : ./build/$fileID.i -> ./build/$fileID.o"
gcc -Wpointer-arith -Wall -g -c ./build/$fileID.i -o ./build/$fileID.o
fileID=$(( fileID+1 ))
done
fileID=$(( fileID+1 ))
for inputFile in $(find ./examples -type f \( -iname "*.c" \))
do
printLine "Running: C Pre-Processor : $inputFile -> ./build/$fileID.i"
if [[ "$1" == "enabled" ]]; then
./src/objectSystem/customPreProcessor.sh $inputFile ./build/$fileID.i
else
gcc -E $inputFile > ./build/$fileID.i
fi
printLine "Running: GCC Compiler : ./build/$fileID.i -> ./build/$fileID.o"
gcc -Wpointer-arith -Wall -c ./build/$fileID.i -o ./build/$fileID.o
printLine "Running: GCC Linker : ./build/*.o -> ./bin/${inputFile%.*}_$OSTYPE.exe"
gcc ./build/*.o -o ${inputFile%.*}_${OSTYPE}.exe
done