-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_all.py
executable file
·64 lines (58 loc) · 2 KB
/
build_all.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
# coding: utf-8
"""Script to build all supported platforms"""
import os
import sys
import shutil
from subprocess import call
import argparse
# read version file
VERSION = "0.0.0"
with open('version.txt') as f:
VERSION = f.read().rstrip('\r\n')
f.close()
# create version.go
with open('cmd/fio/version.go', 'w') as f2:
code = '''package main
const (
// Version - fbk version
Version = "$#$VERSION$#$"
// Author fireblock
Author = "Laurent Mallet laurent.mallet at gmail dot com"
)
'''
code = code.replace('$#$VERSION$#$', VERSION)
f2.write(code)
f2.close()
PLATFORMS = ["windows/amd64", "windows/386", "darwin/amd64", "linux/amd64", "linux/386"]
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('-p', '--platform', help='select a platform')
args = parser.parse_args()
if args.platform:
PLATFORMS = [ args.platform ]
if not os.path.exists("build"):
os.makedirs("build")
if not os.path.exists("dist"):
os.makedirs("dist")
for p in PLATFORMS:
# clean build dir
for f in os.listdir('build'):
os.remove('build/' + f)
# copy LICENSE
shutil.copy2('LICENSE', 'build/')
els = p.split('/')
eos = els[0]
arch = els[1]
if p.find('windows') != -1:
archive = "fio-%s-%s-%s.zip" % (eos, arch, VERSION)
cmdBuild = "GOOS=%s GOARCH=%s go build -o build/%s github.com/fireblock/go-fireblock/cmd/fio" % (eos, arch, "fio")
cmdArch = "zip -r dist/%s build/*" % (archive)
call(cmdBuild, shell=True)
call(cmdArch, shell=True)
else:
archive = "fio-%s-%s-%s.tar.gz" % (eos, arch, VERSION)
cmdBuild = "GOOS=%s GOARCH=%s go build -o build/%s github.com/fireblock/go-fireblock/cmd/fio" % (eos, arch, "fio")
cmdArch = "tar zcvf dist/%s build/%s build/LICENSE" % (archive, "fio")
call(cmdBuild, shell=True)
call(cmdArch, shell=True)