blob: c5cc14a748920413f844628d67edf18b75e9090c [file] [log] [blame]
Steven Burrowsa145e102017-06-16 13:37:50 -04001NODE_VERSION = "v8.1.2"
2NODE_RELEASE_BASE_URL = "https://nodejs.org/dist/"
3
4NODE_SHA1S = {
5 "node-v8.1.2-linux-x64.tar.gz":"61a609c83e2d3458cc2301a63b212a97e6b9f809",
6 "node-v8.1.2-darwin-x64.tar.gz":"a8b31fd645480661a8a777d9b4466dca0e6deb33"
7}
8
9def get_system_arch():
10 import platform
11 os = platform.system().lower()
12 return os
13
14def fetch_node(version):
15 file_name = "node-%s-%s-x64" % (version, get_system_arch())
16 file_fullname = "node-%s-%s-x64.tar.gz" % (version, get_system_arch())
17 if file_fullname not in NODE_SHA1S:
18 raise Exception("Cannot download %s, architecture or version not supported" % file_name)
19
20 remote_file(
21 name = 'node-release-' + version,
22 url = NODE_RELEASE_BASE_URL + version + '/' + file_fullname,
23 sha1 = NODE_SHA1S[file_fullname],
24 )
25
26 genrule(
27 name = 'node-bin-' + version,
Charles Chan5b6e0412017-10-04 11:24:33 -070028 bash = 'tar --no-same-owner -xf $(location :node-release-' + version + ') && ' +
Steven Burrowsa145e102017-06-16 13:37:50 -040029 'mv ' + file_name + ' $OUT && ' +
30 'chmod +x $OUT',
31 out = 'node-binaries',
32 executable = False,
33 visibility = [ "PUBLIC" ],
34 )