@swimlane/nodegit 1.1.5 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.commitlintrc.yml +12 -0
- package/.github/workflows/lint-pr.yml +19 -0
- package/.github/workflows/publish.yml +91 -26
- package/.github/workflows/release.yml +45 -0
- package/.github/workflows/tests.yml +10 -5
- package/README.md +1 -1
- package/binding.gyp +30 -45
- package/lib/credential.js +1 -0
- package/lib/enums.js +29 -9
- package/lib/nodegit.js +46 -3
- package/package.json +26 -16
- package/prebuilds/darwin-arm64/@swimlane+nodegit.glibc.node +0 -0
- package/prebuilds/linux-arm64/@swimlane+nodegit.glibc.node +0 -0
- package/prebuilds/linux-x64/@swimlane+nodegit.glibc.node +0 -0
- package/prebuilds/linux-x64/@swimlane+nodegit.musl.node +0 -0
- package/renovate.json +42 -0
- package/scripts/Dockerfile.alpine +1 -1
- package/scripts/Dockerfile.debian +1 -1
- package/utils/{acquireOpenSSL.js → acquireOpenSSL.mjs} +168 -116
- package/utils/build-openssl.bat +10 -1
- package/utils/buildFlags.js +22 -0
- package/utils/configureLibssh2.js +13 -10
- package/utils/defaultCxxStandard.js +20 -9
- package/utils/uploadOpenSSL.mjs +32 -0
- package/lifecycleScripts/install.js +0 -32
- package/prebuilds/darwin-x64/@swimlane+nodegit.glibc.node +0 -0
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import crypto from "crypto";
|
|
2
|
+
import { spawn } from "child_process";
|
|
3
|
+
import execPromise from "./execPromise.js";
|
|
4
|
+
import got from "got";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import stream from "stream";
|
|
7
|
+
import tar from "tar-fs";
|
|
8
|
+
import zlib from "zlib";
|
|
9
|
+
import { createWriteStream, promises as fs } from "fs";
|
|
10
|
+
import { performance } from "perf_hooks";
|
|
11
|
+
import { promisify } from "util";
|
|
12
|
+
|
|
13
|
+
import { hostArch, targetArch } from "./buildFlags.js";
|
|
14
14
|
|
|
15
15
|
const pipeline = promisify(stream.pipeline);
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
import packageJson from '../package.json' with { type: "json" };
|
|
18
18
|
|
|
19
|
-
const OPENSSL_VERSION = "
|
|
20
|
-
const win32BatPath = path.join(
|
|
21
|
-
const vendorPath = path.resolve(
|
|
19
|
+
const OPENSSL_VERSION = "3.0.18";
|
|
20
|
+
const win32BatPath = path.join(import.meta.dirname, "build-openssl.bat");
|
|
21
|
+
const vendorPath = path.resolve(import.meta.dirname, "..", "vendor");
|
|
22
22
|
const opensslPatchPath = path.join(vendorPath, "patches", "openssl");
|
|
23
23
|
const extractPath = path.join(vendorPath, "openssl");
|
|
24
24
|
|
|
25
|
+
const exists = (filePath) => fs.stat(filePath).then(() => true).catch(() => false);
|
|
26
|
+
|
|
25
27
|
const pathsToIncludeForPackage = [
|
|
26
28
|
"include", "lib"
|
|
27
29
|
];
|
|
@@ -58,7 +60,9 @@ const makeHashVerifyOnFinal = (expected) => (digest) => {
|
|
|
58
60
|
// currently this only needs to be done on linux
|
|
59
61
|
const applyOpenSSLPatches = async (buildCwd, operatingSystem) => {
|
|
60
62
|
try {
|
|
61
|
-
|
|
63
|
+
await fs.access(opensslPatchPath);
|
|
64
|
+
|
|
65
|
+
for (const patchFilename of await fs.readdir(opensslPatchPath)) {
|
|
62
66
|
const patchTarget = patchFilename.split("-")[1];
|
|
63
67
|
if (patchFilename.split(".").pop() === "patch" && (patchTarget === operatingSystem || patchTarget === "all")) {
|
|
64
68
|
console.log(`applying ${patchFilename}`);
|
|
@@ -68,6 +72,11 @@ const applyOpenSSLPatches = async (buildCwd, operatingSystem) => {
|
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
74
|
} catch(e) {
|
|
75
|
+
if (e.code === "ENOENT") {
|
|
76
|
+
// no patches to apply
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
71
80
|
console.log("Patch application failed: ", e);
|
|
72
81
|
throw e;
|
|
73
82
|
}
|
|
@@ -78,8 +87,10 @@ const buildDarwin = async (buildCwd, macOsDeploymentTarget) => {
|
|
|
78
87
|
throw new Error("Expected macOsDeploymentTarget to be specified");
|
|
79
88
|
}
|
|
80
89
|
|
|
81
|
-
const
|
|
82
|
-
|
|
90
|
+
const buildConfig = targetArch === "x64" ? "darwin64-x86_64-cc" : "darwin64-arm64-cc";
|
|
91
|
+
|
|
92
|
+
const configureArgs = [
|
|
93
|
+
buildConfig,
|
|
83
94
|
// speed up ecdh on little-endian platforms with 128bit int support
|
|
84
95
|
"enable-ec_nistp_64_gcc_128",
|
|
85
96
|
// compile static libraries
|
|
@@ -88,6 +99,8 @@ const buildDarwin = async (buildCwd, macOsDeploymentTarget) => {
|
|
|
88
99
|
"no-ssl2",
|
|
89
100
|
"no-ssl3",
|
|
90
101
|
"no-comp",
|
|
102
|
+
// disable tty ui since it fails a bunch of tests on GHA runners and we're just gonna link anyways
|
|
103
|
+
"no-ui-console",
|
|
91
104
|
// set install directory
|
|
92
105
|
`--prefix="${extractPath}"`,
|
|
93
106
|
`--openssldir="${extractPath}"`,
|
|
@@ -95,13 +108,13 @@ const buildDarwin = async (buildCwd, macOsDeploymentTarget) => {
|
|
|
95
108
|
`-mmacosx-version-min=${macOsDeploymentTarget}`
|
|
96
109
|
];
|
|
97
110
|
|
|
98
|
-
await execPromise(`./Configure ${
|
|
111
|
+
await execPromise(`./Configure ${configureArgs.join(" ")}`, {
|
|
99
112
|
cwd: buildCwd
|
|
100
113
|
}, { pipeOutput: true });
|
|
101
114
|
|
|
102
115
|
await applyOpenSSLPatches(buildCwd, "darwin");
|
|
103
116
|
|
|
104
|
-
// only build the libraries, not the
|
|
117
|
+
// only build the libraries, not the fuzzer or apps
|
|
105
118
|
await execPromise("make build_libs", {
|
|
106
119
|
cwd: buildCwd
|
|
107
120
|
}, { pipeOutput: true });
|
|
@@ -117,37 +130,36 @@ const buildDarwin = async (buildCwd, macOsDeploymentTarget) => {
|
|
|
117
130
|
};
|
|
118
131
|
|
|
119
132
|
const buildLinux = async (buildCwd) => {
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
//
|
|
125
|
-
// by the runtime linker.
|
|
126
|
-
"-fvisibility=hidden",
|
|
127
|
-
// compile static libraries
|
|
128
|
-
"no-shared",
|
|
129
|
-
// disable ssl2, ssl3, and compression
|
|
130
|
-
"no-ssl2",
|
|
133
|
+
const buildConfig = targetArch === "x64" ? "linux-x86_64" : "linux-aarch64";
|
|
134
|
+
|
|
135
|
+
const configureArgs = [
|
|
136
|
+
buildConfig,
|
|
137
|
+
// disable ssl3, and compression
|
|
131
138
|
"no-ssl3",
|
|
132
139
|
"no-comp",
|
|
133
140
|
// set install directory
|
|
134
141
|
`--prefix="${extractPath}"`,
|
|
135
|
-
`--openssldir="${extractPath}"
|
|
142
|
+
`--openssldir="${extractPath}"`,
|
|
143
|
+
"--libdir=lib",
|
|
136
144
|
];
|
|
137
|
-
await execPromise(`./Configure ${
|
|
145
|
+
await execPromise(`./Configure ${configureArgs.join(" ")}`, {
|
|
138
146
|
cwd: buildCwd
|
|
139
147
|
}, { pipeOutput: true });
|
|
140
148
|
|
|
141
149
|
await applyOpenSSLPatches(buildCwd, "linux");
|
|
142
150
|
|
|
143
|
-
// only build the libraries, not the
|
|
151
|
+
// only build the libraries, not the fuzzer or apps
|
|
144
152
|
await execPromise("make build_libs", {
|
|
145
|
-
cwd: buildCwd
|
|
153
|
+
cwd: buildCwd,
|
|
154
|
+
maxBuffer: 10 * 1024 * 1024
|
|
146
155
|
}, { pipeOutput: true });
|
|
147
156
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
157
|
+
if (hostArch === targetArch) {
|
|
158
|
+
await execPromise("make test", {
|
|
159
|
+
cwd: buildCwd,
|
|
160
|
+
maxBuffer: 10 * 1024 * 1024
|
|
161
|
+
}, { pipeOutput: true });
|
|
162
|
+
}
|
|
151
163
|
|
|
152
164
|
// only install software, not the docs
|
|
153
165
|
await execPromise("make install_sw", {
|
|
@@ -156,44 +168,108 @@ const buildLinux = async (buildCwd) => {
|
|
|
156
168
|
}, { pipeOutput: true });
|
|
157
169
|
};
|
|
158
170
|
|
|
159
|
-
const buildWin32 = async (buildCwd
|
|
160
|
-
|
|
161
|
-
throw new Error("Expected vsBuildArch to be specified");
|
|
162
|
-
}
|
|
171
|
+
const buildWin32 = async (buildCwd) => {
|
|
172
|
+
let vcvarsallPath = undefined;
|
|
163
173
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
+
if (process.env.npm_config_vcvarsall_path && await exists(process.env.npm_config_vcvarsall_path)) {
|
|
175
|
+
vcvarsallPath = process.env.npm_config_vcvarsall_path;
|
|
176
|
+
} else {
|
|
177
|
+
const potentialMsvsPaths = [];
|
|
178
|
+
|
|
179
|
+
// GYP_MSVS_OVERRIDE_PATH is set by node-gyp so this should cover most cases
|
|
180
|
+
if (process.env.GYP_MSVS_OVERRIDE_PATH) {
|
|
181
|
+
potentialMsvsPaths.push(process.env.GYP_MSVS_OVERRIDE_PATH);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const packageTypes = ["BuildTools", "Community", "Professional", "Enterprise"];
|
|
185
|
+
const versions = ["2022", "2019"]
|
|
186
|
+
|
|
187
|
+
const computePossiblePaths = (parentPath) => {
|
|
188
|
+
let possiblePaths = []
|
|
189
|
+
for (const packageType of packageTypes) {
|
|
190
|
+
for (const version of versions) {
|
|
191
|
+
possiblePaths.push(path.join(parentPath, version, packageType));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return possiblePaths;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (process.env["ProgramFiles(x86)"]) {
|
|
199
|
+
const parentPath = path.join(process.env["ProgramFiles(x86)"], 'Microsoft Visual Studio');
|
|
200
|
+
potentialMsvsPaths.push(...computePossiblePaths(parentPath));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (process.env.ProgramFiles) {
|
|
204
|
+
const parentPath = path.join(process.env.ProgramFiles, 'Microsoft Visual Studio');
|
|
205
|
+
potentialMsvsPaths.push(...computePossiblePaths(parentPath));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
for (const potentialPath of potentialMsvsPaths) {
|
|
209
|
+
const wholePath = path.join(potentialPath, 'VC', 'Auxiliary', 'Build', 'vcvarsall.bat');
|
|
210
|
+
console.log("checking", wholePath);
|
|
211
|
+
if (await exists(wholePath)) {
|
|
212
|
+
vcvarsallPath = wholePath;
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (!vcvarsallPath) {
|
|
218
|
+
throw new Error(`vcvarsall.bat not found`);
|
|
219
|
+
}
|
|
174
220
|
}
|
|
175
221
|
|
|
176
222
|
let vcTarget;
|
|
177
|
-
switch (
|
|
178
|
-
case "x64":
|
|
223
|
+
switch (targetArch) {
|
|
224
|
+
case "x64":
|
|
179
225
|
vcTarget = "VC-WIN64A";
|
|
180
226
|
break;
|
|
181
|
-
}
|
|
182
227
|
|
|
183
|
-
case "x86":
|
|
228
|
+
case "x86":
|
|
184
229
|
vcTarget = "VC-WIN32";
|
|
185
230
|
break;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
231
|
+
|
|
232
|
+
case "arm64":
|
|
233
|
+
vcTarget = "VC-WIN64-ARM";
|
|
234
|
+
break;
|
|
191
235
|
}
|
|
192
236
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
237
|
+
let vsBuildArch = hostArch === targetArch
|
|
238
|
+
? hostArch
|
|
239
|
+
: `${hostArch}_${targetArch}`;
|
|
240
|
+
|
|
241
|
+
console.log("Using vcvarsall.bat at: ", vcvarsallPath);
|
|
242
|
+
console.log("Using vsBuildArch: ", vsBuildArch);
|
|
243
|
+
console.log("Using vcTarget: ", vcTarget);
|
|
244
|
+
|
|
245
|
+
await new Promise((resolve, reject) => {
|
|
246
|
+
const buildProcess = spawn(`"${win32BatPath}" "${vcvarsallPath}" ${vsBuildArch} ${vcTarget}`, {
|
|
247
|
+
cwd: buildCwd,
|
|
248
|
+
shell: process.platform === "win32",
|
|
249
|
+
env: {
|
|
250
|
+
...process.env,
|
|
251
|
+
NODEGIT_SKIP_TESTS: targetArch !== hostArch ? "1" : undefined
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
buildProcess.stdout.on("data", function(data) {
|
|
256
|
+
console.info(data.toString().trim());
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
buildProcess.stderr.on("data", function(data) {
|
|
260
|
+
console.error(data.toString().trim());
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
buildProcess.on("close", function(code) {
|
|
264
|
+
if (!code) {
|
|
265
|
+
resolve();
|
|
266
|
+
} else {
|
|
267
|
+
reject(code);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
|
|
197
273
|
};
|
|
198
274
|
|
|
199
275
|
const removeOpenSSLIfOudated = async (openSSLVersion) => {
|
|
@@ -217,7 +293,7 @@ const removeOpenSSLIfOudated = async (openSSLVersion) => {
|
|
|
217
293
|
}
|
|
218
294
|
|
|
219
295
|
console.log("Removing outdated OpenSSL at: ", extractPath);
|
|
220
|
-
await
|
|
296
|
+
await fs.rm(extractPath, { recursive: true, force: true });
|
|
221
297
|
console.log("Outdated OpenSSL removed.");
|
|
222
298
|
} catch (err) {
|
|
223
299
|
console.log("Remove outdated OpenSSL failed: ", err);
|
|
@@ -237,19 +313,13 @@ const makeOnStreamDownloadProgress = () => {
|
|
|
237
313
|
|
|
238
314
|
const buildOpenSSLIfNecessary = async ({
|
|
239
315
|
macOsDeploymentTarget,
|
|
240
|
-
openSSLVersion
|
|
241
|
-
vsBuildArch
|
|
316
|
+
openSSLVersion
|
|
242
317
|
}) => {
|
|
243
318
|
if (process.platform !== "darwin" && process.platform !== "win32" && process.platform !== "linux") {
|
|
244
319
|
console.log(`Skipping OpenSSL build, not required on ${process.platform}`);
|
|
245
320
|
return;
|
|
246
321
|
}
|
|
247
322
|
|
|
248
|
-
if (process.platform === "linux" && process.env.NODEGIT_OPENSSL_STATIC_LINK !== "1") {
|
|
249
|
-
console.log(`Skipping OpenSSL build, NODEGIT_OPENSSL_STATIC_LINK !== 1`);
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
323
|
await removeOpenSSLIfOudated(openSSLVersion);
|
|
254
324
|
|
|
255
325
|
try {
|
|
@@ -261,7 +331,7 @@ const buildOpenSSLIfNecessary = async ({
|
|
|
261
331
|
const openSSLUrl = getOpenSSLSourceUrl(openSSLVersion);
|
|
262
332
|
const openSSLSha256Url = getOpenSSLSourceSha256Url(openSSLVersion);
|
|
263
333
|
|
|
264
|
-
const openSSLSha256 = (await got(openSSLSha256Url)).body.trim();
|
|
334
|
+
const openSSLSha256 = (await got(openSSLSha256Url)).body.trim().split(' ')[0];
|
|
265
335
|
|
|
266
336
|
const downloadStream = got.stream(openSSLUrl);
|
|
267
337
|
downloadStream.on("downloadProgress", makeOnStreamDownloadProgress());
|
|
@@ -282,7 +352,7 @@ const buildOpenSSLIfNecessary = async ({
|
|
|
282
352
|
} else if (process.platform === "linux") {
|
|
283
353
|
await buildLinux(buildCwd);
|
|
284
354
|
} else if (process.platform === "win32") {
|
|
285
|
-
await buildWin32(buildCwd
|
|
355
|
+
await buildWin32(buildCwd);
|
|
286
356
|
} else {
|
|
287
357
|
throw new Error(`Unknown platform: ${process.platform}`);
|
|
288
358
|
}
|
|
@@ -300,11 +370,6 @@ const downloadOpenSSLIfNecessary = async ({
|
|
|
300
370
|
return;
|
|
301
371
|
}
|
|
302
372
|
|
|
303
|
-
if (process.platform === "linux" && process.env.NODEGIT_OPENSSL_STATIC_LINK !== "1") {
|
|
304
|
-
console.log(`Skipping OpenSSL download, NODEGIT_OPENSSL_STATIC_LINK !== 1`);
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
373
|
try {
|
|
309
374
|
await fs.stat(extractPath);
|
|
310
375
|
console.log("Skipping OpenSSL download, dir exists");
|
|
@@ -334,18 +399,17 @@ const downloadOpenSSLIfNecessary = async ({
|
|
|
334
399
|
console.log("Download finished.");
|
|
335
400
|
}
|
|
336
401
|
|
|
337
|
-
const getOpenSSLPackageName = () => {
|
|
338
|
-
|
|
339
|
-
if (process.platform === "win32" && (
|
|
340
|
-
process.arch === "ia32" || process.env.NODEGIT_VS_BUILD_ARCH === "x86"
|
|
341
|
-
)) {
|
|
342
|
-
arch = "x86";
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
return `openssl-${OPENSSL_VERSION}-${process.platform}-${arch}.tar.gz`;
|
|
402
|
+
export const getOpenSSLPackageName = () => {
|
|
403
|
+
return `openssl-${OPENSSL_VERSION}-${process.platform}-${targetArch}.tar.gz`;
|
|
346
404
|
}
|
|
347
405
|
|
|
348
|
-
const
|
|
406
|
+
export const getOpenSSLPackagePath = () => path.join(import.meta.dirname, getOpenSSLPackageName());
|
|
407
|
+
|
|
408
|
+
const getOpenSSLPackageUrl = () => {
|
|
409
|
+
const hostUrl = new URL(packageJson.binary.host);
|
|
410
|
+
hostUrl.pathname = getOpenSSLPackageName();
|
|
411
|
+
return hostUrl.toString();
|
|
412
|
+
};
|
|
349
413
|
|
|
350
414
|
const buildPackage = async () => {
|
|
351
415
|
let resolve, reject;
|
|
@@ -361,17 +425,17 @@ const buildPackage = async () => {
|
|
|
361
425
|
return path.extname(name) === ".pc"
|
|
362
426
|
|| path.basename(name) === "pkgconfig";
|
|
363
427
|
},
|
|
364
|
-
dmode:
|
|
365
|
-
fmode:
|
|
428
|
+
dmode: 0o0755,
|
|
429
|
+
fmode: 0o0644
|
|
366
430
|
}),
|
|
367
431
|
zlib.createGzip(),
|
|
368
432
|
new HashVerify("sha256", (digest) => {
|
|
369
433
|
resolve(digest);
|
|
370
434
|
}),
|
|
371
|
-
|
|
435
|
+
createWriteStream(getOpenSSLPackagePath())
|
|
372
436
|
);
|
|
373
437
|
const digest = await promise;
|
|
374
|
-
await fs.writeFile(`${
|
|
438
|
+
await fs.writeFile(`${getOpenSSLPackagePath()}.sha256`, digest);
|
|
375
439
|
};
|
|
376
440
|
|
|
377
441
|
const acquireOpenSSL = async () => {
|
|
@@ -394,24 +458,15 @@ const acquireOpenSSL = async () => {
|
|
|
394
458
|
|
|
395
459
|
let macOsDeploymentTarget;
|
|
396
460
|
if (process.platform === "darwin") {
|
|
397
|
-
macOsDeploymentTarget = process.argv[2]
|
|
461
|
+
macOsDeploymentTarget = process.argv[2] ?? process.env.OPENSSL_MACOS_DEPLOYMENT_TARGET
|
|
398
462
|
if (!macOsDeploymentTarget || !macOsDeploymentTarget.match(/\d+\.\d+/)) {
|
|
399
463
|
throw new Error(`Invalid macOsDeploymentTarget: ${macOsDeploymentTarget}`);
|
|
400
464
|
}
|
|
401
465
|
}
|
|
402
466
|
|
|
403
|
-
let vsBuildArch;
|
|
404
|
-
if (process.platform === "win32") {
|
|
405
|
-
vsBuildArch = process.env.NODEGIT_VS_BUILD_ARCH || (process.arch === "x64" ? "x64" : "x86");
|
|
406
|
-
if (!["x64", "x86"].includes(vsBuildArch)) {
|
|
407
|
-
throw new Error(`Invalid vsBuildArch: ${vsBuildArch}`);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
|
|
411
467
|
await buildOpenSSLIfNecessary({
|
|
412
468
|
openSSLVersion: OPENSSL_VERSION,
|
|
413
|
-
macOsDeploymentTarget
|
|
414
|
-
vsBuildArch
|
|
469
|
+
macOsDeploymentTarget
|
|
415
470
|
});
|
|
416
471
|
if (process.env.NODEGIT_OPENSSL_BUILD_PACKAGE) {
|
|
417
472
|
await buildPackage();
|
|
@@ -422,15 +477,12 @@ const acquireOpenSSL = async () => {
|
|
|
422
477
|
}
|
|
423
478
|
};
|
|
424
479
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
if (require.main === module) {
|
|
432
|
-
acquireOpenSSL().catch((error) => {
|
|
480
|
+
if (process.argv[1] === import.meta.filename) {
|
|
481
|
+
try {
|
|
482
|
+
await acquireOpenSSL();
|
|
483
|
+
}
|
|
484
|
+
catch(error) {
|
|
433
485
|
console.error("Acquire OpenSSL failed: ", error);
|
|
434
486
|
process.exit(1);
|
|
435
|
-
}
|
|
487
|
+
}
|
|
436
488
|
}
|
package/utils/build-openssl.bat
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
rem Build OpenSSL for Windows
|
|
2
|
+
rem %1 - path to vcvarsall.bat
|
|
3
|
+
rem %2 - architecture argument for vcvarsall.bat
|
|
4
|
+
rem %3 - OpenSSL Configure target
|
|
5
|
+
|
|
1
6
|
@call %1 %2
|
|
2
7
|
|
|
3
8
|
perl .\Configure %3 no-shared no-ssl2 no-ssl3 no-comp --prefix="%cd%\.." --openssldir="%cd%\.." || goto :error
|
|
4
9
|
|
|
5
10
|
nmake || goto :error
|
|
6
|
-
|
|
11
|
+
|
|
12
|
+
if "%NODEGIT_SKIP_TESTS%" NEQ "1" (
|
|
13
|
+
nmake test || goto :error
|
|
14
|
+
)
|
|
15
|
+
|
|
7
16
|
nmake install || goto :error
|
|
8
17
|
|
|
9
18
|
goto :EOF
|
package/utils/buildFlags.js
CHANGED
|
@@ -10,7 +10,29 @@ try {
|
|
|
10
10
|
isGitRepo = false;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
const convertArch = (archStr) => {
|
|
14
|
+
const convertedArch = {
|
|
15
|
+
'ia32': 'x86',
|
|
16
|
+
'x86': 'x86',
|
|
17
|
+
'x64': 'x64',
|
|
18
|
+
'arm64': 'arm64'
|
|
19
|
+
}[archStr];
|
|
20
|
+
|
|
21
|
+
if (!convertedArch) {
|
|
22
|
+
throw new Error('unsupported architecture');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return convertedArch;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const hostArch = convertArch(process.arch);
|
|
29
|
+
const targetArch = process.env.npm_config_arch
|
|
30
|
+
? convertArch(process.env.npm_config_arch)
|
|
31
|
+
: hostArch;
|
|
32
|
+
|
|
13
33
|
module.exports = {
|
|
34
|
+
hostArch,
|
|
35
|
+
targetArch,
|
|
14
36
|
debugBuild: !!process.env.BUILD_DEBUG,
|
|
15
37
|
isElectron: process.env.npm_config_runtime === "electron",
|
|
16
38
|
isGitRepo: isGitRepo,
|
|
@@ -2,6 +2,8 @@ var cp = require("child_process");
|
|
|
2
2
|
var fse = require("fs-extra");
|
|
3
3
|
var path = require("path");
|
|
4
4
|
|
|
5
|
+
const { hostArch, targetArch } = require("./buildFlags");
|
|
6
|
+
|
|
5
7
|
const opensslVendorDirectory = path.resolve(__dirname, "..", "vendor", "openssl");
|
|
6
8
|
const libssh2VendorDirectory = path.resolve(__dirname, "..", "vendor", "libssh2");
|
|
7
9
|
const libssh2ConfigureScript = path.join(libssh2VendorDirectory, "configure");
|
|
@@ -19,20 +21,21 @@ module.exports = function retrieveExternalDependencies() {
|
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
// Run the `configure` script on Linux
|
|
24
|
+
let cpArgs = ` --with-libssl-prefix=${opensslVendorDirectory}`;
|
|
25
|
+
|
|
26
|
+
const archConfigMap = {
|
|
27
|
+
'x64': 'x86_64-linux-gnu',
|
|
28
|
+
'arm64': 'aarch64-linux-gnu'
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
cpArgs += ` --build=${archConfigMap[hostArch]}`;
|
|
32
|
+
cpArgs += ` --host=${archConfigMap[targetArch]}`;
|
|
33
|
+
|
|
22
34
|
return new Promise(function(resolve, reject) {
|
|
23
|
-
var newEnv = {};
|
|
24
|
-
Object.keys(process.env).forEach(function(key) {
|
|
25
|
-
newEnv[key] = process.env[key];
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
let cpArgs = process.env.NODEGIT_OPENSSL_STATIC_LINK === '1'
|
|
29
|
-
? ` --with-libssl-prefix=${opensslVendorDirectory}`
|
|
30
|
-
: '';
|
|
31
35
|
cp.exec(
|
|
32
36
|
`${libssh2ConfigureScript}${cpArgs}`,
|
|
33
37
|
{
|
|
34
|
-
cwd: libssh2VendorDirectory
|
|
35
|
-
env: newEnv
|
|
38
|
+
cwd: libssh2VendorDirectory
|
|
36
39
|
},
|
|
37
40
|
function(err, stdout, stderr) {
|
|
38
41
|
if (err) {
|
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
const targetSpecified = process.argv[2] !== 'none';
|
|
2
2
|
|
|
3
|
-
let
|
|
3
|
+
let cxxStandard = '14';
|
|
4
|
+
|
|
4
5
|
if (targetSpecified) {
|
|
5
|
-
//
|
|
6
|
+
// --target= is used by both prebuildify (Node version) and electron-rebuild
|
|
7
|
+
// (Electron version). Node 24+ ships V8 13.x which requires C++20 for the
|
|
8
|
+
// `requires` clauses in v8-persistent-handle.h; Electron 32+ similarly needs
|
|
9
|
+
// C++20. Anything older falls back to C++17.
|
|
6
10
|
// If building node 18 / 19 via target, will need to specify C++ standard manually
|
|
7
11
|
const majorVersion = process.argv[2].split('.')[0];
|
|
8
|
-
|
|
12
|
+
if (Number.parseInt(majorVersion) >= 32) {
|
|
13
|
+
cxxStandard = '20';
|
|
14
|
+
} else if (Number.parseInt(majorVersion) >= 24) {
|
|
15
|
+
cxxStandard = '20';
|
|
16
|
+
} else if (Number.parseInt(majorVersion) >= 21) {
|
|
17
|
+
cxxStandard = '17';
|
|
18
|
+
}
|
|
9
19
|
} else {
|
|
20
|
+
const abiVersion = Number.parseInt(process.versions.modules) ?? 0;
|
|
10
21
|
// Node 18 === 108
|
|
11
|
-
|
|
22
|
+
if (abiVersion >= 131) {
|
|
23
|
+
cxxStandard = '20';
|
|
24
|
+
} else if (abiVersion >= 108) {
|
|
25
|
+
cxxStandard = '17';
|
|
26
|
+
}
|
|
12
27
|
}
|
|
13
28
|
|
|
14
|
-
|
|
15
|
-
? '17'
|
|
16
|
-
: '14';
|
|
17
|
-
|
|
18
|
-
process.stdout.write(defaultCxxStandard);
|
|
29
|
+
process.stdout.write(cxxStandard);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import aws from 'aws-sdk';
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
import pkgJson from '../package.json' with { type: "json" };
|
|
6
|
+
import { getOpenSSLPackagePath, getOpenSSLPackageName } from './acquireOpenSSL.mjs';
|
|
7
|
+
|
|
8
|
+
const s3 = new aws.S3();
|
|
9
|
+
|
|
10
|
+
const uploadBinaryToS3 = (fileName, bucketName, pathToFile) =>
|
|
11
|
+
s3.upload({
|
|
12
|
+
Body: fs.createReadStream(pathToFile),
|
|
13
|
+
Bucket: bucketName,
|
|
14
|
+
Key: fileName,
|
|
15
|
+
ACL: "public-read"
|
|
16
|
+
}).promise();
|
|
17
|
+
|
|
18
|
+
export const uploadOpenSSL = async () => {
|
|
19
|
+
const packageName = path.basename(getOpenSSLPackageName());
|
|
20
|
+
const packagePath = getOpenSSLPackagePath();
|
|
21
|
+
console.log(`Uploading ${packagePath} to s3://${pkgJson.binary.bucket_name}/${packageName}`);
|
|
22
|
+
await uploadBinaryToS3(packageName, pkgJson.binary.bucket_name, packagePath);
|
|
23
|
+
const sha256PackageName = `${packageName}.sha256`;
|
|
24
|
+
await uploadBinaryToS3(sha256PackageName, pkgJson.binary.bucket_name, `${packagePath}.sha256`);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
if (process.argv[1] === import.meta.filename) {
|
|
28
|
+
uploadOpenSSL().catch((error) => {
|
|
29
|
+
console.error('Push to S3 failed: ', error);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
var buildFlags = require("../utils/buildFlags");
|
|
2
|
-
|
|
3
|
-
module.exports = async function install() {
|
|
4
|
-
console.log("[nodegit] Running install script");
|
|
5
|
-
|
|
6
|
-
var args = ["install"];
|
|
7
|
-
|
|
8
|
-
if (buildFlags.mustBuild) {
|
|
9
|
-
console.info(
|
|
10
|
-
"[nodegit] Pre-built download disabled, building from source.",
|
|
11
|
-
);
|
|
12
|
-
args.push("--build-from-source");
|
|
13
|
-
|
|
14
|
-
if (buildFlags.debugBuild) {
|
|
15
|
-
console.info("[nodegit] Building debug version.");
|
|
16
|
-
args.push("--debug");
|
|
17
|
-
}
|
|
18
|
-
} else {
|
|
19
|
-
args.push("--fallback-to-build");
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
// Called on the command line
|
|
26
|
-
if (require.main === module) {
|
|
27
|
-
module.exports().catch(function (e) {
|
|
28
|
-
console.error("[nodegit] ERROR - Could not finish install");
|
|
29
|
-
console.error("[nodegit] ERROR - finished with error code: " + e);
|
|
30
|
-
process.exit(e);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
Binary file
|