diff --git a/generate/templates/templates/binding.gyp b/generate/templates/templates/binding.gyp index a332fc74c..dbe70ab5c 100644 --- a/generate/templates/templates/binding.gyp +++ b/generate/templates/templates/binding.gyp @@ -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" }] diff --git a/utils/README.md b/utils/README.md index ce679f8ef..1773e9979 100644 --- a/utils/README.md +++ b/utils/README.md @@ -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 diff --git a/utils/acquireOpenSSL.js b/utils/acquireOpenSSL.js index 2dc54780c..1c1ca29df 100644 --- a/utils/acquireOpenSSL.js +++ b/utils/acquireOpenSSL.js @@ -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 = () => { diff --git a/utils/configureLibssh2.js b/utils/configureLibssh2.js index 401cb5fc9..3ee8cd933 100644 --- a/utils/configureLibssh2.js +++ b/utils/configureLibssh2.js @@ -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}`; @@ -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); @@ -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(); } diff --git a/utils/discoverOpenSSLDistros.js b/utils/discoverOpenSSLDistros.js index f0f6bc94e..5a413a8e6 100644 --- a/utils/discoverOpenSSLDistros.js +++ b/utils/discoverOpenSSLDistros.js @@ -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); diff --git a/vendor/libgit2.gyp b/vendor/libgit2.gyp index 6593372cc..11904835e 100644 --- a/vendor/libgit2.gyp +++ b/vendor/libgit2.gyp @@ -539,7 +539,7 @@ "conditions": [ ["OS=='mac' and node_root_dir.split('/')[-1].startswith('iojs')", { "include_dirs": [ - "openssl/include" + "openssl/include", ] }], ["OS=='win'", { @@ -561,7 +561,6 @@ ], "include_dirs": [ "libssh2/src", - "libssh2/win32", "libssh2/include" ], "defines!": [ @@ -570,7 +569,6 @@ "direct_dependent_settings": { "include_dirs": [ "libssh2/src", - "libssh2/win32", "libssh2/include" ] } diff --git a/vendor/static_config/libssh2/darwin/libssh2_config.h b/vendor/static_config/libssh2/darwin/libssh2_config.h new file mode 100644 index 000000000..eb3228e6c --- /dev/null +++ b/vendor/static_config/libssh2/darwin/libssh2_config.h @@ -0,0 +1,262 @@ +/* src/libssh2_config.h. Generated from libssh2_config.h.in by configure. */ +/* src/libssh2_config.h.in. Generated from configure.ac by autoheader. */ + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +/* #undef CRAY_STACKSEG_END */ + +/* Define to 1 if using `alloca.c'. */ +/* #undef C_ALLOCA */ + +/* Define to 1 if you have `alloca', as a function or macro. */ +#define HAVE_ALLOCA 1 + +/* Define to 1 if you have and it should be used (not on Ultrix). + */ +#define HAVE_ALLOCA_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ARPA_INET_H 1 + +/* Define to 1 if you have the declaration of `SecureZeroMemory', and to 0 if + you don't. */ +/* #undef HAVE_DECL_SECUREZEROMEMORY */ + +/* disabled non-blocking sockets */ +/* #undef HAVE_DISABLED_NONBLOCKING */ + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `EVP_aes_128_ctr' function. */ +#define HAVE_EVP_AES_128_CTR 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* use FIONBIO for non-blocking sockets */ +/* #undef HAVE_FIONBIO */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* use ioctlsocket() for non-blocking sockets */ +/* #undef HAVE_IOCTLSOCKET */ + +/* use Ioctlsocket() for non-blocking sockets */ +/* #undef HAVE_IOCTLSOCKET_CASE */ + +/* Define if you have the bcrypt library. */ +/* #undef HAVE_LIBBCRYPT */ + +/* Define if you have the crypt32 library. */ +/* #undef HAVE_LIBCRYPT32 */ + +/* Define if you have the gcrypt library. */ +/* #undef HAVE_LIBGCRYPT */ + +/* Define if you have the mbedtls library. */ +/* #undef HAVE_LIBMBEDTLS */ + +/* Define if you have the ssl library. */ +#define HAVE_LIBSSL 1 + +/* Define if you have the z library. */ +#define HAVE_LIBZ 1 + +/* Define to 1 if the compiler supports the 'long long' data type. */ +#define HAVE_LONGLONG 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_IN_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NTDEF_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NTSTATUS_H */ + +/* use O_NONBLOCK for non-blocking sockets */ +#define HAVE_O_NONBLOCK 1 + +/* Define to 1 if you have the `poll' function. */ +/* #undef HAVE_POLL */ + +/* Define to 1 if you have the select function. */ +#define HAVE_SELECT 1 + +/* use SO_NONBLOCK for non-blocking sockets */ +/* #undef HAVE_SO_NONBLOCK */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strtoll' function. */ +#define HAVE_STRTOLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINDOWS_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINSOCK2_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WS2TCPIP_H */ + +/* to make a symbol visible */ +/* #undef LIBSSH2_API */ + +/* Enable clearing of memory before being freed */ +/* #undef LIBSSH2_CLEAR_MEMORY */ + +/* Enable "none" cipher -- NOT RECOMMENDED */ +/* #undef LIBSSH2_CRYPT_NONE */ + +/* Enable newer diffie-hellman-group-exchange-sha1 syntax */ +#define LIBSSH2_DH_GEX_NEW 1 + +/* Compile in zlib support */ +#define LIBSSH2_HAVE_ZLIB 1 + +/* Use libgcrypt */ +/* #undef LIBSSH2_LIBGCRYPT */ + +/* Enable "none" MAC -- NOT RECOMMENDED */ +/* #undef LIBSSH2_MAC_NONE */ + +/* Use mbedtls */ +/* #undef LIBSSH2_MBEDTLS */ + +/* Use OpenSSL */ +#define LIBSSH2_OPENSSL 1 + +/* Use Windows CNG */ +/* #undef LIBSSH2_WINCNG */ + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* Define to 1 if _REENTRANT preprocessor symbol must be defined. */ +/* #undef NEED_REENTRANT */ + +/* Name of package */ +#define PACKAGE "libssh2" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "libssh2-devel@cool.haxx.se" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "libssh2" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "libssh2 -" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "libssh2" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "-" + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at runtime. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +/* #undef STACK_DIRECTION */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "-" + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Enable large inode numbers on Mac OS X 10.5. */ +#ifndef _DARWIN_USE_64_BIT_INODE +# define _DARWIN_USE_64_BIT_INODE 1 +#endif + +/* Number of bits in a file offset, on hosts where this is settable. */ +/* #undef _FILE_OFFSET_BITS */ + +/* Define for large files, on AIX-style hosts. */ +/* #undef _LARGE_FILES */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ diff --git a/vendor/static_config/libssh2/win32/libssh2_config.h b/vendor/static_config/libssh2/win32/libssh2_config.h new file mode 100644 index 000000000..b6af97806 --- /dev/null +++ b/vendor/static_config/libssh2/win32/libssh2_config.h @@ -0,0 +1,46 @@ +#ifndef LIBSSH2_CONFIG_H +#define LIBSSH2_CONFIG_H + +#ifndef WIN32 +#define WIN32 +#endif +#ifndef _CRT_SECURE_NO_DEPRECATE +#define _CRT_SECURE_NO_DEPRECATE 1 +#endif /* _CRT_SECURE_NO_DEPRECATE */ +#include +#include +#include + +#ifdef __MINGW32__ +#define HAVE_UNISTD_H +#define HAVE_INTTYPES_H +#define HAVE_SYS_TIME_H +#define HAVE_GETTIMEOFDAY +#endif /* __MINGW32__ */ + +#define LIBSSH2_OPENSSL +#define HAVE_WINSOCK2_H +#define HAVE_IOCTLSOCKET +#define HAVE_SELECT + +#ifdef _MSC_VER +#if _MSC_VER < 1900 +#define snprintf _snprintf +#if _MSC_VER < 1500 +#define vsnprintf _vsnprintf +#endif +#define strdup _strdup +#define strncasecmp _strnicmp +#define strcasecmp _stricmp +#endif +#else +#ifndef __MINGW32__ +#define strncasecmp strnicmp +#define strcasecmp stricmp +#endif /* __MINGW32__ */ +#endif /* _MSC_VER */ + +/* Enable newer diffie-hellman-group-exchange-sha1 syntax */ +#define LIBSSH2_DH_GEX_NEW 1 + +#endif /* LIBSSH2_CONFIG_H */ diff --git a/vendor/openssl_distributions.json b/vendor/static_config/openssl_distributions.json similarity index 100% rename from vendor/openssl_distributions.json rename to vendor/static_config/openssl_distributions.json