mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Add Apple Silicon build and Universal build for macOS (#20776)
* use stages * fix indention * add jobs section * fix error * indention * arm64 for macos * other stages not run * fix container * fix * fix stage * skip tests * variable * dependency * fix name error * sts * const * fall back to x64 * pass in variable * universal flavor * fix universal * fix path * remove * special processing * return on error * copy instead of move * restore sts * release * fix error * Fix readme * remove commented code * add comments * add issue * update comment * pr comments * delete universal yml * update the generated js file
This commit is contained in:
@@ -10,20 +10,53 @@ const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
const plist = require("plist");
|
||||
const product = require("../../product.json");
|
||||
const glob = require("glob"); // {{SQL CARBON EDIT}}
|
||||
async function main() {
|
||||
const buildDir = process.env['AGENT_BUILDDIRECTORY'];
|
||||
const arch = process.env['VSCODE_ARCH'];
|
||||
if (!buildDir) {
|
||||
throw new Error('$AGENT_BUILDDIRECTORY not set');
|
||||
}
|
||||
// {{SQL CARBON EDIT}}
|
||||
const x64AppNameBase = 'azuredatastudio-darwin-x64';
|
||||
const arm64AppNameBase = 'azuredatastudio-darwin-arm64';
|
||||
// {{SQL CARBON EDIT}} - END
|
||||
const appName = product.nameLong + '.app';
|
||||
const x64AppPath = path.join(buildDir, 'VSCode-darwin-x64', appName);
|
||||
const arm64AppPath = path.join(buildDir, 'VSCode-darwin-arm64', appName);
|
||||
const x64AppPath = path.join(buildDir, x64AppNameBase, appName); // {{SQL CARBON EDIT}} - CHANGE VSCode to azuredatastudio
|
||||
const arm64AppPath = path.join(buildDir, arm64AppNameBase, appName); // {{SQL CARBON EDIT}} - CHANGE VSCode to azuredatastudio
|
||||
const x64AsarPath = path.join(x64AppPath, 'Contents', 'Resources', 'app', 'node_modules.asar');
|
||||
const arm64AsarPath = path.join(arm64AppPath, 'Contents', 'Resources', 'app', 'node_modules.asar');
|
||||
const outAppPath = path.join(buildDir, `VSCode-darwin-${arch}`, appName);
|
||||
const outAppPath = path.join(buildDir, `azuredatastudio-darwin-${arch}`, appName); // {{SQL CARBON EDIT}} - CHANGE VSCode to azuredatastudio
|
||||
const productJsonPath = path.resolve(outAppPath, 'Contents', 'Resources', 'app', 'product.json');
|
||||
const infoPlistPath = path.resolve(outAppPath, 'Contents', 'Info.plist');
|
||||
// {{SQL CARBON EDIT}}
|
||||
// Current STS arm64 builds doesn't work on osx-arm64, we need to use the x64 version of STS on osx-arm64 until the issue is fixed.
|
||||
// Tracked by: https://github.com/microsoft/azuredatastudio/issues/20775
|
||||
// makeUniversalApp function will complain if the x64 ADS and arm64 ADS have the same STS binaries, to workaround the issue, we need
|
||||
// to delete STS from both of them and then copy it to the universal app.
|
||||
const stsPath = '/Contents/Resources/app/extensions/mssql/sqltoolsservice';
|
||||
const tempSTSDir = path.join(buildDir, 'sqltoolsservice');
|
||||
const x64STSDir = path.join(x64AppPath, stsPath);
|
||||
const arm64STSDir = path.join(arm64AppPath, stsPath);
|
||||
const targetSTSDirs = [x64STSDir, arm64STSDir];
|
||||
// backup the x64 STS to a temporary directory, later it will be copied to the universal app directory.
|
||||
await fs.copy(x64STSDir, tempSTSDir);
|
||||
// delete STS directories from both x64 ADS and arm64 ADS.
|
||||
console.debug(`Removing SqlToolsService folders.`);
|
||||
targetSTSDirs.forEach(async (dir) => {
|
||||
await fs.remove(dir);
|
||||
});
|
||||
// makeUniversalApp requires the non-binary files in arm64 and x64 versions to be exactly the same,
|
||||
// but sometimes the content of nls.metadata.json files could be different(only the order of the entries).
|
||||
// To workaround the issue, we need to replace these files in arm64 ADS with the files from x64 ADS.
|
||||
// Tracked by issue: https://github.com/microsoft/azuredatastudio/issues/20792
|
||||
const sourceFiles = glob.sync(path.join(x64AppPath, '/Contents/Resources/app/**/nls.metadata.json'));
|
||||
sourceFiles.forEach(source => {
|
||||
const target = source.replace(x64AppNameBase, arm64AppNameBase);
|
||||
console.debug(`Replacing file '${target}' with '${source}'`);
|
||||
fs.copySync(source, target, { overwrite: true });
|
||||
});
|
||||
// {{SQL CARBON EDIT}} - END
|
||||
await (0, vscode_universal_bundler_1.makeUniversalApp)({
|
||||
x64AppPath,
|
||||
arm64AppPath,
|
||||
@@ -57,6 +90,9 @@ async function main() {
|
||||
if (lipoOutput.replace(/\n$/, "") !== 'x86_64 arm64') {
|
||||
throw new Error(`Invalid arch, got : ${lipoOutput}`);
|
||||
}
|
||||
// {{SQL CARBON EDIT}}
|
||||
console.debug(`Copying SqlToolsService to the universal app folder.`);
|
||||
await fs.copy(tempSTSDir, path.join(outAppPath, stsPath), { overwrite: true });
|
||||
}
|
||||
if (require.main === module) {
|
||||
main().catch(err => {
|
||||
|
||||
@@ -11,6 +11,7 @@ import * as fs from 'fs-extra';
|
||||
import * as path from 'path';
|
||||
import * as plist from 'plist';
|
||||
import * as product from '../../product.json';
|
||||
import * as glob from 'glob'; // {{SQL CARBON EDIT}}
|
||||
|
||||
async function main() {
|
||||
const buildDir = process.env['AGENT_BUILDDIRECTORY'];
|
||||
@@ -20,15 +21,50 @@ async function main() {
|
||||
throw new Error('$AGENT_BUILDDIRECTORY not set');
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
const x64AppNameBase = 'azuredatastudio-darwin-x64';
|
||||
const arm64AppNameBase = 'azuredatastudio-darwin-arm64';
|
||||
// {{SQL CARBON EDIT}} - END
|
||||
|
||||
const appName = product.nameLong + '.app';
|
||||
const x64AppPath = path.join(buildDir, 'VSCode-darwin-x64', appName);
|
||||
const arm64AppPath = path.join(buildDir, 'VSCode-darwin-arm64', appName);
|
||||
const x64AppPath = path.join(buildDir, x64AppNameBase, appName); // {{SQL CARBON EDIT}} - CHANGE VSCode to azuredatastudio
|
||||
const arm64AppPath = path.join(buildDir, arm64AppNameBase, appName); // {{SQL CARBON EDIT}} - CHANGE VSCode to azuredatastudio
|
||||
const x64AsarPath = path.join(x64AppPath, 'Contents', 'Resources', 'app', 'node_modules.asar');
|
||||
const arm64AsarPath = path.join(arm64AppPath, 'Contents', 'Resources', 'app', 'node_modules.asar');
|
||||
const outAppPath = path.join(buildDir, `VSCode-darwin-${arch}`, appName);
|
||||
const outAppPath = path.join(buildDir, `azuredatastudio-darwin-${arch}`, appName); // {{SQL CARBON EDIT}} - CHANGE VSCode to azuredatastudio
|
||||
const productJsonPath = path.resolve(outAppPath, 'Contents', 'Resources', 'app', 'product.json');
|
||||
const infoPlistPath = path.resolve(outAppPath, 'Contents', 'Info.plist');
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
// Current STS arm64 builds doesn't work on osx-arm64, we need to use the x64 version of STS on osx-arm64 until the issue is fixed.
|
||||
// Tracked by: https://github.com/microsoft/azuredatastudio/issues/20775
|
||||
// makeUniversalApp function will complain if the x64 ADS and arm64 ADS have the same STS binaries, to workaround the issue, we need
|
||||
// to delete STS from both of them and then copy it to the universal app.
|
||||
const stsPath = '/Contents/Resources/app/extensions/mssql/sqltoolsservice';
|
||||
const tempSTSDir = path.join(buildDir, 'sqltoolsservice');
|
||||
const x64STSDir = path.join(x64AppPath, stsPath);
|
||||
const arm64STSDir = path.join(arm64AppPath, stsPath);
|
||||
const targetSTSDirs = [x64STSDir, arm64STSDir];
|
||||
// backup the x64 STS to a temporary directory, later it will be copied to the universal app directory.
|
||||
await fs.copy(x64STSDir, tempSTSDir);
|
||||
// delete STS directories from both x64 ADS and arm64 ADS.
|
||||
console.debug(`Removing SqlToolsService folders.`);
|
||||
targetSTSDirs.forEach(async dir => {
|
||||
await fs.remove(dir);
|
||||
});
|
||||
|
||||
// makeUniversalApp requires the non-binary files in arm64 and x64 versions to be exactly the same,
|
||||
// but sometimes the content of nls.metadata.json files could be different(only the order of the entries).
|
||||
// To workaround the issue, we need to replace these files in arm64 ADS with the files from x64 ADS.
|
||||
// Tracked by issue: https://github.com/microsoft/azuredatastudio/issues/20792
|
||||
const sourceFiles = glob.sync(path.join(x64AppPath, '/Contents/Resources/app/**/nls.metadata.json'));
|
||||
sourceFiles.forEach(source => {
|
||||
const target = source.replace(x64AppNameBase, arm64AppNameBase);
|
||||
console.debug(`Replacing file '${target}' with '${source}'`);
|
||||
fs.copySync(source, target, { overwrite: true });
|
||||
});
|
||||
// {{SQL CARBON EDIT}} - END
|
||||
|
||||
await makeUniversalApp({
|
||||
x64AppPath,
|
||||
arm64AppPath,
|
||||
@@ -65,6 +101,10 @@ async function main() {
|
||||
if (lipoOutput.replace(/\n$/, "") !== 'x86_64 arm64') {
|
||||
throw new Error(`Invalid arch, got : ${lipoOutput}`)
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
console.debug(`Copying SqlToolsService to the universal app folder.`);
|
||||
await fs.copy(tempSTSDir, path.join(outAppPath, stsPath), { overwrite: true });
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
|
||||
Reference in New Issue
Block a user