blob: de48a919da92375632503c9b4ab6c040cf06ea35 [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",
Sean Condon83fc39f2018-04-19 18:56:13 +01006 "node-v8.1.2-darwin-x64.tar.gz":"a8b31fd645480661a8a777d9b4466dca0e6deb33",
7 "node-v8.11.1-linux-x64.tar.gz":"ee0213f62185c36121c2daf8dcacd34ade90b10c",
8 "node-v8.11.1-darwin-x64.tar.gz":"01effb57fa711aa258d7aab26c6615e1f8a64b1a"
Steven Burrowsa145e102017-06-16 13:37:50 -04009}
10
11def get_system_arch():
12 import platform
13 os = platform.system().lower()
14 return os
15
16def fetch_node(version):
17 file_name = "node-%s-%s-x64" % (version, get_system_arch())
18 file_fullname = "node-%s-%s-x64.tar.gz" % (version, get_system_arch())
19 if file_fullname not in NODE_SHA1S:
20 raise Exception("Cannot download %s, architecture or version not supported" % file_name)
21
22 remote_file(
23 name = 'node-release-' + version,
24 url = NODE_RELEASE_BASE_URL + version + '/' + file_fullname,
25 sha1 = NODE_SHA1S[file_fullname],
26 )
27
28 genrule(
29 name = 'node-bin-' + version,
Charles Chan47c6e262017-10-04 11:24:33 -070030 bash = 'tar --no-same-owner -xf $(location :node-release-' + version + ') && ' +
Steven Burrowsa145e102017-06-16 13:37:50 -040031 'mv ' + file_name + ' $OUT && ' +
32 'chmod +x $OUT',
33 out = 'node-binaries',
34 executable = False,
35 visibility = [ "PUBLIC" ],
36 )