3dec5d3b71
* LYN-2537 Moved the Engine and Editor folder to be within the EngineAssets folder * Fixed Documentation in bootstrap.cfg to correct the path to the user project specific registry file * Adding a newline to the output of AssetCatalog 'Registering asset..., but type is not set' message * Updating the AssetProcessorPlatformConfig.setreg Scan Folder to detect the @ENGINEROOT@/EngineAssets/Engine path for engine runtime assets and @ENGINEROOT@/EngineAssets/Editor path for engine tool assets * Updating references to Icons and other assets to account for moving the Engine and Editor folder under a single EngineAssets folder * Moving the Engine Settings Registry folder from Engine/Registry -> Registry * Removed the LY_PROJECT_CMAKE_PATH define as it is not portable to other locations. It is hard coded to the project location that was used for the CMake configuration. Furthermore it paths with backslashes within it are treated as escape characters and not a path separator * Updated the LyTestTools asset_processor.py script to copy the exclude.filetag from the EngineAssets/Engine directory now * Fixed Atom Shader Preprocessing when running using an External Project * Updated the TSGenerateAction.cpp to fix the build error with using a renamed variable * Updated the Install_Common.cmake ly_setup_others function to install the EngineAssets directory and the each of the Gem's Assets directory while maintaining the relative directory structure to the Engine Root Also updated the install step to install the Registry folder at the engine root * Fixed the copying of the Registry folder to be in the install root, instead of under a second 'Registry' folder * Moving the AssetProcessorPlatformConfig.setreg file over to the Registry folder * Updated the LyTestTools and C++ code to point that the new location of the AssetProcessorPlatformConfig.setreg file inside of the Registry folder * Renamed Test AssetProcessor*Config.ini files to have the .setreg extension * Converted the AssetProcessor test setreg files from ini format to json format using the SerializeContextTools convert-ini command * Updated the AssetProcessor CMakeLists.txt to copy over the test setreg files to the build folder * Updated the assetprocessor test file list to point at the renamed AsssetProcessor*Config setreg filenames * Removed the Output Prefix code from the AssetProcessor. The complexity that it brought to the AP code is not needed, as users can replicate the behavior by just moving there assets underneath a another folder, underneath the scan folder * Adding back support to read the AssetProcessorPlatformConfig.setreg file from the asset root. This is only needed for C++ UnitTests as they run in an environment where the accessing the Engine Settings Registry is not available * Updating the Install_common.cmake logic to copy any "Assets" folder to the install layout. The Script has also been updated to copy over the "Assets" folder in the Engine Root to the install layout instead of an "EngineAssets" folder * Updating References to EngineAssets source asset folder in code to be the Assets source folder * Moved the Engine Source Asset folder of 'EngineAssets' to a new folder name of 'Assets'. This is inline with the naming scheme we use for Gem asset folders * Adding the EngineFinder.cmake to the AutomatedTesting project to allow it to work in a project centric manner * Updating the LyTestTools copy_assets_to_project function to be able to copy assets with folders to the temporary project root Fixed an issue in LyTestTools where the temporary log directory could have shutil.rmtree being called twice on it leading to an exception which fails an automated test Updated the asset_procesor_gui_tests_2 AddScanFolder test to not use the output prefix, but instead place the source asset root into a subdirectory * Correct the AssetProcessorPlatformConfig Scan Folders for the EngineAssets directory to point at the Assets directory * Updated the asset procesor batch dependency test scan folder to point at the 'Assets' folder instead of 'EngineAssets'
334 lines
9.4 KiB
Lua
334 lines
9.4 KiB
Lua
----------------------------------------------------------------------------------------------------
|
|
--
|
|
-- 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.
|
|
--
|
|
-- Original file Copyright Crytek GMBH or its affiliates, used under license.
|
|
--
|
|
--
|
|
-- Description: Containers for Lua
|
|
-- Docs:
|
|
--
|
|
----------------------------------------------------------------------------------------------------
|
|
local countTable = Set and Set.countTable or {};
|
|
|
|
-- Create factory and management table
|
|
Set = {};
|
|
Set.countTable = countTable;
|
|
|
|
-- All tables are registered in Set.countTable, therefore won't GCed!
|
|
-- Unless we make their entries weak references. See Lua docs.
|
|
-- The effect is that these references are ignored by the garbage collector.
|
|
setmetatable(Set.countTable, { __mode="kv" });
|
|
|
|
|
|
-- Create and return a new Set table
|
|
Set.New = function()
|
|
local nt = {}
|
|
Set.countTable[nt] = 0
|
|
return nt
|
|
end
|
|
|
|
Set.SerializeValues = function(tbl)
|
|
local result = {}
|
|
for k,v in pairs(tbl) do
|
|
local item = {}
|
|
table.insert( item, 1, k );
|
|
table.insert( item, 2, v );
|
|
table.insert( result, item );
|
|
end
|
|
return result
|
|
end
|
|
|
|
|
|
Set.DeserializeValues = function(tbl)
|
|
local result = Set.New()
|
|
for i,item in ipairs(tbl) do
|
|
Set.Add( result, item[1], item[2] );
|
|
end
|
|
return result;
|
|
end
|
|
|
|
|
|
|
|
Set.DeserializeEntities = function(tbl)
|
|
local result = Set.New()
|
|
for i,entityID in ipairs(tbl) do
|
|
Set.Add(result, entityID)
|
|
end
|
|
return result
|
|
end
|
|
|
|
|
|
Set.SerializeEntities = function(tbl)
|
|
local result = {};
|
|
for entityID,v in pairs(tbl) do
|
|
table.insert(result, entityID)
|
|
end
|
|
return result;
|
|
end
|
|
|
|
|
|
Set.DeserializeItems = function(tbl)
|
|
local result = Set.New();
|
|
for i,item in ipairs(tbl) do
|
|
if (item) then
|
|
Set.Add(result, item);
|
|
end
|
|
end
|
|
return result;
|
|
end
|
|
|
|
|
|
Set.SerializeItems = function(tbl)
|
|
local result = {};
|
|
local index = 1;
|
|
for item,v in pairs(tbl) do
|
|
result[index] = item;
|
|
index = index + 1;
|
|
end
|
|
return result;
|
|
end
|
|
|
|
|
|
-- Is this table registered as a Set?
|
|
-- When performance and best-effort execution are required, this function
|
|
-- can easily be reduced to a stub or even all calls to it removed with regexp
|
|
Set.Check = function(table)
|
|
-- Run-time checking
|
|
if (not Set.countTable[table]) then
|
|
-- Throwing an error here would be preferable
|
|
if (print) then
|
|
print(tostring(table).."is not registered as a Set");
|
|
else
|
|
System.Log(tostring(table).."is not registered as a Set");
|
|
end
|
|
System.ShowDebugger()
|
|
Set.throwAnError.throwAnError = true;
|
|
end
|
|
end
|
|
|
|
|
|
-- Add an entry into a Set iff it does not already exist
|
|
-- if v == nil, we set it to true - leaving it nil would break things
|
|
-- Returns true on success, false if entry already exists
|
|
Set.Add = function(table, k, v)
|
|
v = v or true;
|
|
Set.Check(table);
|
|
if (not table[k]) then
|
|
table[k] = v;
|
|
Set.countTable[table] = Set.countTable[table] + 1;
|
|
return true;
|
|
end
|
|
return false;
|
|
end
|
|
|
|
-- Removes an entry from a Set
|
|
-- if k == nil, does nothing, which is debatable semantics
|
|
-- Returns true on success, false if entry did not exist
|
|
Set.Remove = function(table, k)
|
|
Set.Check(table);
|
|
if (table[k]) then
|
|
table[k] = nil;
|
|
Set.countTable[table] = Set.countTable[table] - 1;
|
|
return true;
|
|
end
|
|
return false;
|
|
end
|
|
|
|
|
|
-- Get a value from a Set
|
|
-- Return the value or nil if none
|
|
Set.Get = function(table, k)
|
|
Set.Check(table);
|
|
return table[k]
|
|
end
|
|
|
|
|
|
-- Set the value associated with a key, even if it already exists
|
|
-- if v == nil, we set it to true - leaving it nil would break things
|
|
-- Returns true if it did already exist, false if not
|
|
Set.Set = function(table, k, v)
|
|
v = v or true;
|
|
Set.Check(table);
|
|
if (not table[k]) then
|
|
table[k] = v;
|
|
Set.countTable[table] = Set.countTable[table] + 1;
|
|
return false;
|
|
else
|
|
-- Replace, no need to change count
|
|
table[k] = v;
|
|
return true;
|
|
end
|
|
end
|
|
|
|
|
|
-- Get the number of entries in the Set
|
|
Set.Size = function(table)
|
|
Set.Check(table);
|
|
return Set.countTable[table];
|
|
end
|
|
|
|
|
|
-- Remove all entries
|
|
-- No return value
|
|
Set.RemoveAll = function(table)
|
|
Set.Check(table);
|
|
for k,v in pairs(table) do
|
|
table[k] = nil;
|
|
end
|
|
Set.countTable[table] = 0;
|
|
end
|
|
|
|
|
|
-- Add entries of one Set into another
|
|
-- Keys shared by both will not be overwritten
|
|
-- Returns true iff keys were disjoint, none shared
|
|
Set.Merge = function(dest, source)
|
|
local disjoint = true;
|
|
Set.Check(dest);
|
|
Set.Check(source);
|
|
for k,v in pairs(source) do
|
|
if (not Set.Add(dest, k, v)) then
|
|
disjoint = false;
|
|
end
|
|
end
|
|
return disjoint;
|
|
end
|
|
|
|
|
|
-- Iterating:
|
|
-- For now, treat a Set as any table.
|
|
-- This should change.
|
|
|
|
|
|
-- Utility/debugging function:
|
|
-- Sanity check a suspicious Set
|
|
-- Tries to find evidence of tampering
|
|
-- Returns true iff it passes
|
|
Set.SanityCheck = function(table)
|
|
-- Check this was created as a Set
|
|
Set.Check(table);
|
|
-- Find as many things as you can in the Set
|
|
local count = 0;
|
|
for i,v in pairs(table) do
|
|
count = count + 1;
|
|
end
|
|
local size = Set.Size(table);
|
|
if (count ~= size) then
|
|
System.Log("[Set] Sanity check failed - Set size is "..tostring(size)..", counted "..count);
|
|
return false;
|
|
end
|
|
-- Check that all entries have the same type
|
|
-- This is just good practice, rather than an error
|
|
local indexType = nil;
|
|
local valueType = nil;
|
|
for i,v in pairs(table) do
|
|
-- Check index
|
|
if (indexType) then
|
|
if (indexType ~= type(i)) then
|
|
System.Log("[Set] Sanity check failed - Found indices of both types "..indexType.." and "..type(i));
|
|
return false;
|
|
end
|
|
else
|
|
indexType = type(i);
|
|
end
|
|
-- Check value
|
|
if (valueType) then
|
|
if (valueType ~= type(v)) then
|
|
System.Log("[Set] Sanity check failed - Found values of both types "..valueType.." and "..type(v));
|
|
return false;
|
|
end
|
|
else
|
|
valueType = type(v);
|
|
end
|
|
end
|
|
return true;
|
|
end
|
|
|
|
|
|
|
|
-- Unit test
|
|
-- Return true for success or false on failure
|
|
Set.Test = function(fullTest)
|
|
|
|
local A = Set.New();
|
|
local B = Set.New();
|
|
|
|
if ( Set.Add(A, "key1", 1) == false ) then return false; end
|
|
if ( Set.Add(A, "key2") == false ) then return false; end
|
|
if ( Set.Add(A, "key3", 3) == false ) then return false; end
|
|
if ( Set.Add(A, "key1", 1) == true ) then return false; end
|
|
if ( Set.Remove(A, "key1") == false ) then return false; end
|
|
if ( Set.Get(A, "key2")== false ) then return false; end
|
|
if ( Set.Get(A, "key1") ~= nil ) then return false; end
|
|
if ( Set.Get(A, "key3") ~= 3 ) then return false; end
|
|
if ( Set.Size(A) ~= 2 ) then return false; end
|
|
Set.RemoveAll(A);
|
|
if ( Set.Size(A) ~= 0 ) then return false; end
|
|
if ( Set.Add(A, "key1", 1) == false ) then return false; end
|
|
|
|
if ( Set.Set(A, "key1", 9) == false ) then return false; end
|
|
if ( Set.Set(A, "key0", 9) == true ) then return false; end
|
|
if ( Set.Add(A, "keyF", 3) == false ) then return false; end
|
|
if ( Set.Size(A) ~= 3 ) then return false; end
|
|
|
|
|
|
if ( Set.Add(B, "key3", 3) == false ) then return false; end
|
|
if ( Set.Add(B, "key4", 4) == false ) then return false; end
|
|
if ( Set.Add(B, "key5", 5) == false ) then return false; end
|
|
if ( Set.Add(B, "key3", 3) == true ) then return false; end
|
|
|
|
if ( Set.Set(B, "key9") == true ) then return false; end
|
|
if ( Set.Get(B, "key9") == nil ) then return false; end
|
|
|
|
if (not Set.Merge(A,B)) then return false; end
|
|
if (Set.Size(A) ~= 7) then return false; end
|
|
|
|
if (Set.Merge(A,B)) then return false; end
|
|
if (Set.Size(A) ~= 7) then return false; end
|
|
|
|
if (fullTest) then
|
|
-- Check countTable and GC (slow)
|
|
|
|
-- Shouldn't assume there are no Sets when testing
|
|
|
|
collectgarbage();
|
|
|
|
local baseCount = 0;
|
|
for i,v in pairs(Set.countTable) do
|
|
baseCount = baseCount + 1;
|
|
end
|
|
|
|
B = nil;
|
|
collectgarbage();
|
|
|
|
local count = 0;
|
|
for i,v in pairs(Set.countTable) do
|
|
count = count + 1;
|
|
end
|
|
if (baseCount - count ~= 1) then return false; end
|
|
end
|
|
|
|
-- Move this line around for testing
|
|
do return true; end
|
|
|
|
return true;
|
|
end
|
|
|
|
-- Perform quick version of unit test
|
|
if (not Set.Test()) then
|
|
System.Log("Containers: ... Error - Failed Unit Test");
|
|
else
|
|
--System.Log("Containers: ... End loading!");
|
|
end
|
|
|
|
-- Useful testing lines in Editor:
|
|
-- #Script.ReloadScript("Scripts/Utils/Containers.lua");
|
|
-- #System.Log(tostring(Set.Test(true))) |