mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
build: switch build/tsconfig.json to module: nodenext (#238426)
* build/tsconfig: switch to module: nodenext for bun compat * build: rewrite imports for nodenext compat * build: re-generate
This commit is contained in:
@@ -3,13 +3,16 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.generatePackageDeps = generatePackageDeps;
|
||||
const child_process_1 = require("child_process");
|
||||
const fs_1 = require("fs");
|
||||
const os_1 = require("os");
|
||||
const path = require("path");
|
||||
const manifests = require("../../../cgmanifest.json");
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const cgmanifest_json_1 = __importDefault(require("../../../cgmanifest.json"));
|
||||
const dep_lists_1 = require("./dep-lists");
|
||||
function generatePackageDeps(files, arch, chromiumSysroot, vscodeSysroot) {
|
||||
const dependencies = files.map(file => calculatePackageDeps(file, arch, chromiumSysroot, vscodeSysroot));
|
||||
@@ -29,7 +32,7 @@ function calculatePackageDeps(binaryPath, arch, chromiumSysroot, vscodeSysroot)
|
||||
console.error('Tried to stat ' + binaryPath + ' but failed.');
|
||||
}
|
||||
// Get the Chromium dpkg-shlibdeps file.
|
||||
const chromiumManifest = manifests.registrations.filter(registration => {
|
||||
const chromiumManifest = cgmanifest_json_1.default.registrations.filter(registration => {
|
||||
return registration.component.type === 'git' && registration.component.git.name === 'chromium';
|
||||
});
|
||||
const dpkgShlibdepsUrl = `https://raw.githubusercontent.com/chromium/chromium/${chromiumManifest[0].version}/third_party/dpkg-shlibdeps/dpkg-shlibdeps.pl`;
|
||||
@@ -52,7 +55,7 @@ function calculatePackageDeps(binaryPath, arch, chromiumSysroot, vscodeSysroot)
|
||||
}
|
||||
cmd.push(`-l${chromiumSysroot}/usr/lib`);
|
||||
cmd.push(`-L${vscodeSysroot}/debian/libxkbfile1/DEBIAN/shlibs`);
|
||||
cmd.push('-O', '-e', path.resolve(binaryPath));
|
||||
cmd.push('-O', '-e', path_1.default.resolve(binaryPath));
|
||||
const dpkgShlibdepsResult = (0, child_process_1.spawnSync)('perl', cmd, { cwd: chromiumSysroot });
|
||||
if (dpkgShlibdepsResult.status !== 0) {
|
||||
throw new Error(`dpkg-shlibdeps failed with exit code ${dpkgShlibdepsResult.status}. stderr:\n${dpkgShlibdepsResult.stderr} `);
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
import { spawnSync } from 'child_process';
|
||||
import { constants, statSync } from 'fs';
|
||||
import { tmpdir } from 'os';
|
||||
import path = require('path');
|
||||
import * as manifests from '../../../cgmanifest.json';
|
||||
import path from 'path';
|
||||
import manifests from '../../../cgmanifest.json';
|
||||
import { additionalDeps } from './dep-lists';
|
||||
import { DebianArchString } from './types';
|
||||
|
||||
|
||||
@@ -3,20 +3,23 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getVSCodeSysroot = getVSCodeSysroot;
|
||||
exports.getChromiumSysroot = getChromiumSysroot;
|
||||
const child_process_1 = require("child_process");
|
||||
const os_1 = require("os");
|
||||
const fs = require("fs");
|
||||
const https = require("https");
|
||||
const path = require("path");
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const https_1 = __importDefault(require("https"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const crypto_1 = require("crypto");
|
||||
const ansiColors = require("ansi-colors");
|
||||
const ansi_colors_1 = __importDefault(require("ansi-colors"));
|
||||
// Based on https://source.chromium.org/chromium/chromium/src/+/main:build/linux/sysroot_scripts/install-sysroot.py.
|
||||
const URL_PREFIX = 'https://msftelectronbuild.z5.web.core.windows.net';
|
||||
const URL_PATH = 'sysroots/toolchain';
|
||||
const REPO_ROOT = path.dirname(path.dirname(path.dirname(__dirname)));
|
||||
const REPO_ROOT = path_1.default.dirname(path_1.default.dirname(path_1.default.dirname(__dirname)));
|
||||
const ghApiHeaders = {
|
||||
Accept: 'application/vnd.github.v3+json',
|
||||
'User-Agent': 'VSCode Build',
|
||||
@@ -29,7 +32,7 @@ const ghDownloadHeaders = {
|
||||
Accept: 'application/octet-stream',
|
||||
};
|
||||
function getElectronVersion() {
|
||||
const npmrc = fs.readFileSync(path.join(REPO_ROOT, '.npmrc'), 'utf8');
|
||||
const npmrc = fs_1.default.readFileSync(path_1.default.join(REPO_ROOT, '.npmrc'), 'utf8');
|
||||
const electronVersion = /^target="(.*)"$/m.exec(npmrc)[1];
|
||||
const msBuildId = /^ms_build_id="(.*)"$/m.exec(npmrc)[1];
|
||||
return { electronVersion, msBuildId };
|
||||
@@ -37,11 +40,11 @@ function getElectronVersion() {
|
||||
function getSha(filename) {
|
||||
const hash = (0, crypto_1.createHash)('sha256');
|
||||
// Read file 1 MB at a time
|
||||
const fd = fs.openSync(filename, 'r');
|
||||
const fd = fs_1.default.openSync(filename, 'r');
|
||||
const buffer = Buffer.alloc(1024 * 1024);
|
||||
let position = 0;
|
||||
let bytesRead = 0;
|
||||
while ((bytesRead = fs.readSync(fd, buffer, 0, buffer.length, position)) === buffer.length) {
|
||||
while ((bytesRead = fs_1.default.readSync(fd, buffer, 0, buffer.length, position)) === buffer.length) {
|
||||
hash.update(buffer);
|
||||
position += bytesRead;
|
||||
}
|
||||
@@ -49,7 +52,7 @@ function getSha(filename) {
|
||||
return hash.digest('hex');
|
||||
}
|
||||
function getVSCodeSysrootChecksum(expectedName) {
|
||||
const checksums = fs.readFileSync(path.join(REPO_ROOT, 'build', 'checksums', 'vscode-sysroot.txt'), 'utf8');
|
||||
const checksums = fs_1.default.readFileSync(path_1.default.join(REPO_ROOT, 'build', 'checksums', 'vscode-sysroot.txt'), 'utf8');
|
||||
for (const line of checksums.split('\n')) {
|
||||
const [checksum, name] = line.split(/\s+/);
|
||||
if (name === expectedName) {
|
||||
@@ -86,22 +89,22 @@ async function fetchUrl(options, retries = 10, retryDelay = 1000) {
|
||||
});
|
||||
if (assetResponse.ok && (assetResponse.status >= 200 && assetResponse.status < 300)) {
|
||||
const assetContents = Buffer.from(await assetResponse.arrayBuffer());
|
||||
console.log(`Fetched response body buffer: ${ansiColors.magenta(`${assetContents.byteLength} bytes`)}`);
|
||||
console.log(`Fetched response body buffer: ${ansi_colors_1.default.magenta(`${assetContents.byteLength} bytes`)}`);
|
||||
if (options.checksumSha256) {
|
||||
const actualSHA256Checksum = (0, crypto_1.createHash)('sha256').update(assetContents).digest('hex');
|
||||
if (actualSHA256Checksum !== options.checksumSha256) {
|
||||
throw new Error(`Checksum mismatch for ${ansiColors.cyan(asset.url)} (expected ${options.checksumSha256}, actual ${actualSHA256Checksum}))`);
|
||||
throw new Error(`Checksum mismatch for ${ansi_colors_1.default.cyan(asset.url)} (expected ${options.checksumSha256}, actual ${actualSHA256Checksum}))`);
|
||||
}
|
||||
}
|
||||
console.log(`Verified SHA256 checksums match for ${ansiColors.cyan(asset.url)}`);
|
||||
console.log(`Verified SHA256 checksums match for ${ansi_colors_1.default.cyan(asset.url)}`);
|
||||
const tarCommand = `tar -xz -C ${options.dest}`;
|
||||
(0, child_process_1.execSync)(tarCommand, { input: assetContents });
|
||||
console.log(`Fetch complete!`);
|
||||
return;
|
||||
}
|
||||
throw new Error(`Request ${ansiColors.magenta(asset.url)} failed with status code: ${assetResponse.status}`);
|
||||
throw new Error(`Request ${ansi_colors_1.default.magenta(asset.url)} failed with status code: ${assetResponse.status}`);
|
||||
}
|
||||
throw new Error(`Request ${ansiColors.magenta('https://api.github.com')} failed with status code: ${response.status}`);
|
||||
throw new Error(`Request ${ansi_colors_1.default.magenta('https://api.github.com')} failed with status code: ${response.status}`);
|
||||
}
|
||||
finally {
|
||||
clearTimeout(timeout);
|
||||
@@ -139,21 +142,21 @@ async function getVSCodeSysroot(arch) {
|
||||
if (!checksumSha256) {
|
||||
throw new Error(`Could not find checksum for ${expectedName}`);
|
||||
}
|
||||
const sysroot = process.env['VSCODE_SYSROOT_DIR'] ?? path.join((0, os_1.tmpdir)(), `vscode-${arch}-sysroot`);
|
||||
const stamp = path.join(sysroot, '.stamp');
|
||||
const sysroot = process.env['VSCODE_SYSROOT_DIR'] ?? path_1.default.join((0, os_1.tmpdir)(), `vscode-${arch}-sysroot`);
|
||||
const stamp = path_1.default.join(sysroot, '.stamp');
|
||||
const result = `${sysroot}/${triple}/${triple}/sysroot`;
|
||||
if (fs.existsSync(stamp) && fs.readFileSync(stamp).toString() === expectedName) {
|
||||
if (fs_1.default.existsSync(stamp) && fs_1.default.readFileSync(stamp).toString() === expectedName) {
|
||||
return result;
|
||||
}
|
||||
console.log(`Installing ${arch} root image: ${sysroot}`);
|
||||
fs.rmSync(sysroot, { recursive: true, force: true });
|
||||
fs.mkdirSync(sysroot);
|
||||
fs_1.default.rmSync(sysroot, { recursive: true, force: true });
|
||||
fs_1.default.mkdirSync(sysroot);
|
||||
await fetchUrl({
|
||||
checksumSha256,
|
||||
assetName: expectedName,
|
||||
dest: sysroot
|
||||
});
|
||||
fs.writeFileSync(stamp, expectedName);
|
||||
fs_1.default.writeFileSync(stamp, expectedName);
|
||||
return result;
|
||||
}
|
||||
async function getChromiumSysroot(arch) {
|
||||
@@ -168,24 +171,24 @@ async function getChromiumSysroot(arch) {
|
||||
const sysrootDict = sysrootInfo[sysrootArch];
|
||||
const tarballFilename = sysrootDict['Tarball'];
|
||||
const tarballSha = sysrootDict['Sha256Sum'];
|
||||
const sysroot = path.join((0, os_1.tmpdir)(), sysrootDict['SysrootDir']);
|
||||
const sysroot = path_1.default.join((0, os_1.tmpdir)(), sysrootDict['SysrootDir']);
|
||||
const url = [URL_PREFIX, URL_PATH, tarballSha].join('/');
|
||||
const stamp = path.join(sysroot, '.stamp');
|
||||
if (fs.existsSync(stamp) && fs.readFileSync(stamp).toString() === url) {
|
||||
const stamp = path_1.default.join(sysroot, '.stamp');
|
||||
if (fs_1.default.existsSync(stamp) && fs_1.default.readFileSync(stamp).toString() === url) {
|
||||
return sysroot;
|
||||
}
|
||||
console.log(`Installing Debian ${arch} root image: ${sysroot}`);
|
||||
fs.rmSync(sysroot, { recursive: true, force: true });
|
||||
fs.mkdirSync(sysroot);
|
||||
const tarball = path.join(sysroot, tarballFilename);
|
||||
fs_1.default.rmSync(sysroot, { recursive: true, force: true });
|
||||
fs_1.default.mkdirSync(sysroot);
|
||||
const tarball = path_1.default.join(sysroot, tarballFilename);
|
||||
console.log(`Downloading ${url}`);
|
||||
let downloadSuccess = false;
|
||||
for (let i = 0; i < 3 && !downloadSuccess; i++) {
|
||||
fs.writeFileSync(tarball, '');
|
||||
fs_1.default.writeFileSync(tarball, '');
|
||||
await new Promise((c) => {
|
||||
https.get(url, (res) => {
|
||||
https_1.default.get(url, (res) => {
|
||||
res.on('data', (chunk) => {
|
||||
fs.appendFileSync(tarball, chunk);
|
||||
fs_1.default.appendFileSync(tarball, chunk);
|
||||
});
|
||||
res.on('end', () => {
|
||||
downloadSuccess = true;
|
||||
@@ -198,7 +201,7 @@ async function getChromiumSysroot(arch) {
|
||||
});
|
||||
}
|
||||
if (!downloadSuccess) {
|
||||
fs.rmSync(tarball);
|
||||
fs_1.default.rmSync(tarball);
|
||||
throw new Error('Failed to download ' + url);
|
||||
}
|
||||
const sha = getSha(tarball);
|
||||
@@ -209,8 +212,8 @@ async function getChromiumSysroot(arch) {
|
||||
if (proc.status) {
|
||||
throw new Error('Tarball extraction failed with code ' + proc.status);
|
||||
}
|
||||
fs.rmSync(tarball);
|
||||
fs.writeFileSync(stamp, url);
|
||||
fs_1.default.rmSync(tarball);
|
||||
fs_1.default.writeFileSync(stamp, url);
|
||||
return sysroot;
|
||||
}
|
||||
//# sourceMappingURL=install-sysroot.js.map
|
||||
@@ -5,12 +5,12 @@
|
||||
|
||||
import { spawnSync, execSync } from 'child_process';
|
||||
import { tmpdir } from 'os';
|
||||
import * as fs from 'fs';
|
||||
import * as https from 'https';
|
||||
import * as path from 'path';
|
||||
import fs from 'fs';
|
||||
import https from 'https';
|
||||
import path from 'path';
|
||||
import { createHash } from 'crypto';
|
||||
import { DebianArchString } from './types';
|
||||
import * as ansiColors from 'ansi-colors';
|
||||
import ansiColors from 'ansi-colors';
|
||||
|
||||
// Based on https://source.chromium.org/chromium/chromium/src/+/main:build/linux/sysroot_scripts/install-sysroot.py.
|
||||
const URL_PREFIX = 'https://msftelectronbuild.z5.web.core.windows.net';
|
||||
|
||||
Reference in New Issue
Block a user