Skip to content

Commit 3693aaf

Browse files
committed
git-node v8: remove eu-strip during major upgrades
Ref: nodejs/node#20304
1 parent d6ce6dc commit 3693aaf

File tree

3 files changed

+81
-20
lines changed

3 files changed

+81
-20
lines changed

lib/update-v8/applyNodeChanges.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
'use strict';
2+
3+
const path = require('path');
4+
5+
const fs = require('fs-extra');
6+
const Listr = require('listr');
7+
8+
const {
9+
getNodeV8Version,
10+
filterForVersion,
11+
replaceGitignore
12+
} = require('./util');
13+
14+
const nodeChanges = [
15+
{
16+
since: 66,
17+
task: removeEuStrip
18+
}
19+
];
20+
21+
function applyNodeChanges() {
22+
return {
23+
title: 'Apply Node-specific changes',
24+
task: (ctx) => {
25+
const v8Version = getNodeV8Version(ctx.nodeDir);
26+
const list = filterForVersion(nodeChanges, v8Version);
27+
return new Listr(list.map((change) => change.task()));
28+
}
29+
};
30+
}
31+
32+
// Ref: https://github.com/nodejs/node/pull/20304
33+
function removeEuStrip() {
34+
return {
35+
title: 'Remove eu-strip binary',
36+
task: async(ctx) => {
37+
await replaceGitignore(ctx.nodeDir, {
38+
match: '!/third_party/eu-strip\n',
39+
replace: ''
40+
});
41+
await fs.remove(path.join(ctx.nodeDir, 'deps/v8/third_party/eu-strip'));
42+
}
43+
};
44+
}
45+
46+
module.exports = applyNodeChanges;

lib/update-v8/majorUpdate.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ const Listr = require('listr');
88
const mkdirp = require('mkdirp');
99

1010
const common = require('./common');
11-
const util = require('./util');
11+
const {
12+
getNodeV8Version,
13+
filterForVersion,
14+
addToGitignore,
15+
replaceGitignore
16+
} = require('./util');
1217
const {
1318
moveGypfilesOut,
1419
moveGypfilesIn,
1520
updateGypfiles
1621
} = require('./gypfiles');
17-
const { chromiumGit } = require('./constants');
22+
const applyNodeChanges = require('./applyNodeChanges');
23+
const { chromiumGit, v8Deps } = require('./constants');
1824

1925
module.exports = function() {
2026
return {
@@ -28,6 +34,7 @@ module.exports = function() {
2834
cloneLocalV8(),
2935
removeDepsV8Git(),
3036
updateV8Deps(),
37+
applyNodeChanges(),
3138
moveGypfilesIn(),
3239
updateGypfiles()
3340
]);
@@ -102,8 +109,8 @@ function updateV8Deps() {
102109
return {
103110
title: 'Update V8 DEPS',
104111
task: async(ctx) => {
105-
const newV8Version = util.getNodeV8Version(ctx.nodeDir);
106-
const deps = util.getV8Deps(newV8Version);
112+
const newV8Version = getNodeV8Version(ctx.nodeDir);
113+
const deps = filterForVersion(v8Deps, newV8Version);
107114
if (deps.length === 0) return;
108115
/* eslint-disable no-await-in-loop */
109116
for (const dep of deps) {
@@ -123,18 +130,6 @@ function updateV8Deps() {
123130
};
124131
}
125132

126-
async function addToGitignore(nodeDir, value) {
127-
const gitignorePath = path.join(nodeDir, 'deps/v8/.gitignore');
128-
await fs.appendFile(gitignorePath, `${value}\n`);
129-
}
130-
131-
async function replaceGitignore(nodeDir, options) {
132-
const gitignorePath = path.join(nodeDir, 'deps/v8/.gitignore');
133-
let gitignore = await fs.readFile(gitignorePath, 'utf8');
134-
gitignore = gitignore.replace(options.match, options.replace);
135-
await fs.writeFile(gitignorePath, gitignore);
136-
}
137-
138133
async function readDeps(nodeDir, depName) {
139134
const depsStr = await fs.readFile(path.join(nodeDir, 'deps/v8/DEPS'), 'utf8');
140135
const start = depsStr.indexOf('deps = {');

lib/update-v8/util.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
'use strict';
22

3-
const fs = require('fs');
3+
const fs = require('fs-extra');
4+
const path = require('path');
45

56
const constants = require('./constants');
67

7-
exports.getNodeV8Version = function getNodeV8Version(cwd) {
8+
function getNodeV8Version(cwd) {
89
try {
910
const v8VersionH = fs.readFileSync(
1011
`${cwd}/deps/v8/include/v8-version.h`,
@@ -21,11 +22,30 @@ exports.getNodeV8Version = function getNodeV8Version(cwd) {
2122
}
2223
};
2324

24-
exports.getV8Deps = function getV8Deps(version) {
25+
function filterForVersion(list, version) {
2526
const major = version[0];
2627
const minor = version[1];
2728
const number = major * 10 + minor;
28-
return constants.v8Deps.filter(
29+
return list.filter(
2930
(dep) => dep.since <= number && (dep.until || Infinity) >= number
3031
);
32+
}
33+
34+
async function addToGitignore(nodeDir, value) {
35+
const gitignorePath = path.join(nodeDir, 'deps/v8/.gitignore');
36+
await fs.appendFile(gitignorePath, `${value}\n`);
37+
}
38+
39+
async function replaceGitignore(nodeDir, options) {
40+
const gitignorePath = path.join(nodeDir, 'deps/v8/.gitignore');
41+
let gitignore = await fs.readFile(gitignorePath, 'utf8');
42+
gitignore = gitignore.replace(options.match, options.replace);
43+
await fs.writeFile(gitignorePath, gitignore);
44+
}
45+
46+
module.exports = {
47+
getNodeV8Version,
48+
filterForVersion,
49+
addToGitignore,
50+
replaceGitignore
3151
};

0 commit comments

Comments
 (0)