/* * All or portions of this file Copyright(c) Amazon.com, Inc.or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution(the "License").All use of this software is governed by the License, *or, if provided, by the license below or the license accompanying this file.Do not * remove or modify any license notices.This file is distributed on an "AS IS" BASIS, *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #include #include "SeedBuilderWorker.h" #include #include #include namespace DependencyBuilder { SeedBuilderWorker::SeedBuilderWorker() : DependencyBuilderWorker("Seed", true) { } void SeedBuilderWorker::RegisterBuilderWorker() { AssetBuilderSDK::AssetBuilderDesc seedBuilderDescriptor; seedBuilderDescriptor.m_name = "SeedBuilderDescriptor"; seedBuilderDescriptor.m_patterns.push_back(AssetBuilderSDK::AssetBuilderPattern("*.seed", AssetBuilderSDK::AssetBuilderPattern::PatternType::Wildcard)); seedBuilderDescriptor.m_busId = azrtti_typeid(); seedBuilderDescriptor.m_version = 1; seedBuilderDescriptor.m_createJobFunction = AZStd::bind(&SeedBuilderWorker::CreateJobs, this, AZStd::placeholders::_1, AZStd::placeholders::_2); seedBuilderDescriptor.m_processJobFunction = AZStd::bind(&SeedBuilderWorker::ProcessJob, this, AZStd::placeholders::_1, AZStd::placeholders::_2); AssetBuilderSDK::AssetBuilderCommandBus::Handler::BusConnect(seedBuilderDescriptor.m_busId); AssetBuilderSDK::AssetBuilderBus::Broadcast(&AssetBuilderSDK::AssetBuilderBusTraits::RegisterBuilderInformation, seedBuilderDescriptor); } void SeedBuilderWorker::UnregisterBuilderWorker() { AssetBuilderSDK::AssetBuilderCommandBus::Handler::BusDisconnect(); } AZ::Outcome, AZStd::string> SeedBuilderWorker::GetSourceDependencies(const AssetBuilderSDK::CreateJobsRequest& request) const { AZStd::string fullPath; AzFramework::StringFunc::Path::ConstructFull(request.m_watchFolder.c_str(), request.m_sourceFile.c_str(), fullPath, false); AzFramework::StringFunc::Path::Normalize(fullPath); AzFramework::AssetSeedList assetSeedList; if (!AZ::Utils::LoadObjectFromFileInPlace(fullPath.c_str(), assetSeedList)) { return AZ::Failure((AZStd::string::format("Unable to deserialize file (%s) from disk.\n", fullPath.c_str()))); } AZStd::vector sourceFileDependencies; for (AzFramework::SeedInfo& seedInfo : assetSeedList) { AssetBuilderSDK::SourceFileDependency dependency; dependency.m_sourceFileDependencyUUID = seedInfo.m_assetId.m_guid; sourceFileDependencies.emplace_back(dependency); } return AZ::Success(sourceFileDependencies); } }