-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckBits.sh
More file actions
executable file
·102 lines (90 loc) · 3.5 KB
/
checkBits.sh
File metadata and controls
executable file
·102 lines (90 loc) · 3.5 KB
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
96
97
98
99
100
101
102
#!/usr/bin/env bash
set -euo pipefail
workdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source "$workdir/emulator.sh"
checkBitSizePath=".."
source_file="$checkBitSizePath/checkBitSize/checkBitSize.c"
linux_command="$checkBitSizePath/checkBitSize/checkBitSize"
windows_compiler="/c/Program\ Files\ \(x86\)/MSBuild/12.0/Bin/MSBuild.exe"
windows_project_file="$checkBitSizePath/checkBitSize/build/MSVC/checkBitSize.sln"
win32_command="$checkBitSizePath/checkBitSize/build/MSVC/Release/checkBitSize.exe"
win_x64_command="$checkBitSizePath/checkBitSize/build/MSVC/x64/Release/checkBitSize.exe"
script_name="$(basename "$0")"
err_msg() {
echo "Error: $1"
echo "Linux: $script_name <i386|x86_64|armhf>"
echo "Raspberry: $script_name <arm>"
echo "Windows: $script_name <win32|x64>"
}
# #######################################
# start of script.
# #######################################
if [ ! $# -eq 1 ]; then
err_msg "not enough / too much arguments"
exit 1
fi
platform="$1"
kernel="$(uname -s)"
machine="$(uname -m)"
if [[ $kernel == Linux* ]]; then
command="$linux_command"
if [[ $machine == x86_64 ]]; then
case "$platform" in
"i386")
echo "i386"
gcc -m32 -o "$command" "$source_file"
emulator "$command"
;;
"x86_64")
echo "x86_64"
gcc -o "$command" "$source_file"
emulator "$command"
;;
"armhf")
echo armhf
arm-linux-gnueabihf-gcc -o "$command" "$source_file"
emulator "$command"
;;
*)
err_msg "no such target"
exit 1
;;
esac
elif [[ $machine == armv* ]] || [[ $machine == aarch64 ]]; then
case "$platform" in
"arm")
echo "arch: $machine - building on rpi"
gcc -o "$command" "$source_file"
emulator "$command"
;;
*)
err_msg "on the raspberry pi, we won't build and test other platforms"
exit 1
;;
esac
fi
elif [[ $kernel == MINGW64* && $machine == x86_64 ]]; then
case "$platform" in
"win32")
echo "win32"
command="$win32_command"
bash -c "$windows_compiler $windows_project_file //t:Clean"
bash -c "$windows_compiler $windows_project_file //t:Rebuild //p:Configuration=Release //p:Platform=Win32"
emulator "$command"
;;
"x64")
echo "win x64"
command="$win_x64_command"
bash -c "$windows_compiler $windows_project_file //t:Clean"
bash -c "$windows_compiler $windows_project_file //t:Rebuild //p:Configuration=Release //p:Platform=x64"
emulator "$command"
;;
*)
err_msg "no such target"
exit 1
;;
esac
else
echo "Error. This runs on x86_64 machines, either with linux or windows (mingw)"
exit 1
fi