Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(v8): support non-relative paths in V8 DEPS #471

Merged
merged 1 commit into from
Aug 13, 2020
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 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
11 changes: 8 additions & 3 deletions lib/update-v8/majorUpdate.js
Original file line number Diff line number Diff line change
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,12 @@ function updateV8Deps() {
title: 'Update V8 DEPS',
task: async(ctx) => {
const newV8Version = getNodeV8Version(ctx.nodeDir);
const deps = filterForVersion(v8Deps, newV8Version);
const repoPrefix = newV8Version.majorMinor >= 86 ? '' : 'v8/';
const deps = filterForVersion(v8Deps.map((v8Dep) => ({
...v8Dep,
repo: `${repoPrefix}${v8Dep.repo}`,
path: v8Dep.repo
})), newV8Version);
if (deps.length === 0) return;
/* eslint-disable no-await-in-loop */
for (const dep of deps) {
Expand All @@ -113,7 +118,7 @@ function updateV8Deps() {
}
}
const [repo, commit] = await readDeps(ctx.nodeDir, dep.repo);
const thePath = path.join(ctx.nodeDir, 'deps/v8', dep.repo);
const thePath = path.join(ctx.nodeDir, 'deps/v8', dep.path);
await fetchFromGit(thePath, repo, commit);
}
/* eslint-enable */
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