Skip to content

Commit 24a67b5

Browse files
committed
[DSC] Add support for DriverKit shared caches
1 parent a898e96 commit 24a67b5

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

view/sharedcache/core/SharedCacheView.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ enum DSCPlatform
164164
DSCPlatformiOSSimulator = 7,
165165
DSCPlatformTVOSSimulator = 8,
166166
DSCPlatformWatchOSSimulator = 9,
167+
DSCPlatformDriverKit = 10,
167168
DSCPlatformVisionOS = 11, // Apple Vision Pro
168169
DSCPlatformVisionOSSimulator = 12 // Apple Vision Pro Simulator
169170
};
@@ -220,6 +221,11 @@ bool SharedCacheView::Init()
220221
case DSCPlatformVisionOSSimulator:
221222
os = "ios";
222223
break;
224+
case DSCPlatformDriverKit:
225+
// TODO: The same platform value is used for both macOS and iOS DriverKit shared caches.
226+
// Until we have a way to differentiate them, default to macOS.
227+
os = "mac";
228+
break;
223229
// armv7 or slide info v1 (unsupported)
224230
case DSCPlatformWatchOS:
225231
case DSCPlatformWatchOSSimulator:
@@ -864,7 +870,7 @@ bool SharedCacheView::InitController()
864870
// Verify that we are not missing any entries that were stored in the metadata.
865871
// If we are that means we should alert the user that a previously associated cache entry is missing.
866872
std::set<std::string> missingCacheEntries = m_secondaryFileNames;
867-
uint64_t expectedFileCount = 1;
873+
std::optional<uint64_t> expectedFileCount;
868874
for (const auto& entry : sharedCacheBuilder.GetCache().GetEntries())
869875
{
870876
missingCacheEntries.erase(entry.GetFileName());
@@ -873,21 +879,21 @@ bool SharedCacheView::InitController()
873879
if (entry.GetType() == CacheEntryType::Primary)
874880
{
875881
const auto& entryHeader = entry.GetHeader();
876-
// TODO: Some caches seem to have less sub caches than what we report having.
877-
expectedFileCount += entryHeader.subCacheArrayCount;
878-
// On older caches we don't have any sub-caches, so we want to skip alerting the user to that fact.
879-
if (entryHeader.subCacheArrayOffset == 0)
880-
expectedFileCount = 0;
882+
if (expectedFileCount)
883+
m_logger->LogWarnF("Multiple primary cache files found for '{}'.", m_primaryFileName);
884+
885+
// TODO: Some caches seem to have fewer sub caches than what we report having.
886+
expectedFileCount = 1 + entryHeader.subCacheArrayCount;
881887
}
882888
}
883889
for (const auto& missingFileName: missingCacheEntries)
884890
m_logger->LogErrorF("Secondary cache file '{}' is missing!", missingFileName);
885891

886892
// Verify that we have the required amount of sub-caches, if not alert the user.
887-
if (expectedFileCount == 1)
888-
m_logger->LogWarnF("Primary cache file '{}' has no sub-caches! You are likely opening a secondary cache file instead of a primary one.", m_primaryFileName);
893+
if (!expectedFileCount)
894+
m_logger->LogWarnF("Did not find a primary cache file for '{}'! You are likely opening a secondary cache file instead of a primary one.", m_primaryFileName);
889895
else if (totalEntries < expectedFileCount)
890-
m_logger->LogWarnF("Insufficient cache files in dyld header ({}/{}), loading as partial shared cache...", totalEntries, expectedFileCount);
896+
m_logger->LogWarnF("Insufficient cache files in dyld header ({}/{}), loading as partial shared cache...", totalEntries, *expectedFileCount);
891897
}
892898

893899
auto sharedCache = sharedCacheBuilder.Finalize();

0 commit comments

Comments
 (0)