-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcompiler.sh
executable file
·53 lines (50 loc) · 984 Bytes
/
compiler.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
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0-or-later
set -xe
function error() {
# shellcheck disable=SC2059
printf "$@" >&2
exit 1
}
case "$COMPILER" in
clang)
PATH=~/bin/custom-clang/bin
clang -gdwarf-5 -glldb -target "$TARGET" -integrated-as -c -o "$OUTPUT" "$INPUT"
;;
gcc)
mabi=""
case "$TARGET" in
mips64* | mipsisa64*)
mabi="-mabi=64"
;;
*-gnux32)
mabi="-mx32"
esac
PATH=~/bin/gcc-cross/$TARGET/bin
gcc $mabi -gdwarf-5 -c -o "$OUTPUT" "$INPUT"
;;
msvc)
case "$TARGET" in
i[56]86*)
ARCH=x86
;;
x86_64*)
ARCH=x64
;;
thumbv7a*)
ARCH=arm
;;
aarch64*)
ARCH=arm64
;;
*)
error "Unknown msvc target %s" "$TARGET"
esac
cd "$(dirname "$INPUT")"
~/opt/msvc/bin/$ARCH/cl /c /Zi "$INPUT"
mv vc140.pdb "$OUTPUT"
;;
*)
error "Unknown compiler %s" "$COMPILER"
;;
esac