Skip to content

Commit

Permalink
Improve monorepo discovery
Browse files Browse the repository at this point in the history
Protect against parent directories containing Unreal Engine source code without
the current directory being part of a monorepo setup.
  • Loading branch information
samhocevar committed Nov 23, 2021
1 parent 3f3b4b7 commit 1cdef43
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions nimp/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,9 @@ def validate_uproject(self, urpoject):
def display_unreal_info(self):
''' display engine and selected uproject info '''
if hasattr(self, 'unreal_full_version') and hasattr(self, 'unreal_dir'):
logging.info(f'Found Unreal engine {self.unreal_full_version} in {self.unreal_dir}')
logging.info(f'Found Unreal Engine {self.unreal_full_version} in {self.unreal_dir}')
else:
logging.info('No Unreal engine loaded')
logging.info('No Unreal Engine found')
if hasattr(self, 'uproject') and hasattr(self, 'uproject_dir'):
logging.info(f'Found Unreal project {self.uproject} in {self.uproject_dir}')
else:
Expand Down
19 changes: 11 additions & 8 deletions nimp/unreal.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,18 @@ def load_config(env):
unreal_base_paths = [
'UnrealEngine',
'UE4',
'',
'.',
]
for unreal_path in unreal_base_paths:
unreal_dir = nimp.system.find_dir_containing_file(os.path.join(unreal_path, unreal_file))
if unreal_dir:
unreal_dir = os.path.join(unreal_dir, unreal_path)
break

if not unreal_dir:
for base in unreal_base_paths:
path_to_base = nimp.system.find_dir_containing_file(os.path.join(base, unreal_file))
if not path_to_base:
continue
# Sanity check: if `base` indicates a monorepo setup, check that it is really one
if base != '.' and not os.path.isfile(os.path.join(path_to_base, '.nimp/monorepo_commands/__init__.py')):
continue
unreal_dir = os.path.join(path_to_base, base)
break
finally:
env.is_unreal = env.is_ue4 = env.is_ue5 = False
env.is_dne_legacy_ue4 = True
return True
Expand Down

0 comments on commit 1cdef43

Please sign in to comment.