File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,19 @@ MTL::Library* try_load_bundle(
7272 }
7373 return nullptr ;
7474}
75+
76+ MTL::Library* try_load_framework (
77+ MTL::Device* device,
78+ NS::URL* url,
79+ const std::string& lib_name) {
80+ std::string resource_path = std::string (url->fileSystemRepresentation ()) +
81+ " /" + lib_name + " .metallib" ;
82+ auto [lib, error] = load_library_from_path (device, resource_path.c_str ());
83+ if (lib) {
84+ return lib;
85+ }
86+ return nullptr ;
87+ }
7588#endif
7689
7790// Firstly, search for the metallib in the same path as this binary
@@ -103,6 +116,17 @@ std::pair<MTL::Library*, NS::Error*> load_swiftpm_library(
103116 return {library, nullptr };
104117 }
105118 }
119+ // if SWIFTPM_BUNDLE is a framework identifier, try loading from that
120+ auto frameworks = NS::Bundle::allFrameworks ();
121+ for (int i = 0 , c = (int )frameworks->count (); i < c; i++) {
122+ auto bundle = reinterpret_cast <NS::Bundle*>(frameworks->object (i));
123+ if (!strcmp (bundle->bundleIdentifier ()->utf8String (), SWIFTPM_BUNDLE)) {
124+ library = try_load_framework (device, bundle->resourceURL (), lib_name);
125+ if (library != nullptr ) {
126+ return {library, nullptr };
127+ }
128+ }
129+ }
106130#endif
107131 return {nullptr , nullptr };
108132}
You can’t perform that action at this time.
0 commit comments