Skip to content

Commit

Permalink
fix: universal build
Browse files Browse the repository at this point in the history
- Updates vscode-universal-bundler to support x64ArchFiles option
- Kerberos starts building universal binaries which should now be
  skipped from lipo step via x64ArchFiles
- Skips bundling *.mk files
  • Loading branch information
deepak1556 committed Jul 8, 2024
1 parent f4028ae commit 19fa521
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 109 deletions.
31 changes: 18 additions & 13 deletions build/darwin/create-universal-app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 19 additions & 13 deletions build/darwin/create-universal-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import * as path from 'path';
import * as fs from 'fs';
import * as minimatch from 'minimatch';
import { makeUniversalApp } from 'vscode-universal-bundler';
import { spawn } from '@malept/cross-spawn-promise';

Expand All @@ -21,26 +22,31 @@ async function main(buildDir?: string) {
const appName = product.nameLong + '.app';
const x64AppPath = path.join(buildDir, 'VSCode-darwin-x64', appName);
const arm64AppPath = path.join(buildDir, 'VSCode-darwin-arm64', appName);
const x64AsarPath = path.join(x64AppPath, 'Contents', 'Resources', 'app', 'node_modules.asar');
const arm64AsarPath = path.join(arm64AppPath, 'Contents', 'Resources', 'app', 'node_modules.asar');
const asarRelativePath = path.join('Contents', 'Resources', 'app', 'node_modules.asar');
const outAppPath = path.join(buildDir, `VSCode-darwin-${arch}`, appName);
const productJsonPath = path.resolve(outAppPath, 'Contents', 'Resources', 'app', 'product.json');

const filesToSkip = [
'**/CodeResources',
'**/Credits.rtf',
];

await makeUniversalApp({
x64AppPath,
arm64AppPath,
x64AsarPath,
arm64AsarPath,
filesToSkip: [
'Credits.rtf',
'CodeResources',
'fsevents.node',
'Info.plist', // TODO@deepak1556: regressed with 11.4.2 internal builds
'MainMenu.nib', // Generated sequence is not deterministic with Xcode 13
'.npmrc'
],
asarPath: asarRelativePath,
outAppPath,
force: true
force: true,
mergeASARs: true,
x64ArchFiles: '*/kerberos.node',
filesToSkipComparison: (file: string) => {
for (const expected of filesToSkip) {
if (minimatch(file, expected)) {
return true;
}
}
return false;
}
});

const productJson = JSON.parse(fs.readFileSync(productJsonPath, 'utf8'));
Expand Down
2 changes: 2 additions & 0 deletions build/gulpfile.vscode.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ function packageTask(platform, arch, sourceFolderName, destinationFolderName, op
'**/node-pty/lib/shared/conout.js',
'**/*.wasm',
'**/@vscode/vsce-sign/bin/*',
], [
'**/*.mk',
], 'node_modules.asar'));

let all = es.merge(
Expand Down
13 changes: 12 additions & 1 deletion build/lib/asar.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion build/lib/asar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ declare class AsarFilesystem {
insertFile(path: string, shouldUnpack: boolean, file: { stat: { size: number; mode: number } }, options: {}): Promise<void>;
}

export function createAsar(folderPath: string, unpackGlobs: string[], destFilename: string): NodeJS.ReadWriteStream {
export function createAsar(folderPath: string, unpackGlobs: string[], skipGlobs: string[], destFilename: string): NodeJS.ReadWriteStream {

const shouldUnpackFile = (file: VinylFile): boolean => {
for (let i = 0; i < unpackGlobs.length; i++) {
Expand All @@ -28,6 +28,15 @@ export function createAsar(folderPath: string, unpackGlobs: string[], destFilena
return false;
};

const shouldSkipFile = (file: VinylFile): boolean => {
for (const skipGlob of skipGlobs) {
if (minimatch(file.relative, skipGlob)) {
return true;
}
}
return false;
};

const filesystem = new Filesystem(folderPath);
const out: Buffer[] = [];

Expand Down Expand Up @@ -78,6 +87,9 @@ export function createAsar(folderPath: string, unpackGlobs: string[], destFilena
if (!file.stat.isFile()) {
throw new Error(`unknown item in stream!`);
}
if (shouldSkipFile(file)) {
return;
}
const shouldUnpack = shouldUnpackFile(file);
insertFile(file.relative, { size: file.contents.length, mode: file.stat.mode }, shouldUnpack);

Expand Down
2 changes: 1 addition & 1 deletion build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"ternary-stream": "^3.0.0",
"through2": "^4.0.2",
"tmp": "^0.2.1",
"vscode-universal-bundler": "^0.0.2",
"vscode-universal-bundler": "^0.1.0",
"workerpool": "^6.4.0",
"yauzl": "^2.10.0"
},
Expand Down
Loading

0 comments on commit 19fa521

Please sign in to comment.