/* * 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. * */ #pragma once #include #include #include #include #include namespace CopyDependencyBuilder { const char SchemaNamePattern[] = "*.xmlschema"; const char VersionContraintRegexStr[] = "(?:(~>|[>=<]{1,2}) *([0-9]+(?:\\.[0-9]+)*))"; const char VersionRegexStr[] = "([0-9]+)(?:\\.(.*)){0,1}"; const size_t MaxVersionPartsCount = 4; class XmlBuilderWorker : public CopyDependencyBuilderWorker { public: AZ_RTTI(XmlBuilderWorker, "{7FC5D0F1-25E3-4CD2-8FB9-81CB29D940E3}"); XmlBuilderWorker(); void RegisterBuilderWorker() override; void UnregisterBuilderWorker() override; AZ::Outcome, AZStd::string> GetSourceDependencies( const AssetBuilderSDK::CreateJobsRequest& request) const override; bool ParseProductDependencies( const AssetBuilderSDK::ProcessJobRequest& request, AZStd::vector& productDependencies, AssetBuilderSDK::ProductPathDependencySet& pathDependencies) override; void AddSchemaFileDirectory(const AZStd::string& schemaFileLocation); void SetPrintDebug(bool setDebug) { m_printDebug = setDebug; } private: // Traverse the entire source file to create a list of all the XML nodes and mappings from node names to the corresponding nodes void TraverseSourceFile( const AZ::rapidxml::xml_node* currentNode, AZStd::unordered_map*>>& xmlNodeMappings, AZStd::vector*>& xmlNodeList) const; enum class SchemaMatchResult { MatchFound, NoMatchFound, Error }; SchemaMatchResult MatchExistingSchema( const AZStd::string& sourceFilePath, AZStd::vector& sourceDependencyPaths, AZStd::vector& productDependencies, AssetBuilderSDK::ProductPathDependencySet& pathDependencies, const AZStd::string& watchFolderPath) const; SchemaMatchResult MatchLastUsedSchema( const AZStd::string& sourceFilePath, AZStd::vector& productDependencies, AssetBuilderSDK::ProductPathDependencySet& pathDependencies, const AZStd::string& watchFolderPath) const; SchemaMatchResult ParseXmlFile( const AZStd::string& schemaFilePath, const AZStd::string& sourceFilePath, AZStd::vector& productDependencies, AssetBuilderSDK::ProductPathDependencySet& pathDependencies, const AZStd::string& watchFolderPath) const; AZ::Outcome SearchForMatchingRule( const AZStd::string& sourceFilePath, const AZStd::string& schemaFilePath, const AzFramework::Version& version, const AZStd::vector& matchingRules, const AZStd::string& watchFolderPath) const; bool SearchForDependencySearchRule( AZ::rapidxml::xml_node* xmlFileRootNode, const AZStd::string& schemaFilePath, const AzFramework::Version& version, const AZStd::vector& matchingRules, AZStd::vector& productDependencies, AssetBuilderSDK::ProductPathDependencySet& pathDependencies, const AZStd::string& sourceAssetFolder, const AZStd::string& watchFolderPath) const; AZStd::list m_schemaFileDirectories; bool m_printDebug{ false }; }; }