-
Notifications
You must be signed in to change notification settings - Fork 15k
/
upload-node-headers.py
executable file
·89 lines (70 loc) · 2.93 KB
/
upload-node-headers.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env python
import argparse
import glob
import os
import shutil
import sys
sys.path.append(
os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + "/../.."))
from lib.config import PLATFORM, get_target_arch, s3_config
from lib.util import safe_mkdir, scoped_cwd, s3put, get_out_dir, get_dist_dir
DIST_DIR = get_dist_dir()
OUT_DIR = get_out_dir()
GEN_DIR = os.path.join(OUT_DIR, 'gen')
HEADER_TAR_NAMES = [
'node-{0}.tar.gz',
'node-{0}-headers.tar.gz',
'iojs-{0}.tar.gz',
'iojs-{0}-headers.tar.gz'
]
def main():
args = parse_args()
# Upload node's headers to S3.
bucket, access_key, secret_key = s3_config()
upload_node(bucket, access_key, secret_key, args.version)
def parse_args():
parser = argparse.ArgumentParser(description='upload sumsha file')
parser.add_argument('-v', '--version', help='Specify the version',
required=True)
return parser.parse_args()
def upload_node(bucket, access_key, secret_key, version):
with scoped_cwd(GEN_DIR):
generated_tar = os.path.join(GEN_DIR, 'node_headers.tar.gz')
for header_tar in HEADER_TAR_NAMES:
versioned_header_tar = header_tar.format(version)
shutil.copy2(generated_tar, os.path.join(GEN_DIR, versioned_header_tar))
s3put(bucket, access_key, secret_key, GEN_DIR,
'atom-shell/dist/{0}'.format(version), glob.glob('node-*.tar.gz'))
s3put(bucket, access_key, secret_key, GEN_DIR,
'atom-shell/dist/{0}'.format(version), glob.glob('iojs-*.tar.gz'))
if PLATFORM == 'win32':
if get_target_arch() == 'ia32':
node_lib = os.path.join(DIST_DIR, 'node.lib')
iojs_lib = os.path.join(DIST_DIR, 'win-x86', 'iojs.lib')
v4_node_lib = os.path.join(DIST_DIR, 'win-x86', 'node.lib')
elif get_target_arch() == 'arm64':
node_lib = os.path.join(DIST_DIR, 'arm64', 'node.lib')
iojs_lib = os.path.join(DIST_DIR, 'win-arm64', 'iojs.lib')
v4_node_lib = os.path.join(DIST_DIR, 'win-arm64', 'node.lib')
else:
node_lib = os.path.join(DIST_DIR, 'x64', 'node.lib')
iojs_lib = os.path.join(DIST_DIR, 'win-x64', 'iojs.lib')
v4_node_lib = os.path.join(DIST_DIR, 'win-x64', 'node.lib')
safe_mkdir(os.path.dirname(node_lib))
safe_mkdir(os.path.dirname(iojs_lib))
# Copy electron.lib to node.lib and iojs.lib.
electron_lib = os.path.join(OUT_DIR, 'electron.lib')
shutil.copy2(electron_lib, node_lib)
shutil.copy2(electron_lib, iojs_lib)
shutil.copy2(electron_lib, v4_node_lib)
# Upload the node.lib.
s3put(bucket, access_key, secret_key, DIST_DIR,
'atom-shell/dist/{0}'.format(version), [node_lib])
# Upload the iojs.lib.
s3put(bucket, access_key, secret_key, DIST_DIR,
'atom-shell/dist/{0}'.format(version), [iojs_lib])
# Upload the v4 node.lib.
s3put(bucket, access_key, secret_key, DIST_DIR,
'atom-shell/dist/{0}'.format(version), [v4_node_lib])
if __name__ == '__main__':
sys.exit(main())