Reduce runtime changes

This commit is contained in:
Matt Bierner 2025-11-21 15:50:54 -08:00
parent fcfb37c8f8
commit ac71e4f6ad
No known key found for this signature in database
GPG Key ID: 87BD15F7203A4CF2
6 changed files with 37 additions and 30 deletions

View File

@ -13,14 +13,11 @@ import { tmpdir } from 'os';
import { existsSync, mkdirSync, rmSync } from 'fs';
import * as task from './lib/task.ts';
import watcher from './lib/watch/index.ts';
import * as utilModule from './lib/util.ts';
import * as reporterModule from './lib/reporter.ts';
import { debounce } from './lib/util.ts';
import { createReporter } from './lib/reporter.ts';
import untar from 'gulp-untar';
import gunzip from 'gulp-gunzip';
const { debounce } = utilModule;
const { createReporter } = reporterModule;
const root = 'cli';
const rootAbs = path.resolve(import.meta.dirname, '..', root);
const src = `${root}/src`;
@ -103,7 +100,7 @@ const acquireBuiltOpenSSL = (callback: (err?: unknown) => void) => {
const compileWithOpenSSLCheck = (reporter: import('./lib/reporter.ts').IReporter) => es.map((_, callback) => {
compileFromSources(err => {
if (!err) {
callback();
// no-op
} else if (err.toString().includes('Could not find directory of OpenSSL installation') && !existsSync(platformOpensslDir)) {
fancyLog(ansiColors.yellow(`[cli]`), 'OpenSSL libraries not found, acquiring prebuilt bits...');
acquireBuiltOpenSSL(err => {
@ -114,14 +111,14 @@ const compileWithOpenSSLCheck = (reporter: import('./lib/reporter.ts').IReporter
if (err) {
reporter(err.toString());
}
callback();
callback(undefined, '');
});
}
});
} else {
reporter(err.toString());
callback();
}
callback(undefined, '');
});
});
@ -143,14 +140,8 @@ const compileCliTask = task.define('compile-cli', () => {
const watchCliTask = task.define('watch-cli', () => {
warnIfRustNotInstalled();
const compile = () => {
const reporter = createReporter('cli');
return gulp.src(`${root}/Cargo.toml`)
.pipe(compileWithOpenSSLCheck(reporter))
.pipe(reporter.end(true));
};
return watcher(`${src}/**`, { read: false })
.pipe(debounce(compile));
.pipe(debounce(compileCliTask as task.StreamTask));
});
gulp.task(compileCliTask);

View File

@ -184,7 +184,8 @@ BUILD_TARGETS.forEach(({ platform, arch }) => {
const defaultNodeTask = gulp.task(`node-${process.platform}-${process.arch}`);
if (defaultNodeTask) {
gulp.task(task.define('node', () => defaultNodeTask));
// eslint-disable-next-line local/code-no-any-casts
gulp.task(task.define('node', defaultNodeTask as any));
}
function nodejs(platform: string, arch: string): NodeJS.ReadWriteStream | undefined {
@ -309,7 +310,7 @@ function packageTask(type: string, platform: string, arch: string, sourceFolderN
const name = product.nameShort;
let packageJsonContents: string = '';
let packageJsonContents = '';
const packageJsonStream = gulp.src(['remote/package.json'], { base: 'remote' })
.pipe(jsonEditor({ name, version, dependencies: undefined, optionalDependencies: undefined, type: 'module' }))
.pipe(es.through(function (file) {
@ -317,7 +318,7 @@ function packageTask(type: string, platform: string, arch: string, sourceFolderN
this.emit('data', file);
}));
let productJsonContents: string = '';
let productJsonContents = '';
const productJsonStream = gulp.src(['product.json'], { base: '.' })
.pipe(jsonEditor({ commit, date: readISODate('out-build'), version }))
.pipe(es.through(function (file) {
@ -420,6 +421,9 @@ function packageTask(type: string, platform: string, arch: string, sourceFolderN
};
}
/**
* @param product The parsed product.json file contents
*/
function tweakProductForServerWeb(product: typeof import('../product.json')) {
const result: typeof product & { webEndpointUrlTemplate?: string } = { ...product };
delete result.webEndpointUrlTemplate;
@ -463,13 +467,7 @@ function tweakProductForServerWeb(product: typeof import('../product.json')) {
const serverTaskCI = task.define(`vscode-${type}${dashed(platform)}${dashed(arch)}${dashed(minified)}-ci`, task.series(
compileNativeExtensionsBuildTask,
() => {
const nodeTask = gulp.task(`node-${platform}-${arch}`) as task.CallbackTask;
if (nodeTask) {
return nodeTask();
}
return Promise.resolve();
},
gulp.task(`node-${platform}-${arch}`) as task.Task,
util.rimraf(path.join(BUILD_ROOT, destinationFolderName)),
packageTask(type, platform, arch, sourceFolderName, destinationFolderName)
));

View File

@ -14,7 +14,6 @@ import * as deps from './lib/dependencies.ts';
import { existsSync, readdirSync } from 'fs';
const { config } = electronConfigModule;
const electronDest = (electron as unknown as { dest: (destination: string, options: unknown) => NodeJS.ReadWriteStream }).dest;
const root = path.dirname(import.meta.dirname);
@ -48,19 +47,19 @@ BUILD_TARGETS.forEach(buildTarget => {
tasks.push(util.rimraf(destinationExe), util.rimraf(destinationPdb));
// electron
tasks.push(() => electronDest(destinationExe, { ...config, platform, arch: arch === 'armhf' ? 'arm' : arch }));
tasks.push(() => electron.dest(destinationExe, { ...config, platform, arch: arch === 'armhf' ? 'arm' : arch }));
// pdbs for windows
if (platform === 'win32') {
tasks.push(
() => electronDest(destinationPdb, { ...config, platform, arch: arch === 'armhf' ? 'arm' : arch, pdbs: true }),
() => electron.dest(destinationPdb, { ...config, platform, arch: arch === 'armhf' ? 'arm' : arch, pdbs: true }),
() => confirmPdbsExist(destinationExe, destinationPdb)
);
}
if (platform === 'linux') {
tasks.push(
() => electronDest(destinationPdb, { ...config, platform, arch: arch === 'armhf' ? 'arm' : arch, symbols: true })
() => electron.dest(destinationPdb, { ...config, platform, arch: arch === 'armhf' ? 'arm' : arch, symbols: true })
);
}

View File

@ -179,6 +179,10 @@ gulp.task(coreCIPR);
/**
* Compute checksums for some files.
*
* @param out The out folder to read the file from.
* @param filenames The paths to compute a checksum for.
* @return A map of paths to checksums.
*/
function computeChecksums(out: string, filenames: string[]): Record<string, string> {
const result: Record<string, string> = {};
@ -191,6 +195,9 @@ function computeChecksums(out: string, filenames: string[]): Record<string, stri
/**
* Compute checksums for a file.
*
* @param filename The absolute path to a filename.
* @return The checksum for `filename`.
*/
function computeChecksum(filename: string): string {
const contents = fs.readFileSync(filename);

View File

@ -85,6 +85,10 @@ const vscodeWebEntryPoints = [
buildfile.entrypoint('vs/workbench/workbench.web.main.internal') // TODO@esm remove line when we stop supporting web-amd-esm-bridge
].flat();
/**
* @param extensionsRoot {string} The location where extension will be read from
* @param product The parsed product.json file contents
*/
export const createVSCodeWebFileContentMapper = (extensionsRoot: string, product: typeof import('../product.json')) => {
return (path: string): ((content: string) => string) | undefined => {
if (path.endsWith('vs/platform/product/common/product.js')) {

View File

@ -1,3 +1,11 @@
declare module '@vscode/gulp-electron' {
export default function electron(options: any): NodeJS.ReadWriteStream;
interface MainFunction {
(options: any): NodeJS.ReadWriteStream;
dest(destination: string, options: any): NodeJS.ReadWriteStream;
}
const main: MainFunction;
export default main;
}