Support platforms without upstream ccache/sccache releases (#439)

Introduce UnknownPackage to handle platform/arch combinations (e.g.
linux-riscv64) that lack upstream binary releases. When install-method
is "detect", fall back to locally installed ccache/sccache instead of
failing.

Move the detect-and-skip logic from runInner into
UnknownPackage.install so all install paths go through the same
Package interface.
This commit is contained in:
Ludovic Henry
2026-04-21 08:59:52 +02:00
committed by GitHub
parent 05e1c04f70
commit d62db5f07c
5 changed files with 68 additions and 7 deletions
+23 -1
View File
@@ -39060,6 +39060,7 @@ __nccwpck_require__.d(__webpack_exports__, {
INSTALL_METHOD: () => (/* binding */ INSTALL_METHOD),
PLATFORM: () => (/* binding */ PLATFORM),
Package: () => (/* binding */ Package),
UnknownPackage: () => (/* binding */ UnknownPackage),
VARIANT: () => (/* binding */ VARIANT),
"default": () => (/* binding */ src_restore),
selectMethod: () => (/* binding */ selectMethod),
@@ -86649,6 +86650,7 @@ var ARCH;
(function (ARCH) {
ARCH["X86_64"] = "x86_64";
ARCH["AARCH64"] = "aarch64";
ARCH["RISCV64"] = "riscv64";
})(ARCH || (ARCH = {}));
var PLATFORM;
(function (PLATFORM) {
@@ -86809,6 +86811,23 @@ class Package {
}
}
}
class UnknownPackage {
constructor(variant, arch, platform) {
this.variant = variant;
this.arch = arch;
this.platform = platform;
}
async install(method) {
if (method === INSTALL_METHOD.DETECT && await which(this.variant)) {
// If the install method is "detect" and the package is already installed,
// don't try to install it. This is to bypass architectures that are not
// released in upstream projects (linux-riscv64 for ccache/ccache for example).
}
else {
throw new Error(`No metadata found for combination: variant=${this.variant}, arch=${this.arch}, platform=${this.platform}`);
}
}
}
// platform/stuff helpers //
function detectPlatform() {
switch (external_process_namespaceObject.platform) {
@@ -86828,6 +86847,8 @@ function detectArchKey() {
return "x86_64";
case "arm64":
return "aarch64";
case "riscv64":
return "riscv64";
default:
throw new Error(`Unsupported architecture: ${external_process_namespaceObject.arch}`);
}
@@ -86843,7 +86864,8 @@ function selectPackage(variant) {
const allMetadata = JSON.parse(rawData);
const entry = allMetadata[variant]?.[archKey]?.[platform];
if (!entry) {
throw new Error(`No metadata found for combination: variant=${variant}, arch=${archKey}, platform=${platform}`);
warning(`No metadata found for combination: variant=${variant}, arch=${archKey}, platform=${platform}`);
return new UnknownPackage(variant, archKey, platform);
}
return new Package(variant, archKey, platform, entry);
}
+8
View File
@@ -81,6 +81,14 @@
"dir": "sccache-v0.14.0-aarch64-apple-darwin",
"artifact": "sccache-v0.14.0-aarch64-apple-darwin.tar.gz"
}
},
"riscv64": {
"linux": {
"url": "https://github.com/mozilla/sccache/releases/download/v0.14.0/sccache-v0.14.0-riscv64gc-unknown-linux-musl.tar.gz",
"sha256": "67973734f48edfeb07dcc1adf174c4034dbcc1eb66cfae58076f3546684b9300",
"dir": "sccache-v0.14.0-riscv64gc-unknown-linux-musl",
"artifact": "sccache-v0.14.0-riscv64gc-unknown-linux-musl.tar.gz"
}
}
}
}
+6 -1
View File
@@ -65,7 +65,12 @@ package_info() {
*) _bad_platform "$platform" ;;
esac
pkg_name="sccache-$version-$arch-$suffix"
if [ "$arch" = "riscv64" ]; then
# sccache uses `riscv64gc` as arch name
pkg_name="sccache-$version-riscv64gc-$suffix"
else
pkg_name="sccache-$version-$arch-$suffix"
fi
fi
artifact="$pkg_name.$ext"
+3
View File
@@ -21,6 +21,9 @@
"linux": "v0.14.0",
"windows": "v0.14.0",
"darwin": "v0.14.0"
},
"riscv64": {
"linux": "v0.14.0"
}
}
}
+28 -5
View File
@@ -17,6 +17,7 @@ export enum VARIANT {
export enum ARCH {
X86_64 = "x86_64",
AARCH64 = "aarch64",
RISCV64 = "riscv64",
}
export enum PLATFORM {
@@ -205,6 +206,27 @@ export class Package {
}
}
export class UnknownPackage {
constructor(
public readonly variant: VARIANT,
public readonly arch: ARCH,
public readonly platform: PLATFORM) { }
async install(method: INSTALL_METHOD): Promise<void> {
if (method === INSTALL_METHOD.DETECT && await io.which(this.variant)) {
// If the install method is "detect" and the package is already installed,
// don't try to install it. This is to bypass architectures that are not
// released in upstream projects (linux-riscv64 for ccache/ccache for example).
} else {
throw new Error(
`No metadata found for combination: variant=${this.variant}, arch=${this.arch}, platform=${this.platform}`
);
}
}
}
type MaybePackage = Package | UnknownPackage;
// platform/stuff helpers //
function detectPlatform(): PLATFORM {
switch (process.platform) {
@@ -219,18 +241,20 @@ function detectPlatform(): PLATFORM {
}
}
function detectArchKey(): "x86_64" | "aarch64" {
function detectArchKey(): "x86_64" | "aarch64" | "riscv64" {
switch (process.arch) {
case "x64":
return "x86_64";
case "arm64":
return "aarch64";
case "riscv64":
return "riscv64";
default:
throw new Error(`Unsupported architecture: ${process.arch}`);
}
}
export function selectPackage(variant: VARIANT): Package {
export function selectPackage(variant: VARIANT): MaybePackage {
const platform = detectPlatform()
const archKey = detectArchKey()
@@ -246,9 +270,8 @@ export function selectPackage(variant: VARIANT): Package {
const entry: PackageMetadata = allMetadata[variant]?.[archKey]?.[platform];
if (!entry) {
throw new Error(
`No metadata found for combination: variant=${variant}, arch=${archKey}, platform=${platform}`
);
core.warning(`No metadata found for combination: variant=${variant}, arch=${archKey}, platform=${platform}`)
return new UnknownPackage(variant, archKey as ARCH, platform as PLATFORM);
}
return new Package(variant, archKey as ARCH, platform as PLATFORM, entry);