forked from codesenberg/bombardier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
41 lines (38 loc) · 1.21 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
41
import argparse
import os
import subprocess
platforms = [
("darwin", "amd64"),
("darwin", "arm64"),
("freebsd", "386"),
("freebsd", "amd64"),
("freebsd", "arm"),
("linux", "386"),
("linux", "amd64"),
("linux", "arm"),
("linux", "arm64"),
("netbsd", "386"),
("netbsd", "amd64"),
("netbsd", "arm"),
("openbsd", "386"),
("openbsd", "amd64"),
("openbsd", "arm"),
("openbsd", "arm64"),
("windows", "386"),
("windows", "amd64"),
]
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Auxilary build script.")
parser.add_argument("-v", "--version", default="unspecified",
type=str, help="string used as a version when building binaries")
args = parser.parse_args()
version = args.version
for (build_os, build_arch) in platforms:
ext = ""
if build_os == "windows":
ext = ".exe"
build_env = os.environ.copy()
build_env["GOOS"] = build_os
build_env["GOARCH"] = build_arch
subprocess.run(["go", "build", "-ldflags", "-X main.version=%s" %
version, "-o", "bombardier-%s-%s%s" % (build_os, build_arch, ext)], env=build_env)