forked from metafates/mangal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcross-compile.py
45 lines (35 loc) · 865 Bytes
/
cross-compile.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
42
43
44
45
import os
import subprocess
BIN = "mangal"
GOMOD = "github.com/metafates/mangal"
PLATFORMS = {
"windows": {
"arch": ["arm", "arm64", "amd64", "386"],
"ext": ".exe"
},
"linux": {
"arch": ["arm", "arm64", "amd64", "386"],
"ext": ""
},
"darwin": {
"arch": ["arm64", "amd64"],
"ext": ""
}
}
def compile_for(goos):
os.environ["GOOS"] = goos
ext = PLATFORMS[goos]["ext"]
for arch in PLATFORMS[goos]["arch"]:
os.environ["GOARCH"] = arch
target = os.path.join("bin", f"{BIN}-{goos}-{arch}{ext}")
subprocess.call([
"go", "build",
"-o", target,
GOMOD
])
def main():
for goos in PLATFORMS:
print(f"Compiling for {goos.title()}")
compile_for(goos)
if __name__ == "__main__":
main()