Merge branch 'main' into jckand/FoundationAuto

This commit is contained in:
jckand-amzn
2021-05-26 13:03:26 -05:00
76 changed files with 734 additions and 848 deletions
+4
View File
@@ -128,6 +128,10 @@ foreach(external_directory ${LY_EXTERNAL_SUBDIRS})
endforeach()
# The following steps have to be done after all targets are registered:
# Defer generation of the StaticModules.inl file which is needed to create the AZ::Module derived class in monolithic
# builds until after all the targets are known
ly_delayed_generate_static_modules_inl()
# 1. generate a settings registry .setreg file for all ly_add_project_dependencies() and ly_add_target_dependencies() calls
# to provide applications with the filenames of gem modules to load
# This must be done before ly_delayed_target_link_libraries() as that inserts BUILD_DEPENDENCIES as MANUALLY_ADDED_DEPENDENCIES
@@ -244,7 +244,7 @@ public class LumberyardActivity extends NativeActivity
boolean useMainObb = GetBooleanResource("use_main_obb");
boolean usePatchObb = GetBooleanResource("use_patch_obb");
if (IsBootstrapInAPK() && (useMainObb || usePatchObb))
if (AreAssetsInAPK() && (useMainObb || usePatchObb))
{
Log.d(TAG, "Using OBB expansion files for game assets");
@@ -421,12 +421,12 @@ public class LumberyardActivity extends NativeActivity
}
////////////////////////////////////////////////////////////////
private boolean IsBootstrapInAPK()
private boolean AreAssetsInAPK()
{
try
{
InputStream bootstrap = getAssets().open("bootstrap.cfg", AssetManager.ACCESS_UNKNOWN);
bootstrap.close();
InputStream engine = getAssets().open("engine.json", AssetManager.ACCESS_UNKNOWN);
engine.close();
return true;
}
catch (IOException exception)
@@ -148,7 +148,7 @@ namespace AZ
}
}
AZ_Assert(false, "Failed to locate the bootstrap.cfg path");
AZ_Assert(false, "Failed to locate the engine.json path");
return nullptr;
}
+2 -2
View File
@@ -73,8 +73,8 @@ namespace AZ
//! \return The pointer position of the relative asset path
AZ::IO::FixedMaxPath StripApkPrefix(const char* filePath);
//! Searches application storage and the APK for bootstrap.cfg. Will return nullptr
//! if bootstrap.cfg is not found.
//! Searches application storage and the APK for engine.json. Will return nullptr
//! if engine.json is not found.
const char* FindAssetsDirectory();
//! Calls into Java to show the splash screen on the main UI (Java) thread
@@ -462,8 +462,6 @@ namespace AZ
// for the application root.
CalculateAppRoot();
// Merge the bootstrap.cfg file into the Settings Registry as soon as the OSAllocator has been created.
SettingsRegistryMergeUtils::MergeSettingsToRegistry_Bootstrap(*m_settingsRegistry);
SettingsRegistryMergeUtils::MergeSettingsToRegistry_O3deUserRegistry(*m_settingsRegistry, AZ_TRAIT_OS_PLATFORM_CODENAME, {});
SettingsRegistryMergeUtils::MergeSettingsToRegistry_CommandLine(*m_settingsRegistry, m_commandLine, executeRegDumpCommands);
SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*m_settingsRegistry);
@@ -494,13 +494,6 @@ namespace AZ::SettingsRegistryMergeUtils
return configFileParsed;
}
void MergeSettingsToRegistry_Bootstrap(SettingsRegistryInterface& registry)
{
ConfigParserSettings parserSettings;
parserSettings.m_registryRootPointerPath = BootstrapSettingsRootKey;
MergeSettingsToRegistry_ConfigFile(registry, "bootstrap.cfg", parserSettings);
}
void MergeSettingsToRegistry_AddRuntimeFilePaths(SettingsRegistryInterface& registry)
{
using FixedValueString = AZ::SettingsRegistryInterface::FixedValueString;
@@ -172,9 +172,6 @@ namespace AZ::SettingsRegistryMergeUtils
bool MergeSettingsToRegistry_ConfigFile(SettingsRegistryInterface& registry, AZStd::string_view filePath,
const ConfigParserSettings& configParserSettings);
//! Loads bootstrap.cfg into the Settings Registry. This file does not support specializations.
void MergeSettingsToRegistry_Bootstrap(SettingsRegistryInterface& registry);
//! Extracts file path information from the environment and bootstrap to calculate the various file paths and adds those
//! to the Settings Registry under the FilePathsRootKey.
void MergeSettingsToRegistry_AddRuntimeFilePaths(SettingsRegistryInterface& registry);
@@ -679,8 +679,6 @@ namespace AzFramework
{
auto fileIoBase = m_archiveFileIO.get();
// Set up the default file aliases based on the settings registry
fileIoBase->SetAlias("@assets@", "");
fileIoBase->SetAlias("@root@", GetEngineRoot());
fileIoBase->SetAlias("@engroot@", GetEngineRoot());
fileIoBase->SetAlias("@projectroot@", GetEngineRoot());
fileIoBase->SetAlias("@exefolder@", GetExecutableFolder());
@@ -694,8 +692,8 @@ namespace AzFramework
pathAliases.clear();
if (m_settingsRegistry->Get(pathAliases.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_CacheRootFolder))
{
fileIoBase->SetAlias("@projectplatformcache@", pathAliases.c_str());
fileIoBase->SetAlias("@assets@", pathAliases.c_str());
fileIoBase->SetAlias("@projectplatformcache@", pathAliases.c_str());
fileIoBase->SetAlias("@root@", pathAliases.c_str()); // Deprecated Use @projectplatformcache@
}
pathAliases.clear();
@@ -46,7 +46,6 @@ namespace AzFramework::ProjectManager
// Store the Command line to the Setting Registry
AZ::SettingsRegistryImpl settingsRegistry;
AZ::SettingsRegistryMergeUtils::StoreCommandLineToRegistry(settingsRegistry, commandLine);
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_Bootstrap(settingsRegistry);
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_O3deUserRegistry(settingsRegistry, AZ_TRAIT_OS_PLATFORM_CODENAME, {});
// Retrieve Command Line from Settings Registry, it may have been updated by the call to FindEngineRoot()
// in MergeSettingstoRegistry_ConfigFile
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Icon / Local</title>
<g id="Icon-/-Local" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<rect id="Rectangle" x="0" y="0" width="24" height="24"></rect>
<polygon id="L" fill="#FFFFFF" fill-rule="nonzero" points="16.9658203 19 16.9658203 16.5 11.1748047 16.5 11.1748047 4.72265625 8.14746094 4.72265625 8.14746094 19"></polygon>
</g>
</svg>

After

Width:  |  Height:  |  Size: 575 B

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Icon / Parent</title>
<g id="Icon-/-Parent" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<rect id="Rectangle" x="0" y="0" width="24" height="24"></rect>
<path d="M10.5449219,19 L10.5449219,13.921875 L11.84375,13.921875 C13.6145833,13.921875 14.9801432,13.514974 15.9404297,12.7011719 C16.9007161,11.8873698 17.3808594,10.7122396 17.3808594,9.17578125 C17.3808594,7.69791667 16.930013,6.58626302 16.0283203,5.84082031 C15.1266276,5.0953776 13.8098958,4.72265625 12.078125,4.72265625 L12.078125,4.72265625 L7.51757812,4.72265625 L7.51757812,19 L10.5449219,19 Z M11.5410156,11.4414062 L10.5449219,11.4414062 L10.5449219,7.203125 L11.921875,7.203125 C12.7486979,7.203125 13.3557943,7.37239583 13.7431641,7.7109375 C14.1305339,8.04947917 14.3242188,8.57356771 14.3242188,9.28320312 C14.3242188,9.98632812 14.093099,10.5218099 13.6308594,10.8896484 C13.1686198,11.257487 12.4720052,11.4414062 11.5410156,11.4414062 L11.5410156,11.4414062 Z" id="P" fill="#FFFFFF" fill-rule="nonzero"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Icon / World</title>
<g id="Icon-/-World" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<rect id="Rectangle" x="0" y="0" width="24" height="24"></rect>
<path d="M9.41210938,19 L11.3359375,11.5195312 C11.4205729,11.1875 11.5410156,10.632487 11.6972656,9.85449219 C11.8535156,9.0764974 11.9511719,8.51171875 11.9902344,8.16015625 C12.016276,8.44661458 12.1155599,9.00813802 12.2880859,9.84472656 C12.460612,10.6813151 12.5826823,11.2330729 12.6542969,11.5 L12.6542969,11.5 L14.5878906,19 L18.0351562,19 L21.6679688,4.72265625 L18.6894531,4.72265625 L16.8730469,12.515625 C16.7558594,12.984375 16.625651,13.5979818 16.4824219,14.3564453 C16.3391927,15.1149089 16.235026,15.7480469 16.1699219,16.2558594 C16.0983073,15.7285156 15.9941406,15.0970052 15.8574219,14.3613281 C15.7207031,13.625651 15.6067708,13.078776 15.515625,12.7207031 L15.515625,12.7207031 L13.4355469,4.72265625 L10.5742188,4.72265625 L8.49414062,12.7207031 C8.37044271,13.1503906 8.23860677,13.7542318 8.09863281,14.5322266 C7.95865885,15.3102214 7.86914062,15.8847656 7.83007812,16.2558594 C7.68684896,15.2011719 7.45572917,13.9544271 7.13671875,12.515625 L7.13671875,12.515625 L5.31054688,4.72265625 L2.33203125,4.72265625 L5.97460938,19 L9.41210938,19 Z" id="W" fill="#FFFFFF" fill-rule="nonzero"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

@@ -354,6 +354,7 @@
<file>img/UI20/toolbar/Grid.svg</file>
<file>img/UI20/toolbar/Lighting.svg</file>
<file>img/UI20/toolbar/Load.svg</file>
<file>img/UI20/toolbar/Local.svg</file>
<file>img/UI20/toolbar/Locked.svg</file>
<file>img/UI20/toolbar/LUA.svg</file>
<file>img/UI20/toolbar/Material.svg</file>
@@ -362,6 +363,7 @@
<file>img/UI20/toolbar/Object_follow_terrain.svg</file>
<file>img/UI20/toolbar/Object_height.svg</file>
<file>img/UI20/toolbar/Object_list.svg</file>
<file>img/UI20/toolbar/Parent.svg</file>
<file>img/UI20/toolbar/particle.svg</file>
<file>img/UI20/toolbar/Play.svg</file>
<file>img/UI20/toolbar/Redo.svg</file>
@@ -380,6 +382,7 @@
<file>img/UI20/toolbar/undo.svg</file>
<file>img/UI20/toolbar/Unlocked.svg</file>
<file>img/UI20/toolbar/Vertex_snapping.svg</file>
<file>img/UI20/toolbar/World.svg</file>
<file>img/UI20/toolbar/X_axis.svg</file>
<file>img/UI20/toolbar/Y_axis.svg</file>
<file>img/UI20/toolbar/Z_axis.svg</file>
@@ -41,7 +41,7 @@ namespace AzToolsFramework
[[maybe_unused]] bool result =
settingsRegistry->Get(m_projectPathWithOsSeparator.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_ProjectPath);
AZ_Assert(result, "Couldn't retrieve project root path");
AZ_Warning("Prefab", result, "Couldn't retrieve project root path");
m_projectPathWithSlashSeparator = AZ::IO::Path(m_projectPathWithOsSeparator.Native(), '/').MakePreferred();
AZ::Interface<PrefabLoaderInterface>::Register(this);
@@ -435,7 +435,7 @@ namespace AzToolsFramework
}
}
static void DestroyTransformModeSelectionCluster(const ViewportUi::ClusterId clusterId)
static void DestroyCluster(const ViewportUi::ClusterId clusterId)
{
ViewportUi::ViewportUiRequestBus::Event(
ViewportUi::DefaultViewportId,
@@ -483,6 +483,26 @@ namespace AzToolsFramework
return worldFromLocal.TransformPoint(CalculateCenterOffset(entityId, pivot));
}
void EditorTransformComponentSelection::UpdateSpaceCluster(const ReferenceFrame referenceFrame)
{
auto buttonIdFromFrameFn = [this](const ReferenceFrame referenceFrame) {
switch (referenceFrame)
{
case ReferenceFrame::Local:
return m_spaceCluster.m_localButtonId;
case ReferenceFrame::Parent:
return m_spaceCluster.m_parentButtonId;
case ReferenceFrame::World:
return m_spaceCluster.m_worldButtonId;
}
return m_spaceCluster.m_parentButtonId;
};
ViewportUi::ViewportUiRequestBus::Event(
ViewportUi::DefaultViewportId, &ViewportUi::ViewportUiRequestBus::Events::SetClusterActiveButton, m_spaceCluster.m_spaceClusterId,
buttonIdFromFrameFn(referenceFrame));
}
namespace ETCS
{
PivotOrientationResult CalculatePivotOrientation(
@@ -789,13 +809,13 @@ namespace AzToolsFramework
EntityIdManipulators& entityIdManipulators,
OptionalFrame& pivotOverrideFrame,
ViewportInteraction::KeyboardModifiers& prevModifiers,
bool& transformChangedInternally)
bool& transformChangedInternally, SpaceCluster spaceCluster)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
entityIdManipulators.m_manipulators->SetLocalPosition(action.LocalPosition());
const ReferenceFrame referenceFrame = ReferenceFrameFromModifiers(action.m_modifiers);
const ReferenceFrame referenceFrame = spaceCluster.m_spaceLock ? spaceCluster.m_currentSpace : ReferenceFrameFromModifiers(action.m_modifiers);
if (action.m_modifiers.Ctrl())
{
@@ -1027,6 +1047,7 @@ namespace AzToolsFramework
EditorManipulatorCommandUndoRedoRequestBus::Handler::BusConnect(entityContextId);
CreateTransformModeSelectionCluster();
CreateSpaceSelectionCluster();
RegisterActions();
SetupBoxSelect();
RefreshSelectedEntityIdsAndRegenerateManipulators();
@@ -1037,7 +1058,9 @@ namespace AzToolsFramework
m_selectedEntityIds.clear();
DestroyManipulators(m_entityIdManipulators);
DestroyTransformModeSelectionCluster(m_transformModeClusterId);
DestroyCluster(m_transformModeClusterId);
DestroyCluster(m_spaceCluster.m_spaceClusterId);
UnregisterActions();
m_pivotOverrideFrame.Reset();
@@ -1274,8 +1297,8 @@ namespace AzToolsFramework
[this, prevModifiers, manipulatorEntityIds](const LinearManipulator::Action& action) mutable -> void
{
UpdateTranslationManipulator(
action, manipulatorEntityIds->m_entityIds, m_entityIdManipulators,
m_pivotOverrideFrame, prevModifiers, m_transformChangedInternally);
action, manipulatorEntityIds->m_entityIds, m_entityIdManipulators, m_pivotOverrideFrame, prevModifiers,
m_transformChangedInternally, m_spaceCluster);
});
translationManipulators->InstallLinearManipulatorMouseUpCallback(
@@ -1305,8 +1328,8 @@ namespace AzToolsFramework
[this, prevModifiers, manipulatorEntityIds](const PlanarManipulator::Action& action) mutable -> void
{
UpdateTranslationManipulator(
action, manipulatorEntityIds->m_entityIds, m_entityIdManipulators,
m_pivotOverrideFrame, prevModifiers, m_transformChangedInternally);
action, manipulatorEntityIds->m_entityIds, m_entityIdManipulators, m_pivotOverrideFrame, prevModifiers,
m_transformChangedInternally, m_spaceCluster);
});
translationManipulators->InstallPlanarManipulatorMouseUpCallback(
@@ -1335,8 +1358,8 @@ namespace AzToolsFramework
[this, prevModifiers, manipulatorEntityIds](const SurfaceManipulator::Action& action) mutable -> void
{
UpdateTranslationManipulator(
action, manipulatorEntityIds->m_entityIds, m_entityIdManipulators,
m_pivotOverrideFrame, prevModifiers, m_transformChangedInternally);
action, manipulatorEntityIds->m_entityIds, m_entityIdManipulators, m_pivotOverrideFrame, prevModifiers,
m_transformChangedInternally, m_spaceCluster);
});
translationManipulators->InstallSurfaceManipulatorMouseUpCallback(
@@ -1414,7 +1437,7 @@ namespace AzToolsFramework
[this, prevModifiers, sharedRotationState]
(const AngularManipulator::Action& action) mutable -> void
{
const ReferenceFrame referenceFrame = ReferenceFrameFromModifiers(action.m_modifiers);
const ReferenceFrame referenceFrame = m_spaceCluster.m_spaceLock ? m_spaceCluster.m_currentSpace : ReferenceFrameFromModifiers(action.m_modifiers);
const AZ::Quaternion manipulatorOrientation = action.m_start.m_rotation * action.m_current.m_delta;
// store the pivot override frame when positioning the manipulator manually (ctrl)
@@ -2566,6 +2589,67 @@ namespace AzToolsFramework
m_transformModeSelectionHandler);
}
void EditorTransformComponentSelection::CreateSpaceSelectionCluster()
{
// create the cluster for switching spaces/reference frames
ViewportUi::ViewportUiRequestBus::EventResult(
m_spaceCluster.m_spaceClusterId, ViewportUi::DefaultViewportId, &ViewportUi::ViewportUiRequestBus::Events::CreateCluster,
ViewportUi::Alignment::TopRight);
// create and register the buttons (strings correspond to icons even if the values appear different)
m_spaceCluster.m_worldButtonId = RegisterClusterButton(m_spaceCluster.m_spaceClusterId, "World");
m_spaceCluster.m_parentButtonId = RegisterClusterButton(m_spaceCluster.m_spaceClusterId, "Parent");
m_spaceCluster.m_localButtonId = RegisterClusterButton(m_spaceCluster.m_spaceClusterId, "Local");
auto onButtonClicked = [this](ViewportUi::ButtonId buttonId) {
if (buttonId == m_spaceCluster.m_localButtonId)
{
// Unlock
if (m_spaceCluster.m_spaceLock && m_spaceCluster.m_currentSpace == ReferenceFrame::Local)
{
m_spaceCluster.m_spaceLock = false;
}
else
{
m_spaceCluster.m_spaceLock = true;
m_spaceCluster.m_currentSpace = ReferenceFrame::Local;
}
}
else if (buttonId == m_spaceCluster.m_parentButtonId)
{
// Unlock
if (m_spaceCluster.m_spaceLock && m_spaceCluster.m_currentSpace == ReferenceFrame::Parent)
{
m_spaceCluster.m_spaceLock = false;
}
else
{
m_spaceCluster.m_spaceLock = true;
m_spaceCluster.m_currentSpace = ReferenceFrame::Parent;
}
}
else if (buttonId == m_spaceCluster.m_worldButtonId)
{
// Unlock
if (m_spaceCluster.m_spaceLock && m_spaceCluster.m_currentSpace == ReferenceFrame::World)
{
m_spaceCluster.m_spaceLock = false;
}
else
{
m_spaceCluster.m_spaceLock = true;
m_spaceCluster.m_currentSpace = ReferenceFrame::World;
}
}
};
m_spaceCluster.m_spaceSelectionHandler = AZ::Event<ViewportUi::ButtonId>::Handler(onButtonClicked);
ViewportUi::ViewportUiRequestBus::Event(
ViewportUi::DefaultViewportId, &ViewportUi::ViewportUiRequestBus::Events::RegisterClusterEventHandler,
m_spaceCluster.m_spaceClusterId, m_spaceCluster.m_spaceSelectionHandler);
}
EditorTransformComponentSelectionRequests::Mode EditorTransformComponentSelection::GetTransformMode()
{
return m_mode;
@@ -3277,7 +3361,10 @@ namespace AzToolsFramework
ViewportInteraction::BuildMouseButtons(
QGuiApplication::mouseButtons()), m_boxSelect.Active());
const ReferenceFrame referenceFrame = ReferenceFrameFromModifiers(modifiers);
const ReferenceFrame referenceFrame =
m_spaceCluster.m_spaceLock ? m_spaceCluster.m_currentSpace : ReferenceFrameFromModifiers(modifiers);
UpdateSpaceCluster(referenceFrame);
bool refresh = false;
if (referenceFrame != m_referenceFrame)
@@ -106,6 +106,17 @@ namespace AzToolsFramework
World, //!< World space (space aligned to world axes - identity).
};
struct SpaceCluster
{
ViewportUi::ClusterId m_spaceClusterId;
ViewportUi::ButtonId m_localButtonId;
ViewportUi::ButtonId m_parentButtonId;
ViewportUi::ButtonId m_worldButtonId;
AZ::Event<ViewportUi::ButtonId>::Handler m_spaceSelectionHandler;
ReferenceFrame m_currentSpace = ReferenceFrame::Parent;
bool m_spaceLock = false;
};
//! Entity selection/interaction handling.
//! Provide a suite of functionality for manipulating entities, primarily through their TransformComponent.
class EditorTransformComponentSelection
@@ -160,6 +171,7 @@ namespace AzToolsFramework
void RegenerateManipulators();
void CreateTransformModeSelectionCluster();
void CreateSpaceSelectionCluster();
void ClearManipulatorTranslationOverride();
void ClearManipulatorOrientationOverride();
@@ -285,6 +297,9 @@ namespace AzToolsFramework
AZ::Event<ViewportUi::ButtonId>::Handler m_transformModeSelectionHandler; //!< Event handler for the Viewport UI cluster.
AzFramework::ClickDetector m_clickDetector; //!< Detect different types of mouse click.
AzFramework::CursorState m_cursorState; //!< Track the mouse position and delta movement each frame.
SpaceCluster m_spaceCluster;
void UpdateSpaceCluster(ReferenceFrame referenceFrame);
};
//! The ETCS (EntityTransformComponentSelection) namespace contains functions and data used exclusively by
@@ -15,6 +15,7 @@
#include <AzToolsFramework/Asset/AssetSeedManager.h>
#include <AzFramework/Asset/AssetRegistry.h>
#include <AzCore/IO/FileIO.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzFramework/IO/LocalFileIO.h>
#include <AzFramework/Asset/AssetCatalog.h>
#include <AzFramework/StringFunc/StringFunc.h>
@@ -62,6 +63,12 @@ namespace UnitTest
m_assetSeedManager = new AzToolsFramework::AssetSeedManager();
m_assetRegistry = new AzFramework::AssetRegistry();
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
auto projectPathKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
m_application->Start(AzFramework::Application::Descriptor());
for (int idx = 0; idx < s_totalAssets; idx++)
@@ -10,6 +10,8 @@
*
*/
#include <AzCore/Settings/SettingsRegistryImpl.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AzToolsFramework/AssetCatalog/PlatformAddressedAssetCatalogManager.h>
#include <AzFramework/Asset/AssetRegistry.h>
@@ -49,6 +51,14 @@ namespace UnitTest
using namespace AZ::Data;
m_application = new ToolsTestApplication("AddressedAssetCatalogManager"); // Shorter name because Setting Registry
// specialization are 32 characters max.
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
auto projectPathKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
m_application->Start(AzFramework::Application::Descriptor());
// 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
@@ -488,18 +488,17 @@ void TransformCompressor::Marshal(WriteBuffer& wb, const AZ::Transform& value) c
{
AZ::u8 flags = 0;
auto flagsMarker = wb.InsertMarker(flags);
AZ::Matrix3x3 m33 = AZ::Matrix3x3::CreateFromTransform(value);
AZ::Vector3 scale = m33.ExtractScale();
AZ::Quaternion rot = AZ::Quaternion::CreateFromMatrix3x3(m33.GetOrthogonalized());
float scale = value.GetUniformScale();
AZ::Quaternion rot = value.GetRotation();
if (!rot.IsIdentity())
{
flags |= HAS_ROT;
wb.Write(rot, QuatCompMarshaler());
}
if (!scale.IsClose(AZ::Vector3::CreateOne()))
if (!AZ::IsClose(scale, 1.0f, AZ::Constants::Tolerance))
{
flags |= HAS_SCALE;
wb.Write(scale, Vec3CompMarshaler());
wb.Write(scale, HalfMarshaler());
}
AZ::Vector3 pos = value.GetTranslation();
if (!pos.IsZero())
@@ -527,9 +526,9 @@ void TransformCompressor::Unmarshal(AZ::Transform& value, ReadBuffer& rb) const
}
if (flags & HAS_SCALE)
{
AZ::Vector3 scale;
rb.Read(scale, Vec3CompMarshaler());
xform.MultiplyByScale(scale);
float scale;
rb.Read(scale, HalfMarshaler());
xform.MultiplyByUniformScale(scale);
}
if (flags & HAS_POS)
{
@@ -11,6 +11,7 @@
*/
#include <AzTest/AzTest.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AzCore/UnitTest/UnitTest.h>
#include <AzCore/UserSettings/UserSettingsComponent.h>
@@ -40,6 +41,13 @@ namespace UnitTest
void SetUp() override
{
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
auto projectPathKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
m_application->Start({});
// 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
+9
View File
@@ -16,6 +16,7 @@
#include <AzCore/UnitTest/UnitTest.h>
#include <AzCore/IO/SystemFile.h> // for max path decl
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/std/parallel/thread.h>
#include <AzCore/std/parallel/semaphore.h>
#include <AzCore/std/functional.h> // for function<> in the find files callback.
@@ -42,6 +43,14 @@ namespace UnitTest
{
AZ::ComponentApplication::Descriptor descriptor;
descriptor.m_stackRecordLevels = 30;
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
auto projectPathKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
m_application->Start(descriptor);
// 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
+8
View File
@@ -23,6 +23,7 @@
#include <AzCore/Math/Uuid.h>
#include <AzCore/Memory/Memory.h>
#include <AzCore/Memory/PoolAllocator.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AzCore/UserSettings/UserSettingsComponent.h>
@@ -304,6 +305,13 @@ namespace UnitTest
m_app.reset(aznew AzFramework::Application());
AZ::ComponentApplication::Descriptor desc;
desc.m_useExistingAllocator = true;
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
auto projectPathKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
m_app->Start(desc);
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
@@ -12,6 +12,7 @@
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzCore/Outcome/Outcome.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AzCore/UserSettings/UserSettingsComponent.h>
@@ -572,6 +573,12 @@ namespace UnitTest
{
AllocatorsTestFixture::SetUp();
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
auto projectPathKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
AzFramework::Application::Descriptor descriptor;
descriptor.m_enableDrilling = false;
m_app.Start(descriptor);
+7
View File
@@ -17,6 +17,7 @@
#include <AzCore/Serialization/Json/JsonSerialization.h>
#include <AzCore/Serialization/Json/JsonSystemComponent.h>
#include <AzCore/Serialization/Json/RegistrationContext.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AzCore/Utils/Utils.h>
#include <AzFramework/FileFunc/FileFunc.h>
@@ -278,6 +279,12 @@ namespace UnitTest
{
FrameworkApplicationFixture::SetUp();
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
auto projectPathKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
m_serializeContext = AZStd::make_unique<AZ::SerializeContext>();
m_jsonRegistrationContext = AZStd::make_unique<AZ::JsonRegistrationContext>();
m_jsonSystemComponent = AZStd::make_unique<AZ::JsonSystemComponent>();
+1
View File
@@ -83,6 +83,7 @@ namespace UnitTest
void SetUp() override
{
AllocatorsFixture::SetUp();
m_data = AZStd::make_unique<StaticData>();
using namespace AzFramework::FileTag;
AZ::ComponentApplication::Descriptor desc;
@@ -54,7 +54,7 @@ namespace UnitTest
};
void SetUp() override
{
{
m_appDescriptor.m_allocationRecords = true;
m_appDescriptor.m_allocationRecordsSaveNames = true;
m_appDescriptor.m_recordingMode = AZ::Debug::AllocationRecords::Mode::RECORD_FULL;
@@ -12,6 +12,7 @@
#include <AzTest/AzTest.h>
#include <AzCore/Slice/SliceComponent.h>
#include <AzCore/Serialization/Utils.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/UserSettings/UserSettingsComponent.h>
#include <AzToolsFramework/ToolsComponents/GenericComponentWrapper.h>
#include <AzToolsFramework/Application/ToolsApplication.h>
@@ -59,6 +60,12 @@ class WrappedEditorComponentTest
protected:
void SetUp() override
{
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
auto projectPathKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
m_app.Start(AZ::ComponentApplication::Descriptor());
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
@@ -178,6 +185,12 @@ class FindWrappedComponentsTest
public:
void SetUp() override
{
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
auto projectPathKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
m_app.Start(AzFramework::Application::Descriptor());
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
+7
View File
@@ -22,6 +22,7 @@
#include <AzCore/Slice/SliceAssetHandler.h>
#include <AzCore/Script/ScriptSystemComponent.h>
#include <AzCore/Script/ScriptAsset.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/std/chrono/chrono.h>
#include <AzCore/RTTI/TypeInfo.h>
#include <AzCore/UnitTest/TestTypes.h>
@@ -1059,6 +1060,12 @@ namespace UnitTest
void SetUp() override
{
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
auto projectPathKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
m_app.Start(AzFramework::Application::Descriptor());
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
+64 -42
View File
@@ -9,6 +9,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set_property(GLOBAL PROPERTY LAUNCHER_UNIFIED_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
# Launcher targets for a project need to be generated when configuring a project.
# When building the engine source, this file will be included by LauncherUnified's CMakeLists.txt
# When using an installed engine, this file will be included by the FindLauncherGenerator.cmake script
@@ -40,28 +42,8 @@ foreach(project_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJEC
# In the monolithic case, we need to register the gem modules, to do so we will generate a StaticModules.inl
# file from StaticModules.in
set_property(GLOBAL APPEND PROPERTY LY_STATIC_MODULE_PROJECTS_NAME ${project_name})
get_property(game_gem_dependencies GLOBAL PROPERTY LY_DELAYED_DEPENDENCIES_${project_name}.GameLauncher)
unset(extern_module_declarations)
unset(module_invocations)
foreach(game_gem_dependency ${game_gem_dependencies})
# To match the convention on how gems targets vs gem modules are named, we remove the "Gem::" from prefix
# and remove the ".Static" from the suffix
string(REGEX REPLACE "^Gem::" "Gem_" game_gem_dependency ${game_gem_dependency})
string(REGEX REPLACE "^Project::" "Project_" game_gem_dependency ${game_gem_dependency})
# Replace "." with "_"
string(REPLACE "." "_" game_gem_dependency ${game_gem_dependency})
string(APPEND extern_module_declarations "extern \"C\" AZ::Module* CreateModuleClass_${game_gem_dependency}();\n")
string(APPEND module_invocations " modulesOut.push_back(CreateModuleClass_${game_gem_dependency}());\n")
endforeach()
configure_file(StaticModules.in
${CMAKE_CURRENT_BINARY_DIR}/${project_name}.GameLauncher/Includes/StaticModules.inl
)
set(game_build_dependencies
${game_gem_dependencies}
@@ -70,29 +52,9 @@ foreach(project_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJEC
if(PAL_TRAIT_BUILD_SERVER_SUPPORTED)
get_property(server_gem_dependencies GLOBAL PROPERTY LY_DELAYED_DEPENDENCIES_${project_name}.ServerLauncher)
unset(extern_module_declarations)
unset(module_invocations)
foreach(server_gem_dependency ${server_gem_dependencies})
# To match the convention on how gems targets vs gem modules are named, we remove the "Gem::" from prefix
# and remove the ".Static" from the suffix
string(REGEX REPLACE "^Gem::" "Gem_" server_gem_dependency ${server_gem_dependency})
string(REGEX REPLACE "^Project::" "Project_" server_gem_dependency ${server_gem_dependency})
# Replace "." with "_"
string(REPLACE "." "_" server_gem_dependency ${server_gem_dependency})
string(APPEND extern_module_declarations "extern \"C\" AZ::Module* CreateModuleClass_${server_gem_dependency}();\n")
string(APPEND module_invocations " modulesOut.push_back(CreateModuleClass_${server_gem_dependency}());\n")
endforeach()
configure_file(StaticModules.in
${CMAKE_CURRENT_BINARY_DIR}/${project_name}.ServerLauncher/Includes/StaticModules.inl
)
set(server_build_dependencies
${game_gem_dependencies}
${server_gem_dependencies}
Legacy::CrySystem
)
endif()
@@ -186,3 +148,63 @@ foreach(project_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJEC
endif()
endforeach()
#! Defer generation of the StaticModules.inl file needed in monolithic builds until after all the CMake targets are known
# This is that the GEM_MODULE target runtime dependencies can be parsed to discover the list of dependent modules
# to load
function(ly_delayed_generate_static_modules_inl)
if(LY_MONOLITHIC_GAME)
get_property(launcher_unified_binary_dir GLOBAL PROPERTY LAUNCHER_UNIFIED_BINARY_DIR)
get_property(project_names GLOBAL PROPERTY LY_STATIC_MODULE_PROJECTS_NAME)
foreach(project_name ${project_names})
unset(extern_module_declarations)
unset(module_invocations)
unset(all_game_gem_dependencies)
ly_get_gem_load_dependencies(all_game_gem_dependencies ${project_name}.GameLauncher)
foreach(game_gem_dependency ${all_game_gem_dependencies})
# To match the convention on how gems targets vs gem modules are named,
# we remove the ".Static" from the suffix
# Replace "." with "_"
string(REPLACE "." "_" game_gem_dependency ${game_gem_dependency})
string(APPEND extern_module_declarations "extern \"C\" AZ::Module* CreateModuleClass_Gem_${game_gem_dependency}();\n")
string(APPEND module_invocations " modulesOut.push_back(CreateModuleClass_Gem_${game_gem_dependency}());\n")
endforeach()
configure_file(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/StaticModules.in
${launcher_unified_binary_dir}/${project_name}.GameLauncher/Includes/StaticModules.inl
)
if(PAL_TRAIT_BUILD_SERVER_SUPPORTED)
get_property(server_gem_dependencies GLOBAL PROPERTY LY_STATIC_MODULE_PROJECTS_DEPENDENCIES_${project_name}.ServerLauncher)
unset(extern_module_declarations)
unset(module_invocations)
unset(all_server_gem_dependencies)
ly_get_gem_load_dependencies(all_server_gem_dependencies ${project_name}.ServerLauncher)
foreach(server_gem_dependency ${server_gem_dependencies})
ly_get_gem_load_dependencies(server_gem_load_dependencies ${server_gem_dependency})
list(APPEND all_server_gem_dependencies ${server_gem_load_dependencies} ${server_gem_dependency})
endforeach()
foreach(server_gem_dependency ${all_server_gem_dependencies})
# Replace "." with "_"
string(REPLACE "." "_" server_gem_dependency ${server_gem_dependency})
string(APPEND extern_module_declarations "extern \"C\" AZ::Module* CreateModuleClass_Gem_${server_gem_dependency}();\n")
string(APPEND module_invocations " modulesOut.push_back(CreateModuleClass_Gem_${server_gem_dependency}());\n")
endforeach()
configure_file(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/StaticModules.in
${launcher_unified_binary_dir}/${project_name}.ServerLauncher/Includes/StaticModules.inl
)
endif()
endforeach()
endif()
endfunction()
@@ -17,6 +17,7 @@
#include <AzToolsFramework/Application/ToolsApplication.h>
#include <AzToolsFramework/Asset/AssetBundler.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/Settings/SettingsRegistryImpl.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/UserSettings/UserSettingsComponent.h>
@@ -57,6 +58,22 @@ namespace AssetBundler
UnitTest::ScopedAllocatorSetupFixture::SetUp();
m_data = AZStd::make_unique<StaticData>();
AZ::SettingsRegistryInterface* registry = nullptr;
if (!AZ::SettingsRegistry::Get())
{
AZ::SettingsRegistry::Register(&m_registry);
registry = &m_registry;
}
else
{
registry = AZ::SettingsRegistry::Get();
}
auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey)
+ "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
m_data->m_applicationManager.reset(aznew MockApplicationManagerTest(0, 0));
m_data->m_applicationManager->Start(AzFramework::Application::Descriptor());
@@ -84,6 +101,12 @@ namespace AssetBundler
delete m_data->m_localFileIO;
AZ::IO::FileIOBase::SetInstance(m_data->m_priorFileIO);
auto settingsRegistry = AZ::SettingsRegistry::Get();
if(settingsRegistry == &m_registry)
{
AZ::SettingsRegistry::Unregister(settingsRegistry);
}
m_data->m_applicationManager->Stop();
m_data->m_applicationManager.reset();
m_data.reset();
@@ -99,6 +122,7 @@ namespace AssetBundler
};
AZStd::unique_ptr<StaticData> m_data;
AZ::SettingsRegistryImpl m_registry;
};
TEST_F(ApplicationManagerTest, ValidatePlatformFlags_ReadConfigFiles_OK)
+39 -21
View File
@@ -97,7 +97,28 @@ namespace AssetBundler
{
public:
void SetUp() override
{
{
AZ::SettingsRegistryInterface* registry = nullptr;
if (!AZ::SettingsRegistry::Get())
{
AZ::SettingsRegistry::Register(&m_registry);
registry = &m_registry;
}
else
{
registry = AZ::SettingsRegistry::Get();
}
auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey)
+ "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
AZ::IO::FixedMaxPath engineRoot = AZ::Utils::GetEnginePath();
if (engineRoot.empty())
{
GTEST_FATAL_FAILURE_(AZStd::string::format("Unable to locate engine root.\n").c_str());
}
m_data = AZStd::make_unique<StaticData>();
m_data->m_application.reset(aznew AzToolsFramework::ToolsApplication());
m_data->m_application.get()->Start(AzFramework::Application::Descriptor());
@@ -107,19 +128,6 @@ namespace AssetBundler
// in the unit tests.
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
if (!AZ::SettingsRegistry::Get())
{
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_Bootstrap(m_registry);
AZ::SettingsRegistry::Register(&m_registry);
}
AZ::IO::FixedMaxPath engineRoot = AZ::Utils::GetEnginePath();
if (engineRoot.empty())
{
GTEST_FATAL_FAILURE_(AZStd::string::format("Unable to locate engine root.\n").c_str());
}
m_data->m_testEngineRoot = (engineRoot / RelativeTestFolder).LexicallyNormal().String();
m_data->m_localFileIO = aznew AZ::IO::LocalFileIO();
@@ -144,14 +152,24 @@ namespace AssetBundler
}
void TearDown() override
{
AZ::IO::FileIOBase::SetInstance(nullptr);
delete m_data->m_localFileIO;
AZ::IO::FileIOBase::SetInstance(m_data->m_priorFileIO);
if (m_data)
{
AZ::IO::FileIOBase::SetInstance(nullptr);
delete m_data->m_localFileIO;
AZ::IO::FileIOBase::SetInstance(m_data->m_priorFileIO);
m_data->m_gemInfoList.set_capacity(0);
m_data->m_gemSeedFilePairList.set_capacity(0);
m_data->m_application.get()->Stop();
m_data->m_application.reset();
}
if(auto settingsRegistry = AZ::SettingsRegistry::Get();
settingsRegistry == &m_registry)
{
AZ::SettingsRegistry::Unregister(settingsRegistry);
}
m_data->m_gemInfoList.set_capacity(0);
m_data->m_gemSeedFilePairList.set_capacity(0);
m_data->m_application.get()->Stop();
m_data->m_application.reset();
}
void AddGemData(const char* engineRoot, const char* gemName, bool seedFileExists = true)
@@ -291,7 +291,6 @@ namespace AssetProcessor
}
}
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_Bootstrap(registry);
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_EngineRegistry(registry, platform, specialization, &scratchBuffer);
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_GemRegistries(registry, platform, specialization, &scratchBuffer);
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_ProjectRegistry(registry, platform, specialization, &scratchBuffer);
@@ -130,6 +130,9 @@ namespace AssetProcessor
auto cacheRootKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_cache_path";
settingsRegistry->Set(cacheRootKey, m_data->m_temporarySourceDir.absoluteFilePath("Cache").toUtf8().constData());
auto projectPathKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
settingsRegistry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*settingsRegistry);
AssetUtilities::ComputeProjectCacheRoot(m_data->m_cacheRootDir);
QString normalizedCacheRoot = AssetUtilities::NormalizeDirectoryPath(m_data->m_cacheRootDir.absolutePath());
@@ -12,7 +12,7 @@
#include "AssetProcessorTest.h"
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/UserSettings/UserSettingsComponent.h>
#include "BaseAssetProcessorTest.h"
@@ -67,6 +67,12 @@ namespace AssetProcessor
static char processName[] = {"AssetProcessorBatch"};
static char* namePtr = &processName[0];
static char** paramStringArray = &namePtr;
auto registry = AZ::SettingsRegistry::Get();
auto projectPathKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
m_application.reset(new UnitTestAppManager(&numParams, &paramStringArray));
ASSERT_EQ(m_application->BeforeRun(), ApplicationManager::Status_Success);
@@ -14,6 +14,7 @@
#include <AzTest/AzTest.h>
#include <AzCore/Memory/Memory.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzFramework/Application/Application.h>
#include <native/utilities/assetUtils.h>
#include <native/unittests/UnitTestRunner.h> // for the assert absorber.
@@ -44,7 +45,18 @@ namespace AssetProcessor
AZ::AllocatorInstance<AZ::SystemAllocator>::Create();
}
m_errorAbsorber = new UnitTestUtils::AssertAbsorber();
m_application = AZStd::make_unique<AzFramework::Application>();
// Inject the AutomatedTesting project as a project path into test fixture
using FixedValueString = AZ::SettingsRegistryInterface::FixedValueString;
constexpr auto projectPathKey = FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey)
+ "/project_path";
if(auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
{
settingsRegistry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*settingsRegistry);
}
}
void TearDown() override
@@ -204,6 +204,9 @@ void AssetProcessorManagerTest::SetUp()
auto cacheRootKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_cache_path";
registry->Set(cacheRootKey, tempPath.absoluteFilePath("Cache").toUtf8().constData());
auto projectPathKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
m_data->m_databaseLocationListener.BusConnect();
@@ -39,7 +39,6 @@ void PlatformConfigurationUnitTests::SetUp()
m_qApp = new QCoreApplication(m_argc, m_argv);
AssetProcessorTest::SetUp();
AssetUtilities::ResetAssetRoot();
}
void PlatformConfigurationUnitTests::TearDown()
@@ -37,6 +37,5 @@ private:
int m_argc;
char** m_argv;
QCoreApplication* m_qApp;
};
@@ -13,6 +13,7 @@
#include <AzTest/AzTest.h>
#include <AzCore/Memory/OSAllocator.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/string/string.h>
#include <AzFramework/Asset/AssetBundleManifest.h>
@@ -45,6 +46,12 @@ public:
protected:
void SetUp() override
{
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
auto projectPathKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
AZ::ComponentApplication::Descriptor desc;
desc.m_useExistingAllocator = true;
desc.m_enableDrilling = false; // we already created a memory driller for the test (AllocatorsFixture)
@@ -152,8 +152,11 @@ struct AssetValidationTest
{
AZ::SettingsRegistry::Register(&m_registry);
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_Bootstrap(m_registry);
auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey)
+ "/project_path";
m_registry.Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(m_registry);
// Set the engine root to the temporary directory and re-update the runtime file paths
auto enginePathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey)
+ "/engine_path";
+4
View File
@@ -60,7 +60,9 @@ namespace UnitTest
TEST_F(UtilsTests, LoadFileString_Error_DoesNotExist)
{
AZ_TEST_START_TRACE_SUPPRESSION;
auto outcome = AZ::RHI::LoadFileString("FileDoesNotExist");
AZ_TEST_STOP_TRACE_SUPPRESSION_NO_COUNT;
EXPECT_FALSE(outcome.IsSuccess());
EXPECT_TRUE(outcome.GetError().find("Could not open file") != AZStd::string::npos);
EXPECT_TRUE(outcome.GetError().find("FileDoesNotExist") != AZStd::string::npos);
@@ -68,7 +70,9 @@ namespace UnitTest
TEST_F(UtilsTests, LoadFileBytes_Error_DoesNotExist)
{
AZ_TEST_START_TRACE_SUPPRESSION;
auto outcome = AZ::RHI::LoadFileBytes("FileDoesNotExist");
AZ_TEST_STOP_TRACE_SUPPRESSION_NO_COUNT;
EXPECT_FALSE(outcome.IsSuccess());
EXPECT_TRUE(outcome.GetError().find("Could not open file") != AZStd::string::npos);
EXPECT_TRUE(outcome.GetError().find("FileDoesNotExist") != AZStd::string::npos);
@@ -158,47 +158,8 @@ namespace AZ
void AtomBridgeSystemComponent::OnBootstrapSceneReady(AZ::RPI::Scene* bootstrapScene)
{
AZStd::shared_ptr<AZ::RPI::WindowContext> windowContext;
AZ::Render::Bootstrap::DefaultWindowBus::BroadcastResult(windowContext, &AZ::Render::Bootstrap::DefaultWindowInterface::GetDefaultWindowContext);
if (!windowContext)
{
AZ_Warning("Atom", false, "Cannot initialize Atom because no window context is available");
return;
}
AZ::RPI::RenderPipelinePtr renderPipeline = bootstrapScene->GetDefaultRenderPipeline();
// If RenderPipeline doesn't have a default view, create a view and make it the default view.
// These settings will be overridden by the editor or game camera.
if (renderPipeline->GetDefaultView() == nullptr)
{
auto viewContextManager = AZ::Interface<RPI::ViewportContextRequestsInterface>::Get();
m_view = AZ::RPI::View::CreateView(AZ::Name("AtomSystem Default View"), RPI::View::UsageCamera);
viewContextManager->PushView(viewContextManager->GetDefaultViewportContextName(), m_view);
const auto& viewport = windowContext->GetViewport();
const float aspectRatio = viewport.m_maxX / viewport.m_maxY;
// Note: This is projection assumes a setup for reversed depth
AZ::Matrix4x4 viewToClipMatrix;
AZ::MakePerspectiveFovMatrixRH(viewToClipMatrix, AZ::Constants::HalfPi, aspectRatio, 0.1f, 100.f, true);
m_view->SetViewToClipMatrix(viewToClipMatrix);
renderPipeline = bootstrapScene->GetDefaultRenderPipeline();
renderPipeline->SetDefaultView(m_view);
}
else
{
m_view = renderPipeline->GetDefaultView();
}
auto auxGeomFP = bootstrapScene->GetFeatureProcessor<RPI::AuxGeomFeatureProcessorInterface>();
if (auxGeomFP)
{
auxGeomFP->GetOrCreateDrawQueueForView(m_view.get());
}
// Make default AtomDebugDisplayViewportInterface for the scene
AZ_UNUSED(bootstrapScene);
// Make default AtomDebugDisplayViewportInterface
AZStd::shared_ptr<AtomDebugDisplayViewportInterface> mainEntityDebugDisplay = AZStd::make_shared<AtomDebugDisplayViewportInterface>(AzFramework::g_defaultSceneEntityDebugDisplayId);
m_activeViewportsList[AzFramework::g_defaultSceneEntityDebugDisplayId] = mainEntityDebugDisplay;
}
@@ -384,8 +384,7 @@ def stash_env(_SYNTH_ENV_DICT = OrderedDict()):
# changed to just make the fallback what is set in boostrap
# so now it's less of a fallnack and more correct if not
# explicitly set
_LY_PROJECT = os.getenv(ENVAR_LY_PROJECT,
get_current_project(_LY_DEV))
_LY_PROJECT = os.getenv(ENVAR_LY_PROJECT)
_SYNTH_ENV_DICT[ENVAR_LY_PROJECT] = _LY_PROJECT
_LY_BUILD_DIR_NAME = os.getenv(ENVAR_LY_BUILD_DIR_NAME,
@@ -274,12 +274,15 @@ namespace DebugDraw
AzFramework::DebugDisplayRequests* debugDisplay =
AzFramework::DebugDisplayRequestBus::FindFirstHandler(debugDisplayBus);
OnTickAabbs(*debugDisplay);
OnTickLines(*debugDisplay);
OnTickObbs(*debugDisplay);
OnTickRays(*debugDisplay);
OnTickSpheres(*debugDisplay);
OnTickText(*debugDisplay);
if (debugDisplay)
{
OnTickAabbs(*debugDisplay);
OnTickLines(*debugDisplay);
OnTickObbs(*debugDisplay);
OnTickRays(*debugDisplay);
OnTickSpheres(*debugDisplay);
OnTickText(*debugDisplay);
}
}
template <typename F>
@@ -59,7 +59,16 @@ namespace EMotionFX
{
public:
ComponentFixtureApp() = default;
ComponentFixtureApp()
{
using FixedValueString = AZ::SettingsRegistryInterface::FixedValueString;
constexpr auto projectPathKey = FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
if(auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
{
settingsRegistry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*settingsRegistry);
}
}
AZ::ComponentTypeList GetRequiredSystemComponents() const override
{
@@ -77,7 +77,6 @@ namespace EMotionFX
{
auto testAssetsPath = AZ::IO::Path(GetEMotionFX().GetAssetCacheFolder()) / "TmpTestAssets";
QString dataDir = QString::fromUtf8(testAssetsPath.c_str(), aznumeric_cast<int>(testAssetsPath.Native().size()));
dataDir += "TmpTestAssets";
if (!QDir(dataDir).exists())
{
@@ -18,6 +18,7 @@
#include <EditorPythonBindings/EditorPythonBindingsBus.h>
#include <AzCore/Debug/TraceMessageBus.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzToolsFramework/API/EditorPythonRunnerRequestsBus.h>
@@ -322,6 +323,13 @@ sys.version
void SetUp() override
{
PythonTestingFixture::SetUp();
auto registry = AZ::SettingsRegistry::Get();
auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey)
+ "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
m_app.RegisterComponentDescriptor(EditorPythonBindings::PythonSystemComponent::CreateDescriptor());
}
@@ -15,6 +15,7 @@
#include <Builders/LevelBuilder/LevelBuilderWorker.h>
#include <AzTest/Utils.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/Slice/SliceAssetHandler.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AzCore/UserSettings/UserSettingsComponent.h>
@@ -98,6 +99,12 @@ class LevelBuilderTest
protected:
void SetUp() override
{
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
auto projectPathKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
m_app.Start(m_descriptor);
// 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
@@ -15,6 +15,7 @@
#include <Builders/LuaBuilder/LuaBuilderWorker.h>
#include <AzTest/Utils.h>
#include <AssetBuilderSDK/AssetBuilderSDK.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AzCore/UserSettings/UserSettingsComponent.h>
#include <AzCore/Utils/Utils.h>
@@ -32,6 +33,12 @@ namespace UnitTest
{
void SetUp() override
{
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
auto projectPathKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
m_app.Start(m_descriptor);
// 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
@@ -12,6 +12,7 @@
#include "LmbrCentral_precompiled.h"
#include <AzTest/AzTest.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AzToolsFramework/Application/ToolsApplication.h>
#include <Builders/DependencyBuilder/SeedBuilderWorker/SeedBuilderWorker.h>
@@ -22,6 +23,12 @@ class SeedBuilderTests
{
void SetUp() override
{
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
auto projectPathKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
m_app.Start(AZ::ComponentApplication::Descriptor());
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
@@ -16,6 +16,7 @@
#include <CryCommon/Mocks/ISystemMock.h>
#include <LyShineBuilder/UiCanvasBuilderWorker.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/UserSettings/UserSettingsComponent.h>
#include <AzCore/Utils/Utils.h>
#include <AzToolsFramework/Application/ToolsApplication.h>
@@ -88,6 +89,12 @@ protected:
m_data->m_stubEnv.pSystem = &m_data->m_mockSystem;
gEnv = &m_data->m_stubEnv;
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
auto projectPathKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
m_app.Start(m_descriptor);
// 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
@@ -34,11 +34,11 @@ namespace Multiplayer
private:
void OnRotationChangedEvent(const AZ::Quaternion& rotation);
void OnTranslationChangedEvent(const AZ::Vector3& translation);
void OnScaleChangedEvent(const AZ::Vector3& scale);
void OnScaleChangedEvent(float scale);
AZ::Event<AZ::Quaternion>::Handler m_rotationEventHandler;
AZ::Event<AZ::Vector3>::Handler m_translationEventHandler;
AZ::Event<AZ::Vector3>::Handler m_scaleEventHandler;
AZ::Event<float>::Handler m_scaleEventHandler;
};
class NetworkTransformComponentController
@@ -14,7 +14,7 @@
<NetworkProperty Type="AZ::Quaternion" Name="rotation" Init="AZ::Quaternion::CreateIdentity()" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="true" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="false" GenerateEventBindings="true" />
<NetworkProperty Type="AZ::Vector3" Name="translation" Init="AZ::Vector3::CreateZero()" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="true" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="false" GenerateEventBindings="true" />
<NetworkProperty Type="AZ::Vector3" Name="scale" Init="AZ::Vector3::CreateZero()" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="true" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="false" GenerateEventBindings="true" />
<NetworkProperty Type="float" Name="scale" Init="1.0f" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="true" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="false" GenerateEventBindings="true" />
<NetworkProperty Type="uint8_t" Name="resetCount" Init="0" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="false" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="false" GenerateEventBindings="true" />
<NetworkProperty Type="NetEntityId" Name="parentEntityId" Init="InvalidNetEntityId" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="true" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="false" GenerateEventBindings="true" />
<NetworkProperty Type="int32_t" Name="parentAttachmentBoneId" Init="-1" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="true" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="false" GenerateEventBindings="true" />
@@ -32,7 +32,7 @@ namespace Multiplayer
NetworkTransformComponent::NetworkTransformComponent()
: m_rotationEventHandler([this](const AZ::Quaternion& rotation) { OnRotationChangedEvent(rotation); })
, m_translationEventHandler([this](const AZ::Vector3& translation) { OnTranslationChangedEvent(translation); })
, m_scaleEventHandler([this](const AZ::Vector3& scale) { OnScaleChangedEvent(scale); })
, m_scaleEventHandler([this](float scale) { OnScaleChangedEvent(scale); })
{
;
}
@@ -68,10 +68,10 @@ namespace Multiplayer
GetTransformComponent()->SetWorldTM(worldTm);
}
void NetworkTransformComponent::OnScaleChangedEvent(const AZ::Vector3& scale)
void NetworkTransformComponent::OnScaleChangedEvent(float scale)
{
AZ::Transform worldTm = GetTransformComponent()->GetWorldTM();
worldTm.SetScale(scale);
worldTm.SetUniformScale(scale);
GetTransformComponent()->SetWorldTM(worldTm);
}
@@ -100,7 +100,7 @@ namespace Multiplayer
{
SetRotation(worldTm.GetRotation());
SetTranslation(worldTm.GetTranslation());
SetScale(worldTm.GetScale());
SetScale(worldTm.GetUniformScale());
}
}
}
@@ -105,39 +105,55 @@ namespace PhysX
AZ::Vector3 CharacterControllerComponent::GetBasePosition() const
{
return IsPhysicsEnabled() ? m_controller->GetBasePosition() : AZ::Vector3::CreateZero();
if (auto* controller = GetControllerConst())
{
return controller->GetBasePosition();
}
return AZ::Vector3::CreateZero();
}
void CharacterControllerComponent::SetBasePosition(const AZ::Vector3& position)
{
if (IsPhysicsEnabled())
if (auto* controller = GetController())
{
m_controller->SetBasePosition(position);
controller->SetBasePosition(position);
AZ::TransformBus::Event(GetEntityId(), &AZ::TransformBus::Events::SetWorldTranslation, position);
}
}
AZ::Vector3 CharacterControllerComponent::GetCenterPosition() const
{
return IsPhysicsEnabled() ? m_controller->GetCenterPosition() : AZ::Vector3::CreateZero();
if (auto* controller = GetControllerConst())
{
return controller->GetCenterPosition();
}
return AZ::Vector3::CreateZero();
}
float CharacterControllerComponent::GetStepHeight() const
{
return IsPhysicsEnabled() ? m_controller->GetStepHeight() : 0.0f;
if (auto* controller = GetControllerConst())
{
return controller->GetStepHeight();
}
return 0.0f;
}
void CharacterControllerComponent::SetStepHeight(float stepHeight)
{
if (IsPhysicsEnabled())
if (auto* controller = GetController())
{
m_controller->SetStepHeight(stepHeight);
controller->SetStepHeight(stepHeight);
}
}
AZ::Vector3 CharacterControllerComponent::GetUpDirection() const
{
return IsPhysicsEnabled() ? m_controller->GetUpDirection() : AZ::Vector3::CreateZero();
if (auto* controller = GetControllerConst())
{
return controller->GetUpDirection();
}
return AZ::Vector3::CreateZero();
}
void CharacterControllerComponent::SetUpDirection([[maybe_unused]] const AZ::Vector3& upDirection)
@@ -147,51 +163,58 @@ namespace PhysX
float CharacterControllerComponent::GetSlopeLimitDegrees() const
{
return IsPhysicsEnabled() ? m_controller->GetSlopeLimitDegrees() : 0.0f;
if (auto* controller = GetControllerConst())
{
return controller->GetSlopeLimitDegrees();
}
return 0.0f;
}
void CharacterControllerComponent::SetSlopeLimitDegrees(float slopeLimitDegrees)
{
if (IsPhysicsEnabled())
if (auto* controller = GetController())
{
m_controller->SetSlopeLimitDegrees(slopeLimitDegrees);
controller->SetSlopeLimitDegrees(slopeLimitDegrees);
}
}
float CharacterControllerComponent::GetMaximumSpeed() const
{
if (IsPhysicsEnabled())
if (auto* controller = GetControllerConst())
{
return m_controller->GetMaximumSpeed();
return controller->GetMaximumSpeed();
}
return 0.0f;
}
void CharacterControllerComponent::SetMaximumSpeed(float maximumSpeed)
{
if (IsPhysicsEnabled())
if (auto* controller = GetController())
{
m_controller->SetMaximumSpeed(maximumSpeed);
controller->SetMaximumSpeed(maximumSpeed);
}
}
AZ::Vector3 CharacterControllerComponent::GetVelocity() const
{
return IsPhysicsEnabled() ? m_controller->GetVelocity() : AZ::Vector3::CreateZero();
if (auto* controller = GetControllerConst())
{
return controller->GetVelocity();
}
return AZ::Vector3::CreateZero();
}
void CharacterControllerComponent::AddVelocity(const AZ::Vector3& velocity)
{
if (IsPhysicsEnabled())
if (auto* controller = GetController())
{
m_controller->AddVelocity(velocity);
controller->AddVelocity(velocity);
}
}
Physics::Character* CharacterControllerComponent::GetCharacter()
{
return m_controller;
return GetController();
}
void CharacterControllerComponent::EnablePhysics()
@@ -206,14 +229,14 @@ namespace PhysX
bool CharacterControllerComponent::IsPhysicsEnabled() const
{
return m_controller != nullptr;
return GetControllerConst() != nullptr;
}
AZ::Aabb CharacterControllerComponent::GetAabb() const
{
if (m_controller)
if (auto* controller = GetControllerConst())
{
return m_controller->GetAabb();
return controller->GetAabb();
}
return AZ::Aabb::CreateNull();
}
@@ -225,94 +248,121 @@ namespace PhysX
AzPhysics::SimulatedBodyHandle CharacterControllerComponent::GetSimulatedBodyHandle() const
{
if (m_controller)
{
return m_controller->m_bodyHandle;
}
return AzPhysics::InvalidSimulatedBodyHandle;
return m_controllerBodyHandle;
}
AzPhysics::SceneQueryHit CharacterControllerComponent::RayCast(const AzPhysics::RayCastRequest& request)
{
if (m_controller)
if (auto* controller = GetController())
{
return m_controller->RayCast(request);
return controller->RayCast(request);
}
return AzPhysics::SceneQueryHit();
}
// CharacterControllerRequestBus
void CharacterControllerComponent::Resize(float height)
{
return m_controller->Resize(height);
if (auto* controller = GetController())
{
controller->Resize(height);
}
}
float CharacterControllerComponent::GetHeight()
{
return m_controller->GetHeight();
if (auto* controller = GetController())
{
return controller->GetHeight();
}
return 0.0f;
}
void CharacterControllerComponent::SetHeight(float height)
{
return m_controller->SetHeight(height);
if (auto* controller = GetController())
{
controller->SetHeight(height);
}
}
float CharacterControllerComponent::GetRadius()
{
return m_controller->GetRadius();
if (auto* controller = GetController())
{
return controller->GetRadius();
}
return 0.0f;
}
void CharacterControllerComponent::SetRadius(float radius)
{
return m_controller->SetRadius(radius);
if (auto* controller = GetController())
{
controller->SetRadius(radius);
}
}
float CharacterControllerComponent::GetHalfSideExtent()
{
return m_controller->GetHalfSideExtent();
if (auto* controller = GetController())
{
return controller->GetHalfSideExtent();
}
return 0.0f;
}
void CharacterControllerComponent::SetHalfSideExtent(float halfSideExtent)
{
return m_controller->SetHalfSideExtent(halfSideExtent);
if (auto* controller = GetController())
{
controller->SetHalfSideExtent(halfSideExtent);
}
}
float CharacterControllerComponent::GetHalfForwardExtent()
{
return m_controller->GetHalfForwardExtent();
if (auto* controller = GetController())
{
return controller->GetHalfForwardExtent();
}
return 0.0f;
}
void CharacterControllerComponent::SetHalfForwardExtent(float halfForwardExtent)
{
return m_controller->SetHalfForwardExtent(halfForwardExtent);
if (auto* controller = GetController())
{
controller->SetHalfForwardExtent(halfForwardExtent);
}
}
// TransformNotificationBus
void CharacterControllerComponent::OnTransformChanged(const AZ::Transform& /*local*/, const AZ::Transform& world)
{
if (!IsPhysicsEnabled())
if (auto* controller = GetController())
{
return;
controller->SetBasePosition(world.GetTranslation());
}
m_controller->SetBasePosition(world.GetTranslation());
}
void CharacterControllerComponent::SetCollisionLayer(const AZStd::string& layerName, AZ::Crc32 colliderTag)
{
if (!IsPhysicsEnabled())
auto* controller = GetController();
if (controller == nullptr)
{
return;
}
if (Physics::Utils::FilterTag(m_controller->GetColliderTag(), colliderTag))
if (Physics::Utils::FilterTag(controller->GetColliderTag(), colliderTag))
{
bool success = false;
AzPhysics::CollisionLayer collisionLayer;
Physics::CollisionRequestBus::BroadcastResult(success, &Physics::CollisionRequests::TryGetCollisionLayerByName, layerName, collisionLayer);
if (success)
{
m_controller->SetCollisionLayer(collisionLayer);
controller->SetCollisionLayer(collisionLayer);
}
}
}
@@ -320,30 +370,33 @@ namespace PhysX
AZStd::string CharacterControllerComponent::GetCollisionLayerName()
{
AZStd::string layerName;
if (!IsPhysicsEnabled())
auto* controller = GetControllerConst();
if (controller == nullptr)
{
return layerName;
}
Physics::CollisionRequestBus::BroadcastResult(layerName, &Physics::CollisionRequests::GetCollisionLayerName, m_controller->GetCollisionLayer());
Physics::CollisionRequestBus::BroadcastResult(
layerName, &Physics::CollisionRequests::GetCollisionLayerName, controller->GetCollisionLayer());
return layerName;
}
void CharacterControllerComponent::SetCollisionGroup(const AZStd::string& groupName, AZ::Crc32 colliderTag)
{
if (!IsPhysicsEnabled())
auto* controller = GetController();
if (controller == nullptr)
{
return;
}
if (Physics::Utils::FilterTag(m_controller->GetColliderTag(), colliderTag))
if (Physics::Utils::FilterTag(controller->GetColliderTag(), colliderTag))
{
bool success = false;
AzPhysics::CollisionGroup collisionGroup;
Physics::CollisionRequestBus::BroadcastResult(success, &Physics::CollisionRequests::TryGetCollisionGroupByName, groupName, collisionGroup);
if (success)
{
m_controller->SetCollisionGroup(collisionGroup);
controller->SetCollisionGroup(collisionGroup);
}
}
}
@@ -351,23 +404,26 @@ namespace PhysX
AZStd::string CharacterControllerComponent::GetCollisionGroupName()
{
AZStd::string groupName;
if (!IsPhysicsEnabled())
auto* controller = GetControllerConst();
if (controller == nullptr)
{
return groupName;
}
Physics::CollisionRequestBus::BroadcastResult(groupName, &Physics::CollisionRequests::GetCollisionGroupName, m_controller->GetCollisionGroup());
Physics::CollisionRequestBus::BroadcastResult(
groupName, &Physics::CollisionRequests::GetCollisionGroupName, controller->GetCollisionGroup());
return groupName;
}
void CharacterControllerComponent::ToggleCollisionLayer(const AZStd::string& layerName, AZ::Crc32 colliderTag, bool enabled)
{
if (!IsPhysicsEnabled())
auto* controller = GetController();
if (controller == nullptr)
{
return;
}
if (Physics::Utils::FilterTag(m_controller->GetColliderTag(), colliderTag))
if (Physics::Utils::FilterTag(controller->GetColliderTag(), colliderTag))
{
bool success = false;
AzPhysics::CollisionLayer collisionLayer;
@@ -375,23 +431,43 @@ namespace PhysX
if (success)
{
AzPhysics::CollisionLayer layer(layerName);
AzPhysics::CollisionGroup group = m_controller->GetCollisionGroup();
AzPhysics::CollisionGroup group = controller->GetCollisionGroup();
group.SetLayer(layer, enabled);
m_controller->SetCollisionGroup(group);
controller->SetCollisionGroup(group);
}
}
}
void CharacterControllerComponent::OnPreSimulate(float deltaTime)
{
if (m_controller)
if (auto* controller = GetController())
{
m_controller->ApplyRequestedVelocity(deltaTime);
const AZ::Vector3 newPosition = GetBasePosition();
controller->ApplyRequestedVelocity(deltaTime);
const AZ::Vector3 newPosition = controller->GetBasePosition();
AZ::TransformBus::Event(GetEntityId(), &AZ::TransformBus::Events::SetWorldTranslation, newPosition);
}
}
const PhysX::CharacterController* CharacterControllerComponent::GetControllerConst() const
{
if (m_controllerBodyHandle == AzPhysics::InvalidSimulatedBodyHandle || m_attachedSceneHandle == AzPhysics::InvalidSceneHandle)
{
return nullptr;
}
if (auto* sceneInterface = AZ::Interface<AzPhysics::SceneInterface>::Get())
{
return azdynamic_cast<PhysX::CharacterController*>(
sceneInterface->GetSimulatedBodyFromHandle(m_attachedSceneHandle, m_controllerBodyHandle));
}
return nullptr;
}
PhysX::CharacterController* CharacterControllerComponent::GetController()
{
return const_cast<PhysX::CharacterController*>(GetControllerConst());
}
void CharacterControllerComponent::CreateController()
{
if (IsPhysicsEnabled())
@@ -399,9 +475,8 @@ namespace PhysX
return;
}
AzPhysics::SceneHandle defaultSceneHandle = AzPhysics::InvalidSceneHandle;
Physics::DefaultWorldBus::BroadcastResult(defaultSceneHandle, &Physics::DefaultWorldRequests::GetDefaultSceneHandle);
if (defaultSceneHandle == AzPhysics::InvalidSceneHandle)
Physics::DefaultWorldBus::BroadcastResult(m_attachedSceneHandle, &Physics::DefaultWorldRequests::GetDefaultSceneHandle);
if (m_attachedSceneHandle == AzPhysics::InvalidSceneHandle)
{
AZ_Error("PhysX Character Controller Component", false, "Failed to retrieve default scene.");
return;
@@ -427,11 +502,9 @@ namespace PhysX
auto* sceneInterface = AZ::Interface<AzPhysics::SceneInterface>::Get();
if (sceneInterface != nullptr)
{
m_controllerBodyHandle = sceneInterface->AddSimulatedBody(defaultSceneHandle, m_characterConfig.get());
m_controller = azdynamic_cast<PhysX::CharacterController*>(
sceneInterface->GetSimulatedBodyFromHandle(defaultSceneHandle, m_controllerBodyHandle));
m_controllerBodyHandle = sceneInterface->AddSimulatedBody(m_attachedSceneHandle, m_characterConfig.get());
}
if (m_controller == nullptr)
if (m_controllerBodyHandle == AzPhysics::InvalidSimulatedBodyHandle)
{
AZ_Error("PhysX Character Controller Component", false, "Failed to create character controller.");
return;
@@ -447,7 +520,7 @@ namespace PhysX
DestroyController();
}
});
sceneInterface->RegisterSimulationBodyRemovedHandler(defaultSceneHandle, m_onSimulatedBodyRemovedHandler);
sceneInterface->RegisterSimulationBodyRemovedHandler(m_attachedSceneHandle, m_onSimulatedBodyRemovedHandler);
}
CharacterControllerRequestBus::Handler::BusConnect(GetEntityId());
@@ -467,24 +540,23 @@ namespace PhysX
void CharacterControllerComponent::DisableController()
{
if (!IsPhysicsEnabled())
if (auto* controller = GetController())
{
return;
controller->DisablePhysics();
if (auto* sceneInterface = AZ::Interface<AzPhysics::SceneInterface>::Get())
{
sceneInterface->RemoveSimulatedBody(m_attachedSceneHandle, controller->m_bodyHandle);
}
DestroyController();
}
m_controller->DisablePhysics();
if (auto* sceneInterface = AZ::Interface<AzPhysics::SceneInterface>::Get())
{
sceneInterface->RemoveSimulatedBody(m_controller->m_sceneOwner, m_controller->m_bodyHandle);
}
DestroyController();
}
void CharacterControllerComponent::DestroyController()
{
m_controller = nullptr;
m_controllerBodyHandle = AzPhysics::InvalidSimulatedBodyHandle;
m_attachedSceneHandle = AzPhysics::InvalidSceneHandle;
m_preSimulateHandler.Disconnect();
m_onSimulatedBodyRemovedHandler.Disconnect();
CharacterControllerRequestBus::Handler::BusDisconnect();
@@ -131,6 +131,8 @@ namespace PhysX
void ToggleCollisionLayer(const AZStd::string& layerName, AZ::Crc32 colliderTag, bool enabled) override;
private:
const PhysX::CharacterController* GetControllerConst() const;
PhysX::CharacterController* GetController();
// Creates the physics character controller in the current default physics scene.
// This will do nothing if the controller is already created.
void CreateController();
@@ -143,8 +145,8 @@ namespace PhysX
AZStd::unique_ptr<Physics::CharacterConfiguration> m_characterConfig;
AZStd::shared_ptr<Physics::ShapeConfiguration> m_shapeConfig;
PhysX::CharacterController* m_controller = nullptr;
AzPhysics::SimulatedBodyHandle m_controllerBodyHandle = AzPhysics::InvalidSimulatedBodyHandle;
AzPhysics::SceneHandle m_attachedSceneHandle = AzPhysics::InvalidSceneHandle;
AzPhysics::SystemEvents::OnPresimulateEvent::Handler m_preSimulateHandler;
AzPhysics::SceneEvents::OnSimulationBodyRemoved::Handler m_onSimulatedBodyRemovedHandler;
};
@@ -14,6 +14,7 @@
#include <AzCore/Component/TransformBus.h>
#include <AzCore/Serialization/Json/JsonSystemComponent.h>
#include <AzCore/Serialization/Json/RegistrationContext.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/UserSettings/UserSettingsComponent.h>
namespace UnitTest
@@ -172,6 +173,12 @@ namespace UnitTest
void PrefabBuilderTests::SetUp()
{
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
auto projectPathKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
AZ::ComponentApplication::Descriptor desc;
m_app.Start(desc);
m_app.CreateReflectionManager();
@@ -16,6 +16,7 @@
#include <AzCore/Component/ComponentApplication.h>
#include <AzCore/Module/Environment.h>
#include <AzCore/RTTI/ReflectContext.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AzCore/UserSettings/UserSettingsComponent.h>
#include <AzCore/std/smart_ptr/make_shared.h>
@@ -139,6 +140,12 @@ class SceneBuilderPhasesFixture
public:
void SetUp() override
{
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
auto projectPathKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
m_app.Start(AZ::ComponentApplication::Descriptor());
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
@@ -13,6 +13,7 @@
#include <AssetBuilderSDK/AssetBuilderSDK.h>
#include <AzCore/IO/FileIO.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AzCore/UserSettings/UserSettingsComponent.h>
#include <AzFramework/StringFunc/StringFunc.h>
@@ -30,6 +31,12 @@ class SceneBuilderTests
protected:
void SetUp() override
{
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
auto projectPathKey =
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
registry->Set(projectPathKey, "AutomatedTesting");
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry);
m_app.Start(AZ::ComponentApplication::Descriptor());
AZ::Debug::TraceMessageBus::Handler::BusConnect();
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
@@ -250,9 +250,6 @@ class AbstractResourceLocator(object):
"""
return os.path.join(self.build_directory(), 'CrySCompileServer')
def bootstrap_config_file(self):
return os.path.join(self.engine_root(), 'bootstrap.cfg')
def asset_processor_config_file(self):
return os.path.join(self.engine_root(), 'Registry', 'AssetProcessorPlatformConfig.setreg')
@@ -123,7 +123,6 @@ class Launcher(object):
"""
backup_path = self.workspace.settings.get_temp_path()
log.debug(f"Performing automatic backup of bootstrap, platform and user settings in path {backup_path}")
self.workspace.settings.backup_bootstrap_settings(backup_path)
self.workspace.settings.backup_platform_settings(backup_path)
self.workspace.settings.backup_shader_compiler_settings(backup_path)
@@ -664,8 +664,7 @@ class AssetProcessor(object):
make_dir = os.path.join(self._temp_asset_root, copy_dir)
if not os.path.isdir(make_dir):
os.makedirs(make_dir)
for copyfile_name in ['bootstrap.cfg',
'Registry/AssetProcessorPlatformConfig.setreg',
for copyfile_name in ['Registry/AssetProcessorPlatformConfig.setreg',
os.path.join(self._workspace.project, "project.json"),
os.path.join('Assets', 'Engine', 'exclude.filetag')]:
shutil.copyfile(os.path.join(self._workspace.paths.engine_root(), copyfile_name),
@@ -57,14 +57,6 @@ class LySettings(object):
"""
self._backup_settings(self._resource_locator.platform_config_file(), backup_path)
def backup_bootstrap_settings(self, backup_path=None):
"""
Creates a backup of the bootstrap settings file (~/dev/bootstrap.cfg) in the backup_path. If no path is
provided, it will store in the workspace temp path (the contents of the workspace temp directory are removed
during workspace teardown)
"""
self._backup_settings(self._resource_locator.bootstrap_config_file(), backup_path)
def backup_shader_compiler_settings(self, backup_path=None):
self._backup_settings(self._resource_locator.shader_compiler_config_file(), backup_path)
@@ -79,14 +71,6 @@ class LySettings(object):
"""
self._restore_settings(self._resource_locator.platform_config_file(), backup_path)
def restore_bootstrap_settings(self, backup_path=None):
"""
Restores the bootstrap settings file (~/dev/bootstrap.cfg) from its backup.
The backup is stored in the backup_path.
If no backup_path is provided, it will attempt to retrieve the backup from the workspace temp path.
"""
self._restore_settings(self._resource_locator.bootstrap_config_file(), backup_path)
def restore_shader_compiler_settings(self, backup_path=None):
self._restore_settings(self._resource_locator.shader_compiler_config_file(), backup_path)
@@ -158,13 +158,6 @@ class TestAbstractResourceLocator(object):
assert mock_abstract_resource_locator.shader_cache() == expected_path
def test_BootstrapConfigFile_IsCalled_ReturnBootstrapConfigFilePath(self):
mock_abstract_resource_locator = abstract_resource_locator.AbstractResourceLocator(
mock_build_directory, mock_project)
expected_path = os.path.join(mock_abstract_resource_locator.engine_root(), 'bootstrap.cfg')
assert mock_abstract_resource_locator.bootstrap_config_file() == expected_path
def test_AssetProcessorConfigFile_IsCalled_ReturnsAssetProcessorConfigFilePath(self):
mock_abstract_resource_locator = abstract_resource_locator.AbstractResourceLocator(
mock_build_directory, mock_project)
-12
View File
@@ -1,12 +0,0 @@
; This file is deprecated and is only use currently for setting the path when running O3DE in an engine-centric manner
; By engine-centric, what is meant is using CMake to configure from the <engine-root> directory and passing in the LY_PROJECTS value
project_path=AutomatedTesting
; The Asset Processor Specific settings are now the <engine-root>/Engine/Registry/bootstrap.setreg settings
; The Engine specific settings can be overridden in order of least precedence to most
; 1. Override the settings in a "<gem-root>/Registry/*.setreg(patch)" file (Shared per Gem Settings)
; 2. Override the settings in a "<project-root>/Registry/*.setreg(patch)" file (Shared per Project Settings)
; 3. Override the settings in a "<project-root>/user/Registry/*.setreg(patch)" file (User per Project Settings)
; 4. Override the settings in a "~/.o3de/Registry/*.setreg(patch)" file (User Global Settings)
; Where "~" is %USERPROFILE% on Windows and $HOME on Unix like platforms
+27 -2
View File
@@ -46,6 +46,7 @@ define_property(TARGET PROPERTY GEM_MODULE
#
# \arg:NAME name of the target
# \arg:STATIC (bool) defines this target to be a static library
# \arg:GEM_STATIC (bool) defines this target to be a static library while also setting the GEM_MODULE property
# \arg:SHARED (bool) defines this target to be a dynamic library
# \arg:MODULE (bool) defines this target to be a module library
# \arg:GEM_MODULE (bool) defines this target to be a module library while also marking the target as a "Gem" via the GEM_MODULE property
@@ -76,7 +77,7 @@ define_property(TARGET PROPERTY GEM_MODULE
# \arg:AUTOGEN_RULES a set of AutoGeneration rules to be passed to the AzAutoGen expansion system
function(ly_add_target)
set(options STATIC SHARED MODULE GEM_MODULE HEADERONLY EXECUTABLE APPLICATION UNKNOWN IMPORTED AUTOMOC AUTOUIC AUTORCC NO_UNITY)
set(options STATIC GEM_STATIC SHARED MODULE GEM_MODULE HEADERONLY EXECUTABLE APPLICATION UNKNOWN IMPORTED AUTOMOC AUTOUIC AUTORCC NO_UNITY)
set(oneValueArgs NAME NAMESPACE OUTPUT_SUBDIRECTORY OUTPUT_NAME)
set(multiValueArgs FILES_CMAKE GENERATED_FILES INCLUDE_DIRECTORIES COMPILE_DEFINITIONS BUILD_DEPENDENCIES RUNTIME_DEPENDENCIES PLATFORM_INCLUDE_FILES TARGET_PROPERTIES AUTOGEN_RULES)
@@ -96,6 +97,10 @@ function(ly_add_target)
if(ly_add_target_GEM_MODULE)
set(ly_add_target_MODULE ${ly_add_target_GEM_MODULE})
endif()
# If the GEM_STATIC tag is passed mark the target as STATIC
if(ly_add_target_GEM_STATIC)
set(ly_add_target_STATIC ${ly_add_target_GEM_STATIC})
endif()
foreach(file_cmake ${ly_add_target_FILES_CMAKE})
ly_include_cmake_file_list(${file_cmake})
@@ -199,7 +204,7 @@ function(ly_add_target)
endif()
if(ly_add_target_GEM_MODULE)
if(ly_add_target_GEM_MODULE OR ly_add_target_GEM_STATIC)
set_target_properties(${ly_add_target_NAME} PROPERTIES GEM_MODULE TRUE)
endif()
@@ -719,3 +724,23 @@ function(ly_project_add_subdirectory project_name)
endif()
endif()
endfunction()
# given a target name, returns the "real" name of the target if its an alias.
# this function recursively de-aliases
function(ly_de_alias_target target_name output_variable_name)
# its not okay to call get_target_property on a non-existent target
if (NOT TARGET ${target_name})
message(FATAL_ERROR "ly_de_alias_target called on non-existent target: ${target_name}")
endif()
while(target_name)
set(de_aliased_target_name ${target_name})
get_target_property(target_name ${target_name} ALIASED_TARGET)
endwhile()
if(NOT de_aliased_target_name)
message(FATAL_ERROR "Empty de_aliased for ${target_name}")
endif()
set(${output_variable_name} ${de_aliased_target_name} PARENT_SCOPE)
endfunction()
+1 -1
View File
@@ -14,7 +14,7 @@ set(LY_MONOLITHIC_GAME FALSE CACHE BOOL "Indicates if the game will be built mon
if(LY_MONOLITHIC_GAME)
add_compile_definitions(AZ_MONOLITHIC_BUILD)
ly_set(PAL_TRAIT_MONOLITHIC_DRIVEN_LIBRARY_TYPE STATIC)
ly_set(PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE STATIC)
ly_set(PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE GEM_STATIC)
# Disable targets that are not supported with monolithic
ly_set(PAL_TRAIT_BUILD_HOST_TOOLS FALSE)
ly_set(PAL_TRAIT_BUILD_HOST_GUI_TOOLS FALSE)
+12 -14
View File
@@ -64,18 +64,16 @@ function(ly_get_gem_load_dependencies ly_GEM_LOAD_DEPENDENCIES ly_TARGET)
get_target_property(load_dependencies ${ly_TARGET} MANUALLY_ADDED_DEPENDENCIES)
if(load_dependencies)
foreach(load_dependency ${load_dependencies})
# Skip wrapping produced when targets are not created in the same directory
if(NOT ${load_dependency} MATCHES "^::@")
get_property(dependency_type TARGET ${load_dependency} PROPERTY TYPE)
get_property(is_gem_target TARGET ${load_dependency} PROPERTY GEM_MODULE SET)
# If the dependency is a "gem module" then add it as a load dependencies
# and recurse into its manually added dependencies
if (is_gem_target)
unset(dependencies)
ly_get_gem_load_dependencies(dependencies ${load_dependency})
list(APPEND all_gem_load_dependencies ${load_dependency})
list(APPEND all_gem_load_dependencies ${dependencies})
endif()
# Skip wrapping produced when targets are not created in the same directory
ly_de_alias_target(${load_dependency} dealias_load_dependency)
get_property(is_gem_target TARGET ${dealias_load_dependency} PROPERTY GEM_MODULE SET)
# If the dependency is a "gem module" then add it as a load dependencies
# and recurse into its manually added dependencies
if (is_gem_target)
unset(dependencies)
ly_get_gem_load_dependencies(dependencies ${dealias_load_dependency})
list(APPEND all_gem_load_dependencies ${dependencies})
list(APPEND all_gem_load_dependencies ${dealias_load_dependency})
endif()
endforeach()
endif()
@@ -133,8 +131,8 @@ function(ly_delayed_generate_settings_registry)
file(RELATIVE_PATH gem_relative_source_dir ${ly_root_folder_cmake} ${gem_relative_source_dir})
endif()
# Strip target namespace from gem targets before configuring them into the json template
ly_strip_target_namespace(TARGET ${gem_target} OUTPUT_VARIABLE stripped_gem_target)
# De-alias namespace from gem targets before configuring them into the json template
ly_de_alias_target(${gem_target} stripped_gem_target)
string(CONFIGURE ${gem_module_template} gem_module_json @ONLY)
list(APPEND target_gem_dependencies_names ${gem_module_json})
endforeach()
+20 -7
View File
@@ -137,19 +137,32 @@ def get_config_file_values(config_file_path, keys_to_extract):
return result_map
def get_bootstrap_values(engine_root, keys_to_extract):
def get_bootstrap_values(bootstrap_dir, keys_to_extract):
"""
Extract requested values from the bootstrap.cfg file in the def root folder
:param engine_root: The engine root folder where bootstrap.cfg exists
Extract requested values from the bootstrap.setreg file in the Registry folder
:param bootstrap_dir: The parent directory of the bootstrap.setreg file
:param keys_to_extract: The keys to extract into a dictionary
:return: Dictionary of keys and its values (for matched keys)
"""
bootstrap_file = os.path.join(engine_root, 'bootstrap.cfg')
bootstrap_file = os.path.join(bootstrap_dir, 'bootstrap.setreg')
if not os.path.isfile(bootstrap_file):
raise LmbrCmdError("Missing 'bootstrap.cfg' file from engine root ('{}')".format(engine_root),
ERROR_CODE_FILE_NOT_FOUND)
raise logging.error(f'Bootstrap.setreg file {bootstrap_file} does not exist.')
result_map = {}
with bootstrap_file.open('r') as f:
try:
json_data = json.load(f)
except Exception as e:
logging.error(f'Bootstrap.setreg failed to load: {str(e)}')
else:
for search_key in keys_to_extract:
try:
search_result = json_data["Amazon"]["AzCore"]["Bootstrap"][f'"{search_key}"']
except KeyError as e:
logging.error(f'Bootstrap.setreg cannot find Amazon:AzCore:Bootstrap:{search_result}: {str(e)}')
else:
result_map[search_key] = search_result
result_map = get_config_file_values(bootstrap_file, keys_to_extract)
return result_map
-244
View File
@@ -1,244 +0,0 @@
#
# 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.
#
import argparse
import datetime
import logging
import pathlib
import platform
import sys
import os
import subprocess
ROOT_DEV_PATH = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', '..'))
if ROOT_DEV_PATH not in sys.path:
sys.path.append(ROOT_DEV_PATH)
from cmake.Tools import common
# The location of this python script is not portable relative to the engine root, we determine the engine root based
# on its relative location
DEV_ROOT = os.path.realpath(os.path.join(__file__, '../../..'))
BOOTSTRAP_CFG = os.path.join(DEV_ROOT, 'bootstrap.cfg')
EXECUTABLE_EXTN = '.exe' if platform.system() == 'Windows' else ''
RC_NAME = f'rc{EXECUTABLE_EXTN}'
APB_NAME = f'AssetProcessorBatch{EXECUTABLE_EXTN}'
# Depending on the user request for verbosity, the argument list to subprocess may or may not redirect stdout to NULL
VERBOSE_CALL_ARGS = dict(
shell=True,
cwd=DEV_ROOT
)
NON_VERBOSE_CALL_ARGS = dict(
**VERBOSE_CALL_ARGS,
stdout=subprocess.DEVNULL
)
def command_arg(arg):
"""
Work-around for an issue when running subprocess on Linux: subprocess.check_call will take in the argument as an array
but only invokes the first item in the array, ignoring the arguments. As quick fix, we will combine the array into the
full command line and execute it that way on non-windows platforms
"""
if platform.system() == 'Windows':
return arg
else:
return ' '.join(arg)
def validate(binfolder, game_name, pak_script):
#
# Validate the binfolder is relative and contains 'rc' and 'AssetProcessorBatch'
#
if os.path.isabs(binfolder):
raise common.LmbrCmdError("Invalid value for '-b/--binfolder'. It must be a path relative to the engine root folder",
common.ERROR_CODE_ERROR_DIRECTORY)
binfolder_abs_path = pathlib.Path(DEV_ROOT) / binfolder
if not binfolder_abs_path.is_dir():
raise common.LmbrCmdError("Invalid value for '-b/--binfolder'. Path does not exist or is not a directory",
common.ERROR_CODE_ERROR_DIRECTORY)
rc_check = binfolder_abs_path / RC_NAME
if not rc_check.is_file():
raise common.LmbrCmdError(f"Invalid value for '-b/--binfolder'. Path does not contain {RC_NAME}",
common.ERROR_CODE_ERROR_DIRECTORY)
apb_check = binfolder_abs_path / APB_NAME
if not apb_check.is_file():
raise common.LmbrCmdError(f"Invalid value for '-b/--binfolder'. Path does not contain {APB_NAME}",
common.ERROR_CODE_ERROR_DIRECTORY)
#
# Validate the game name represents a game project within the game engine
#
gamefolder_abs_path = pathlib.Path(DEV_ROOT) / game_name
if not gamefolder_abs_path.is_dir():
raise common.LmbrCmdError(f"Invalid value for '-g/--game-name'. No game '{game_name} exists.",
common.ERROR_CODE_ERROR_DIRECTORY)
project_json_path = gamefolder_abs_path / 'project.json'
if not project_json_path.is_file():
raise common.LmbrCmdError(
f"Invalid value for '-g/--game-name'. Folder '{game_name} is not a valid game project.",
common.ERROR_CODE_FILE_NOT_FOUND)
if not os.path.isfile(pak_script):
raise common.LmbrCmdError(f'Pak script file {pak_script} does not exist.',
common.ERROR_CODE_FILE_NOT_FOUND)
def process(binfolder, game_name, asset_platform, autorun_assetprocessor, recompress, fastest_compression, target,
pak_script, warn_on_assetprocessor_error, verbose):
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG if verbose else logging.INFO)
target_path_root_abs = pathlib.Path(DEV_ROOT) / target
if target_path_root_abs.is_file():
raise common.LmbrCmdError(f"Target '{target}' already exists as a file.",
common.ERROR_CODE_GENERAL_ERROR)
os.makedirs(target_path_root_abs.absolute(), exist_ok=True)
target_pak_folder_name = f'{game_name.lower()}_{asset_platform}_paks'
target_pak = target_path_root_abs / target_pak_folder_name
# Prepare the asset processor batch arguments and execute if requested
if autorun_assetprocessor:
ap_executable = os.path.join(binfolder, APB_NAME)
ap_cmd_args = [ap_executable,
f'/gamefolder={game_name}',
f'/platforms={asset_platform}']
logging.debug("Calling {}".format(' '.join(ap_cmd_args)))
try:
logging.info(f"Running {APB_NAME} on {game_name}")
start_time = datetime.datetime.now()
call_args = VERBOSE_CALL_ARGS if verbose else NON_VERBOSE_CALL_ARGS
subprocess.check_call(command_arg(ap_cmd_args),
**call_args)
total_time = datetime.datetime.now() - start_time
logging.info(f"Asset Processing Complete. Elapse: {total_time}")
except subprocess.CalledProcessError:
if warn_on_assetprocessor_error:
logging.warning('AssetProcessorBatch reported errors')
else:
raise common.LmbrCmdError("AssetProcessorBatch has one or more failed assets.",
common.ERROR_CODE_GENERAL_ERROR)
rc_executable = os.path.join(binfolder, RC_NAME)
rc_cmd_args = [rc_executable,
f'/job={pak_script}',
f'/p={asset_platform}',
f'/game={game_name}',
f'/trg={target_pak}']
if recompress:
rc_cmd_args.append('/recompress=1')
if fastest_compression:
rc_cmd_args.append('/use_fastest=1')
logging.debug("Calling {}".format(' '.join(rc_cmd_args)))
try:
logging.info(f"Running {APB_NAME} on {game_name}")
start_time = datetime.datetime.now()
call_args = VERBOSE_CALL_ARGS if verbose else NON_VERBOSE_CALL_ARGS
subprocess.check_call(command_arg(rc_cmd_args),
**call_args)
total_time = datetime.datetime.now() - start_time
logging.info(f"Asset Processing Complete. Elapse: {total_time}")
logging.info(f"Pak files for {game_name} written to {target_pak}")
except subprocess.CalledProcessError as err:
raise common.LmbrCmdError(f"{RC_NAME} returned an error: {str(err)}.",
err.returncode)
def main(args):
parser = argparse.ArgumentParser()
parser.add_argument('-b', '--binfolder',
help='The relative location of the binary folder that contains the resource compiler and asset processor')
bootstrap = common.get_bootstrap_values(DEV_ROOT, ['project_path'])
parser.add_argument('-g', '--game-name',
help='The name of the Game whose asset pak will be generated for',
default=bootstrap.get('project_path'))
parser.add_argument('-p', '--asset-platform',
help='The asset platform type to process')
parser.add_argument('-a', '--autorun-assetprocessor',
help='Option to automatically invoke asset processor batch on the game before generating the pak',
action='store_true')
parser.add_argument('-w', '--warn-on-assetprocessor-error',
help='When -a/--autorun-assetprocessor is specified, warn on asset processor failure rather than aborting the process',
action='store_true')
parser.add_argument('-r', '--recompress',
action='store_true',
help='If present, the ResourceCompiler (RC.exe) will decompress and compress back each PAK file '
'found as they are transferred from the cache folder to the game_pc_pak folder.')
parser.add_argument('-fc', '--fastest-compression',
action='store_true',
help='As each file is being added to its PAK file, they will be compressed across all available '
'codecs (ZLIB, ZSTD and LZ4) and the one with the fastest decompression time will be '
'chosen. The default is to always use ZLIB')
parser.add_argument('--target',
default='Pak',
help='Specify a target folder for the pak files. (Default : Pak)')
parser.add_argument('--pak-script',
default=f'{DEV_ROOT}/{os.path.normpath("Code/Tools/RC/Config/rc/RCJob_Generic_MakePaks.xml")}',
help="The absolute path of the pak script configuration file to use to create the paks.")
parser.add_argument('-v', '--verbose',
help='Enable debug messages',
action='store_true')
parsed = parser.parse_args(args)
validate(binfolder=parsed.binfolder,
game_name=parsed.game_name,
pak_script=parsed.pak_script)
process(binfolder=parsed.binfolder,
game_name=parsed.game_name,
asset_platform=parsed.asset_platform,
autorun_assetprocessor=parsed.autorun_assetprocessor,
recompress=parsed.recompress,
fastest_compression=parsed.fastest_compression,
target=parsed.target,
pak_script=parsed.pak_script,
warn_on_assetprocessor_error=parsed.warn_on_assetprocessor_error,
verbose=parsed.verbose)
if __name__ == '__main__':
try:
if not os.path.isfile(BOOTSTRAP_CFG):
raise common.LmbrCmdError("Invalid dev root, missing bootstrap.cfg.",
common.ERROR_CODE_FILE_NOT_FOUND)
main(sys.argv[1:])
exit(0)
except common.LmbrCmdError as err:
print(str(err), file=sys.stderr)
exit(err.code)
+16 -21
View File
@@ -78,19 +78,19 @@ def verify_layout(layout_dir, platform_name, project_path, asset_mode, asset_typ
if remote_on_check is None:
# Validate that if '<platform>_connect_to_remote is enabled, that the 'input_remote_ip' is not set to local host
if input_remote_connect == '1' and input_remote_ip == LOCAL_HOST:
return _warn("'bootstrap.cfg' is configured to connect to Asset Processor remotely, but the 'remote_ip' "
return _warn("'bootstrap.setreg' is configured to connect to Asset Processor remotely, but the 'remote_ip' "
" is configured for LOCAL HOST")
else:
if remote_on_check:
# Verify we are set for remote AP connection
if input_remote_ip == LOCAL_HOST:
return _warn(f"'bootstrap.cfg' is not configured for a remote Asset Processor connection (remote_ip={input_remote_ip})")
return _warn(f"'bootstrap.setreg' is not configured for a remote Asset Processor connection (remote_ip={input_remote_ip})")
if input_remote_connect != '1':
return _warn(f"'bootstrap.cfg' is not configured for a remote Asset Processor connection ({platform_name}_connect_to_remote={input_remote_connect}")
return _warn(f"'bootstrap.setreg' is not configured for a remote Asset Processor connection ({platform_name}_connect_to_remote={input_remote_connect}")
else:
# Verify we are disabled for remote AP connection
if input_remote_connect != '0':
return _warn(f"'bootstrap.cfg' is not configured for a remote Asset Processor connection ({platform_name}_connect_to_remote={input_remote_connect}")
return _warn(f"'bootstrap.setreg' is not configured for a remote Asset Processor connection ({platform_name}_connect_to_remote={input_remote_connect}")
return 0
@@ -107,20 +107,15 @@ def verify_layout(layout_dir, platform_name, project_path, asset_mode, asset_typ
project_name_lower = project_path.lower()
layout_path = pathlib.Path(layout_dir)
# Validate bootstrap.cfg exists
bootstrap_file = layout_path / 'bootstrap.cfg'
if not bootstrap_file.is_file():
warning_count += _warn(f"'bootstrap.cfg' is missing from {str(layout_path)}")
bootstrap_values = None
else:
bootstrap_values = common.get_config_file_values(str(bootstrap_file), [f'{platform_name_lower}_remote_filesystem',
f'{platform_name_lower}_connect_to_remote',
f'{platform_name_lower}_wait_for_connect',
f'{platform_name_lower}_assets',
f'assets',
f'{platform_name_lower}_remote_ip',
f'remote_ip'
])
bootstrap_path = layout_path / 'Registry'
bootstrap_values = common.get_bootstrap_values(str(bootstrap_path), [f'{platform_name_lower}_remote_filesystem',
f'{platform_name_lower}_connect_to_remote',
f'{platform_name_lower}_wait_for_connect',
f'{platform_name_lower}_assets',
f'assets',
f'{platform_name_lower}_remote_ip',
f'remote_ip'
])
# Validate the system_{platform}_{asset type}.cfg exists
platform_system_cfg_file = layout_path / f'system_{platform_name_lower}_{asset_type}.cfg'
@@ -141,9 +136,9 @@ def verify_layout(layout_dir, platform_name, project_path, asset_mode, asset_typ
# Validate that the asset type for the platform matches the one set for the build
bootstrap_asset_type = bootstrap_values.get(f'{platform_name_lower}_assets') or bootstrap_values.get('assets')
if not bootstrap_asset_type:
warning_count += _warn("'bootstrap.cfg' is missing specifications for asset type.")
warning_count += _warn("'bootstrap.setreg' is missing specifications for asset type.")
elif bootstrap_asset_type != asset_type:
warning_count += _warn(f"The asset type specified in bootstrap.cfg ({bootstrap_asset_type}) does not match the asset type specified for this deployment({asset_type}).")
warning_count += _warn(f"The asset type specified in bootstrap.setreg ({bootstrap_asset_type}) does not match the asset type specified for this deployment({asset_type}).")
# Validate that if '<platform>_connect_to_remote is enabled, that the 'remote_ip' is not set to local host
warning_count += _validate_remote_ap(remote_ip, remote_connect, None)
@@ -211,7 +206,7 @@ def verify_layout(layout_dir, platform_name, project_path, asset_mode, asset_typ
elif asset_mode == ASSET_MODE_VFS:
remote_file_system = bootstrap_values.get(f'{platform_name_lower}_remote_filesystem') or '0'
if not remote_file_system != '1':
warning_count += _warn("Remote file system is not configured in bootstrap.cfg for VFS mode.")
warning_count += _warn("Remote file system is not configured in bootstrap.setreg for VFS mode.")
else:
warning_count += _validate_remote_ap(remote_ip, remote_connect, True)
-121
View File
@@ -48,60 +48,6 @@ def test_determine_engine_root(tmpdir, engine_json_content, expected_success):
assert result is None
TEST_BOOTSTRAP_CONTENT_1 = """
project_path = Game1
foo = bar
key1 = value1
key2 = value2
assets = pc
--No Assets
"""
TEST_BOOTSTRAP_CONTENT_2 = """
project_path = Game2
foo = bar
#-------------------------
key1 = value1
key2 = value2
assets = pc
--No Assets
"""
@pytest.mark.parametrize(
"contents, input_keys, expected_result_map", [
pytest.param(TEST_BOOTSTRAP_CONTENT_1, ['project_path', 'foo', 'assets'], {'project_path': 'Game1',
'foo': 'bar',
'assets': 'pc'}, id="TestFullMatch"),
pytest.param(TEST_BOOTSTRAP_CONTENT_2, ['project_path', 'foo', 'barnone'], {'project_path': 'Game2',
'foo': 'bar'}, id="TestPartialMatch"),
pytest.param(TEST_BOOTSTRAP_CONTENT_2, ['project_pathnone', 'foonone', 'barnone'], {}, id="TestNoMatch")
]
)
def test_get_bootstrap_values_success(tmpdir, contents, input_keys, expected_result_map):
test_dev_root = 'dev'
tmpdir.ensure('{}/bootstrap.cfg'.format(test_dev_root))
bootstrap_file = tmpdir.join('{}/bootstrap.cfg'.format(test_dev_root))
bootstrap_file.write(contents)
bootstrap_file_path = str(tmpdir.join(test_dev_root).realpath())
result = common.get_bootstrap_values(bootstrap_file_path, input_keys)
assert expected_result_map == result
def test_get_bootstrap_values_fail():
try:
bad_file = 'x:\\foo\\bar\\file\\'
common.get_bootstrap_values(bad_file, ['input_keys'])
except common.LmbrCmdError as err:
assert 'Missing' in str(err)
else:
assert False, "Excepted LayoutToolError (missing file)"
TEST_AP_CONFIG_1 = """
[Platforms]
;pc=enabled
@@ -245,7 +191,6 @@ def test_verify_game_project_and_dev_root_success(tmpdir):
game_name = 'MyFoo'
game_folder = 'myfoo'
game_project_json = TEST_GAME_PROJECT_JSON_FORMAT.format(project_name=game_name)
tmpdir.ensure(f'{dev_root}/bootstrap.cfg')
tmpdir.ensure(f'{dev_root}/{game_folder}/project.json')
project_json_path = tmpdir / dev_root / game_folder / 'project.json'
project_json_path.write_text(game_project_json, encoding='ascii')
@@ -285,72 +230,6 @@ asset_deploy_type={test_asset_deploy_type}
assert result.asset_deploy_type == test_asset_deploy_type
def test_transform_bootstrap_project_path(tmpdir):
tmpdir.ensure('bootstrap.cfg')
test_bootstrap_content = """
-- Blah Blah
-- Blah Blah
project_path=OldProject
-- remote_filesystem - enable Virtual File System (VFS)
-- This feature allows a remote instance of the game to run off assets
-- on the asset processor computers cache instead of deploying them the remote device
-- By default it is off and can be overridden for any platform
remote_filesystem=0
"""
test_src_bootstrap = tmpdir / 'bootstrap.cfg'
test_src_bootstrap.write_text(test_bootstrap_content, encoding='ascii')
test_dst_bootstrap = tmpdir / 'bootstrap.transformed.cfg'
test_game_name = 'FooBar'
common.transform_bootstrap_for_project(game_name=test_game_name,
src_bootstrap=str(test_src_bootstrap),
dst_bootstrap=str(test_dst_bootstrap))
transformed_text = test_dst_bootstrap.read_text('ascii')
search_gamename = re.search(r"project_path\s*=\s*(.*)", transformed_text)
assert search_gamename
assert search_gamename.group(1)
assert search_gamename.group(1) == test_game_name
def test_transform_bootstrap_project_path_missing(tmpdir):
tmpdir.ensure('bootstrap.cfg')
test_bootstrap_content = """
-- Blah Blah
-- Blah Blah
-- remote_filesystem - enable Virtual File System (VFS)
-- This feature allows a remote instance of the game to run off assets
-- on the asset processor computers cache instead of deploying them the remote device
-- By default it is off and can be overridden for any platform
remote_filesystem=0
"""
test_src_bootstrap = tmpdir / 'bootstrap.cfg'
test_src_bootstrap.write_text(test_bootstrap_content, encoding='ascii')
test_dst_bootstrap = tmpdir / 'bootstrap.transformed.cfg'
test_game_name = 'FooBar'
common.transform_bootstrap_for_project(game_name=test_game_name,
src_bootstrap=str(test_src_bootstrap),
dst_bootstrap=str(test_dst_bootstrap))
transformed_text = test_dst_bootstrap.read_text('ascii')
search_gamename = re.search(r"project_path\s*=\s*(.*)", transformed_text)
assert search_gamename
assert search_gamename.group(1)
assert search_gamename.group(1) == test_game_name
def test_cmake_dependency_success(tmpdir):
test_module = 'FooBar'
-102
View File
@@ -1,102 +0,0 @@
#
# 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.
#
import os
import pytest
from . import current_project
TEST_BOOTSTRAP_CONTENT_1 = """
project_path = Game1
foo = bar
key1 = value1
key2 = value2
assets = pc
"""
TEST_BOOTSTRAP_CONTENT_2 = """
project_path=Game1
foo = bar
key1 = value1
key2 = value2
assets = pc
"""
TEST_BOOTSTRAP_CONTENT_3 = """
project_path= Game1
foo = bar
key1 = value1
key2 = value2
assets = pc
"""
TEST_BOOTSTRAP_CONTENT_4 = """
project_path =Game1
foo = bar
key1 = value1
key2 = value2
assets = pc
"""
TEST_BOOTSTRAP_CONTENT_5 = """
project_path = Game1
foo = bar
key1 = value1
key2 = value2
assets = pc
"""
@pytest.mark.parametrize(
"contents, expected_result", [
pytest.param(TEST_BOOTSTRAP_CONTENT_1, 'Game1'),
pytest.param(TEST_BOOTSTRAP_CONTENT_2, 'Game1'),
pytest.param(TEST_BOOTSTRAP_CONTENT_3, 'Game1'),
pytest.param(TEST_BOOTSTRAP_CONTENT_4, 'Game1'),
pytest.param(TEST_BOOTSTRAP_CONTENT_5, 'Game1'),
]
)
def test_get_current_project(tmpdir, contents, expected_result):
dev_root = str(tmpdir.join('dev').realpath()).replace('\\', '/')
os.makedirs(dev_root, exist_ok=True)
bootstrap_file = f'{dev_root}/bootstrap.cfg'
if os.path.isfile(bootstrap_file):
os.unlink(bootstrap_file)
with open(bootstrap_file, 'a') as s:
s.write(contents)
result = current_project.get_current_project(dev_root)
assert expected_result == result
@pytest.mark.parametrize(
"contents, project_to_set, expected_result", [
pytest.param(TEST_BOOTSTRAP_CONTENT_1, 'Test1', 0),
pytest.param(TEST_BOOTSTRAP_CONTENT_1, ' Test2', 0),
pytest.param(TEST_BOOTSTRAP_CONTENT_1, 'Test3 ', 0),
pytest.param(TEST_BOOTSTRAP_CONTENT_1, '/Test4', 1),
pytest.param(TEST_BOOTSTRAP_CONTENT_1, '=Test5', 1),
]
)
def test_set_current_project(tmpdir, contents, project_to_set, expected_result):
dev_root = str(tmpdir.join('dev').realpath()).replace('\\', '/')
os.makedirs(dev_root, exist_ok=True)
bootstrap_file = f'{dev_root}/bootstrap.cfg'
if os.path.isfile(bootstrap_file):
os.unlink(bootstrap_file)
with open(bootstrap_file, 'a') as s:
s.write(contents)
result = current_project.set_current_project(dev_root, project_to_set)
assert expected_result == result
if result == 0:
project_that_is_set = current_project.get_current_project(dev_root)
print(project_that_is_set)
print(project_to_set)
assert project_to_set.strip() == project_that_is_set
+7 -9
View File
@@ -212,16 +212,15 @@ def test_create_link_error():
@pytest.mark.parametrize(
"project_path, asset_type, ensure_path, warn_on_missing, expected_result", [
pytest.param('Foo', 'pc', 'Foo/Cache/pc/bootstrap.cfg', False, 'Foo/Cache/pc'),
pytest.param('Foo', 'pc', 'dev/bootstrap.cfg', True, None),
pytest.param('Foo', 'pc', 'Foo/Cache/es3/bootstrap.cfg', True, None),
pytest.param('Foo', 'pc', 'dev/bootstrap.cfg', False, common.LmbrCmdError),
pytest.param('Foo', 'pc', 'Foo/Cache/es3/bootstrap.cfg', False, common.LmbrCmdError),
"project_path, asset_type, warn_on_missing, expected_result", [
pytest.param('Foo', 'pc', False, 'Foo/Cache/pc'),
pytest.param('Foo', 'pc', True, None),
pytest.param('Foo', 'pc', True, None),
pytest.param('Foo', 'pc', False, common.LmbrCmdError),
pytest.param('Foo', 'pc', False, common.LmbrCmdError),
]
)
def test_construct_and_validate_cache_game_asset_folder_success(tmpdir, project_path, asset_type, ensure_path, warn_on_missing, expected_result):
tmpdir.ensure(ensure_path)
def test_construct_and_validate_cache_game_asset_folder_success(tmpdir, project_path, asset_type, warn_on_missing, expected_result):
if isinstance(expected_result, str):
expected_path_realpath = str(tmpdir.join(expected_result).realpath())
elif expected_result == common.LmbrCmdError:
@@ -385,7 +384,6 @@ def test_sync_layout_non_vfs_success(tmpdir, mode, existing_game_link, existing_
old_remove_link = layout_tool.remove_link
try:
# Simple Test Parameters
tmpdir.ensure('engine-root/bootstrap.cfg')
engine_root_realpath = str(tmpdir.join('engine-root').realpath())
test_project_path = str(tmpdir.join('Foo').realpath())
test_project_name_lower = 'foo'
@@ -83,7 +83,7 @@
"CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DCMAKE_C_COMPILER=clang-6.0 -DCMAKE_CXX_COMPILER=clang++-6.0 -DLY_UNITY_BUILD=TRUE -DLY_PARALLEL_LINK_JOBS=4 -DO3DE_HOME_PATH=\"${WORKSPACE}/home\" -DO3DE_REGISTER_ENGINE_PATH=\"${WORKSPACE}/o3de\" -DO3DE_REGISTER_THIS_ENGINE=TRUE",
"CMAKE_LY_PROJECTS": "AutomatedTesting",
"CMAKE_TARGET": "all",
"CTEST_OPTIONS": "-E (Gem::EMotionFX.Editor.Tests|Gem::AWSClientAuth.Tests|Gem::AWSCore.Editor.Tests) -L FRAMEWORK_googletest"
"CTEST_OPTIONS": "-E (Gem::EMotionFX.Editor.Tests|Gem::AWSClientAuth.Tests|Gem::AWSCore.Editor.Tests) -LE SUITE_sandbox -L FRAMEWORK_googletest"
}
},
"test_profile_nounity": {
@@ -95,7 +95,7 @@
"CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DCMAKE_C_COMPILER=clang-6.0 -DCMAKE_CXX_COMPILER=clang++-6.0 -DLY_UNITY_BUILD=FALSE -DLY_PARALLEL_LINK_JOBS=4 -DO3DE_HOME_PATH=\"${WORKSPACE}/home\" -DO3DE_REGISTER_ENGINE_PATH=\"${WORKSPACE}/o3de\" -DO3DE_REGISTER_THIS_ENGINE=TRUE",
"CMAKE_LY_PROJECTS": "AutomatedTesting",
"CMAKE_TARGET": "all",
"CTEST_OPTIONS": "-E (Gem::EMotionFX.Editor.Tests|Gem::AWSClientAuth.Tests|Gem::AWSCore.Editor.Tests) -L FRAMEWORK_googletest"
"CTEST_OPTIONS": "-E (Gem::EMotionFX.Editor.Tests|Gem::AWSClientAuth.Tests|Gem::AWSCore.Editor.Tests) -LE SUITE_sandbox -L FRAMEWORK_googletest"
}
},
"asset_profile": {
-31
View File
@@ -25,9 +25,6 @@ from glob3 import glob
def package(options):
package_env = PackageEnv(options.platform, options.type, options.package_env)
# Override values in bootstrap.cfg for PC package
override_bootstrap_cfg(package_env)
if not package_env.get('SKIP_BUILD'):
print(package_env.get('SKIP_BUILD'))
print('SKIP_BUILD is False, running CMake build...')
@@ -51,34 +48,6 @@ def get_python_path(package_env):
return os.path.join(package_env.get('ENGINE_ROOT'), 'python', 'python.sh')
def override_bootstrap_cfg(package_env):
print('Override values in bootstrap.cfg')
engine_root = package_env.get('ENGINE_ROOT')
bootstrap_path = os.path.join(engine_root, 'bootstrap.cfg')
replace_values = {'project_path':'{}'.format(package_env.get('BOOTSTRAP_CFG_GAME_FOLDER'))}
try:
with open(bootstrap_path, 'r') as bootstrap_cfg:
content = bootstrap_cfg.read()
except:
error('Cannot read file {}'.format(bootstrap_path))
content = content.split('\n')
new_content = []
for line in content:
if not line.startswith('--'):
strs = line.split('=')
if len(strs):
key = strs[0].strip(' ')
if key in replace_values:
line = '{}={}'.format(key, replace_values[key])
new_content.append(line)
try:
with open(bootstrap_path, 'w') as out:
out.write('\n'.join(new_content))
except:
error('Cannot write to file {}'.format(bootstrap_path))
print('{} updated with value {}'.format(bootstrap_path, replace_values))
def cmake_build(package_env):
build_targets = package_env.get('BUILD_TARGETS')
for build_target in build_targets: