diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4cc034d..2659d71 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -346,7 +346,7 @@ jobs: COMPOSITE: ./.ref-download-test strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest, ubuntu-24.04-arm] + os: [ubuntu-latest, macos-latest, windows-latest, ubuntu-24.04-arm, windows-11-arm] steps: - name: Setup wrapper composite action at ${{ env.COMPOSITE }} uses: actions/github-script@v7 diff --git a/__tests__/installer/windows.test.ts b/__tests__/installer/windows.test.ts index 11689b3..c2730a8 100644 --- a/__tests__/installer/windows.test.ts +++ b/__tests__/installer/windows.test.ts @@ -78,7 +78,7 @@ describe('windows toolchain installation verification', () => { it('tests setting up on ARM64 Windows 10', async () => { jest.spyOn(os, 'release').mockReturnValue('10.0.17063') const installer = new WindowsToolchainInstaller(toolchain) - expect(installer['vsRequirement']('aarch64').components).toStrictEqual([ + expect(installer['vsRequirement']('arm64').components).toStrictEqual([ 'Microsoft.VisualStudio.Component.VC.Tools.ARM64', 'Microsoft.VisualStudio.Component.Windows10SDK.17763' ]) @@ -118,7 +118,7 @@ describe('windows toolchain installation verification', () => { preventCaching: false } const installer = new WindowsToolchainInstaller(toolchain) - expect(installer['vsRequirement']('aarch64').components).toStrictEqual([ + expect(installer['vsRequirement']('arm64').components).toStrictEqual([ 'Microsoft.VisualStudio.Component.VC.Tools.ARM64', 'Microsoft.VisualStudio.Component.Windows11SDK.22000' ]) diff --git a/__tests__/snapshot/windows.test.ts b/__tests__/snapshot/windows.test.ts index 78dc882..ef218c3 100644 --- a/__tests__/snapshot/windows.test.ts +++ b/__tests__/snapshot/windows.test.ts @@ -185,4 +185,22 @@ describe('fetch windows tool data based on options', () => { expect(tool.dir).toBe(name) expect(tool.branch).toBe('swiftwasm') }) + + it('fetches windows 11 arm64 latest swift 6.0.0 tool', async () => { + setos({os: 'win32', dist: 'Windows', release: '10.0.26100'}) + jest.spyOn(os, 'arch').mockReturnValue('arm64') + const ver6_0_0 = ToolchainVersion.create('6.0.0', false) + const tool = await Platform.toolchain(ver6_0_0) + expect(tool).toBeTruthy() + const wTool = tool as WindowsToolchainSnapshot + expect(wTool.download).toBe('swift-6.0-RELEASE-windows10-arm64.exe') + expect(wTool.dir).toBe('swift-6.0-RELEASE') + expect(wTool.platform).toBe('windows10-arm64') + expect(wTool.branch).toBe('swift-6.0-release') + expect(wTool.download_signature).toBe( + 'swift-6.0-RELEASE-windows10-arm64.exe.sig' + ) + expect(wTool.docker).toBe('6.0-windowsservercore-ltsc2022') + expect(wTool.preventCaching).toBe(false) + }) }) diff --git a/dist/index.js b/dist/index.js index 4c80f7c..2b9fc89 100644 --- a/dist/index.js +++ b/dist/index.js @@ -516,7 +516,7 @@ class WindowsToolchainInstaller extends verify_1.VerifyingToolchainInstaller { return ((utils_1.VISUAL_STUDIO_WINSDK_COMPONENT_REGEX.exec(component)?.length ?? 0) > 1); }); const vsComponents = [ - `Microsoft.VisualStudio.Component.VC.Tools.${arch == 'aarch64' ? 'ARM64' : 'x86.x64'}`, + `Microsoft.VisualStudio.Component.VC.Tools.${arch == 'arm64' ? 'ARM64' : 'x86.x64'}`, ...providedComponents ]; if (!winsdkComponent) { @@ -1329,18 +1329,7 @@ const xcode_1 = __nccwpck_require__(8775); const linux_1 = __nccwpck_require__(2136); const windows_1 = __nccwpck_require__(5687); base_1.Platform.currentPlatform = async () => { - let arch; - switch (os.arch()) { - case 'x64': - arch = 'x86_64'; - break; - case 'arm64': - arch = 'aarch64'; - break; - default: - arch = os.arch(); - break; - } + const arch = os.arch(); const _os = await new Promise((resolve, reject) => { (0, getos_1.default)((e, o) => { if (e) { @@ -1452,6 +1441,25 @@ const versioned_1 = __nccwpck_require__(7507); const installer_1 = __nccwpck_require__(1135); const const_1 = __nccwpck_require__(6575); class LinuxPlatform extends versioned_1.VersionedPlatform { + name; + version; + arch; + constructor(name, version, arch) { + switch (arch) { + case 'x64': + arch = 'x86_64'; + break; + case 'arm64': + arch = 'aarch64'; + break; + default: + break; + } + super(name, version, arch); + this.name = name; + this.version = version; + this.arch = arch; + } get downloadExtension() { return 'tar.gz'; } @@ -1685,6 +1693,22 @@ exports.WindowsPlatform = void 0; const versioned_1 = __nccwpck_require__(7507); const installer_1 = __nccwpck_require__(1135); class WindowsPlatform extends versioned_1.VersionedPlatform { + name; + version; + arch; + constructor(name, version, arch) { + switch (arch) { + case 'x64': + arch = 'x86_64'; + break; + default: + break; + } + super(name, version, arch); + this.name = name; + this.version = version; + this.arch = arch; + } get downloadExtension() { return 'exe'; } @@ -1752,6 +1776,16 @@ const installer_1 = __nccwpck_require__(1135); class XcodePlatform extends base_1.Platform { arch; constructor(arch) { + switch (arch) { + case 'x64': + arch = 'x86_64'; + break; + case 'arm64': + arch = 'aarch64'; + break; + default: + break; + } super(); this.arch = arch; } diff --git a/src/installer/windows/index.ts b/src/installer/windows/index.ts index 056d4f6..d8a3e09 100644 --- a/src/installer/windows/index.ts +++ b/src/installer/windows/index.ts @@ -31,7 +31,7 @@ export class WindowsToolchainInstaller extends VerifyingToolchainInstaller { - let arch: string - switch (os.arch()) { - case 'x64': - arch = 'x86_64' - break - case 'arm64': - arch = 'aarch64' - break - default: - arch = os.arch() - break - } - + const arch = os.arch() const _os: getos.Os = await new Promise((resolve, reject) => { getos((e, o) => { if (e) { diff --git a/src/platform/linux.ts b/src/platform/linux.ts index 1e82a73..ee6eefa 100644 --- a/src/platform/linux.ts +++ b/src/platform/linux.ts @@ -10,6 +10,24 @@ import {LinuxToolchainInstaller} from '../installer' import {MODULE_DIR} from '../const' export class LinuxPlatform extends VersionedPlatform { + constructor( + readonly name: string, + readonly version: number, + readonly arch: string + ) { + switch (arch) { + case 'x64': + arch = 'x86_64' + break + case 'arm64': + arch = 'aarch64' + break + default: + break + } + super(name, version, arch) + } + protected get downloadExtension() { return 'tar.gz' } diff --git a/src/platform/windows.ts b/src/platform/windows.ts index 8417991..b15779b 100644 --- a/src/platform/windows.ts +++ b/src/platform/windows.ts @@ -3,6 +3,21 @@ import {WindowsToolchainInstaller} from '../installer' import {WindowsToolchainSnapshot, ToolchainSnapshot} from '../snapshot' export class WindowsPlatform extends VersionedPlatform { + constructor( + readonly name: string, + readonly version: number, + readonly arch: string + ) { + switch (arch) { + case 'x64': + arch = 'x86_64' + break + default: + break + } + super(name, version, arch) + } + protected get downloadExtension() { return 'exe' } diff --git a/src/platform/xcode.ts b/src/platform/xcode.ts index 2b041f9..8bdd19a 100644 --- a/src/platform/xcode.ts +++ b/src/platform/xcode.ts @@ -6,6 +6,16 @@ import {XcodeToolchainInstaller} from '../installer' export class XcodePlatform extends Platform { constructor(readonly arch: string) { + switch (arch) { + case 'x64': + arch = 'x86_64' + break + case 'arm64': + arch = 'aarch64' + break + default: + break + } super() } diff --git a/src/snapshot/windows.ts b/src/snapshot/windows.ts index a375ce5..8239bea 100644 --- a/src/snapshot/windows.ts +++ b/src/snapshot/windows.ts @@ -2,4 +2,5 @@ import {SignedToolchainSnapshot} from './signed' export interface WindowsToolchainSnapshot extends SignedToolchainSnapshot { readonly windows: boolean + readonly docker?: string }