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,62 @@
/*
* 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 <AzCore/Component/TickBus.h>
#include <AzCore/std/parallel/thread.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <SceneAPI/SceneUI/Handlers/ProcessingHandlers/AsyncOperationProcessingHandler.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneUI
{
AsyncOperationProcessingHandler::AsyncOperationProcessingHandler(Uuid traceTag, AZStd::function<void()> targetFunction, AZStd::function<void()> onComplete, QObject* parent)
: ProcessingHandler(traceTag, parent)
, m_operationToRun(targetFunction)
, m_onComplete(onComplete)
{
}
void AsyncOperationProcessingHandler::BeginProcessing()
{
emit StatusMessageUpdated("Waiting for background processes to complete...");
m_thread.reset(
new AZStd::thread(
[this]()
{
AZ_TraceContext("Tag", m_traceTag);
m_operationToRun();
EBUS_QUEUE_FUNCTION(AZ::TickBus, AZStd::bind(&AsyncOperationProcessingHandler::OnBackgroundOperationComplete, this));
}
)
);
}
void AsyncOperationProcessingHandler::OnBackgroundOperationComplete()
{
m_thread->detach();
m_thread.reset(nullptr);
emit StatusMessageUpdated("Processing complete");
if (m_onComplete)
{
m_onComplete();
}
emit ProcessingComplete();
}
}
}
}
#include <Handlers/ProcessingHandlers/moc_AsyncOperationProcessingHandler.cpp>
@@ -0,0 +1,53 @@
#pragma once
/*
* 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.
*
*/
#if !defined(Q_MOC_RUN)
#include <SceneAPI/SceneUI/Handlers/ProcessingHandlers/ProcessingHandler.h>
#include <AzCore/std/functional.h>
#include <AzCore/std/smart_ptr/unique_ptr.h>
#include <SceneAPI/SceneUI/SceneUIConfiguration.h>
#endif
namespace AZStd
{
class thread;
}
namespace AZ
{
namespace SceneAPI
{
namespace SceneUI
{
class SCENE_UI_API AsyncOperationProcessingHandler : public ProcessingHandler
{
Q_OBJECT
public:
AsyncOperationProcessingHandler(Uuid traceTag, AZStd::function<void()> targetFunction, AZStd::function<void()> onComplete = nullptr, QObject* parent = nullptr);
~AsyncOperationProcessingHandler() override = default;
void BeginProcessing() override;
private:
void OnBackgroundOperationComplete();
private:
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
AZStd::function<void()> m_operationToRun;
AZStd::function<void()> m_onComplete;
AZStd::unique_ptr<AZStd::thread> m_thread;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
}
}
}
@@ -0,0 +1,87 @@
/*
* 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 <QRegExp>
#include <AzCore/Casting/numeric_cast.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <AzToolsFramework/UI/Logging/LogEntry.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <SceneAPI/SceneCore/Utilities/Reporting.h>
#include <SceneAPI/SceneUI/Handlers/ProcessingHandlers/ExportJobProcessingHandler.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneUI
{
ExportJobProcessingHandler::ExportJobProcessingHandler(Uuid traceTag, const AZStd::string& sourceAssetPath, QObject* parent)
: ProcessingHandler(traceTag, parent)
, m_sourceAssetPath(sourceAssetPath)
{
}
void ExportJobProcessingHandler::BeginProcessing()
{
m_jobWatcher.reset(new JobWatcher(m_sourceAssetPath, m_traceTag));
connect(m_jobWatcher.get(), &JobWatcher::JobProcessingComplete, this, &ExportJobProcessingHandler::OnJobProcessingComplete);
connect(m_jobWatcher.get(), &JobWatcher::AllJobsComplete, this, &ExportJobProcessingHandler::OnAllJobsComplete);
m_jobWatcher->StartMonitoring();
emit StatusMessageUpdated("File processing...");
}
void ExportJobProcessingHandler::OnJobQueryFailed([[maybe_unused]] const char* message)
{
emit StatusMessageUpdated("Processing failed.");
AZ_TracePrintf(Utilities::ErrorWindow, "%s", message);
emit ProcessingComplete();
}
void ExportJobProcessingHandler::OnJobProcessingComplete(const AZStd::string& platform, [[maybe_unused]] AZ::u64 jobId, bool success, const AZStd::string& fullLogText)
{
AZ_TraceContext("Platform", platform);
if (!fullLogText.empty())
{
bool parseResult = AzToolsFramework::Logging::LogEntry::ParseLog(fullLogText.c_str(), aznumeric_cast<AZ::u64>(fullLogText.length()),
[this](const AzToolsFramework::Logging::LogEntry& entry)
{
emit AddLogEntry(entry);
});
if (!parseResult)
{
AZ_TracePrintf(Utilities::ErrorWindow, "Failed to parse log. See Asset Processor for more info.");
}
}
if (success)
{
AZ_TracePrintf(Utilities::SuccessWindow, "Job #%i compiled successfully", jobId);
}
else
{
AZ_TracePrintf(Utilities::ErrorWindow, "Job #%i failed", jobId);
}
}
void ExportJobProcessingHandler::OnAllJobsComplete()
{
emit StatusMessageUpdated("All jobs completed.");
emit ProcessingComplete();
}
}
}
}
#include <Handlers/ProcessingHandlers/moc_ExportJobProcessingHandler.cpp>
@@ -0,0 +1,52 @@
#pragma once
/*
* 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.
*
*/
#if !defined(Q_MOC_RUN)
#include <SceneAPI/SceneUI/Handlers/ProcessingHandlers/ProcessingHandler.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/containers/list.h>
#include <AzCore/std/string/string.h>
#include <AzCore/std/smart_ptr/unique_ptr.h>
#include <SceneAPI/SceneUI/SceneUIConfiguration.h>
#include <SceneAPI/SceneUI/CommonWidgets/JobWatcher.h>
#endif
namespace AZ
{
namespace SceneAPI
{
namespace SceneUI
{
class SCENE_UI_API ExportJobProcessingHandler : public ProcessingHandler
{
Q_OBJECT
public:
ExportJobProcessingHandler(Uuid traceTag, const AZStd::string& sourceAssetPath, QObject* parent = nullptr);
~ExportJobProcessingHandler() override = default;
void BeginProcessing() override;
private slots:
void OnJobQueryFailed(const char* message);
void OnJobProcessingComplete(const AZStd::string& platform, AZ::u64 jobId, bool success, const AZStd::string& fullLogText);
void OnAllJobsComplete();
private:
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
AZStd::string m_sourceAssetPath;
AZStd::unique_ptr<JobWatcher> m_jobWatcher;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
} // namespace SceneUI
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,30 @@
/*
* 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 <SceneAPI/SceneUI/Handlers/ProcessingHandlers/ProcessingHandler.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneUI
{
ProcessingHandler::ProcessingHandler(Uuid traceTag, QObject* parent)
: QObject(parent)
, m_traceTag(traceTag)
{
}
}
}
}
#include <Handlers/ProcessingHandlers/moc_ProcessingHandler.cpp>
@@ -0,0 +1,59 @@
#pragma once
/*
* 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.
*
*/
#if !defined(Q_MOC_RUN)
#include <QObject>
#include <AzCore/std/string/string.h>
#include <SceneAPI/SceneUI/SceneUIConfiguration.h>
#endif
namespace AzToolsFramework
{
namespace Logging
{
class LogEntry;
}
}
namespace AZ
{
namespace SceneAPI
{
namespace SceneUI
{
class SCENE_UI_API ProcessingHandler : public QObject
{
Q_OBJECT
public:
// The traceTag uuid is added to the trace context stack before work is done. This allows
// for filtering messages that are send by this processing handler.
explicit ProcessingHandler(Uuid traceTag, QObject* parent = nullptr);
~ProcessingHandler() override = default;
virtual void BeginProcessing() = 0;
signals:
void AddLogEntry(const AzToolsFramework::Logging::LogEntry& entry);
void StatusMessageUpdated(const AZStd::string& message);
void ProcessingComplete();
protected:
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
Uuid m_traceTag;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
}
}
}