From 7a25a17fae641fef241d3fecf80d6ea6cdd8fb5d Mon Sep 17 00:00:00 2001 From: phistere Date: Thu, 20 May 2021 09:13:01 -0500 Subject: [PATCH 1/3] Fixes a few issues when using an engine name different from the default --- .../Template/EngineFinder.cmake | 5 ++- cmake/install/engine.json.in | 2 +- scripts/o3de/o3de/engine_template.py | 43 +++++++++++++++++-- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/Templates/DefaultProject/Template/EngineFinder.cmake b/Templates/DefaultProject/Template/EngineFinder.cmake index 7dfddf2c5f..a7dbf671fd 100644 --- a/Templates/DefaultProject/Template/EngineFinder.cmake +++ b/Templates/DefaultProject/Template/EngineFinder.cmake @@ -20,13 +20,14 @@ if(json_error) message(FATAL_ERROR "Unable to read key 'engine' from 'project.json', error: ${json_error}") endif() -# Read the list of paths from ~.o3de/o3de_manifest.json -if($ENV{USERPROFILE} AND EXISTS $ENV{USERPROFILE}) +if(DEFINED ENV{USERPROFILE} AND EXISTS $ENV{USERPROFILE}) set(manifest_path $ENV{USERPROFILE}/.o3de/o3de_manifest.json) # Windows else() set(manifest_path $ENV{HOME}/.o3de/o3de_manifest.json) # Unix endif() +# Read the ~/.o3de/o3de_manifest.json file and look through the 'engines_path' object. +# Find a key that matches LY_ENGINE_NAME_TO_USE and use that as the engine path. if(EXISTS ${manifest_path}) file(READ ${manifest_path} manifest_json) diff --git a/cmake/install/engine.json.in b/cmake/install/engine.json.in index 04ee6348d3..4a8579d864 100644 --- a/cmake/install/engine.json.in +++ b/cmake/install/engine.json.in @@ -1,6 +1,6 @@ { "engine_name": "@LY_VERSION_ENGINE_NAME@", - "restricted": "@LY_VERSION_ENGINE_NAME@", + "restricted": "o3de", "FileVersion": 1, "O3DEVersion": "@LY_VERSION_STRING@", "O3DECopyrightYear": @LY_VERSION_COPYRIGHT_YEAR@, diff --git a/scripts/o3de/o3de/engine_template.py b/scripts/o3de/o3de/engine_template.py index 23acab33d4..ad7ec55e1f 100755 --- a/scripts/o3de/o3de/engine_template.py +++ b/scripts/o3de/o3de/engine_template.py @@ -1652,10 +1652,45 @@ def create_project(project_path: str, d.write('# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n') d.write('# {END_LICENSE}\n') - # copy the o3de_manifest.cmake into the project root - engine_path = registration.get_this_engine_path() - o3de_manifest_cmake = f'{engine_path}/cmake/o3de_manifest.cmake' - shutil.copy(o3de_manifest_cmake, project_path) + # set the "engine" element of the project.json + engine_json = f'{registration.get_this_engine_path()}/engine.json' + if not registration.valid_o3de_engine_json(engine_json): + logger.error(f"Engine json {engine_json} is not valid.") + return 1 + + with open(engine_json) as s: + try: + engine_json_data = json.load(s) + except Exception as e: + logger.error(f"Failed to read engine json {engine_json}: {str(e)}") + return 1 + + try: + engine_name = engine_json_data['engine_name'] + except Exception as e: + logger.error(f"Engine json {engine_json} engine_name not found.") + return 1 + + project_json = f"{project_path}/project.json".replace('//', '/') + if not registration.valid_o3de_project_json(project_json): + logger.error(f'Project json {project_json} is not valid.') + return 1 + + with open(project_json, 'r') as s: + try: + project_json_data = json.load(s) + except Exception as e: + logger.error(f'Failed to load project json {project_json}.') + return 1 + + project_json_data.update({"engine": engine_name}) + os.unlink(project_json) + with open(project_json, 'w') as s: + try: + s.write(json.dumps(project_json_data, indent=4)) + except Exception as e: + logger.error(f'Failed to write project json {project_json}.') + return 1 return 0 From 0f4e00e48f940eab016cf3f01be27821c0236f1e Mon Sep 17 00:00:00 2001 From: phistere Date: Thu, 20 May 2021 10:38:44 -0500 Subject: [PATCH 2/3] Updating the Gems selctions for the DefaultProject template --- .../Template/Code/runtime_dependencies.cmake | 10 ---------- .../Template/Code/tool_dependencies.cmake | 15 --------------- 2 files changed, 25 deletions(-) diff --git a/Templates/DefaultProject/Template/Code/runtime_dependencies.cmake b/Templates/DefaultProject/Template/Code/runtime_dependencies.cmake index ce8df8152d..f55677a9b6 100644 --- a/Templates/DefaultProject/Template/Code/runtime_dependencies.cmake +++ b/Templates/DefaultProject/Template/Code/runtime_dependencies.cmake @@ -18,19 +18,9 @@ set(GEM_DEPENDENCIES Gem::LyShine Gem::Camera Gem::CameraFramework - Gem::Atom_RHI.Private Gem::EMotionFX - Gem::Atom_RPI.Private - Gem::Atom_Feature_Common Gem::ImGui - Gem::Atom_Bootstrap - Gem::Atom_Component_DebugCamera - Gem::AtomImGuiTools - Gem::AtomLyIntegration_CommonFeatures - Gem::EMotionFX_Atom - Gem::ImguiAtom Gem::Atom_AtomBridge Gem::GradientSignal - Gem::AtomFont Gem::WhiteBox ) diff --git a/Templates/DefaultProject/Template/Code/tool_dependencies.cmake b/Templates/DefaultProject/Template/Code/tool_dependencies.cmake index 010d45bd0f..c6a782c17e 100644 --- a/Templates/DefaultProject/Template/Code/tool_dependencies.cmake +++ b/Templates/DefaultProject/Template/Code/tool_dependencies.cmake @@ -20,24 +20,9 @@ set(GEM_DEPENDENCIES Gem::EditorPythonBindings.Editor Gem::Camera.Editor Gem::CameraFramework - Gem::Atom_RHI.Private Gem::EMotionFX.Editor - Gem::Atom_RPI.Builders - Gem::Atom_RPI.Editor - Gem::Atom_Feature_Common.Builders - Gem::Atom_Feature_Common.Editor Gem::ImGui.Editor - Gem::Atom_Bootstrap - Gem::Atom_Asset_Shader.Builders - Gem::Atom_Component_DebugCamera - Gem::AtomImGuiTools - Gem::AtomLyIntegration_CommonFeatures.Editor - Gem::EMotionFX_Atom.Editor - Gem::ImageProcessingAtom.Editor Gem::Atom_AtomBridge.Editor - Gem::ImguiAtom - Gem::AtomFont - Gem::AtomToolsFramework.Editor Gem::GradientSignal.Editor Gem::WhiteBox.Editor ) From a4243f4be37473003b4f896712185dedc8caa286 Mon Sep 17 00:00:00 2001 From: phistere Date: Thu, 20 May 2021 10:42:06 -0500 Subject: [PATCH 3/3] Temporarily fixes an issue with some Gems where asset paths aren't properly generated for asset processor --- cmake/SettingsRegistry.cmake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmake/SettingsRegistry.cmake b/cmake/SettingsRegistry.cmake index 31ce36c516..dcfbd8a1f0 100644 --- a/cmake/SettingsRegistry.cmake +++ b/cmake/SettingsRegistry.cmake @@ -124,12 +124,13 @@ function(ly_delayed_generate_settings_registry) message(FATAL_ERROR "Dependency ${gem_target} from ${target} does not exist") endif() get_property(gem_relative_source_dir TARGET ${gem_target} PROPERTY SOURCE_DIR) + if(gem_relative_source_dir) - # Most gems SOURCE dir is nested in the path, we need to find the path to the gem.json or project.json file - while(NOT EXISTS ${gem_relative_source_dir}/gem.json AND NOT EXISTS ${gem_relative_source_dir}/project.json) + # Most gems SOURCE dir is nested in the path, we need to find the path where an 'Assets' or 'Code' folder resides + while(NOT EXISTS ${gem_relative_source_dir}/Assets AND NOT EXISTS ${gem_relative_source_dir}/Code) get_filename_component(parent_dir ${gem_relative_source_dir} DIRECTORY) if (${parent_dir} STREQUAL ${gem_relative_source_dir}) - message(FATAL_ERROR "Did not find gem.json or project.json while processing target ${gem_target}!") + message(FATAL_ERROR "Did not find a Gem source dir while processing target ${gem_target}!") endif() set(gem_relative_source_dir ${parent_dir}) endwhile()