-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcompile.sh
executable file
·108 lines (91 loc) · 2.94 KB
/
compile.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
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
# note: you will need to follow the guide here to install the tools required
# to cross-compile for different architectures on your host machine.
# http://dave.cheney.net/2015/08/22/cross-compilation-with-go-1-5
# ensure the compiler exits with status 0
function assert() {
if [[ $1 != 0 ]]; then
echo "one or more architectures failed to compile"
exit $1;
fi
}
# ensure the files were compiled to the correct architecture
declare -A matrix
matrix["build/pbf2json.darwin-x64"]="Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS>"
matrix["build/pbf2json.linux-arm"]="ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, not stripped"
matrix["build/pbf2json.linux-x64"]="ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped"
matrix["build/pbf2json.win32-x64"]="PE32 executable (console) Intel 80386 (stripped to external PDB), for MS Windows"
function checkFiles() {
for path in "${!matrix[@]}"
do
expected="$path: ${matrix[$path]}";
actual=$(file $path);
if [ "$actual" != "$expected" ]; then
echo "invalid file architecture: $path"
echo "expected: $expected"
echo "actual: $actual"
exit 1
fi
done
}
echo "[compile] linux arm";
env GOOS=linux GOARCH=arm go build;
assert $?;
chmod +x pbf2json;
mv pbf2json build/pbf2json.linux-arm;
# echo "[compile] linux i386";
# env GOOS=linux GOARCH=386 go build;
# assert $?;
# chmod +x pbf2json;
# mv pbf2json build/pbf2json.linux-ia32;
echo "[compile] linux x64";
env GOOS=linux GOARCH=amd64 go build;
assert $?;
chmod +x pbf2json;
mv pbf2json build/pbf2json.linux-x64;
# echo "[compile] darwin i386";
# env GOOS=darwin GOARCH=386 go build;
# assert $?;
# chmod +x pbf2json;
# mv pbf2json build/pbf2json.darwin-ia32;
echo "[compile] darwin x64";
env GOOS=darwin GOARCH=amd64 go build;
assert $?;
chmod +x pbf2json;
mv pbf2json build/pbf2json.darwin-x64;
# echo "[compile] windows i386";
# env GOOS=windows GOARCH=386 go build;
# assert $?;
# chmod +x pbf2json.exe;
# mv pbf2json.exe build/pbf2json.win32-ia32;
echo "[compile] windows x64";
env GOOS=windows GOARCH=386 go build -o pbf2json.exe;
assert $?;
chmod +x pbf2json.exe;
mv pbf2json.exe build/pbf2json.win32-x64;
# echo "[compile] freebsd arm";
# env GOOS=freebsd GOARCH=arm go build;
# assert $?;
# chmod +x pbf2json;
# mv pbf2json build/pbf2json.freebsd-arm;
# echo "[compile] freebsd i386";
# env GOOS=freebsd GOARCH=386 go build;
# assert $?;
# chmod +x pbf2json;
# mv pbf2json build/pbf2json.freebsd-ia32;
# echo "[compile] freebsd x64";
# env GOOS=freebsd GOARCH=amd64 go build;
# assert $?;
# chmod +x pbf2json;
# mv pbf2json build/pbf2json.freebsd-x64;
# echo "[compile] openbsd i386";
# env GOOS=openbsd GOARCH=386 go build;
# assert $?;
# chmod +x pbf2json;
# mv pbf2json build/pbf2json.openbsd-ia32;
# echo "[compile] openbsd x64";
# env GOOS=openbsd GOARCH=amd64 go build;
# assert $?;
# chmod +x pbf2json;
# mv pbf2json build/pbf2json.openbsd-x64;
checkFiles