Remove bootstrap.cfg and references to it.

This commit is contained in:
amzn-sj
2021-05-19 13:57:35 -07:00
parent 6a108c0515
commit 268fd8b714
22 changed files with 52 additions and 598 deletions
@@ -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);
@@ -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
@@ -109,7 +109,6 @@ namespace AssetBundler
if (!AZ::SettingsRegistry::Get())
{
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_Bootstrap(m_registry);
AZ::SettingsRegistry::Register(&m_registry);
}
@@ -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);
@@ -152,7 +152,6 @@ struct AssetValidationTest
{
AZ::SettingsRegistry::Register(&m_registry);
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_Bootstrap(m_registry);
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)
@@ -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')
@@ -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
+21 -7
View File
@@ -137,19 +137,33 @@ 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.')
return None
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 Exception 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'
-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: