Steven Burrows | a145e10 | 2017-06-16 13:37:50 -0400 | [diff] [blame] | 1 | NODE_RELEASE_BASE_URL = "https://nodejs.org/dist/" |
| 2 | |
| 3 | NODE_SHA1S = { |
| 4 | "node-v8.1.2-linux-x64.tar.gz":"61a609c83e2d3458cc2301a63b212a97e6b9f809", |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 5 | "node-v8.1.2-darwin-x64.tar.gz":"a8b31fd645480661a8a777d9b4466dca0e6deb33", |
| 6 | "node-v8.11.1-linux-x64.tar.gz":"ee0213f62185c36121c2daf8dcacd34ade90b10c", |
| 7 | "node-v8.11.1-darwin-x64.tar.gz":"01effb57fa711aa258d7aab26c6615e1f8a64b1a" |
Steven Burrows | a145e10 | 2017-06-16 13:37:50 -0400 | [diff] [blame] | 8 | } |
| 9 | |
| 10 | def get_system_arch(): |
| 11 | import platform |
| 12 | os = platform.system().lower() |
| 13 | return os |
| 14 | |
| 15 | def fetch_node(version): |
| 16 | file_name = "node-%s-%s-x64" % (version, get_system_arch()) |
| 17 | file_fullname = "node-%s-%s-x64.tar.gz" % (version, get_system_arch()) |
| 18 | if file_fullname not in NODE_SHA1S: |
| 19 | raise Exception("Cannot download %s, architecture or version not supported" % file_name) |
| 20 | |
| 21 | remote_file( |
| 22 | name = 'node-release-' + version, |
| 23 | url = NODE_RELEASE_BASE_URL + version + '/' + file_fullname, |
| 24 | sha1 = NODE_SHA1S[file_fullname], |
| 25 | ) |
| 26 | |
| 27 | genrule( |
| 28 | name = 'node-bin-' + version, |
Charles Chan | 47c6e26 | 2017-10-04 11:24:33 -0700 | [diff] [blame] | 29 | bash = 'tar --no-same-owner -xf $(location :node-release-' + version + ') && ' + |
Steven Burrows | a145e10 | 2017-06-16 13:37:50 -0400 | [diff] [blame] | 30 | 'mv ' + file_name + ' $OUT && ' + |
| 31 | 'chmod +x $OUT', |
| 32 | out = 'node-binaries', |
| 33 | executable = False, |
| 34 | visibility = [ "PUBLIC" ], |
| 35 | ) |