| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,11 +61,11 @@ | |||
| 61 | 61 | "conditions": [ | |
| 62 | 62 | ["node_root_dir.split('/')[-1].startswith('iojs')", { | |
| 63 | 63 | "include_dirs": [ | |
| 64 | - "/usr/local/opt/openssl@1.1/include" | ||
| 64 | + "vendor/openssl/include" | ||
| 65 | 65 | ], | |
| 66 | 66 | "libraries": [ | |
| 67 | - "/usr/local/opt/openssl@1.1/lib/libcrypto.a", | ||
| 68 | - "/usr/local/opt/openssl@1.1/lib/libssl.a" | ||
| 67 | + "<(module_root_dir)/vendor/openssl/lib/libcrypto.a", | ||
| 68 | + "<(module_root_dir)/vendor/openssl/lib/libssl.a" | ||
| 69 | 69 | ] | |
| 70 | 70 | }] | |
| 71 | 71 | ], | |
@@ -86,20 +86,10 @@ | |||
| 86 | 86 | "OS=='win'", { | |
| 87 | 87 | "conditions": [ | |
| 88 | 88 | ["node_root_dir.split('\\\\')[-1].startswith('iojs')", { | |
| 89 | - "conditions": [ | ||
| 90 | - ["target_arch == 'x64'", { | ||
| 91 | - "include_dirs": ["vendor/win/openssl/include64"], | ||
| 92 | - "libraries": [ | ||
| 93 | - "<(module_root_dir)/vendor/win/openssl/lib64/libcryptoMT.lib", | ||
| 94 | - "<(module_root_dir)/vendor/win/openssl/lib64/libsslMT.lib" | ||
| 95 | - ] | ||
| 96 | - }, { | ||
| 97 | - "include_dirs": ["vendor/win/openssl/include"], | ||
| 98 | - "libraries": [ | ||
| 99 | - "<(module_root_dir)/vendor/win/openssl/lib/libcryptoMT.lib", | ||
| 100 | - "<(module_root_dir)/vendor/win/openssl/lib/libsslMT.lib" | ||
| 101 | - ] | ||
| 102 | - }] | ||
| 89 | + "include_dirs": ["vendor/openssl/include"], | ||
| 90 | + "libraries": [ | ||
| 91 | + "<(module_root_dir)/vendor/openssl/lib/libcrypto.lib", | ||
| 92 | + "<(module_root_dir)/vendor/openssl/lib/libssl.lib" | ||
| 103 | 93 | ] | |
| 104 | 94 | }] | |
| 105 | 95 | ], | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,13 +6,6 @@ var rooted = function (dir) { | |||
| 6 | 6 | return escapedPathForShell; | |
| 7 | 7 | }; | |
| 8 | 8 | ||
| 9 | - var isWin64 = function() { | ||
| 10 | - return process.platform === "win32" && ( | ||
| 11 | - process.arch === "x64" || | ||
| 12 | - process.env.hasOwnProperty("PROCESSOR_ARCHITEW6432") | ||
| 13 | - ); | ||
| 14 | - }; | ||
| 15 | - | ||
| 16 | 9 | module.exports = function retrieveExternalDependencies() { | |
| 17 | 10 | if (process.platform === "win32") { | |
| 18 | 11 | return Promise.resolve(""); | |
@@ -23,22 +16,18 @@ module.exports = function retrieveExternalDependencies() { | |||
| 23 | 16 | var opensslDir; | |
| 24 | 17 | ||
| 25 | 18 | if (process.platform === "darwin") { | |
| 26 | - opensslDir = "/usr/local/opt/openssl@1.1"; | ||
| 27 | - } else if (process.platform === "win32") { | ||
| 28 | - opensslDir = path.join(process.cwd(), "vendor", "win", "openssl"); | ||
| 19 | + opensslDir = "vendor/openssl"; | ||
| 29 | 20 | } | |
| 30 | 21 | ||
| 31 | 22 | var newEnv = {}; | |
| 32 | 23 | Object.keys(process.env).forEach(function(key) { | |
| 33 | 24 | newEnv[key] = process.env[key]; | |
| 34 | 25 | }); | |
| 35 | 26 | ||
| 36 | - const includeDirName = isWin64() ? "include64" : "include"; | ||
| 37 | - | ||
| 38 | 27 | var maybeLibsslPrefix = ""; | |
| 39 | 28 | if (opensslDir) { | |
| 40 | 29 | newEnv.CPPFLAGS = newEnv.CPPFLAGS || ""; | |
| 41 | - newEnv.CPPFLAGS += " -I" + path.join(opensslDir, includeDirName); | ||
| 30 | + newEnv.CPPFLAGS += " -I" + path.join(opensslDir, "include"); | ||
| 42 | 31 | newEnv.CPPFLAGS = newEnv.CPPFLAGS.trim(); | |
| 43 | 32 | maybeLibsslPrefix = ` --with-libssl-prefix=${opensslDir}`; | |
| 44 | 33 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -60,6 +60,7 @@ | |||
| 60 | 60 | "mocha": "^5.2.0", | |
| 61 | 61 | "ramda": "^0.25.0", | |
| 62 | 62 | "request-promise-native": "^1.0.5", | |
| 63 | + "tar-fs": "^1.16.3", | ||
| 63 | 64 | "walk": "^2.3.9" | |
| 64 | 65 | }, | |
| 65 | 66 | "vendorDependencies": { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,90 @@ | |||
| 1 | + const fs = require('fs'); | ||
| 2 | + const fse = require('fs-extra'); | ||
| 3 | + const path = require('path'); | ||
| 4 | + const R = require('ramda'); | ||
| 5 | + const request = require('request-promise-native'); | ||
| 6 | + const stream = require('stream'); | ||
| 7 | + const tar = require('tar-fs'); | ||
| 8 | + const zlib = require('zlib'); | ||
| 9 | + | ||
| 10 | + const vendorPath = path.resolve('..', 'vendor'); | ||
| 11 | + const distrosFilePath = path.join(vendorPath, 'openssl_distributions.json'); | ||
| 12 | + const extractPath = path.join(vendorPath, 'openssl'); | ||
| 13 | + | ||
| 14 | + const getOSName = () => { | ||
| 15 | + if (process.platform === 'win32') { | ||
| 16 | + if (process.arch === "x64" || process.env.hasOwnProperty("PROCESSOR_ARCHITEW6432")) { | ||
| 17 | + return 'win64'; | ||
| 18 | + } else { | ||
| 19 | + return 'win32'; | ||
| 20 | + } | ||
| 21 | + } else if (process.platform === 'darwin') { | ||
| 22 | + return 'macOS'; | ||
| 23 | + } else { | ||
| 24 | + // We only discover distros for Mac and Windows. We don't care about any other OS. | ||
| 25 | + return 'unknown'; | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + const getCompilerVersion = () => { | ||
| 30 | + // TODO: Get actual compiler version. For now, just assume latest compiler for distros in openssl_distributions.js | ||
| 31 | + const osName = getOSName(); | ||
| 32 | + if (osName === 'win32' || osName === 'win64') { | ||
| 33 | + return 'vs15'; | ||
| 34 | + } else if (osName === 'macOS') { | ||
| 35 | + return 'clang-9'; | ||
| 36 | + } else { | ||
| 37 | + // We only discover distros for Mac and Windows. We don't care about any other OS. | ||
| 38 | + return 'unknown'; | ||
| 39 | + } | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + const getIsDebug = () => true // TODO: Determine if we are GYPing in Debug | ||
| 43 | + | ||
| 44 | + const getMatchingDistributionName = () => | ||
| 45 | + `${getOSName()}-${getCompilerVersion()}-static${getIsDebug() ? '-debug' : ''}`; | ||
| 46 | + | ||
| 47 | + const getDistributionsConfig = () => | ||
| 48 | + fse.readFile(distrosFilePath, 'utf8') | ||
| 49 | + .then(JSON.parse) | ||
| 50 | + | ||
| 51 | + const getDistrbutionURLFromConfig = (config) => { | ||
| 52 | + const distName = getMatchingDistributionName(); | ||
| 53 | + const distURL = R.propOr(null, distName, config); | ||
| 54 | + | ||
| 55 | + if (!distURL) { | ||
| 56 | + return Promise.reject(new Error('No matching distribution for this operating system')); | ||
| 57 | + } | ||
| 58 | + return Promise.resolve(distURL); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + const fetchFileFromURL = (distUrl) => request({ | ||
| 62 | + method: 'GET', | ||
| 63 | + uri: distUrl, | ||
| 64 | + encoding: null, | ||
| 65 | + gzip: true | ||
| 66 | + }); | ||
| 67 | + | ||
| 68 | + const extractFile = (body) => new Promise((resolve, reject) => { | ||
| 69 | + const streamableBody = new stream.Readable(); | ||
| 70 | + streamableBody.push(body); | ||
| 71 | + streamableBody.push(null); | ||
| 72 | + streamableBody | ||
| 73 | + .pipe(zlib.createGunzip()) | ||
| 74 | + .on('error', reject) | ||
| 75 | + .pipe(tar.extract(extractPath)) | ||
| 76 | + .on('error', reject) | ||
| 77 | + .on('close', resolve); | ||
| 78 | + }); | ||
| 79 | + | ||
| 80 | + const acquireOpenSSL = () => | ||
| 81 | + getDistributionsConfig() | ||
| 82 | + .then(getDistrbutionURLFromConfig) | ||
| 83 | + .then(fetchFileFromURL) | ||
| 84 | + .then(extractFile) | ||
| 85 | + .catch((e) => { | ||
| 86 | + console.error(e); | ||
| 87 | + process.exit(1); | ||
| 88 | + }); | ||
| 89 | + | ||
| 90 | + acquireOpenSSL(); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -363,13 +363,7 @@ | |||
| 363 | 363 | }, | |
| 364 | 364 | }], | |
| 365 | 365 | ["node_root_dir.split('\\\\')[-1].startswith('iojs')", { | |
| 366 | - "conditions": [ | ||
| 367 | - ["target_arch=='x64'", { | ||
| 368 | - "include_dirs": ["win/openssl/include64"] | ||
| 369 | - }, { | ||
| 370 | - "include_dirs": ["win/openssl/include"] | ||
| 371 | - }] | ||
| 372 | - ] | ||
| 366 | + "include_dirs": ["openssl/include"] | ||
| 373 | 367 | }] | |
| 374 | 368 | ], | |
| 375 | 369 | }, | |
@@ -542,18 +536,14 @@ | |||
| 542 | 536 | "conditions": [ | |
| 543 | 537 | ["OS=='mac' and node_root_dir.split('/')[-1].startswith('iojs')", { | |
| 544 | 538 | "include_dirs": [ | |
| 545 | - "/usr/local/opt/openssl@1.1/include" | ||
| 539 | + "openssl/include" | ||
| 546 | 540 | ] | |
| 547 | 541 | }], | |
| 548 | 542 | ["OS=='win'", { | |
| 549 | 543 | "conditions": [ | |
| 550 | 544 | ["node_root_dir.split('\\\\')[-1].startswith('iojs')", { | |
| 551 | - "conditions": [ | ||
| 552 | - ["target_arch=='x64'", { | ||
| 553 | - "include_dirs": ["win/openssl/include64"] | ||
| 554 | - }, { | ||
| 555 | - "include_dirs": ["win/openssl/include"] | ||
| 556 | - }] | ||
| 545 | + "include_dirs": [ | ||
| 546 | + "openssl/include" | ||
| 557 | 547 | ] | |
| 558 | 548 | }, { | |
| 559 | 549 | "defines": [ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments