electron-mksnapshot 37.2.6 → 37.3.0
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/download-mksnapshot.js +17 -6
- package/mksnapshot.js +49 -21
- package/package.json +6 -4
package/download-mksnapshot.js
CHANGED
|
@@ -5,27 +5,34 @@ const extractZip = require('extract-zip')
|
|
|
5
5
|
const versionToDownload = require('./package').version
|
|
6
6
|
let archToDownload = process.env.npm_config_arch
|
|
7
7
|
|
|
8
|
-
function download
|
|
8
|
+
function download(version) {
|
|
9
9
|
return downloadArtifact({
|
|
10
10
|
version: version,
|
|
11
11
|
artifactName: 'mksnapshot',
|
|
12
12
|
platform: process.env.npm_config_platform,
|
|
13
13
|
arch: archToDownload,
|
|
14
14
|
rejectUnauthorized: process.env.npm_config_strict_ssl === 'true',
|
|
15
|
-
quiet:
|
|
15
|
+
quiet:
|
|
16
|
+
['info', 'verbose', 'silly', 'http'].indexOf(
|
|
17
|
+
process.env.npm_config_loglevel,
|
|
18
|
+
) === -1,
|
|
16
19
|
})
|
|
17
20
|
}
|
|
18
21
|
|
|
19
|
-
async function attemptDownload
|
|
22
|
+
async function attemptDownload(version) {
|
|
20
23
|
// Fall back to latest stable if there is not a stamped version, for tests
|
|
21
24
|
if (version === '0.0.0-development') {
|
|
22
25
|
if (!process.env.ELECTRON_MKSNAPSHOT_STABLE_FALLBACK) {
|
|
23
|
-
console.log(
|
|
26
|
+
console.log(
|
|
27
|
+
'WARNING: mksnapshot in development needs the environment variable ELECTRON_MKSNAPSHOT_STABLE_FALLBACK set',
|
|
28
|
+
)
|
|
24
29
|
process.exit(1)
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
const { ElectronVersions } = require('@electron/fiddle-core')
|
|
28
|
-
const versions = await ElectronVersions.create(undefined, {
|
|
33
|
+
const versions = await ElectronVersions.create(undefined, {
|
|
34
|
+
ignoreCache: true,
|
|
35
|
+
})
|
|
29
36
|
version = versions.latestStable.version
|
|
30
37
|
}
|
|
31
38
|
|
|
@@ -36,7 +43,11 @@ async function attemptDownload (version) {
|
|
|
36
43
|
process.exit(1)
|
|
37
44
|
}
|
|
38
45
|
|
|
39
|
-
if (
|
|
46
|
+
if (
|
|
47
|
+
archToDownload &&
|
|
48
|
+
archToDownload.indexOf('arm') === 0 &&
|
|
49
|
+
process.platform !== 'darwin'
|
|
50
|
+
) {
|
|
40
51
|
archToDownload += '-x64'
|
|
41
52
|
}
|
|
42
53
|
|
package/mksnapshot.js
CHANGED
|
@@ -8,10 +8,10 @@ const workingDir = temp.mkdirSync('mksnapshot-workdir')
|
|
|
8
8
|
const crossArchDirs = [
|
|
9
9
|
'clang_x86_v8_arm',
|
|
10
10
|
'clang_x64_v8_arm64',
|
|
11
|
-
'win_clang_x64'
|
|
11
|
+
'win_clang_x64',
|
|
12
12
|
]
|
|
13
13
|
|
|
14
|
-
function getBinaryPath
|
|
14
|
+
function getBinaryPath(binary, binaryPath) {
|
|
15
15
|
if (process.platform === 'win32') {
|
|
16
16
|
return path.join(binaryPath, `${binary}.exe`)
|
|
17
17
|
} else {
|
|
@@ -21,8 +21,10 @@ function getBinaryPath (binary, binaryPath) {
|
|
|
21
21
|
|
|
22
22
|
const args = process.argv.slice(2)
|
|
23
23
|
if (args.length === 0 || args.includes('--help')) {
|
|
24
|
-
console.log(
|
|
25
|
-
'
|
|
24
|
+
console.log(
|
|
25
|
+
'Usage: mksnapshot file.js (--output_dir OUTPUT_DIR). ' +
|
|
26
|
+
'Additional mksnapshot args except for --startup_blob are supported:',
|
|
27
|
+
)
|
|
26
28
|
args.push('--help')
|
|
27
29
|
}
|
|
28
30
|
const outDirIdx = args.indexOf('--output_dir')
|
|
@@ -30,18 +32,22 @@ let outputDir = process.cwd()
|
|
|
30
32
|
let mksnapshotArgs = args
|
|
31
33
|
if (outDirIdx > -1) {
|
|
32
34
|
mksnapshotArgs = args.slice(0, outDirIdx)
|
|
33
|
-
if (args.length >=
|
|
34
|
-
outputDir = args[
|
|
35
|
-
if (args.length >
|
|
35
|
+
if (args.length >= outDirIdx + 2) {
|
|
36
|
+
outputDir = args[outDirIdx + 1]
|
|
37
|
+
if (args.length > outDirIdx + 2) {
|
|
36
38
|
mksnapshotArgs = mksnapshotArgs.concat(args.slice(outDirIdx + 2))
|
|
37
39
|
}
|
|
38
40
|
} else {
|
|
39
|
-
console.log(
|
|
41
|
+
console.log(
|
|
42
|
+
'Error! Output directory argument given but directory not specified.',
|
|
43
|
+
)
|
|
40
44
|
process.exit(1)
|
|
41
45
|
}
|
|
42
46
|
}
|
|
43
47
|
if (args.includes('--startup_blob')) {
|
|
44
|
-
console.log(
|
|
48
|
+
console.log(
|
|
49
|
+
'--startup_blob argument not supported. Use --output_dir to specify where to output snapshot_blob.bin',
|
|
50
|
+
)
|
|
45
51
|
process.exit(1)
|
|
46
52
|
}
|
|
47
53
|
|
|
@@ -60,16 +66,26 @@ if (fs.existsSync(argsFile)) {
|
|
|
60
66
|
const newlineRegEx = /(\r\n|\r|\n)/g
|
|
61
67
|
const turboProfileRegEx = /--turbo-profiling/g
|
|
62
68
|
const builtinsRegEx = /.*builtins-pgo.*/g
|
|
63
|
-
const mksnapshotArgsFromFile = mksnapshotArgsFile
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
const mksnapshotArgsFromFile = mksnapshotArgsFile
|
|
70
|
+
.split(newlineRegEx)
|
|
71
|
+
.filter((arg) => {
|
|
72
|
+
return (
|
|
73
|
+
!arg.match(newlineRegEx) &&
|
|
74
|
+
!arg.match(turboProfileRegEx) &&
|
|
75
|
+
!arg.match(builtinsRegEx) &&
|
|
76
|
+
arg !== ''
|
|
77
|
+
)
|
|
78
|
+
})
|
|
66
79
|
const mksnapshotBinaryPath = path.parse(mksnapshotArgsFromFile[0])
|
|
67
80
|
if (mksnapshotBinaryPath.dir) {
|
|
68
81
|
mksnapshotBinaryDir = path.join(workingDir, mksnapshotBinaryPath.dir)
|
|
69
82
|
}
|
|
70
83
|
mksnapshotArgs = mksnapshotArgs.concat(mksnapshotArgsFromFile.slice(1))
|
|
71
84
|
} else {
|
|
72
|
-
mksnapshotArgs = mksnapshotArgs.concat([
|
|
85
|
+
mksnapshotArgs = mksnapshotArgs.concat([
|
|
86
|
+
'--startup_blob',
|
|
87
|
+
'snapshot_blob.bin',
|
|
88
|
+
])
|
|
73
89
|
if (!mksnapshotArgs.includes('--turbo_instruction_scheduling')) {
|
|
74
90
|
mksnapshotArgs.push('--turbo_instruction_scheduling')
|
|
75
91
|
}
|
|
@@ -92,7 +108,7 @@ if (fs.existsSync(argsFile)) {
|
|
|
92
108
|
const options = {
|
|
93
109
|
cwd: mksnapshotBinaryDir,
|
|
94
110
|
env: process.env,
|
|
95
|
-
stdio: 'inherit'
|
|
111
|
+
stdio: 'inherit',
|
|
96
112
|
}
|
|
97
113
|
|
|
98
114
|
const mksnapshotCommand = getBinaryPath('mksnapshot', mksnapshotBinaryDir)
|
|
@@ -109,10 +125,15 @@ if (args.includes('--help')) {
|
|
|
109
125
|
process.exit(0)
|
|
110
126
|
}
|
|
111
127
|
|
|
112
|
-
fs.copyFileSync(
|
|
113
|
-
path.join(
|
|
128
|
+
fs.copyFileSync(
|
|
129
|
+
path.join(mksnapshotBinaryDir, 'snapshot_blob.bin'),
|
|
130
|
+
path.join(outputDir, 'snapshot_blob.bin'),
|
|
131
|
+
)
|
|
114
132
|
|
|
115
|
-
const v8ContextGenCommand = getBinaryPath(
|
|
133
|
+
const v8ContextGenCommand = getBinaryPath(
|
|
134
|
+
'v8_context_snapshot_generator',
|
|
135
|
+
mksnapshotBinaryDir,
|
|
136
|
+
)
|
|
116
137
|
let v8ContextFile = 'v8_context_snapshot.bin'
|
|
117
138
|
if (process.platform === 'darwin') {
|
|
118
139
|
const targetArch = process.env.npm_config_arch || process.arch
|
|
@@ -123,17 +144,24 @@ if (process.platform === 'darwin') {
|
|
|
123
144
|
}
|
|
124
145
|
}
|
|
125
146
|
const v8ContextGenArgs = [
|
|
126
|
-
`--output_file=${path.join(outputDir, v8ContextFile)}
|
|
147
|
+
`--output_file=${path.join(outputDir, v8ContextFile)}`,
|
|
127
148
|
]
|
|
128
149
|
|
|
129
150
|
const v8ContextGenOptions = {
|
|
130
151
|
cwd: mksnapshotDir,
|
|
131
152
|
env: process.env,
|
|
132
|
-
stdio: 'inherit'
|
|
153
|
+
stdio: 'inherit',
|
|
133
154
|
}
|
|
134
|
-
const v8ContextGenProcess = spawnSync(
|
|
155
|
+
const v8ContextGenProcess = spawnSync(
|
|
156
|
+
v8ContextGenCommand,
|
|
157
|
+
v8ContextGenArgs,
|
|
158
|
+
v8ContextGenOptions,
|
|
159
|
+
)
|
|
135
160
|
if (v8ContextGenProcess.status !== 0) {
|
|
136
|
-
console.log(
|
|
161
|
+
console.log(
|
|
162
|
+
'Error running the v8 context snapshot generator.',
|
|
163
|
+
v8ContextGenProcess,
|
|
164
|
+
)
|
|
137
165
|
process.exit(v8ContextGenProcess.status)
|
|
138
166
|
}
|
|
139
167
|
process.exit(0)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "electron-mksnapshot",
|
|
3
|
-
"version": "37.
|
|
3
|
+
"version": "37.3.0",
|
|
4
4
|
"description": "Electron version of the mksnapshot binary",
|
|
5
5
|
"repository": "https://github.com/electron/mksnapshot",
|
|
6
6
|
"bin": {
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"mksnapshot": "node ./mksnapshot.js",
|
|
15
15
|
"install": "node ./download-mksnapshot.js",
|
|
16
|
-
"
|
|
16
|
+
"prettier": "prettier --single-quote --no-semi --check \"**/*.js\"",
|
|
17
|
+
"prettier:write": "prettier --single-quote --no-semi --write \"**/*.js\"",
|
|
18
|
+
"test": "mocha && npm run prettier"
|
|
17
19
|
},
|
|
18
20
|
"license": "MIT",
|
|
19
21
|
"dependencies": {
|
|
@@ -26,8 +28,8 @@
|
|
|
26
28
|
"@continuous-auth/client": "^2.3.0",
|
|
27
29
|
"@electron/fiddle-core": "^1.3.0",
|
|
28
30
|
"mocha": "^10.1.0",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
+
"prettier": "^3.6.2",
|
|
32
|
+
"semver": "^7.3.8"
|
|
31
33
|
},
|
|
32
34
|
"standard": {
|
|
33
35
|
"ignore": [
|