| 2322 | }; |
| 2323 | |
| 2324 | static MapFile parseMapFile(Diagnostics& diags, json::Node& mapNode) |
| 2325 | { |
| 2326 | MapFile mapFile; |
| 2327 | |
| 2328 | // Top level node should be a map of the version and files |
| 2329 | if ( mapNode.map.empty() ) { |
| 2330 | diags.error("Expected map for JSON cache map node\n"); |
| 2331 | return { }; |
| 2332 | } |
| 2333 | |
| 2334 | // Parse the nodes in the top level manifest node |
| 2335 | const json::Node& versionMapNode = json::getRequiredValue(diags, mapNode, "version"); |
| 2336 | uint64_t mapVersion = json::parseRequiredInt(diags, versionMapNode); |
| 2337 | if ( diags.hasError() ) |
| 2338 | return { }; |
| 2339 | |
| 2340 | const uint64_t supportedMapVersion = 1; |
| 2341 | if ( mapVersion != supportedMapVersion ) { |
| 2342 | diags.error("JSON map version of %lld is unsupported. Supported version is %lld\n", |
| 2343 | mapVersion, supportedMapVersion); |
| 2344 | return { }; |
| 2345 | } |
| 2346 | |
| 2347 | // Parse arch if we have it |
| 2348 | if ( const json::Node* archNode = json::getOptionalValue(diags, mapNode, "arch") ) |
| 2349 | mapFile.archName = archNode->value; |
| 2350 | |
| 2351 | // Parse arch if we have it |
| 2352 | if ( const json::Node* platformNode = json::getOptionalValue(diags, mapNode, "platform") ) |
| 2353 | mapFile.platformName = platformNode->value; |
| 2354 | |
| 2355 | // Parse the images |
| 2356 | const json::Node& imagesNode = json::getRequiredValue(diags, mapNode, "images"); |
| 2357 | if ( diags.hasError() ) |
| 2358 | return { }; |
| 2359 | if ( imagesNode.array.empty() ) { |
| 2360 | diags.error("Images node is not an array\n"); |
| 2361 | return { }; |
| 2362 | } |
| 2363 | |
| 2364 | for (const json::Node& imageNode : imagesNode.array) { |
| 2365 | const json::Node& pathNode = json::getRequiredValue(diags, imageNode, "path"); |
| 2366 | if (pathNode.value.empty()) { |
| 2367 | diags.error("Image path node is not a string\n"); |
| 2368 | return { }; |
| 2369 | } |
| 2370 | mapFile.imagePaths.push_back(pathNode.value); |
| 2371 | } |
| 2372 | |
| 2373 | return mapFile; |
| 2374 | } |
| 2375 | |
| 2376 | BaselineCachesChecker::BaselineCachesChecker(std::vector<const char*> archs, mach_o::Platform platform) |
| 2377 | { |
no test coverage detected