Skip to content

Commit

Permalink
build: add cross compile script
Browse files Browse the repository at this point in the history
  • Loading branch information
metafates committed Jun 17, 2022
1 parent 019fb14 commit 0704da8
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions cross-compile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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()

0 comments on commit 0704da8

Please sign in to comment.