Skip to content

Commit a8fa558

Browse files
author
nshaheed
committed
add proper support for finding latest package for a unviersal mac binary
1 parent 6f97d3e commit a8fa558

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

src/package.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,16 @@ optional<PackageVersion> Package::latest_version(string os, Architecture arch,
334334
continue;
335335
if (language_version < ck_min_ver)
336336
continue;
337-
if (version.arch != ARCH_ALL && version.arch != arch)
338-
continue;
337+
338+
// special cases for macos universal binaries and ARCH_ANY
339+
if (version.arch != ARCH_ALL && version.arch != arch) {
340+
// The version is a different arch and it's not a mac universal binary
341+
if (version.arch != MAC_UNIVERSAL) continue;
342+
343+
// The version is a mac universal binary and our arch is not a mac arch
344+
if (version.arch == MAC_UNIVERSAL && (arch != X86_64 && arch != ARM64))
345+
continue;
346+
}
339347

340348
if (version.language_version_max) {
341349
ChuckVersion ck_max_ver(version.language_version_max.value());

tests/data/test-package-list.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,29 @@
5555
}
5656
]
5757
},
58+
{
59+
"version": "1.0.0",
60+
"api_version": {
61+
"major": 9,
62+
"minor": 0
63+
},
64+
"language_version_min": {
65+
"mega": 1,
66+
"major": 5,
67+
"minor": 2,
68+
"patch": 1
69+
},
70+
"os": "mac",
71+
"arch": "universal",
72+
"files": [
73+
{
74+
"url": "https://ccrma.stanford.edu/~nshaheed/chugins/Hydra/linux/butt.chug",
75+
"local_dir": "./",
76+
"file_type": "package",
77+
"checksum": "1234"
78+
}
79+
]
80+
},
5881
{
5982
"version": "0.9.1",
6083
"api_version": {

tests/package_list_test.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,14 @@ TEST_CASE("Find Package Version") {
106106
pkglist.find_package_version("Butt", "1.2.0");
107107
REQUIRE_FALSE(version.has_value());
108108
}
109+
110+
SECTION("Mac universal successfully find package") {
111+
optional<PackageVersion> version = pkglist.find_latest_package_version(
112+
"Butt", "mac", arch, ChuckVersion("1.5.2.1"), ApiVersion("9.0"));
113+
114+
REQUIRE(version.has_value());
115+
REQUIRE(version.value().major == 1);
116+
REQUIRE(version.value().minor == 0);
117+
REQUIRE(version.value().patch == 0);
118+
}
109119
}

0 commit comments

Comments
 (0)