| 486 | } |
| 487 | |
| 488 | bool GameCooker::Build(BuildPlatform platform, BuildConfiguration configuration, const StringView& outputPath, BuildOptions options, const Array<String>& customDefines, const StringView& preset, const StringView& presetTarget) |
| 489 | { |
| 490 | if (IsRunning()) |
| 491 | { |
| 492 | LOG(Warning, "Cannot start a build. Already running."); |
| 493 | return true; |
| 494 | } |
| 495 | PlatformTools* tools = GetTools(platform); |
| 496 | if (tools == nullptr) |
| 497 | { |
| 498 | LOG(Error, "Build platform {0} is not supported.", ::ToString(platform)); |
| 499 | return true; |
| 500 | } |
| 501 | PROFILE_MEM(Editor); |
| 502 | |
| 503 | // Setup |
| 504 | CancelFlag = 0; |
| 505 | ProgressMsg.Clear(); |
| 506 | ProgressValue = 1.0f; |
| 507 | Data = New<CookingData>(); |
| 508 | CookingData& data = *Data; |
| 509 | data.Tools = tools; |
| 510 | data.Platform = platform; |
| 511 | data.Configuration = configuration; |
| 512 | data.Options = options; |
| 513 | data.Preset = preset; |
| 514 | data.PresetTarget = presetTarget; |
| 515 | data.CustomDefines = customDefines; |
| 516 | data.OriginalOutputPath = outputPath; |
| 517 | FileSystem::NormalizePath(data.OriginalOutputPath); |
| 518 | data.OriginalOutputPath = FileSystem::ConvertRelativePathToAbsolute(Globals::ProjectFolder, data.OriginalOutputPath); |
| 519 | data.NativeCodeOutputPath = data.ManagedCodeOutputPath = data.DataOutputPath = data.OriginalOutputPath; |
| 520 | data.CacheDirectory = Globals::ProjectCacheFolder / TEXT("Cooker") / tools->GetName(); |
| 521 | if (!FileSystem::DirectoryExists(data.CacheDirectory)) |
| 522 | { |
| 523 | if (FileSystem::CreateDirectory(data.CacheDirectory)) |
| 524 | { |
| 525 | LOG(Error, "Cannot setup game building cache directory."); |
| 526 | return true; |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | // Start |
| 531 | GameCookerImpl::IsRunning = true; |
| 532 | |
| 533 | // Start thread if need to |
| 534 | if (!IsThreadRunning) |
| 535 | { |
| 536 | Function<int32()> f; |
| 537 | f.Bind(ThreadFunction); |
| 538 | uint32 stackSize = 4 * 1024 * 1024; // Larger stack |
| 539 | const auto thread = ThreadSpawner::Start(f, GameCookerServiceInstance.Name, ThreadPriority::Highest, stackSize); |
| 540 | if (thread == nullptr) |
| 541 | { |
| 542 | GameCookerImpl::IsRunning = false; |
| 543 | LOG(Error, "Failed to start a build thread."); |
| 544 | return true; |
| 545 | } |
no test coverage detected