commit 5cfa34158b1174c3adeaef11ca90b3765d7bec96
parent 8325b97f022849edadec9839c3b9a4c8c97477bb
Author: cfillion <cfillion@users.noreply.github.com>
Date: Tue, 29 Oct 2024 15:32:00 -0400
install x64 binaries when packages don't provide arm64ec ones
Diffstat:
4 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/src/index_v1.cpp b/src/index_v1.cpp
@@ -22,11 +22,11 @@
#include <sstream>
-static void LoadMetadataV1(XmlNode , Metadata *);
-static void LoadCategoryV1(XmlNode , Index *);
-static void LoadPackageV1(XmlNode , Category *);
-static void LoadVersionV1(XmlNode , Package *);
-static void LoadSourceV1(XmlNode , Version *);
+static void LoadMetadataV1(XmlNode, Metadata *);
+static void LoadCategoryV1(XmlNode, Index *);
+static void LoadPackageV1(XmlNode, Category *);
+static void LoadVersionV1(XmlNode, Package *);
+static void LoadSourceV1(XmlNode, Version *, bool hasArm64Ec);
void Index::loadV1(XmlNode root, Index *ri)
{
@@ -117,8 +117,21 @@ void LoadVersionV1(XmlNode verNode, Package *pkg)
XmlNode node = verNode.firstChild("source");
+ bool hasArm64Ec = false;
+#if defined(_WIN32) && defined(_M_ARM64EC)
while(node) {
- LoadSourceV1(node, ver);
+ const char *platform = *node.attribute("platform");
+ if(platform && Platform(platform) == Platform::Windows_arm64ec) {
+ hasArm64Ec = true;
+ break;
+ }
+ node = node.nextSibling("source");
+ }
+ node = verNode.firstChild("source");
+#endif
+
+ while(node) {
+ LoadSourceV1(node, ver, hasArm64Ec);
node = node.nextSibling("source");
}
@@ -133,7 +146,7 @@ void LoadVersionV1(XmlNode verNode, Package *pkg)
ptr.release();
}
-void LoadSourceV1(XmlNode node, Version *ver)
+void LoadSourceV1(XmlNode node, Version *ver, const bool hasArm64Ec)
{
const XmlString &platform = node.attribute("platform"),
&type = node.attribute("type"),
@@ -146,7 +159,7 @@ void LoadSourceV1(XmlNode node, Version *ver)
std::unique_ptr<Source> ptr(src);
src->setChecksum(checksum.value_or(""));
- src->setPlatform(platform.value_or("all"));
+ src->setPlatform(Platform(platform.value_or("all"), hasArm64Ec));
src->setTypeOverride(Package::getType(type.value_or("")));
int sections = 0;
diff --git a/src/platform.cpp b/src/platform.cpp
@@ -62,7 +62,7 @@ const Platform::Enum Platform::Current = Platform::
static_assert(Platform::Current != Platform::Unknown,
"The current operating system or architecture is not supported.");
-auto Platform::parse(const char *platform) -> Enum
+auto Platform::parse(const char *platform, const bool hasArm64Ec) -> Enum
{
constexpr std::pair<const char *, Enum> map[] {
{ "all", Generic },
@@ -85,8 +85,11 @@ auto Platform::parse(const char *platform) -> Enum
};
for(auto &[key, value] : map) {
- if(!strcmp(platform, key))
+ if(!strcmp(platform, key)) {
+ if(!hasArm64Ec && value == Windows_x64)
+ return Windows_x64_arm64ec;
return value;
+ }
}
return Unknown;
diff --git a/src/platform.hpp b/src/platform.hpp
@@ -38,6 +38,7 @@ public:
Windows_x64 = 1<<8,
Windows_arm64ec = 1<<9,
Windows_Any = Windows_x86 | Windows_x64 | Windows_arm64ec,
+ Windows_x64_arm64ec = Windows_x64 | Windows_arm64ec,
Generic = Darwin_Any | Linux_Any | Windows_Any,
};
@@ -46,7 +47,7 @@ public:
Platform() : m_value(Generic) {}
Platform(Enum val) : m_value(val) {}
- Platform(const char *str) : m_value(parse(str)) {}
+ Platform(const char *str, bool hasArm64Ec = true) : m_value(parse(str, hasArm64Ec)) {}
Enum value() const { return m_value; }
bool test() const;
@@ -55,7 +56,7 @@ public:
Platform &operator=(Enum n) { m_value = n; return *this; }
private:
- static Enum parse(const char *);
+ static Enum parse(const char *, bool hasArm64Ec);
Enum m_value;
};
diff --git a/test/platform.cpp b/test/platform.cpp
@@ -23,6 +23,7 @@ TEST_CASE("platform from string", M) {
REQUIRE(Platform("windows") == Platform::Windows_Any);
REQUIRE(Platform("win32") == Platform::Windows_x86);
REQUIRE(Platform("win64") == Platform::Windows_x64);
+ REQUIRE(Platform("win64", false) == Platform::Windows_x64_arm64ec);
REQUIRE(Platform("windows-arm64ec") == Platform::Windows_arm64ec);
}