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