Skip to content

Commit

Permalink
fix(v8): support relative paths in V8 DEPS
Browse files Browse the repository at this point in the history
  • Loading branch information
targos committed Aug 4, 2020
1 parent 332576a commit 15bc3b0
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 73 deletions.
2 changes: 1 addition & 1 deletion lib/update-v8/backport.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ function incrementV8Version() {
return {
title: 'Increment V8 version',
task: async(ctx) => {
const incremented = ++ctx.currentVersion[3];
const incremented = ++ctx.currentVersion.patch;
const versionHPath = `${ctx.nodeDir}/deps/v8/include/v8-version.h`;
let versionH = await fs.readFile(versionHPath, 'utf8');
versionH = versionH.replace(
Expand Down
4 changes: 2 additions & 2 deletions lib/update-v8/commitUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ module.exports = function() {
return {
title: 'Commit V8 update',
task: async(ctx) => {
const newV8Version = util.getNodeV8Version(ctx.nodeDir).join('.');
const newV8Version = util.getNodeV8Version(ctx.nodeDir);
await ctx.execGitNode('add', ['deps/v8']);
const moreArgs = [];
let message;
if (ctx.minor) {
const prev = ctx.currentVersion.join('.');
const prev = ctx.currentVersion.toString();
const next = ctx.latestVersion.join('.');
moreArgs.push(
'-m',
Expand Down
105 changes: 54 additions & 51 deletions lib/update-v8/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,57 +31,60 @@ const zlibIgnore = `!/third_party/zlib
/third_party/zlib/contrib/tests
/third_party/zlib/google/test`;

exports.v8Deps = [
{
name: 'trace_event',
repo: 'v8/base/trace_event/common',
path: 'base/trace_event/common',
gitignore: {
match: '/base\n',
replace: ''
exports.getV8Deps = function getV8Deps({ relative }) {
const prefix = relative ? 'v8/' : '';
return [
{
name: 'trace_event',
repo: `${prefix}base/trace_event/common`,
path: 'base/trace_event/common',
gitignore: {
match: '/base\n',
replace: ''
},
since: 55
},
since: 55
},
{
name: 'gtest',
repo: 'v8/testing/gtest',
path: 'testing/gtest',
gitignore: {
match: '/testing/gtest',
replace: gtestReplace
{
name: 'gtest',
repo: `${prefix}testing/gtest`,
path: 'testing/gtest',
gitignore: {
match: '/testing/gtest',
replace: gtestReplace
},
since: 55,
until: 66
},
since: 55,
until: 66
},
{
name: 'jinja2',
repo: 'v8/third_party/jinja2',
path: 'third_party/jinja2',
gitignore: '!/third_party/jinja2',
since: 56
},
{
name: 'markupsafe',
repo: 'v8/third_party/markupsafe',
path: 'third_party/markupsafe',
gitignore: '!/third_party/markupsafe',
since: 56
},
{
name: 'googletest',
repo: 'v8/third_party/googletest/src',
path: 'third_party/googletest/src',
gitignore: {
match: '/third_party/googletest/src',
replace: googleTestReplace
{
name: 'jinja2',
repo: `${prefix}third_party/jinja2`,
path: 'third_party/jinja2',
gitignore: '!/third_party/jinja2',
since: 56
},
since: 67
},
{
name: 'zlib',
repo: 'v8/third_party/zlib',
path: 'third_party/zlib',
gitignore: zlibIgnore,
since: 80
}
];
{
name: 'markupsafe',
repo: `${prefix}third_party/markupsafe`,
path: 'third_party/markupsafe',
gitignore: '!/third_party/markupsafe',
since: 56
},
{
name: 'googletest',
repo: `${prefix}third_party/googletest/src`,
path: 'third_party/googletest/src',
gitignore: {
match: '/third_party/googletest/src',
replace: googleTestReplace
},
since: 67
},
{
name: 'zlib',
repo: `${prefix}third_party/zlib`,
path: 'third_party/zlib',
gitignore: zlibIgnore,
since: 80
}
];
};
8 changes: 5 additions & 3 deletions lib/update-v8/majorUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const {
replaceGitignore
} = require('./util');
const applyNodeChanges = require('./applyNodeChanges');
const { chromiumGit, v8Deps } = require('./constants');
const { chromiumGit, getV8Deps } = require('./constants');

module.exports = function() {
return {
Expand Down Expand Up @@ -58,7 +58,7 @@ function checkoutBranch() {
ctx.branch = version;
}
}
if (version === ctx.currentVersion.join('.')) {
if (version === ctx.currentVersion.toString()) {
throw new Error(`Current version is already ${version}`);
}
ctx.newVersion = version.split('.').map((s) => parseInt(s, 10));
Expand Down Expand Up @@ -101,7 +101,9 @@ function updateV8Deps() {
title: 'Update V8 DEPS',
task: async(ctx) => {
const newV8Version = getNodeV8Version(ctx.nodeDir);
const deps = filterForVersion(v8Deps, newV8Version);
const deps = filterForVersion(getV8Deps({
relative: newV8Version.majorMinor >= 86
}), newV8Version);
if (deps.length === 0) return;
/* eslint-disable no-await-in-loop */
for (const dep of deps) {
Expand Down
8 changes: 4 additions & 4 deletions lib/update-v8/minorUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ function getLatestV8Version() {
return {
title: 'Get latest V8 version',
task: async(ctx) => {
const currentV8Tag = ctx.currentVersion.slice(0, 3).join('.');
const version = ctx.currentVersion;
const currentV8Tag = `${version.major}.${version.minor}.${version.build}`;
const result = await execa('git', ['tag', '-l', `${currentV8Tag}.*`], {
cwd: ctx.v8Dir,
encoding: 'utf8'
Expand All @@ -48,7 +49,7 @@ function minorUpdate() {
return doMinorUpdate(ctx, latestStr);
},
skip: (ctx) => {
if (ctx.currentVersion[3] >= ctx.latestVersion[3]) {
if (ctx.currentVersion.patch >= ctx.latestVersion[3]) {
ctx.skipped = 'V8 is up-to-date';
return ctx.skipped;
}
Expand All @@ -58,10 +59,9 @@ function minorUpdate() {
}

async function doMinorUpdate(ctx, latestStr) {
const currentStr = ctx.currentVersion.join('.');
const { stdout: diff } = await execa(
'git',
['format-patch', '--stdout', `${currentStr}...${latestStr}`],
['format-patch', '--stdout', `${ctx.currentVersion}...${latestStr}`],
{ cwd: ctx.v8Dir, encoding: 'utf8' }
);
try {
Expand Down
8 changes: 4 additions & 4 deletions lib/update-v8/updateVersionNumbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function bumpNodeModule() {
v8Version,
ctx.nodeMajorVersion
);
await updateModuleVersion(ctx.nodeDir, newModuleVersion, v8Version);
await updateModuleVersion(ctx.nodeDir, newModuleVersion);
await ctx.execGitNode(
'add',
['doc/abi_version_registry.json', 'src/node_version.h']
Expand Down Expand Up @@ -56,7 +56,7 @@ async function updateModuleVersionRegistry(
const newVersion = registry.NODE_MODULE_VERSION[0].modules + 1;
const newLine =
`{ "modules": ${newVersion}, "runtime": "node", ` +
`"variant": "v8_${v8Version[0]}.${v8Version[1]}", ` +
`"variant": "v8_${v8Version.major}.${v8Version.minor}", ` +
`"versions": "${nodeMajorVersion}.0.0-pre" },\n `;
const firstLineIndex = registryStr.indexOf('{ "modules"');
const newRegistry =
Expand All @@ -83,8 +83,8 @@ function getCommitTitle(moduleVersion) {

function getCommitBody(v8Version) {
return `Major V8 updates are usually API/ABI incompatible with previous
versions. This commit adapts NODE_MODULE_VERSION for V8 ${v8Version[0]}.${
v8Version[1]
versions. This commit adapts NODE_MODULE_VERSION for V8 ${v8Version.major}.${
v8Version.minor
}.
Refs: https://github.com/nodejs/CTC/blob/master/meetings/2016-09-28.md`;
Expand Down
24 changes: 16 additions & 8 deletions lib/update-v8/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,28 @@ function getNodeV8Version(cwd) {
const minor = parseInt(/V8_MINOR_VERSION (\d+)/.exec(v8VersionH)[1], 10);
const build = parseInt(/V8_BUILD_NUMBER (\d+)/.exec(v8VersionH)[1], 10);
const patch = parseInt(/V8_PATCH_LEVEL (\d+)/.exec(v8VersionH)[1], 10);
if (patch === 0) return [major, minor, build];
else return [major, minor, build, patch];
return {
major,
minor,
build,
patch,
majorMinor: major * 10 + minor,
toString() {
return this.patch
? `${this.major}.${this.minor}.${this.build}`
: `${this.major}.${this.minor}.${this.build}.${this.patch}`;
}
};
} catch (e) {
throw new Error('Could not find V8 version');
}
};

function filterForVersion(list, version) {
const major = version[0];
const minor = version[1];
const number = major * 10 + minor;
return list.filter(
(dep) => dep.since <= number && (dep.until || Infinity) >= number
);
return list.filter((dep) => {
return dep.since <= version.majorMinor &&
(dep.until || Infinity) >= version.majorMinor;
});
}

async function addToGitignore(nodeDir, value) {
Expand Down

0 comments on commit 15bc3b0

Please sign in to comment.