-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.py
40 lines (33 loc) · 1.26 KB
/
build.py
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
#!/usr/bin/env python3
import subprocess
import sys
GO_OS_ARCH_LIST = [
["darwin", "amd64"],
["linux", "amd64"],
["linux", "arm"],
["linux", "arm64"],
["linux", "mips", "softfloat"],
["linux", "mips", "hardfloat"],
["linux", "mipsle", "softfloat"],
["linux", "mipsle", "hardfloat"],
["windows", "amd64"]
]
def go_build():
version = subprocess.check_output(
"git describe --tags", shell=True).decode()
version = "".join(version.split())
for o, a, *p in GO_OS_ARCH_LIST:
zip_name = "doublebarrel-" + o + "-" + a + \
("-" + (p[0] if p else "") if p else "")
binary_name = zip_name + (".exe" if o == "windows" else "")
mipsflag = (" GOMIPS=" + (p[0] if p else "") if p else "")
command = "GOOS=" + o + " GOARCH=" + a + mipsflag + " CGO_ENABLED=0" + \
" go build -ldflags \"-s -w " + "-X main.version=" + \
version + "\" -o " + binary_name + " main.go"
print(command)
subprocess.check_call(command, shell=True)
subprocess.check_call("zip " + "output/" + zip_name + ".zip " +
binary_name + " " + "config.json cidrlist", shell=True)
if __name__ == "__main__":
if "-build" in sys.argv:
go_build()