-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Expand file tree
/
Copy pathgulpfile.scan.ts
More file actions
130 lines (106 loc) · 4.11 KB
/
Copy pathgulpfile.scan.ts
File metadata and controls
130 lines (106 loc) · 4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { gulp, filter } from './lib/gulp/facade.ts';
import * as path from 'path';
import * as task from './lib/gulp/task.ts';
import * as util from './lib/util.ts';
import electron from '@vscode/gulp-electron';
import { config } from './lib/electron.ts';
import * as deps from './lib/dependencies.ts';
import { existsSync, readdirSync } from 'fs';
const root = path.dirname(import.meta.dirname);
const BUILD_TARGETS = [
{ platform: 'win32', arch: 'x64' },
{ platform: 'win32', arch: 'arm64' },
{ platform: 'darwin', arch: null, opts: { stats: true } },
{ platform: 'linux', arch: 'x64' },
{ platform: 'linux', arch: 'armhf' },
{ platform: 'linux', arch: 'arm64' },
];
// The following files do not have PDBs downloaded for them during the download symbols process.
const excludedCheckList = [
'd3dcompiler_47.dll',
'dxil.dll',
'dxcompiler.dll',
];
BUILD_TARGETS.forEach(buildTarget => {
const dashed = (str: string | null) => (str ? `-${str}` : ``);
const platform = buildTarget.platform;
const arch = buildTarget.arch;
const destinationExe = path.join(path.dirname(root), 'scanbin', `VSCode${dashed(platform)}${dashed(arch)}`, 'bin');
const destinationPdb = path.join(path.dirname(root), 'scanbin', `VSCode${dashed(platform)}${dashed(arch)}`, 'pdb');
const tasks: task.Task[] = [];
// removal tasks
tasks.push(util.rimraf(destinationExe), util.rimraf(destinationPdb));
// electron
tasks.push(() => electron.dest(destinationExe, { ...config, platform, arch: arch === 'armhf' ? 'arm' : arch }));
// pdbs for windows
if (platform === 'win32') {
tasks.push(
() => electron.dest(destinationPdb, { ...config, platform, arch: arch === 'armhf' ? 'arm' : arch, pdbs: true }),
() => confirmPdbsExist(destinationExe, destinationPdb)
);
}
if (platform === 'linux') {
tasks.push(
() => electron.dest(destinationPdb, { ...config, platform, arch: arch === 'armhf' ? 'arm' : arch, symbols: true })
);
}
// node modules
tasks.push(
nodeModules(destinationExe, destinationPdb, platform)
);
const setupSymbolsTask = task.define(`vscode-symbols${dashed(platform)}${dashed(arch)}`,
task.series(...tasks)
);
task.task(setupSymbolsTask);
});
function getProductionDependencySources() {
const productionDependencies = deps.getProductionDependencies(root);
return productionDependencies.map(d => path.relative(root, d)).map(d => [`${d}/**`, `!${d}/**/{test,tests}/**`]).flat();
}
function nodeModules(destinationExe: string, destinationPdb: string, platform: string): task.CallbackTask {
const exe = () => {
return gulp.src(getProductionDependencySources(), { base: '.', dot: true })
.pipe(filter([
'**/*.node',
// Exclude these paths.
// We don't build the prebuilt node files so we don't scan them
'!**/prebuilds/**/*.node'
]))
.pipe(gulp.dest(destinationExe));
};
if (platform === 'win32') {
const pdb = () => {
return gulp.src(getProductionDependencySources(), { base: '.', dot: true })
.pipe(filter(['**/*.pdb']))
.pipe(gulp.dest(destinationPdb));
};
return task.parallel(exe, pdb) as task.CallbackTask;
}
if (platform === 'linux') {
const pdb = () => {
return gulp.src(getProductionDependencySources(), { base: '.', dot: true })
.pipe(filter(['**/*.sym']))
.pipe(gulp.dest(destinationPdb));
};
return task.parallel(exe, pdb) as task.CallbackTask;
}
return exe;
}
function confirmPdbsExist(destinationExe: string, destinationPdb: string) {
readdirSync(destinationExe).forEach(file => {
if (excludedCheckList.includes(file)) {
return;
}
if (file.endsWith('.dll') || file.endsWith('.exe')) {
const pdb = `${file}.pdb`;
if (!existsSync(path.join(destinationPdb, pdb))) {
throw new Error(`Missing pdb file for ${file}. Tried searching for ${pdb} in ${destinationPdb}.`);
}
}
});
return Promise.resolve();
}