10 from lib.config import PLATFORM, get_target_arch, s3_config
11 from lib.util import execute, safe_mkdir, scoped_cwd, s3put
14 SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
15 DIST_DIR = os.path.join(SOURCE_ROOT, 'dist')
16 NODE_DIR = os.path.join(SOURCE_ROOT, 'vendor', 'node')
17 OUT_DIR = os.path.join(SOURCE_ROOT, 'out', 'R')
41 node_headers_dir = os.path.join(DIST_DIR, 'node-{0}'.format(args.version))
42 iojs_headers_dir = os.path.join(DIST_DIR, 'iojs-{0}'.format(args.version))
43 iojs2_headers_dir = os.path.join(DIST_DIR,
44 'iojs-{0}-headers'.format(args.version))
46 copy_headers(node_headers_dir)
47 create_header_tarball(node_headers_dir)
48 copy_headers(iojs_headers_dir)
49 create_header_tarball(iojs_headers_dir)
50 copy_headers(iojs2_headers_dir)
51 create_header_tarball(iojs2_headers_dir)
53 # Upload node's headers to S3.
54 bucket, access_key, secret_key = s3_config()
55 upload_node(bucket, access_key, secret_key, args.version)
59 parser = argparse.ArgumentParser(description='upload sumsha file')
60 parser.add_argument('-v', '--version', help='Specify the version',
62 return parser.parse_args()
65 def copy_headers(dist_headers_dir):
66 safe_mkdir(dist_headers_dir)
68 # Copy standard node headers from node. repository.
69 for include_path in HEADERS_DIRS:
70 abs_path = os.path.join(NODE_DIR, include_path)
71 for dirpath, _, filenames in os.walk(abs_path):
72 for filename in filenames:
73 extension = os.path.splitext(filename)[1]
74 if extension not in HEADERS_SUFFIX:
76 copy_source_file(os.path.join(dirpath, filename), NODE_DIR,
78 for other_file in HEADERS_FILES:
79 copy_source_file(os.path.join(NODE_DIR, other_file), NODE_DIR,
82 # Copy V8 headers from chromium's repository.
83 src = os.path.join(SOURCE_ROOT, 'vendor', 'brightray', 'vendor', 'download',
84 'libchromiumcontent', 'src')
85 for dirpath, _, filenames in os.walk(os.path.join(src, 'v8')):
86 for filename in filenames:
87 extension = os.path.splitext(filename)[1]
88 if extension not in HEADERS_SUFFIX:
90 copy_source_file(os.path.join(dirpath, filename), src,
91 os.path.join(dist_headers_dir, 'deps'))
94 def create_header_tarball(dist_headers_dir):
95 target = dist_headers_dir + '.tar.gz'
96 with scoped_cwd(DIST_DIR):
97 tarball = tarfile.open(name=target, mode='w:gz')
98 tarball.add(os.path.relpath(dist_headers_dir))
102 def copy_source_file(source, start, destination):
103 relative = os.path.relpath(source, start=start)
104 final_destination = os.path.join(destination, relative)
105 safe_mkdir(os.path.dirname(final_destination))
106 shutil.copy2(source, final_destination)
109 def upload_node(bucket, access_key, secret_key, version):
110 with scoped_cwd(DIST_DIR):
111 s3put(bucket, access_key, secret_key, DIST_DIR,
112 'atom-shell/dist/{0}'.format(version), glob.glob('node-*.tar.gz'))
113 s3put(bucket, access_key, secret_key, DIST_DIR,
114 'atom-shell/dist/{0}'.format(version), glob.glob('iojs-*.tar.gz'))
116 if PLATFORM == 'win32':
117 if get_target_arch() == 'ia32':
118 node_lib = os.path.join(DIST_DIR, 'node.lib')
119 iojs_lib = os.path.join(DIST_DIR, 'win-x86', 'iojs.lib')
121 node_lib = os.path.join(DIST_DIR, 'x64', 'node.lib')
122 iojs_lib = os.path.join(DIST_DIR, 'win-x64', 'iojs.lib')
123 safe_mkdir(os.path.dirname(node_lib))
124 safe_mkdir(os.path.dirname(iojs_lib))
126 # Copy atom.lib to node.lib and iojs.lib.
127 atom_lib = os.path.join(OUT_DIR, 'node.dll.lib')
128 shutil.copy2(atom_lib, node_lib)
129 shutil.copy2(atom_lib, iojs_lib)
131 # Upload the node.lib.
132 s3put(bucket, access_key, secret_key, DIST_DIR,
133 'atom-shell/dist/{0}'.format(version), [node_lib])
135 # Upload the iojs.lib.
136 s3put(bucket, access_key, secret_key, DIST_DIR,
137 'atom-shell/dist/{0}'.format(version), [iojs_lib])
140 if __name__ == '__main__':