Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion generate/templates/templates/binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"actions": [{
"action_name": "acquire",
"action": ["node", "utils/acquireOpenSSL.js"],
"inputs": ["vendor/openssl_distributions.json"],
"inputs": ["vendor/static_config/openssl_distributions.json"],
"outputs": ["vendor/openssl"],
"message": "Acquiring OpensSL binaries and headers"
}]
Expand Down
6 changes: 3 additions & 3 deletions utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
* Mac: clang-8.1 or clang-9.
* Windows: vs12, vs14, vs15

The discovered distributions are written into `vendor/openssl_distributions.json`. This script does not need to be run unless you are updating the version of OpenSSL to build against.
The discovered distributions are written into `vendor/static_config/openssl_distributions.json`. This script does not need to be run unless you are updating the version of OpenSSL to build against.

### acquireOpenSSL
Download the OpenSSL binaries and headers applicable to the current OS for the latest compiler version (clang-9/vs14). Uses links from `vendor/openssl_distributions.json`.
## acquireOpenSSL
Download the OpenSSL binaries and headers applicable to the current OS for the latest compiler version (clang-9/vs14). Uses links from `vendor/static_config/openssl_distributions.json`.

TODO:
* Make the script pull the debug versions if node-gyp is building in debug mode
Expand Down
2 changes: 1 addition & 1 deletion utils/acquireOpenSSL.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const tar = require("tar-fs");
const zlib = require("zlib");

const vendorPath = path.resolve(__dirname, "..", "vendor");
const distrosFilePath = path.join(vendorPath, "openssl_distributions.json");
const distrosFilePath = path.join(vendorPath, "static_config", "openssl_distributions.json");
const extractPath = path.join(vendorPath, "openssl");

const getOSName = () => {
Expand Down
48 changes: 24 additions & 24 deletions utils/configureLibssh2.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
var cp = require("child_process");
var fse = require('fs-extra');
var path = require("path");
var rooted = function (dir) {
var fullPath = path.join(__dirname, "..", dir);
var escapedPathForShell = fullPath.replace(/ /g, "\\ ");
return escapedPathForShell;
};

const libssh2VendorDirectory = path.resolve(__dirname, "..", "vendor", "libssh2");
const libssh2ConfigureScript = path.join(libssh2VendorDirectory, "configure");
const libssh2StaticConfigDirectory = path.resolve(__dirname, "..", "vendor", "static_config", "libssh2");

module.exports = function retrieveExternalDependencies() {
if (process.platform === "win32") {
return Promise.resolve("");
console.info("[nodegit] Configuring libssh2.");

// Copy Windows / Mac preconfigured files
if (process.platform === "win32" || process.platform === "darwin") {
return fse.copy(
path.join(libssh2StaticConfigDirectory, process.platform),
path.join(libssh2VendorDirectory, "src")
);
}

// Run the `configure` script on Linux
return new Promise(function(resolve, reject) {
console.info("[nodegit] Configuring libssh2.");

var opensslDir = process.argv[2];
var isElectron = process.argv[3] === "1";
var opensslIncludes = isElectron ? path.join(opensslDir, "includes") : opensslDir;

var newEnv = {};

// For some magic reason, MacOS fails to build if we copy over the current environment variables, but Linux
// builds fail if we DON'T copy over the current environment variables
if (process.platform !== "darwin") {
Object.keys(process.env).forEach(function(key) {
newEnv[key] = process.env[key];
});
}
Object.keys(process.env).forEach(function(key) {
newEnv[key] = process.env[key];
});

newEnv.CPPFLAGS = newEnv.CPPFLAGS || "";
newEnv.CPPFLAGS += ` -I${opensslIncludes}`;
Expand All @@ -37,8 +39,11 @@ module.exports = function retrieveExternalDependencies() {
}

cp.exec(
rooted("vendor/libssh2/configure") + maybeLibsslPrefix,
{cwd: rooted("vendor/libssh2/"), env: newEnv},
libssh2ConfigureScript + maybeLibsslPrefix,
{
cwd: libssh2VendorDirectory,
env: newEnv
},
function(err, stdout, stderr) {
if (err) {
console.error(err);
Expand All @@ -55,10 +60,5 @@ module.exports = function retrieveExternalDependencies() {

// Called on the command line
if (require.main === module) {
if (process.platform === "win32") {
console.log("nothing to do");
}
else {
module.exports();
}
module.exports();
}
8 changes: 6 additions & 2 deletions utils/discoverOpenSSLDistros.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,14 @@ const discoverDistributions = (treeHtml) => {
);
}

const outputPath = path.resolve(__dirname, "..", "vendor", "openssl_distributions.json");
const writeFile = (distributions) =>
fse.ensureDir(path.dirname(outputPath))
.then(fse.writeFile(outputPath, JSON.stringify(distributions, null, 2)));

const outputPath = path.resolve(__dirname, "..", "vendor", "static_config", "openssl_distributions.json");
request(getDistributionsRootURL())
.then(discoverDistributions)
.then(R.filter(R.identity))
.then(R.sortBy(R.prop(0)))
.then(R.fromPairs)
.then(distributions => fse.writeFile(outputPath, JSON.stringify(distributions, null, 2)));
.then(writeFile);
4 changes: 1 addition & 3 deletions vendor/libgit2.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@
"conditions": [
["OS=='mac' and node_root_dir.split('/')[-1].startswith('iojs')", {
"include_dirs": [
"openssl/include"
"openssl/include",
]
}],
["OS=='win'", {
Expand All @@ -561,7 +561,6 @@
],
"include_dirs": [
"libssh2/src",
"libssh2/win32",
"libssh2/include"
],
"defines!": [
Expand All @@ -570,7 +569,6 @@
"direct_dependent_settings": {
"include_dirs": [
"libssh2/src",
"libssh2/win32",
"libssh2/include"
]
}
Expand Down
Loading