Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,72 @@
#
# 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.
#
ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME})
include(${pal_dir}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
if(NOT PAL_TRAIT_BUILD_RESOURCECOMPILERLEGACY_SUPPORTED OR NOT PAL_TRAIT_BUILD_HOST_TOOLS)
return()
endif()
ly_add_target(
NAME ResourceCompilerLegacy.Static STATIC
NAMESPACE Legacy
FILES_CMAKE
resourcecompilerlegacy_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
.
BUILD_DEPENDENCIES
PRIVATE
AZ::SceneCore
PUBLIC
Legacy::CryCommon
Legacy::CryCommonTools
Legacy::ResourceCompiler.Static
AZ::AssetBuilderSDK
)
ly_add_target(
NAME ResourceCompilerLegacy MODULE
NAMESPACE Legacy
OUTPUT_SUBDIRECTORY rc_plugins
FILES_CMAKE
resourcecompilerlegacy_shared_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
.
BUILD_DEPENDENCIES
PRIVATE
Legacy::ResourceCompilerLegacy.Static
)
ly_add_dependencies(RC Legacy::ResourceCompilerLegacy)
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
ly_add_target(
NAME ResourceCompilerLegacy.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
NAMESPACE Legacy
FILES_CMAKE
resourcecompilerlegacy_test_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
Source
Tests
.
BUILD_DEPENDENCIES
PRIVATE
AZ::AzTest
Legacy::ResourceCompilerLegacy.Static
)
ly_add_googletest(
NAME Legacy::ResourceCompilerLegacy.Tests
)
endif()
@@ -0,0 +1,29 @@
/*
* 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 "AssetParser.h"
namespace AZ
{
namespace RC
{
AssetParser::AssetParser(const AZStd::string& assetName)
: m_assetName(assetName)
{
}
AssetBuilderSDK::ProductPathDependencySet AssetParser::GetProductDependencies(const AZStd::string& /*fullPath*/)
{
return {};
}
} // namespace RC
} // namespace AZ
@@ -0,0 +1,34 @@
/*
* 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 <AzCore/std/string/string.h>
#include <AzCore/std/containers/vector.h>
#include "AssetBuilderSDK/AssetBuilderSDK.h"
namespace AZ
{
namespace RC
{
class AssetParser
{
public:
AssetParser(const AZStd::string& assetName);
virtual ~AssetParser() {}
virtual AssetBuilderSDK::ProductPathDependencySet GetProductDependencies(const AZStd::string& fullPath);
protected:
AZStd::string m_assetName;
};
} // namespace RC
} // namespace AZ
@@ -0,0 +1,57 @@
/*
* 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 "ProductInfoCreator.h"
#include <CryPath.h>
#include <QFileInfo>
namespace AZ
{
namespace RC
{
ProductInfoCreator::ProductInfoCreator()
{
m_productAssetType = AZ::Data::AssetType::CreateNull();
}
AssetBuilderSDK::JobProduct ProductInfoCreator::GenerateProductInfo(const AZStd::string& sourceFile, const AZStd::string& fullPath)
{
AZStd::unique_ptr<AssetParser> legacyAssetParser = CreateLegacyAssetParser(sourceFile);
AZStd::string fileName = QFileInfo(sourceFile.c_str()).fileName().toUtf8().constData();
AssetBuilderSDK::JobProduct product(fileName, m_productAssetType);
product.m_pathDependencies = legacyAssetParser->GetProductDependencies(fullPath);
product.m_dependenciesHandled = true; // We've populated the dependencies immediately above so it's OK to tell the AP we've handled dependencies
return product;
}
AZStd::unique_ptr<AssetParser> ProductInfoCreator::CreateLegacyAssetParser(const AZStd::string& sourceFile)
{
AZStd::string fileExtension(PathUtil::GetExt(sourceFile.c_str()));
// Use the file extension to select the correct asset parser.
/*Sample code:
if (fileExtension == "font" || fileExtension == "fontfamily")
{
m_productAssetType = fontAssetType;
return AZStd::unique_ptr<AssetParser>(new FontAssetParser(sourceFile));
}*/
return AZStd::unique_ptr<AssetParser>(new AssetParser(sourceFile));
}
} // namespace RC
} // namespace AZ
@@ -0,0 +1,42 @@
/*
* 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 "AssetParser.h"
#include <AzCore/std/smart_ptr/unique_ptr.h>
#include <AzCore/Asset/AssetCommon.h>
#include <AssetBuilderSDK/AssetBuilderSDK.h>
namespace AZ
{
namespace RC
{
static AZ::Data::AssetType fontAssetType("{57767D37-0EBE-43BE-8F60-AB36D2056EF8}"); // form UiAssetTypes.h
class ProductInfoCreator
{
public:
ProductInfoCreator();
AssetBuilderSDK::JobProduct GenerateProductInfo(const AZStd::string& sourceFile, const AZStd::string& fullPath);
protected:
virtual AZStd::unique_ptr<AssetParser> CreateLegacyAssetParser(const AZStd::string& sourceFile);
AZ::Data::AssetType m_productAssetType;
};
} // namespace RC
} // namespace AZ
@@ -0,0 +1,113 @@
/*
* 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 "ResourceCompilerLegacy_precompiled.h"
#include "LegacyCompiler.h"
#include "LegacyAssetParser/ProductInfoCreator.h"
#include "Utilities.h"
#include "CryPath.h"
#include <AssetBuilderSDK/AssetBuilderSDK.h>
#include <AzCore/Memory/AllocatorManager.h>
#include <AzCore/Component/ComponentApplication.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <AzToolsFramework/Application/ToolsApplication.h>
namespace AZ
{
namespace RC
{
LegacyCompiler::LegacyCompiler()
{
}
void LegacyCompiler::Release()
{
delete this;
}
void LegacyCompiler::BeginProcessing(const IConfig* /*config*/)
{
}
bool LegacyCompiler::Process()
{
// Register the AssetBuilderSDK structures needed later on.
AzToolsFramework::ToolsApplication application;
AZ::ComponentApplication::Descriptor descriptor;
application.Start(descriptor);
AssetBuilderSDK::InitializeSerializationContext();
bool result = false;
AssetBuilderSDK::ProcessJobResponse response;
// Read ProcessJobRequest.xml from the output folder
AZStd::unique_ptr<AssetBuilderSDK::ProcessJobRequest> request = ReadJobRequest(m_context.GetOutputFolder().c_str());
if (!request)
{
return WriteResponse(m_context.GetOutputFolder().c_str(), response, false);
}
// Parse the source file and get product dependencies
ProductInfoCreator productInfoCreator;
response.m_outputProducts.push_back(productInfoCreator.GenerateProductInfo(request->m_sourceFile, request->m_fullPath));
// Write ProcessJobResponse.xml to the output folder
return WriteResponse(m_context.GetOutputFolder().c_str(), response, true);
}
void LegacyCompiler::EndProcessing()
{
}
IConvertContext* LegacyCompiler::GetConvertContext()
{
return &m_context;
}
AZStd::unique_ptr<AssetBuilderSDK::ProcessJobRequest> LegacyCompiler::ReadJobRequest(const char* folder) const
{
AZStd::string requestFilePath;
AzFramework::StringFunc::Path::ConstructFull(folder, AssetBuilderSDK::s_processJobRequestFileName, requestFilePath);
AssetBuilderSDK::ProcessJobRequest* result = AZ::Utils::LoadObjectFromFile<AssetBuilderSDK::ProcessJobRequest>(requestFilePath);
if (!result)
{
AZ_Error(LegacyCompilerUtils::TracePrint, false,"Unable to load ProcessJobRequest. Not enough information to process this file %s.\n", requestFilePath.c_str());
}
return AZStd::unique_ptr<AssetBuilderSDK::ProcessJobRequest>(result);
}
bool LegacyCompiler::WriteResponse(const char* cacheFolder, AssetBuilderSDK::ProcessJobResponse& response, bool success) const
{
AZStd::string responseFilePath;
AzFramework::StringFunc::Path::ConstructFull(cacheFolder, AssetBuilderSDK::s_processJobResponseFileName, responseFilePath);
response.m_requiresSubIdGeneration = false;
response.m_resultCode = success ? AssetBuilderSDK::ProcessJobResult_Success : AssetBuilderSDK::ProcessJobResult_Failed;
bool result = AZ::Utils::SaveObjectToFile(responseFilePath, AZ::DataStream::StreamType::ST_XML, &response);
if (!result)
{
AZ_Error(LegacyCompilerUtils::TracePrint, false, "Unable to save ProcessJobResponse file to %s.\n", responseFilePath.c_str());
}
return result && success;
}
} // namespace RC
} // namespace AZ
@@ -0,0 +1,52 @@
/*
* 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 "ResourceCompilerLegacy_precompiled.h"
#include <IConvertor.h>
#include <AzCore/std/smart_ptr/unique_ptr.h>
#include <AzCore/Asset/AssetCommon.h>
namespace AssetBuilderSDK
{
struct ProcessJobRequest;
struct ProcessJobResponse;
}
namespace AZ
{
namespace RC
{
class LegacyCompiler
: public ICompiler
{
public:
LegacyCompiler();
void Release() override;
void BeginProcessing(const IConfig* config) override;
bool Process() override;
void EndProcessing() override;
IConvertContext* GetConvertContext() override;
protected:
AZStd::unique_ptr<AssetBuilderSDK::ProcessJobRequest> ReadJobRequest(const char* folder) const;
bool WriteResponse(const char* folder, AssetBuilderSDK::ProcessJobResponse& response, bool success = true) const;
ConvertContext m_context;
};
}
}
@@ -0,0 +1,58 @@
/*
* 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 "ResourceCompilerLegacy_precompiled.h"
#include <LegacyConverter.h>
#include <LegacyCompiler.h>
#include <AzCore/std/iterator.h>
#include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
namespace AZ
{
namespace RC
{
LegacyConverter::LegacyConverter()
{
}
void LegacyConverter::Release()
{
delete this;
}
void LegacyConverter::Init([[maybe_unused]] const ConvertorInitContext& context)
{
}
ICompiler* LegacyConverter::CreateCompiler()
{
return new LegacyCompiler();
}
const char* LegacyConverter::GetExt(int index) const
{
// List all the file types that should use this resource compiler module to retrieve product dependencies.
// These file types require the old cry code to parse the source asset file.
// Sample Code:
if (index == 0)
{
return "font";
}
else if (index == 1)
{
return "fontfamily";
}
return nullptr;
}
}
}
@@ -0,0 +1,37 @@
/*
* 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 <AzCore/std/string/string.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/smart_ptr/shared_ptr.h>
#include <IConvertor.h>
namespace AZ
{
namespace RC
{
class LegacyConverter
: public IConvertor
{
public:
LegacyConverter();
void Release() override;
void Init(const ConvertorInitContext& context) override;
ICompiler* CreateCompiler() override;
const char* GetExt(int index) const override;
};
}
}
@@ -0,0 +1,12 @@
#
# 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.
#
set(PAL_TRAIT_BUILD_RESOURCECOMPILERLEGACY_SUPPORTED FALSE)
@@ -0,0 +1,12 @@
#
# 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.
#
set(PAL_TRAIT_BUILD_RESOURCECOMPILERLEGACY_SUPPORTED FALSE)
@@ -0,0 +1,12 @@
#
# 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.
#
set(PAL_TRAIT_BUILD_RESOURCECOMPILERLEGACY_SUPPORTED TRUE)
@@ -0,0 +1,12 @@
#
# 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.
#
set(PAL_TRAIT_BUILD_RESOURCECOMPILERLEGACY_SUPPORTED TRUE)
@@ -0,0 +1,12 @@
#
# 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.
#
set(PAL_TRAIT_BUILD_RESOURCECOMPILERLEGACY_SUPPORTED FALSE)
@@ -0,0 +1,28 @@
/*
* 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 "ResourceCompilerLegacy_precompiled.h"
#include <IResCompiler.h>
#include <LegacyConverter.h>
#include <CryCommon/ISystem.h>
//=========================================================================
// RegisterConvertors
//=========================================================================
extern "C" DLL_EXPORT void __stdcall RegisterConvertors(IResourceCompiler* pRC)
{
PREVENT_MODULE_AND_ENVIRONMENT_SYMBOL_STRIPPING
SetRCLog(pRC->GetIRCLog());
pRC->RegisterConvertor("LegacyConverter", new AZ::RC::LegacyConverter());
}
@@ -0,0 +1,37 @@
/*
* 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 <assert.h>
#define CRY_ASSERT(condition) assert(condition)
#define CRY_ASSERT_TRACE(condition, message) assert(condition)
#define CRY_ASSERT_MESSAGE(condition, message) assert(condition)
// Define this to prevent including CryAssert (there is no proper hook for turning this off, like the above).
#define CRYINCLUDE_CRYCOMMON_CRYASSERT_H
#include <platform.h>
#include <functional>
#include <vector>
#include <map>
#include <stdio.h>
#include <AzCore/PlatformDef.h>
#if defined(AZ_PLATFORM_WINDOWS)
#include <tchar.h>
#endif
#include "IRCLog.h"
@@ -0,0 +1,36 @@
<ObjectStream version="3">
<Class name="ProcessJobRequest" version="2" type="{20461454-D2F9-4079-AB95-703905E06002}">
<Class name="AZStd::string" field="Source File" value="Example.fontfamily" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
<Class name="AZStd::string" field="Watch Folder" value="Output" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
<Class name="AZStd::string" field="Full Path" value="Output/Example.fontfamily" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
<Class name="AZ::Uuid" field="Builder Guid" value="{31B74BFD-7046-47AC-A7DA-7D5167E9B2F8}" type="{E152C105-A133-4D03-BBF8-3D4B2FBA3E2A}"/>
<Class name="JobDescriptor" field="Job Description" version="3" type="{BD0472A4-7634-41F3-97EF-00F3B239BAE2}">
<Class name="AZStd::string" field="Additional Fingerprint Info" value="0copy{57767D37-0EBE-43BE-8F60-AB36D2056EF8}" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
<Class name="int" field="Platform" value="1" type="{72039442-EB38-4D42-A1AD-CB68F7E0EEF6}"/>
<Class name="AZStd::string" field="Platform Identifier" value="pc" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
<Class name="AZStd::string" field="Job Key" value="fontfamily" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
<Class name="bool" field="Critical" value="true" type="{A0CA880C-AFE4-43CB-926C-59AC48496112}"/>
<Class name="int" field="Priority" value="1" type="{72039442-EB38-4D42-A1AD-CB68F7E0EEF6}"/>
<Class name="AZStd::unordered_map" field="Job Parameters" type="{4113BC4E-1027-500F-93A2-545C3DBB824D}">
<Class name="AZStd::pair" field="element" type="{3690DA11-3F3B-5A64-B683-471C4BA90FFC}">
<Class name="unsigned int" field="value1" value="1589735409" type="{43DA906B-7DEF-4CA8-9790-854106D3F983}"/>
<Class name="AZStd::string" field="value2" value="fontfamily" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
</Class>
</Class>
<Class name="bool" field="Check Exclusive Lock" value="false" type="{A0CA880C-AFE4-43CB-926C-59AC48496112}"/>
<Class name="bool" field="Fail On Error" value="false" type="{A0CA880C-AFE4-43CB-926C-59AC48496112}"/>
<Class name="AZStd::vector" field="Job Dependency List" type="{DEFBFFD3-D0FA-53B3-B5D3-0ABA49B2FEBD}"/>
</Class>
<Class name="AZStd::string" field="Temp Dir Path" value="Output" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
<Class name="PlatformInfo" field="Platform Info" version="1" type="{F7DA39A5-C319-4552-954B-3479E2454D3F}">
<Class name="AZStd::string" field="Platform Identifier" value="pc" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
<Class name="AZStd::unordered_set" field="Tags on Platform" type="{32EC831B-8AE7-5715-998B-C0C723CB61DA}">
<Class name="AZStd::string" field="element" value="tools" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
<Class name="AZStd::string" field="element" value="renderer" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
</Class>
</Class>
<Class name="AZStd::vector" field="Source File Dependency List" type="{A78563AF-17EE-5D6D-940A-9FE76BD74AB9}"/>
<Class name="AZ::Uuid" field="Source File UUID" value="{A1CEEB96-D5FC-52A6-8678-86722B7DCFB2}" type="{E152C105-A133-4D03-BBF8-3D4B2FBA3E2A}"/>
</Class>
</ObjectStream>
@@ -0,0 +1,112 @@
/*
* 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 "ResourceCompilerLegacy_precompiled.h"
#include "LegacyCompiler.h"
#include <AssetBuilderSDK/AssetBuilderSDK.h>
#include <AzFramework/IO/LocalFileIO.h>
#include <AzCore/Component/ComponentApplication.h>
#include <AzCore/UnitTest/UnitTest.h>
#include <AzCore/UserSettings/UserSettingsComponent.h>
#include <AzToolsFramework/Application/ToolsApplication.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzTest/AzTest.h>
#include <AzTest/Utils.h>
class ResourceCompilerLegacyTest
: public ::testing::Test
, public AZ::RC::LegacyCompiler
{
protected:
void SetUp() override
{
AZ::AllocatorInstance<AZ::SystemAllocator>::Create();
m_app.reset(aznew AzFramework::Application());
AZ::ComponentApplication::Descriptor desc;
desc.m_useExistingAllocator = true;
m_app->Start(desc);
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
// shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
// in the unit tests.
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
AssetBuilderSDK::InitializeSerializationContext();
}
void TearDown() override
{
m_app->Destroy();
m_app.reset();
AZ::AllocatorInstance<AZ::SystemAllocator>::Destroy();
}
AZStd::unique_ptr<AssetBuilderSDK::ProcessJobRequest> WrapReadJobRequest(const char* folder) const
{
return ReadJobRequest(folder);
}
bool WrapWriteResponse(const char* folder, AssetBuilderSDK::ProcessJobResponse& response, bool success = true) const
{
return WriteResponse(folder, response, success);
}
AZStd::unique_ptr<AzFramework::Application> m_app;
};
TEST_F(ResourceCompilerLegacyTest, ReadJobRequest_NoRequestFile_GenerateProcessJobRequest)
{
// Tests without ProcessJobRequest.xml
const char* testFileFolder = "@devroot@/Code/Tools/RC/ResourceCompilerLegacy/Tests";
char testFileResolvedPath[AZ_MAX_PATH_LEN];
AZ::IO::FileIOBase::GetInstance()->ResolvePath(testFileFolder, testFileResolvedPath, AZ_ARRAY_SIZE(testFileResolvedPath));
AZ_TEST_START_TRACE_SUPPRESSION;
ASSERT_FALSE(WrapReadJobRequest(testFileResolvedPath));
// Expected error:
// Unable to load ProcessJobRequest. Not enough information to process this file
AZ_TEST_STOP_TRACE_SUPPRESSION(1);
}
TEST_F(ResourceCompilerLegacyTest, ReadJobRequest_ValidRequestFile_GenerateProcessJobRequest)
{
// Tests reading ProcessJobRequest.xml
const char* testFileFolder = "@devroot@/Code/Tools/RC/ResourceCompilerLegacy/Tests/Output";
char testFileResolvedFolder[AZ_MAX_PATH_LEN];
AZ::IO::FileIOBase::GetInstance()->ResolvePath(testFileFolder, testFileResolvedFolder, AZ_ARRAY_SIZE(testFileResolvedFolder));
ASSERT_TRUE(WrapReadJobRequest(testFileResolvedFolder));
}
TEST_F(ResourceCompilerLegacyTest, WriteJobResponse_ValidProcessJobResponse_WriteProcessJobResponseToDisk)
{
// Tests writing ProcessJobResponse.xml to disk
const char* testFileFolder = "@assets@/Code/Tools/RC/ResourceCompilerLegacy/Tests/Output";
char testFileResolvedFolder[AZ_MAX_PATH_LEN];
AZ::IO::FileIOBase::GetInstance()->ResolvePath(testFileFolder, testFileResolvedFolder, AZ_ARRAY_SIZE(testFileResolvedFolder));
AssetBuilderSDK::ProcessJobResponse response;
ASSERT_TRUE(WrapWriteResponse(testFileResolvedFolder, response));
AZStd::string responseFilePath;
AzFramework::StringFunc::Path::ConstructFull(testFileResolvedFolder, AssetBuilderSDK::s_processJobResponseFileName, responseFilePath);
ASSERT_TRUE(AZ::IO::FileIOBase::GetInstance()->Exists(responseFilePath.c_str()));
ASSERT_TRUE(AZ::IO::FileIOBase::GetInstance()->Remove(responseFilePath.c_str()));
}
AZ_UNIT_TEST_HOOK(DEFAULT_UNIT_TEST_ENV);
@@ -0,0 +1,25 @@
/*
* 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
namespace AZ
{
namespace RC
{
namespace LegacyCompilerUtils
{
// Window name used for logging through AZ_TracePrintf.
const char* const TracePrint = "LegacyCompiler";
} // LegacyCompilerUtils
} // RC
} // AZ
@@ -0,0 +1,23 @@
#
# 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.
#
set(FILES
ResourceCompilerLegacy_precompiled.h
LegacyConverter.h
LegacyConverter.cpp
LegacyCompiler.h
LegacyCompiler.cpp
Utilities.h
LegacyAssetParser/AssetParser.h
LegacyAssetParser/AssetParser.cpp
LegacyAssetParser/ProductInfoCreator.h
LegacyAssetParser/ProductInfoCreator.cpp
)
@@ -0,0 +1,14 @@
#
# 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.
#
set(FILES
ResourceCompilerLegacy.cpp
)
@@ -0,0 +1,14 @@
#
# 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.
#
set(FILES
Tests/test_Main.cpp
)