diff --git a/README.md b/README.md index 41be67cace..d581a7c8c0 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,9 @@ Go to our [download page](https://aka.ms/getazuredatastudio) for more specific i - [Windows User Installer - **Insiders build**](https://azuredatastudio-update.azurewebsites.net/latest/win32-x64-user/insider) - [Windows System Installer - **Insiders build**](https://azuredatastudio-update.azurewebsites.net/latest/win32-x64/insider) - [Windows ZIP - **Insiders build**](https://azuredatastudio-update.azurewebsites.net/latest/win32-x64-archive/insider) -- [macOS ZIP - **Insiders build**](https://azuredatastudio-update.azurewebsites.net/latest/darwin/insider) +- [macOS ZIP (Universal) - **Insiders build**](https://azuredatastudio-update.azurewebsites.net/latest/darwin-universal/insider) +- [macOS ZIP (Intel Chip) - **Insiders build**](https://azuredatastudio-update.azurewebsites.net/latest/darwin/insider) +- [macOS ZIP (Apple Silicon) - **Insiders build**](https://azuredatastudio-update.azurewebsites.net/latest/darwin-arm64/insider) - [Linux TAR.GZ - **Insiders build**](https://azuredatastudio-update.azurewebsites.net/latest/linux-x64/insider) See the [change log](https://github.com/Microsoft/azuredatastudio/blob/main/CHANGELOG.md) for additional details of what's in this release. diff --git a/build/.cachesalt b/build/.cachesalt index b7ac004d6c..3b2a71b972 100644 --- a/build/.cachesalt +++ b/build/.cachesalt @@ -1 +1 @@ -2021-11-19T02:27:18.022Z +2022-10-06T02:27:18.022Z diff --git a/build/azure-pipelines/darwin/sql-product-build-darwin-signing.yml b/build/azure-pipelines/darwin/sql-product-build-darwin-signing.yml index 2f85b31c8c..91957dc012 100644 --- a/build/azure-pipelines/darwin/sql-product-build-darwin-signing.yml +++ b/build/azure-pipelines/darwin/sql-product-build-darwin-signing.yml @@ -9,12 +9,12 @@ steps: displayName: 'Download Build Artifacts' inputs: downloadType: specific - itemPattern: 'drop/darwin/archive/azuredatastudio-darwin-unsigned.zip' + itemPattern: 'drop/darwin/archive/azuredatastudio-darwin-$(VSCODE_ARCH)-unsigned.zip' downloadPath: '$(Build.SourcesDirectory)/.build/' - script: | pushd $(Build.SourcesDirectory)/.build/drop/darwin/archive - mv azuredatastudio-darwin-unsigned.zip azuredatastudio-darwin.zip + mv azuredatastudio-darwin-$(VSCODE_ARCH)-unsigned.zip azuredatastudio-darwin-$(VSCODE_ARCH).zip displayName: 'Rename the file' - task: UseDotNet@2 @@ -29,7 +29,7 @@ steps: inputs: ConnectedServiceName: 'Code Signing' FolderPath: '$(Build.SourcesDirectory)/.build/drop/darwin/archive' - Pattern: 'azuredatastudio-darwin.zip' + Pattern: 'azuredatastudio-darwin-$(VSCODE_ARCH).zip' signConfigType: inlineSignParams inlineOperation: | [ @@ -47,7 +47,7 @@ steps: condition: and(succeeded(), eq(variables['signed'], true)) - script: | - zip -d $(Build.SourcesDirectory)/.build/drop/darwin/archive/azuredatastudio-darwin.zip "*.pkg" + zip -d $(Build.SourcesDirectory)/.build/drop/darwin/archive/azuredatastudio-darwin-$(VSCODE_ARCH).zip "*.pkg" displayName: Clean Archive condition: and(succeeded(), eq(variables['signed'], true)) @@ -56,7 +56,7 @@ steps: inputs: ConnectedServiceName: 'Code Signing' FolderPath: '$(Build.SourcesDirectory)/.build/drop/darwin/archive' - Pattern: 'azuredatastudio-darwin.zip' + Pattern: 'azuredatastudio-darwin-$(VSCODE_ARCH).zip' signConfigType: inlineSignParams inlineOperation: | [ diff --git a/build/azure-pipelines/darwin/sql-product-build-darwin.yml b/build/azure-pipelines/darwin/sql-product-build-darwin.yml index d6c5a65dab..7667af04de 100644 --- a/build/azure-pipelines/darwin/sql-product-build-darwin.yml +++ b/build/azure-pipelines/darwin/sql-product-build-darwin.yml @@ -52,7 +52,7 @@ steps: - script: | mkdir -p .build - node build/azure-pipelines/common/sql-computeNodeModulesCacheKey.js > .build/yarnlockhash + node build/azure-pipelines/common/sql-computeNodeModulesCacheKey.js $(NPM_CONFIG_ARCH) > .build/yarnlockhash displayName: Prepare yarn cache key - task: Cache@2 @@ -71,6 +71,7 @@ steps: - script: | set -e + export npm_config_arch=$(NPM_CONFIG_ARCH) CHILD_CONCURRENCY=1 yarn --frozen-lockfile displayName: Install dependencies env: @@ -99,10 +100,11 @@ steps: - script: | set -e yarn gulp package-rebuild-extensions - yarn gulp vscode-darwin-x64-min-ci + yarn gulp vscode-darwin-$(VSCODE_ARCH)-min-ci displayName: Build env: VSCODE_MIXIN_PASSWORD: $(github-distro-mixin-password) + condition: and(succeeded(), ne(variables['VSCODE_ARCH'], 'universal')) - script: | set -e @@ -115,7 +117,7 @@ steps: # including the remote server and configure the integration tests # to run with these builds instead of running out of sources. set -e - APP_ROOT=$(agent.builddirectory)/azuredatastudio-darwin-x64 + APP_ROOT=$(agent.builddirectory)/azuredatastudio-darwin-$(VSCODE_ARCH) APP_NAME="`ls $APP_ROOT | head -n 1`" INTEGRATION_TEST_ELECTRON_PATH="$APP_ROOT/$APP_NAME/Contents/MacOS/Electron" \ VSCODE_REMOTE_SERVER_PATH="$(agent.builddirectory)/azuredatastudio-reh-darwin" \ @@ -127,12 +129,13 @@ steps: set -e yarn gulp compile-extensions displayName: Compile Extensions + condition: and(succeeded(), ne(variables['VSCODE_ARCH'], 'universal')) # Per https://developercommunity.visualstudio.com/t/variablesexpressions-dont-work-with-continueonerro/1187733 we can't use variables # in continueOnError directly so instead make two copies of the task and only run one or the other based on the SMOKE_FAIL_ON_ERROR value - script: | set -e - APP_ROOT=$(agent.builddirectory)/azuredatastudio-darwin-x64 + APP_ROOT=$(agent.builddirectory)/azuredatastudio-darwin-$(VSCODE_ARCH) APP_NAME="`ls $APP_ROOT | head -n 1`" yarn smoketest --build "$APP_ROOT/$APP_NAME" --screenshots "$(build.artifactstagingdirectory)/smokeshots" --log "$(build.artifactstagingdirectory)/logs/darwin/smoke.log" --extensionsDir "$(build.sourcesdirectory)/extensions" displayName: Run smoke tests (Electron) (Continue on Error) @@ -141,7 +144,7 @@ steps: - script: | set -e - APP_ROOT=$(agent.builddirectory)/azuredatastudio-darwin-x64 + APP_ROOT=$(agent.builddirectory)/azuredatastudio-darwin-$(VSCODE_ARCH) APP_NAME="`ls $APP_ROOT | head -n 1`" yarn smoketest --build "$APP_ROOT/$APP_NAME" --screenshots "$(build.artifactstagingdirectory)/smokeshots" --log "$(build.artifactstagingdirectory)/logs/darwin/smoke.log" --extensionsDir "$(build.sourcesdirectory)/extensions" displayName: Run smoke tests (Electron) (Fail on Error) @@ -156,9 +159,25 @@ steps: # continueOnError: true # condition: and(succeeded(), eq(variables['RUN_TESTS'], 'true')) + - task: DownloadBuildArtifacts@0 + displayName: 'Download arm64 and x64 packages' + inputs: + downloadType: specific + itemPattern: 'drop/darwin/archive/azuredatastudio-darwin-@(arm64|x64)-unsigned.zip' + downloadPath: $(agent.builddirectory) + condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'universal')) + - script: | set -e - pushd ../azuredatastudio-darwin-x64 + unzip $(agent.builddirectory)/drop/darwin/archive/azuredatastudio-darwin-x64-unsigned.zip -d $(agent.builddirectory)/azuredatastudio-darwin-x64 + unzip $(agent.builddirectory)/drop/darwin/archive/azuredatastudio-darwin-arm64-unsigned.zip -d $(agent.builddirectory)/azuredatastudio-darwin-arm64 + DEBUG=* node build/darwin/create-universal-app.js + displayName: Create Universal App + condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'universal')) + + - script: | + set -e + pushd ../azuredatastudio-darwin-$(VSCODE_ARCH) ls echo "Cleaning the application" @@ -188,8 +207,8 @@ steps: - script: | set -e mkdir -p .build/darwin/archive - pushd ../azuredatastudio-darwin-x64 - ditto -c -k --keepParent *.app $(Build.SourcesDirectory)/.build/darwin/archive/azuredatastudio-darwin.zip + pushd ../azuredatastudio-darwin-$(VSCODE_ARCH) + ditto -c -k --keepParent *.app $(Build.SourcesDirectory)/.build/darwin/archive/azuredatastudio-darwin-$(VSCODE_ARCH).zip popd displayName: 'Archive (no signing)' condition: and(succeeded(), eq(variables['signed'], false)) @@ -197,8 +216,8 @@ steps: - script: | set -e mkdir -p .build/darwin/archive - pushd ../azuredatastudio-darwin-x64 - ditto -c -k --keepParent *.app $(Build.SourcesDirectory)/.build/darwin/archive/azuredatastudio-darwin-unsigned.zip + pushd ../azuredatastudio-darwin-$(VSCODE_ARCH) + ditto -c -k --keepParent *.app $(Build.SourcesDirectory)/.build/darwin/archive/azuredatastudio-darwin-$(VSCODE_ARCH)-unsigned.zip popd displayName: 'Archive' condition: and(succeeded(), eq(variables['signed'], true)) diff --git a/build/azure-pipelines/darwin/sql-publish.ps1 b/build/azure-pipelines/darwin/sql-publish.ps1 index c22c772008..e4a480eba5 100644 --- a/build/azure-pipelines/darwin/sql-publish.ps1 +++ b/build/azure-pipelines/darwin/sql-publish.ps1 @@ -13,12 +13,22 @@ $Version = $VersionJson.version $Quality = $VersionJson.quality $CommitId = $VersionJson.commit -$ZipName = "azuredatastudio-darwin.zip" -$Zip = "$artifactsDir\darwin\archive\$ZipName" -$UploadName = "azuredatastudio-macos-$Version" +$Flavors = "x64","arm64","universal" +$FlavorSuffixes = "","-arm64","-universal" -If (-NOT ($Quality -eq "stable")) { - $UploadName = "$UploadName-$Quality" +For($i = 0; $i -lt $Flavors.Length; $i++) +{ + $Flavor = $Flavors[$i] + $FlavorSuffix = $FlavorSuffixes[$i] + $ZipName = "azuredatastudio-darwin-$Flavor.zip" + $Zip = "$artifactsDir\darwin\archive\$ZipName" + $UploadName = "azuredatastudio-macos$FlavorSuffix-$Version" + + If (-NOT ($Quality -eq "stable")) { + $UploadName = "$UploadName-$Quality" + } + + $Platform = "darwin$FlavorSuffix" + + node $sourcesDir\build\azure-pipelines\common\publish.js $Quality $Platform archive "$UploadName.zip" $Version true $Zip $CommitId } - -node $sourcesDir\build\azure-pipelines\common\publish.js $Quality darwin archive "$UploadName.zip" $Version true $Zip $CommitId diff --git a/build/azure-pipelines/sql-product-build.yml b/build/azure-pipelines/sql-product-build.yml index a289d9b10a..e6335e82b7 100644 --- a/build/azure-pipelines/sql-product-build.yml +++ b/build/azure-pipelines/sql-product-build.yml @@ -4,87 +4,142 @@ resources: image: sqltoolscontainers.azurecr.io/linux-build-agent:6 endpoint: SqlToolsContainers -jobs: -- job: Compile - pool: - vmImage: 'Ubuntu-20.04' - container: linux-x64 - steps: - - script: | - set -e - echo "##vso[build.addbuildtag]$(VSCODE_QUALITY)" - displayName: Add Quality Build Tag - - template: sql-product-compile.yml - timeoutInMinutes: 120 +stages: + - stage: Compile + jobs: + - job: Compile + pool: + vmImage: 'Ubuntu-20.04' + container: linux-x64 + steps: + - script: | + set -e + echo "##vso[build.addbuildtag]$(VSCODE_QUALITY)" + displayName: Add Quality Build Tag + - template: sql-product-compile.yml + timeoutInMinutes: 120 -- job: macOS - condition: and(succeeded(), eq(variables['VSCODE_BUILD_MACOS'], 'true'), ne(variables['VSCODE_QUALITY'], 'saw')) - pool: - vmImage: 'macos-latest' - dependsOn: - - Compile - steps: - - template: darwin/sql-product-build-darwin.yml - timeoutInMinutes: 90 + - stage: macOS + condition: and(succeeded(), eq(variables['VSCODE_BUILD_MACOS'], 'true'), ne(variables['VSCODE_QUALITY'], 'saw')) + pool: + vmImage: 'macos-latest' + dependsOn: + - Compile + jobs: + - job: macOS + variables: + NPM_CONFIG_ARCH: x64 + VSCODE_ARCH: x64 + steps: + - template: darwin/sql-product-build-darwin.yml + timeoutInMinutes: 90 -- job: macOS_Signing - condition: and(succeeded(), eq(variables['VSCODE_BUILD_MACOS'], 'true'), eq(variables['signed'], true), ne(variables['VSCODE_QUALITY'], 'saw')) - pool: - vmImage: 'macos-latest' - dependsOn: - - macOS - steps: - - template: darwin/sql-product-build-darwin-signing.yml - timeoutInMinutes: 60 + - job: macOS_Signing + variables: + VSCODE_ARCH: x64 + condition: and(succeeded(), eq(variables['signed'], true)) + dependsOn: + - macOS + steps: + - template: darwin/sql-product-build-darwin-signing.yml + timeoutInMinutes: 60 -- job: Linux - condition: and(succeeded(), eq(variables['VSCODE_BUILD_LINUX'], 'true')) - pool: - vmImage: 'Ubuntu-20.04' - container: linux-x64 - dependsOn: - - Compile - steps: - - template: linux/sql-product-build-linux.yml - parameters: - extensionsToUnitTest: ["admin-tool-ext-win", "agent", "azcli", "azurecore", "cms", "dacpac", "data-workspace", "import", "machine-learning", "notebook", "resource-deployment", "schema-compare", "sql-bindings", "sql-database-projects"] - timeoutInMinutes: 90 + - job: macOS_ARM64 + variables: + NPM_CONFIG_ARCH: arm64 + VSCODE_ARCH: arm64 + # Do not run tests for arm64 build + RUN_TESTS: false + RUN_SMOKE_TESTS: false + steps: + - template: darwin/sql-product-build-darwin.yml + timeoutInMinutes: 90 -- job: Windows - condition: and(succeeded(), eq(variables['VSCODE_BUILD_WIN32'], 'true')) - pool: - vmImage: 'windows-2019' - dependsOn: - - Compile - steps: - - template: win32/sql-product-build-win32.yml - timeoutInMinutes: 90 + - job: macOS_Signing_ARM64 + variables: + VSCODE_ARCH: arm64 + condition: and(succeeded(), eq(variables['signed'], true)) + dependsOn: + - macOS_ARM64 + steps: + - template: darwin/sql-product-build-darwin-signing.yml + timeoutInMinutes: 60 -# disable due to invalid machine pool (karlb 3/9/2022) -# - job: Windows_Test -# condition: and(succeeded(), eq(variables['VSCODE_BUILD_WIN32'], 'true')) -# pool: -# name: mssqltools -# dependsOn: -# - Linux -# - Windows -# steps: -# - template: win32/sql-product-test-win32.yml -# timeoutInMinutes: 90 + - job: macOS_Universal + variables: + NPM_CONFIG_ARCH: x64 + VSCODE_ARCH: universal + # Do not run tests for universal build + RUN_TESTS: false + RUN_SMOKE_TESTS: false + dependsOn: + - macOS + - macOS_ARM64 + steps: + - template: darwin/sql-product-build-darwin.yml + timeoutInMinutes: 90 -- job: Release - condition: and(succeeded(), or(eq(variables['VSCODE_RELEASE'], 'true'), and(eq(variables['VSCODE_QUALITY'], 'insider'), eq(variables['Build.Reason'], 'Schedule')))) - pool: - vmImage: 'Ubuntu-20.04' - dependsOn: - - macOS - - Linux - - Windows -# disable due to invalid machine pool (karlb 3/9/2022) -# - Windows_Test - - macOS_Signing - steps: - - template: sql-release.yml + - job: macOS_Signing_Universal + variables: + VSCODE_ARCH: universal + condition: and(succeeded(), eq(variables['signed'], true)) + dependsOn: + - macOS_Universal + steps: + - template: darwin/sql-product-build-darwin-signing.yml + timeoutInMinutes: 60 + + - stage: Linux + condition: and(succeeded(), eq(variables['VSCODE_BUILD_LINUX'], true)) + dependsOn: + - Compile + jobs: + - job: Linux + pool: + vmImage: 'Ubuntu-20.04' + container: linux-x64 + steps: + - template: linux/sql-product-build-linux.yml + parameters: + extensionsToUnitTest: ["admin-tool-ext-win", "agent", "azcli", "azurecore", "cms", "dacpac", "data-workspace", "import", "machine-learning", "notebook", "resource-deployment", "schema-compare", "sql-bindings", "sql-database-projects"] + timeoutInMinutes: 90 + + - stage: Windows + condition: and(succeeded(), eq(variables['VSCODE_BUILD_WIN32'], true)) + pool: + vmImage: 'windows-2019' + dependsOn: + - Compile + jobs: + - job: Windows + steps: + - template: win32/sql-product-build-win32.yml + timeoutInMinutes: 90 + + # disable due to invalid machine pool (karlb 3/9/2022) + # - job: Windows_Test + # condition: and(succeeded(), eq(variables['VSCODE_BUILD_WIN32'], 'true')) + # pool: + # name: mssqltools + # dependsOn: + # - Linux + # - Windows + # steps: + # - template: win32/sql-product-test-win32.yml + # timeoutInMinutes: 90 + + - stage: Release + condition: and(succeeded(), or(eq(variables['VSCODE_RELEASE'], 'true'), and(eq(variables['VSCODE_QUALITY'], 'insider'), eq(variables['Build.Reason'], 'Schedule')))) + pool: + vmImage: 'Ubuntu-20.04' + dependsOn: + - macOS + - Linux + - Windows + jobs: + - job: Release + steps: + - template: sql-release.yml trigger: none pr: none diff --git a/build/darwin/create-universal-app.js b/build/darwin/create-universal-app.js index 04e63f13d9..f706d6e512 100644 --- a/build/darwin/create-universal-app.js +++ b/build/darwin/create-universal-app.js @@ -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 => { diff --git a/build/darwin/create-universal-app.ts b/build/darwin/create-universal-app.ts index 7cfd8e2050..9c974e04d8 100644 --- a/build/darwin/create-universal-app.ts +++ b/build/darwin/create-universal-app.ts @@ -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) { diff --git a/extensions/mssql/build/postinstall.js b/extensions/mssql/build/postinstall.js index d692b49cc0..3db216ff11 100644 --- a/extensions/mssql/build/postinstall.js +++ b/extensions/mssql/build/postinstall.js @@ -5,7 +5,7 @@ (async () => { const serviceDownloader = require('@microsoft/ads-service-downloader').ServiceDownloadProvider; - const platform = require('@microsoft/ads-service-downloader/out/platform').PlatformInformation; + const platform = require('@microsoft/ads-service-downloader/out/platform'); const path = require('path'); const fs = require('fs').promises; const rimraf = require('rimraf'); @@ -15,7 +15,15 @@ async function installService() { const absoluteConfigPath = require.resolve('../config.json'); const config = require(absoluteConfigPath); - const runtime = (await platform.getCurrent()).runtimeId; + let runtime = (await platform.PlatformInformation.getCurrent()).runtimeId; + const arch = process.env['npm_config_arch']; + + // In the build pipeline, macOS x64 image is used to produce arm64 build, + // we need to check the environment variable to determine the actual target runtime. + if (runtime === platform.Runtime.OSX && arch === 'arm64') { + console.log(`Set the target runtime to OSX_ARM64`); + runtime = platform.Runtime.OSX_ARM64; + } // fix path since it won't be correct config.installDirectory = path.join(path.dirname(absoluteConfigPath), config.installDirectory); let installer = new serviceDownloader(config);