fix: add arch aliases + support CMake on Windows Arm

This commit is contained in:
Amin Yahyaabadi 2024-09-08 03:30:37 -07:00
parent e714af79eb
commit 6003b39332
No known key found for this signature in database
GPG Key ID: F52AF77F636088F0
8 changed files with 65 additions and 103 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,8 @@
import { info } from "ci-log"
import { addExeExt } from "patha" import { addExeExt } from "patha"
import semverCoerce from "semver/functions/coerce" import semverCoerce from "semver/functions/coerce"
import semverLte from "semver/functions/lte" import semverLte from "semver/functions/lte"
import { arm64, x86, x86_64 } from "../utils/env/arch.js"
import { type InstallationInfo, type PackageInfo, setupBin } from "../utils/setup/setupBin.js" import { type InstallationInfo, type PackageInfo, setupBin } from "../utils/setup/setupBin.js"
/** Get the platform data for cmake */ /** Get the platform data for cmake */
@ -10,10 +12,15 @@ function getCmakePackageInfo(version: string, platform: NodeJS.Platform, arch: s
case "win32": { case "win32": {
const isOld = semverLte(semVersion, "v3.19.6") const isOld = semverLte(semVersion, "v3.19.6")
let osArchStr: string let osArchStr: string
if (["ia32", "x86", "i386", "x32"].includes(arch)) { if (x86_64.includes(arch)) {
osArchStr = isOld ? "win32-x86" : "windows-i386"
} else {
osArchStr = isOld ? "win64-x64" : "windows-x86_64" osArchStr = isOld ? "win64-x64" : "windows-x86_64"
} else if (x86.includes(arch)) {
osArchStr = isOld ? "win32-x86" : "windows-i386"
} else if (arm64.includes(arch)) {
osArchStr = "windows-arm64"
} else {
info(`Trying unsupported arch '${arch}' for cmake on Windows`)
osArchStr = `windows-${arch}`
} }
const folderName = `cmake-${version}-${osArchStr}` const folderName = `cmake-${version}-${osArchStr}`
return { return {
@ -37,10 +44,13 @@ function getCmakePackageInfo(version: string, platform: NodeJS.Platform, arch: s
case "linux": { case "linux": {
const isOld = semverLte(semVersion, "v3.19.8") const isOld = semverLte(semVersion, "v3.19.8")
let osArchStr: string let osArchStr: string
if (["aarch64"].includes(arch)) { if (arm64.includes(arch)) {
osArchStr = isOld ? "Linux-aarch64" : "linux-aarch64" osArchStr = isOld ? "Linux-aarch64" : "linux-aarch64"
} else { } else if (x86_64.includes(arch)) {
osArchStr = isOld ? "Linux-x86_64" : "linux-x86_64" osArchStr = isOld ? "Linux-x86_64" : "linux-x86_64"
} else {
info(`Trying unsupported arch '${arch}' for cmake on Linux`)
osArchStr = `linux-${arch}`
} }
const folderName = `cmake-${version}-${osArchStr}` const folderName = `cmake-${version}-${osArchStr}`
return { return {

View File

@ -3,6 +3,7 @@ import { fileURLToPath } from "url"
import { info } from "ci-log" import { info } from "ci-log"
import { addExeExt } from "patha" import { addExeExt } from "patha"
import { loadAssetList, matchAsset } from "../utils/asset/load-assets.js" import { loadAssetList, matchAsset } from "../utils/asset/load-assets.js"
import { arm64, armv7, powerpc64le, sparc64, x86, x86_64 } from "../utils/env/arch.js"
import { hasDnf } from "../utils/env/hasDnf.js" import { hasDnf } from "../utils/env/hasDnf.js"
import { isUbuntu } from "../utils/env/isUbuntu.js" import { isUbuntu } from "../utils/env/isUbuntu.js"
import { ubuntuVersion } from "../utils/env/ubuntu_version.js" import { ubuntuVersion } from "../utils/env/ubuntu_version.js"
@ -85,32 +86,15 @@ async function getAssetKeywords(platform: string, arch: string) {
switch (platform) { switch (platform) {
case "win32": { case "win32": {
switch (arch) { if (x86_64.includes(arch)) {
case "win64": keywords.push("win64")
case "x64": } else if (x86.includes(arch)) {
case "amd64": keywords.push("win32")
case "x86_64": } else if (arm64.includes(arch)) {
case "64": keywords.push("woa64")
keywords.push("win64") } else {
break info(`Using arch ${arch} for LLVM`)
case "win32": keywords.push(arch)
case "x86":
case "i386":
case "ia32":
case "32":
keywords.push("win32")
break
case "woa64":
case "aarch64":
case "arm64":
case "arm": {
keywords.push("woa64")
break
}
default:
info(`Using arch ${arch} for LLVM`)
keywords.push(arch)
break
} }
break break
} }
@ -132,39 +116,21 @@ async function getAssetKeywords(platform: string, arch: string) {
optionalKeywords.push("rhel") optionalKeywords.push("rhel")
} }
switch (arch) { if (x86_64.includes(arch)) {
case "x86_64": keywords.push("x86_64")
case "x64": } else if (x86.includes(arch)) {
case "amd64": keywords.push("x86")
case "64": } else if (arm64.includes(arch)) {
keywords.push("x86_64") keywords.push("aarch64")
break } else if (armv7.includes(arch)) {
case "x86": keywords.push("armv7a")
case "i386": } else if (powerpc64le.includes(arch)) {
case "ia32": keywords.push("powerpc64le")
case "32": } else if (sparc64.includes(arch)) {
keywords.push("x86") keywords.push("sparc64")
break } else {
case "aarch64": info(`Using arch ${arch} for LLVM`)
case "arm64": keywords.push(arch)
case "arm":
keywords.push("aarch64")
break
case "armv7a":
case "armv7":
keywords.push("armv7a")
break
case "powerpc64le":
case "ppc64le":
keywords.push("powerpc64le")
break
case "sparc64":
keywords.push("sparc64")
break
default:
info(`Using arch ${arch} for LLVM`)
keywords.push(arch)
break
} }
break break
@ -172,46 +138,27 @@ async function getAssetKeywords(platform: string, arch: string) {
case "darwin": { case "darwin": {
keywords.push("apple") keywords.push("apple")
switch (arch) { if (x86_64.includes(arch)) {
case "x86_64": keywords.push("x86_64")
case "x64": } else if (arm64.includes(arch)) {
case "amd64": // allow falling back to x86_64 if arm64 is not available
case "64": optionalKeywords.push("arm64")
keywords.push("x86_64") } else {
break info(`Using arch ${arch} for LLVM`)
case "arm64": keywords.push(arch)
case "arm":
case "aarch64":
// allow falling back to x86_64 if arm64 is not available
optionalKeywords.push("arm64")
break
default:
info(`Using arch ${arch} for LLVM`)
keywords.push(arch)
break
} }
break break
} }
case "freebsd": { case "freebsd": {
keywords.push("freebsd") keywords.push("freebsd")
switch (arch) { if (x86_64.includes(arch)) {
case "x86_64": keywords.push("amd64")
case "x64": } else if (x86.includes(arch)) {
case "amd64": keywords.push("i386")
case "64": } else {
keywords.push("amd64") info(`Using arch ${arch} for LLVM`)
break keywords.push(arch)
case "x86":
case "i386":
case "ia32":
case "32":
keywords.push("i386")
break
default:
info(`Using arch ${arch} for LLVM`)
keywords.push(arch)
break
} }
break break

View File

@ -1,4 +1,3 @@
import { info } from "ci-log"
import { readFile } from "fs/promises" import { readFile } from "fs/promises"
/** /**

6
src/utils/env/arch.ts vendored Normal file
View File

@ -0,0 +1,6 @@
export const x86_64 = ["x64", "amd64", "x86_64", "win64", "64"]
export const x86 = ["x86", "i386", "ia32", "win32", "32", "x32"]
export const arm64 = ["aarch64", "arm64", "woa64", "arm"]
export const armv7 = ["armv7", "armv7a"]
export const powerpc64le = ["powerpc64le", "ppc64le"]
export const sparc64 = ["sparc64"]