Skip to content

Commit 8f94aaf

Browse files
committed
Begin work for displaying architecture of install
1 parent 1c6fdaa commit 8f94aaf

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

source/AppleUtilities.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,10 @@
22
#include <cstdint>
33

44
void getCFBundleVersionFromPlist(const char* path, char* outbuf, uint8_t outbuf_size);
5+
6+
enum architecture{
7+
Unknown = 0,
8+
x86_64 = 1 << 1,
9+
arm64 = 1 << 2,
10+
};
11+
int getArchitectureFromBundle(const char* path);

source/AppleUtilities.mm

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,23 @@ void getCFBundleVersionFromPlist(const char* path, char* outbuf, uint8_t outbuf_
99
memset(outbuf, 0, outbuf_size);
1010
strncpy(outbuf, [item cStringUsingEncoding:NSUTF8StringEncoding], outbuf_size);
1111
}
12+
13+
int getArchitectureFromBundle(const char* path){
14+
auto bundle = [NSBundle bundleWithPath:[NSString stringWithUTF8String:path]];
15+
auto archs = [bundle executableArchitectures];
16+
17+
int archmask = architecture::Unknown;
18+
19+
for(NSNumber* archptr in archs){
20+
auto arch = [archptr intValue];
21+
if (arch == NSBundleExecutableArchitectureX86_64){
22+
archmask |= architecture::x86_64;
23+
}
24+
if (@available(macOS 11.0, *)) {
25+
if (arch == NSBundleExecutableArchitectureARM64){
26+
archmask |= architecture::arm64;
27+
}
28+
}
29+
}
30+
return archmask;
31+
}

source/interface_derived.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,10 @@ void MainFrameDerived::LoadEditorVersions(){
608608
//add it to the backing datastructure
609609
editor e = {buffer, path};
610610
if (std::find(editors.begin(), editors.end(), e) == editors.end()){
611+
//get the target architecture
612+
auto bundlepath = path / entry->d_name / "Unity.app";
613+
auto arch = getArchitectureFromBundle(bundlepath.string().c_str());
614+
611615
a.Add(e.name + " - " + e.path.string());
612616
editors.push_back(e);
613617
}
@@ -619,6 +623,8 @@ void MainFrameDerived::LoadEditorVersions(){
619623
//add it to the backing datastructure
620624
editor e = {entry->d_name, path};
621625
if (std::find(editors.begin(), editors.end(), e) == editors.end()){
626+
auto bundlepath = path / entry->d_name / "Unity.app";
627+
auto arch = getArchitectureFromBundle(bundlepath.string().c_str());
622628
a.Add(e.name + " - " + e.path.string());
623629
editors.push_back(e);
624630
}

0 commit comments

Comments
 (0)