| 343 | } |
| 344 | |
| 345 | bool Scripting::LoadBinaryModules(const String& path, const String& projectFolderPath) |
| 346 | { |
| 347 | PROFILE_CPU_NAMED("LoadBinaryModules"); |
| 348 | PROFILE_MEM(Scripting); |
| 349 | LOG(Info, "Loading binary modules from build info file {0}", path); |
| 350 | |
| 351 | // Read file contents |
| 352 | Array<byte> fileData; |
| 353 | if (File::ReadAllBytes(path, fileData)) |
| 354 | { |
| 355 | LOG(Error, "Failed to read file contents."); |
| 356 | return true; |
| 357 | } |
| 358 | |
| 359 | // Parse Json data |
| 360 | rapidjson_flax::Document document; |
| 361 | { |
| 362 | PROFILE_CPU_NAMED("Json.Parse"); |
| 363 | document.Parse((char*)fileData.Get(), fileData.Count()); |
| 364 | } |
| 365 | if (document.HasParseError()) |
| 366 | { |
| 367 | LOG(Error, "Failed to file contents."); |
| 368 | return true; |
| 369 | } |
| 370 | |
| 371 | // TODO: validate Name, Platform, Architecture, Configuration from file |
| 372 | |
| 373 | // Load all references |
| 374 | auto referencesMember = document.FindMember("References"); |
| 375 | if (referencesMember != document.MemberEnd() && referencesMember->value.IsArray()) |
| 376 | { |
| 377 | auto& referencesArray = referencesMember->value; |
| 378 | for (rapidjson::SizeType i = 0; i < referencesArray.Size(); i++) |
| 379 | { |
| 380 | auto& reference = referencesArray[i]; |
| 381 | String referenceProjectPath = JsonTools::GetString(reference, "ProjectPath", String::Empty); |
| 382 | if (referenceProjectPath == TEXT("$(EnginePath)/Flax.flaxproj")) |
| 383 | continue; // Skip reference to engine |
| 384 | String referencePath = JsonTools::GetString(reference, "Path", String::Empty); |
| 385 | if (referenceProjectPath.IsEmpty() || referencePath.IsEmpty()) |
| 386 | { |
| 387 | LOG(Error, "Empty reference."); |
| 388 | return true; |
| 389 | } |
| 390 | |
| 391 | ProcessBuildInfoPath(referenceProjectPath, projectFolderPath); |
| 392 | ProcessBuildInfoPath(referencePath, projectFolderPath); |
| 393 | |
| 394 | String referenceProjectFolderPath = StringUtils::GetDirectoryName(referenceProjectPath); |
| 395 | |
| 396 | if (LoadBinaryModules(referencePath, referenceProjectFolderPath)) |
| 397 | { |
| 398 | LOG(Error, "Failed to load reference."); |
| 399 | return true; |
| 400 | } |
| 401 | } |
| 402 | } |
nothing calls this directly
no test coverage detected