Fixed several o3de python package and install layout issues (#1714)

* Updated the CrashLog directory path to save to the project user
directory instead of the engine-root directory

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Removing the custom OUTPUT_NAME for the Multiplayer Gem Builder target

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Changed the default value for the LY_3RDPARTY_PATH cache variable to be
~/.o3de/3rdParty

This simplifies the first time user experience when running cmake

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Fixed Windows only issue where using creating a VS Solution for an O3DE project on a different drive resulted in an unloaded "<drive letter>:" entry appearing in the solution explorer

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Refactored install layout logic for External Subdirectories

Instead of performing a regular expression over the Gems/* directory, now the each external subdirectory including the project (external) directory is recursied over and scanned for any folders that aren't excluded.
By default those folders are the [Cc]ache, [Bb]uild and [Uu]ser directories

Afterwards the list files to copy over are then split into a directory list and a file list that is filtered by an include regex
Next the directory list is iterated over and the directories are copied to the install layout
Finally the file list is iterated and the list of files are also copied to the install layout

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Fixed the o3de.bat script changing the working directory before running the o3de.py script

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Fixed exception in engine-template.py script when the create-gem command
is invoked with the --template-name parameter that does not correspond
to a registered Template

Updated the create-project command to register the project with the
o3de_manifest.json and the engine with the project as the final step

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Fixed register.py over-registration of non-engine directories when then
--this-engine parameter is supplied.
All the projects, gems and templates inside of the default o3de_manifest
folder locations were being registered with the engine that was being
registered

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Fixed register.py register_project_path() method to return 0 when the
project path is successfully registered.

This issue was that the save_o3de_manifest method "return" value was
being checked and that method doesn't actually return a value

Added question mark to the engine_template.py to correct text around
notifying the user if the project was registered

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Added doc comment on the new cmke ly_get_vs_folder_directory function()

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Added clarifying comment to the ly_setup_others() command logic to copy over directories and files from any external subdirectories(Gems) that are registered with the engine at the time of install

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Fixed infinite recursion when trying to create a template with the
source directory used to seed the template

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
This commit is contained in:
lumberyard-employee-dm
2021-07-02 00:22:12 -05:00
committed by GitHub
parent 9758aea3d6
commit 2478c60793
9 changed files with 142 additions and 82 deletions
+1 -3
View File
@@ -9,7 +9,7 @@ REM
pushd %~dp0%
CD %~dp0..
SET "BASE_PATH=%CD%"
CD %~dp0
popd
SET "PYTHON_DIRECTORY=%BASE_PATH%\python"
IF EXIST "%PYTHON_DIRECTORY%" GOTO pythonPathAvailable
GOTO pythonDirNotFound
@@ -25,10 +25,8 @@ GOTO fail
ECHO Python executable not found: %PYTHON_EXECUTABLE%
GOTO fail
:fail
popd
EXIT /b 1
:end
popd
EXIT /b %ERRORLEVEL%
+17 -30
View File
@@ -17,7 +17,7 @@ import uuid
import re
from o3de import manifest, validation, utils
from o3de import manifest, register, validation, utils
logger = logging.getLogger()
logging.basicConfig()
@@ -388,10 +388,11 @@ def create_template(source_path: pathlib.Path,
if not source_path:
logger.error('Src path cannot be empty.')
return 1
if not os.path.isdir(source_path):
if not source_path.is_dir():
logger.error(f'Src path {source_path} is not a folder.')
return 1
source_path = source_path.resolve()
# source_name is now the last component of the source_path
if not source_name:
source_name = os.path.basename(source_path)
@@ -401,11 +402,11 @@ def create_template(source_path: pathlib.Path,
if not template_path:
logger.info(f'Template path empty. Using source name {source_name}')
template_path = source_name
if not os.path.isabs(template_path):
if not template_path.is_absolute():
default_templates_folder = manifest.get_registered(default_folder='templates')
template_path = default_templates_folder/ template_path
template_path = default_templates_folder / template_path
logger.info(f'Template path not a full path. Using default templates folder {template_path}')
if not force and os.path.isdir(template_path):
if not force and template_path.is_dir():
logger.error(f'Template path {template_path} already exists.')
return 1
@@ -415,8 +416,7 @@ def create_template(source_path: pathlib.Path,
except ValueError:
pass
else:
logger.error(f'Template output path {template_path} cannot be a subdirectory of the source_path {source_path}:\n'
f'{err}')
logger.error(f'Template output path {template_path} cannot be a subdirectory of the source_path {source_path}\n')
return 1
# template name is now the last component of the template_path
@@ -1200,7 +1200,7 @@ def create_from_template(destination_path: pathlib.Path,
if not destination_name:
# destination name is now the last component of the destination_path
destination_name = os.path.basename(destination_path)
destination_name = destination_path.name
# destination name cannot be the same as a restricted platform name
if destination_name in restricted_platforms:
@@ -1654,28 +1654,10 @@ def create_project(project_path: pathlib.Path,
d.write('# SPDX-License-Identifier: Apache-2.0 OR MIT\n')
d.write('# {END_LICENSE}\n')
# set the "engine" element of the project.json
engine_json_data = manifest.get_engine_json_data(engine_path=manifest.get_this_engine_path())
try:
engine_name = engine_json_data['engine_name']
except KeyError as e:
logger.error(f"engine_name for this engine not found in engine.json.")
return 1
project_json_data = manifest.get_project_json_data(project_path=project_path)
if not project_json_data:
# get_project_json_data already logs an error if the project.json is mising
return 1
project_json_data.update({"engine": engine_name})
with open(project_json, 'w') as s:
try:
s.write(json.dumps(project_json_data, indent=4) + '\n')
except OSError as e:
logger.error(f'Failed to write project json at {project_path}.')
return 1
return 0
# Register the project with the global o3de_manifest.json and set the project.json "engine" field to match the
# engine.json "engine_name" field
return register.register(project_path=project_path)
def create_gem(gem_path: pathlib.Path,
@@ -1745,6 +1727,11 @@ def create_gem(gem_path: pathlib.Path,
if template_name and not template_path:
template_path = manifest.get_registered(template_name=template_name)
if not template_path:
logger.error(f'Could not find the template path using name {template_name}.\n'
'Has the template been registered yet? It can be registered via the '
'"o3de.py register --tp <template-path>" command')
return 1
if not os.path.isdir(template_path):
logger.error(f'Could not find the template {template_name}=>{template_path}')
return 1
@@ -2068,7 +2055,7 @@ def _run_create_from_template(args: argparse) -> int:
return create_from_template(args.destination_path,
args.template_path,
args.template_name,
args.destination_path,
args.destination_name,
args.destination_restricted_path,
args.destination_restricted_name,
args.template_restricted_path,
+4 -2
View File
@@ -194,9 +194,9 @@ def load_o3de_manifest(manifest_path: pathlib.Path = None) -> dict:
return json_data
def save_o3de_manifest(json_data: dict, manifest_path: pathlib.Path = None) -> None:
def save_o3de_manifest(json_data: dict, manifest_path: pathlib.Path = None) -> bool:
"""
Save the json dictionary to the supplied manifest file or ~/.o3de/o3de_manifest.json if None
Save the json dictionary to the supplied manifest file or ~/.o3de/o3de_manifest.json if manifest_path is None
:param json_data: dictionary to save in json format at the file path
:param manifest_path: optional path to manifest file to save
@@ -206,8 +206,10 @@ def save_o3de_manifest(json_data: dict, manifest_path: pathlib.Path = None) -> N
with manifest_path.open('w') as s:
try:
s.write(json.dumps(json_data, indent=4) + '\n')
return True
except OSError as e:
logger.error(f'Manifest json failed to save: {str(e)}')
return False
# Data query methods
+1 -5
View File
@@ -341,7 +341,7 @@ def register_o3de_object_path(json_data: dict,
try:
paths_to_remove.append(o3de_object_path.relative_to(save_path.parent))
except ValueError:
pass # It is OK relative path cannot be formed
pass # It is OK relative path cannot be formed
manifest_data[o3de_object_key] = list(filter(lambda p: pathlib.Path(p) not in paths_to_remove,
manifest_data.setdefault(o3de_object_key, [])))
@@ -425,7 +425,6 @@ def register_project_path(json_data: dict,
if not manifest.save_o3de_manifest(project_json_data, project_json_path):
return 1
return 0
@@ -754,9 +753,6 @@ def _run_register(args: argparse) -> int:
return repo.refresh_repos()
elif args.this_engine:
ret_val = register(engine_path=manifest.get_this_engine_path(), force=args.force)
error_code = register_shipped_engine_o3de_objects(force=args.force)
if error_code:
ret_val = error_code
return ret_val
elif args.all_engines_path:
return register_all_engines_in_folder(args.all_engines_path, args.remove, args.force)