Skip to content

Commit 746e5e5

Browse files
authored
fix(v8): support non-relative paths in V8 DEPS (#471)
V8 versions < 8.6 do not specify a relative path in the DEPS file. Fixes: nodejs/node-v8#166 Refs: v8/v8@56bf834 Refs: 57b7df8
1 parent 57b7df8 commit 746e5e5

File tree

6 files changed

+35
-22
lines changed

6 files changed

+35
-22
lines changed

lib/update-v8/backport.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ function incrementV8Version() {
216216
return {
217217
title: 'Increment V8 version',
218218
task: async(ctx) => {
219-
const incremented = ++ctx.currentVersion[3];
219+
const incremented = ++ctx.currentVersion.patch;
220220
const versionHPath = `${ctx.nodeDir}/deps/v8/include/v8-version.h`;
221221
let versionH = await fs.readFile(versionHPath, 'utf8');
222222
versionH = versionH.replace(

lib/update-v8/commitUpdate.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ module.exports = function() {
66
return {
77
title: 'Commit V8 update',
88
task: async(ctx) => {
9-
const newV8Version = util.getNodeV8Version(ctx.nodeDir).join('.');
9+
const newV8Version = util.getNodeV8Version(ctx.nodeDir);
1010
await ctx.execGitNode('add', ['deps/v8']);
1111
const moreArgs = [];
1212
let message;
1313
if (ctx.minor) {
14-
const prev = ctx.currentVersion.join('.');
14+
const prev = ctx.currentVersion.toString();
1515
const next = ctx.latestVersion.join('.');
1616
moreArgs.push(
1717
'-m',

lib/update-v8/majorUpdate.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function checkoutBranch() {
5858
ctx.branch = version;
5959
}
6060
}
61-
if (version === ctx.currentVersion.join('.')) {
61+
if (version === ctx.currentVersion.toString()) {
6262
throw new Error(`Current version is already ${version}`);
6363
}
6464
ctx.newVersion = version.split('.').map((s) => parseInt(s, 10));
@@ -101,7 +101,12 @@ function updateV8Deps() {
101101
title: 'Update V8 DEPS',
102102
task: async(ctx) => {
103103
const newV8Version = getNodeV8Version(ctx.nodeDir);
104-
const deps = filterForVersion(v8Deps, newV8Version);
104+
const repoPrefix = newV8Version.majorMinor >= 86 ? '' : 'v8/';
105+
const deps = filterForVersion(v8Deps.map((v8Dep) => ({
106+
...v8Dep,
107+
repo: `${repoPrefix}${v8Dep.repo}`,
108+
path: v8Dep.repo
109+
})), newV8Version);
105110
if (deps.length === 0) return;
106111
/* eslint-disable no-await-in-loop */
107112
for (const dep of deps) {
@@ -113,7 +118,7 @@ function updateV8Deps() {
113118
}
114119
}
115120
const [repo, commit] = await readDeps(ctx.nodeDir, dep.repo);
116-
const thePath = path.join(ctx.nodeDir, 'deps/v8', dep.repo);
121+
const thePath = path.join(ctx.nodeDir, 'deps/v8', dep.path);
117122
await fetchFromGit(thePath, repo, commit);
118123
}
119124
/* eslint-enable */

lib/update-v8/minorUpdate.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ function getLatestV8Version() {
2525
return {
2626
title: 'Get latest V8 version',
2727
task: async(ctx) => {
28-
const currentV8Tag = ctx.currentVersion.slice(0, 3).join('.');
28+
const version = ctx.currentVersion;
29+
const currentV8Tag = `${version.major}.${version.minor}.${version.build}`;
2930
const result = await execa('git', ['tag', '-l', `${currentV8Tag}.*`], {
3031
cwd: ctx.v8Dir,
3132
encoding: 'utf8'
@@ -48,7 +49,7 @@ function minorUpdate() {
4849
return doMinorUpdate(ctx, latestStr);
4950
},
5051
skip: (ctx) => {
51-
if (ctx.currentVersion[3] >= ctx.latestVersion[3]) {
52+
if (ctx.currentVersion.patch >= ctx.latestVersion[3]) {
5253
ctx.skipped = 'V8 is up-to-date';
5354
return ctx.skipped;
5455
}
@@ -58,10 +59,9 @@ function minorUpdate() {
5859
}
5960

6061
async function doMinorUpdate(ctx, latestStr) {
61-
const currentStr = ctx.currentVersion.join('.');
6262
const { stdout: diff } = await execa(
6363
'git',
64-
['format-patch', '--stdout', `${currentStr}...${latestStr}`],
64+
['format-patch', '--stdout', `${ctx.currentVersion}...${latestStr}`],
6565
{ cwd: ctx.v8Dir, encoding: 'utf8' }
6666
);
6767
try {

lib/update-v8/updateVersionNumbers.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function bumpNodeModule() {
2626
v8Version,
2727
ctx.nodeMajorVersion
2828
);
29-
await updateModuleVersion(ctx.nodeDir, newModuleVersion, v8Version);
29+
await updateModuleVersion(ctx.nodeDir, newModuleVersion);
3030
await ctx.execGitNode(
3131
'add',
3232
['doc/abi_version_registry.json', 'src/node_version.h']
@@ -56,7 +56,7 @@ async function updateModuleVersionRegistry(
5656
const newVersion = registry.NODE_MODULE_VERSION[0].modules + 1;
5757
const newLine =
5858
`{ "modules": ${newVersion}, "runtime": "node", ` +
59-
`"variant": "v8_${v8Version[0]}.${v8Version[1]}", ` +
59+
`"variant": "v8_${v8Version.major}.${v8Version.minor}", ` +
6060
`"versions": "${nodeMajorVersion}.0.0-pre" },\n `;
6161
const firstLineIndex = registryStr.indexOf('{ "modules"');
6262
const newRegistry =
@@ -83,8 +83,8 @@ function getCommitTitle(moduleVersion) {
8383

8484
function getCommitBody(v8Version) {
8585
return `Major V8 updates are usually API/ABI incompatible with previous
86-
versions. This commit adapts NODE_MODULE_VERSION for V8 ${v8Version[0]}.${
87-
v8Version[1]
86+
versions. This commit adapts NODE_MODULE_VERSION for V8 ${v8Version.major}.${
87+
v8Version.minor
8888
}.
8989
9090
Refs: https://github.com/nodejs/CTC/blob/master/meetings/2016-09-28.md`;

lib/update-v8/util.js

+16-8
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,28 @@ function getNodeV8Version(cwd) {
1313
const minor = parseInt(/V8_MINOR_VERSION (\d+)/.exec(v8VersionH)[1], 10);
1414
const build = parseInt(/V8_BUILD_NUMBER (\d+)/.exec(v8VersionH)[1], 10);
1515
const patch = parseInt(/V8_PATCH_LEVEL (\d+)/.exec(v8VersionH)[1], 10);
16-
if (patch === 0) return [major, minor, build];
17-
else return [major, minor, build, patch];
16+
return {
17+
major,
18+
minor,
19+
build,
20+
patch,
21+
majorMinor: major * 10 + minor,
22+
toString() {
23+
return this.patch
24+
? `${this.major}.${this.minor}.${this.build}`
25+
: `${this.major}.${this.minor}.${this.build}.${this.patch}`;
26+
}
27+
};
1828
} catch (e) {
1929
throw new Error('Could not find V8 version');
2030
}
2131
};
2232

2333
function filterForVersion(list, version) {
24-
const major = version[0];
25-
const minor = version[1];
26-
const number = major * 10 + minor;
27-
return list.filter(
28-
(dep) => dep.since <= number && (dep.until || Infinity) >= number
29-
);
34+
return list.filter((dep) => {
35+
return dep.since <= version.majorMinor &&
36+
(dep.until || Infinity) >= version.majorMinor;
37+
});
3038
}
3139

3240
async function addToGitignore(nodeDir, value) {

0 commit comments

Comments
 (0)