feat: Add support for a new architecture loongarch

This commit is contained in:
zevanzhao 2025-07-10 22:33:19 +08:00
parent 14a94d379a
commit e7ade5bc7f
5 changed files with 16 additions and 5 deletions

View File

@ -35,6 +35,7 @@ namespace mamba::specs
linux_s390x, linux_s390x,
linux_riscv32, linux_riscv32,
linux_riscv64, linux_riscv64,
linux_loongarch64,
osx_64, osx_64,
osx_arm64, osx_arm64,
win_32, win_32,
@ -190,6 +191,8 @@ namespace mamba::specs
return "linux-riscv32"; return "linux-riscv32";
case KnownPlatform::linux_riscv64: case KnownPlatform::linux_riscv64:
return "linux-riscv64"; return "linux-riscv64";
case KnownPlatform::linux_loongarch64:
return "linux-loongarch64";
case KnownPlatform::osx_64: case KnownPlatform::osx_64:
return "osx-64"; return "osx-64";
case KnownPlatform::osx_arm64: case KnownPlatform::osx_arm64:

View File

@ -38,7 +38,8 @@ namespace mamba::specs
|| (plat == KnownPlatform::linux_ppc64) // || (plat == KnownPlatform::linux_ppc64) //
|| (plat == KnownPlatform::linux_s390x) // || (plat == KnownPlatform::linux_s390x) //
|| (plat == KnownPlatform::linux_riscv32) // || (plat == KnownPlatform::linux_riscv32) //
|| (plat == KnownPlatform::linux_riscv64); || (plat == KnownPlatform::linux_riscv64) //
|| (plat == KnownPlatform::linux_loongarch64);
} }
auto platform_is_linux(DynamicPlatform plat) -> bool auto platform_is_linux(DynamicPlatform plat) -> bool
@ -119,6 +120,8 @@ namespace mamba::specs
return KnownPlatform::linux_riscv32; return KnownPlatform::linux_riscv32;
#elif defined(__riscv) && defined(__riscv_xlen) && (__riscv_xlen == 64) #elif defined(__riscv) && defined(__riscv_xlen) && (__riscv_xlen == 64)
return KnownPlatform::linux_riscv64; return KnownPlatform::linux_riscv64;
#elif defined(__loongarch64)
return KnownPlatform::linux_loongarch64;
#else #else
#error "Unknown Linux platform" #error "Unknown Linux platform"
#endif #endif

View File

@ -17,6 +17,7 @@ namespace
SECTION("name") SECTION("name")
{ {
REQUIRE(platform_name(KnownPlatform::linux_riscv32) == "linux-riscv32"); REQUIRE(platform_name(KnownPlatform::linux_riscv32) == "linux-riscv32");
REQUIRE(platform_name(KnownPlatform::linux_loongarch64) == "linux-loongarch64");
REQUIRE(platform_name(KnownPlatform::osx_arm64) == "osx-arm64"); REQUIRE(platform_name(KnownPlatform::osx_arm64) == "osx-arm64");
REQUIRE(platform_name(KnownPlatform::win_64) == "win-64"); REQUIRE(platform_name(KnownPlatform::win_64) == "win-64");
} }
@ -24,6 +25,7 @@ namespace
SECTION("parse") SECTION("parse")
{ {
REQUIRE(platform_parse("linux-armv6l") == KnownPlatform::linux_armv6l); REQUIRE(platform_parse("linux-armv6l") == KnownPlatform::linux_armv6l);
REQUIRE(platform_parse("linux-loongarch64") == KnownPlatform::linux_loongarch64);
REQUIRE(platform_parse(" win-32 ") == KnownPlatform::win_32); REQUIRE(platform_parse(" win-32 ") == KnownPlatform::win_32);
REQUIRE(platform_parse(" OSX-64") == KnownPlatform::osx_64); REQUIRE(platform_parse(" OSX-64") == KnownPlatform::osx_64);
REQUIRE(platform_parse("linus-46") == std::nullopt); REQUIRE(platform_parse("linus-46") == std::nullopt);
@ -32,10 +34,11 @@ namespace
SECTION("known_platform") SECTION("known_platform")
{ {
static constexpr decltype(known_platform_names()) expected{ static constexpr decltype(known_platform_names()) expected{
"noarch", "linux-32", "linux-64", "linux-armv6l", "linux-armv7l", "noarch", "linux-32", "linux-64", "linux-armv6l",
"linux-aarch64", "linux-ppc64le", "linux-ppc64", "linux-s390x", "linux-riscv32", "linux-armv7l", "linux-aarch64", "linux-ppc64le", "linux-ppc64",
"linux-riscv64", "osx-64", "osx-arm64", "win-32", "win-64", "linux-s390x", "linux-riscv32", "linux-riscv64", "linux-loongarch64",
"win-arm64", "zos-z", "osx-64", "osx-arm64", "win-32", "win-64",
"win-arm64", "zos-z",
}; };
REQUIRE(expected == known_platform_names()); REQUIRE(expected == known_platform_names());

View File

@ -75,6 +75,7 @@ namespace mambapy
.value("linux_s390x", KnownPlatform::linux_s390x) .value("linux_s390x", KnownPlatform::linux_s390x)
.value("linux_riscv32", KnownPlatform::linux_riscv32) .value("linux_riscv32", KnownPlatform::linux_riscv32)
.value("linux_riscv64", KnownPlatform::linux_riscv64) .value("linux_riscv64", KnownPlatform::linux_riscv64)
.value("linux_loongarch64", KnownPlatform::linux_loongarch64)
.value("osx_64", KnownPlatform::osx_64) .value("osx_64", KnownPlatform::osx_64)
.value("osx_arm64", KnownPlatform::osx_arm64) .value("osx_arm64", KnownPlatform::osx_arm64)
.value("win_32", KnownPlatform::win_32) .value("win_32", KnownPlatform::win_32)

View File

@ -47,6 +47,7 @@ def test_KnownPlatform():
assert KnownPlatform.linux_s390x.name == "linux_s390x" assert KnownPlatform.linux_s390x.name == "linux_s390x"
assert KnownPlatform.linux_riscv32.name == "linux_riscv32" assert KnownPlatform.linux_riscv32.name == "linux_riscv32"
assert KnownPlatform.linux_riscv64.name == "linux_riscv64" assert KnownPlatform.linux_riscv64.name == "linux_riscv64"
assert KnownPlatform.linux_loongarch64.name == "linux_loongarch64"
assert KnownPlatform.osx_64.name == "osx_64" assert KnownPlatform.osx_64.name == "osx_64"
assert KnownPlatform.osx_arm64.name == "osx_arm64" assert KnownPlatform.osx_arm64.name == "osx_arm64"
assert KnownPlatform.win_32.name == "win_32" assert KnownPlatform.win_32.name == "win_32"