From 057717598d490a88b3b235ae15445933f79154d8 Mon Sep 17 00:00:00 2001 From: Eric Froemling Date: Sun, 12 Jul 2020 22:11:00 -0700 Subject: [PATCH] Moved the update_assets_makefile script into the batools package --- .../assetsmakefile.py} | 11 ++--------- tools/batools/pcommand.py | 7 +++++++ tools/pcommand | 2 +- tools/update_project | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) rename tools/{update_assets_makefile => batools/assetsmakefile.py} (98%) diff --git a/tools/update_assets_makefile b/tools/batools/assetsmakefile.py similarity index 98% rename from tools/update_assets_makefile rename to tools/batools/assetsmakefile.py index 32e2f628..0e4663fb 100755 --- a/tools/update_assets_makefile +++ b/tools/batools/assetsmakefile.py @@ -259,17 +259,14 @@ def _get_extras_targets_win(all_targets: Set[str], platform: str) -> str: return out -def main() -> None: +def update_assets_makefile(projroot: str, check: bool) -> None: """Main script entry point.""" # pylint: disable=too-many-locals from efrotools import getconfig from pathlib import Path - # In 'check' mode we simply error on differences. - check = ('--check' in sys.argv) - # Always operate out of dist root dir. - os.chdir(os.path.join(os.path.dirname(sys.argv[0]), '..')) + os.chdir(projroot) public = getconfig(Path('.'))['public'] assert isinstance(public, bool) @@ -396,7 +393,3 @@ def _write_manifest(manifest_path: str, all_targets: Set[str], print(f'{Clr.SBLU}Updating: {manifest_path}{Clr.RST}') with open(manifest_path, 'w') as outfile: outfile.write(json.dumps(manifest, indent=1)) - - -if __name__ == '__main__': - main() diff --git a/tools/batools/pcommand.py b/tools/batools/pcommand.py index 196c31cf..9e1e519a 100644 --- a/tools/batools/pcommand.py +++ b/tools/batools/pcommand.py @@ -703,3 +703,10 @@ def stage_assets() -> None: except CleanError as exc: exc.pretty_print() sys.exit(1) + + +def update_assets_makefile() -> None: + """Update the assets makefile.""" + from batools.assetsmakefile import update_assets_makefile as uam + check = ('--check' in sys.argv) + uam(projroot=str(PROJROOT), check=check) diff --git a/tools/pcommand b/tools/pcommand index 6351f9c6..1e349cf6 100755 --- a/tools/pcommand +++ b/tools/pcommand @@ -55,7 +55,7 @@ from batools.pcommand import ( get_modern_make, warm_start_asset_build, update_docs_md, list_pip_reqs, install_pip_reqs, checkenv, ensure_prefab_platform, prefab_run_var, make_prefab, update_makebob, lazybuild, android_archive_unstripped_libs, - efro_gradle, stage_assets) + efro_gradle, stage_assets, update_assets_makefile) # pylint: enable=unused-import if TYPE_CHECKING: diff --git a/tools/update_project b/tools/update_project index 719c01f5..ef2d15c1 100755 --- a/tools/update_project +++ b/tools/update_project @@ -634,8 +634,8 @@ class App: sys.exit(255) def _update_assets_makefile(self) -> None: - assert os.path.exists('tools/update_assets_makefile') - if os.system('tools/update_assets_makefile' + self._checkarg) != 0: + if os.system(f'tools/pcommand update_assets_makefile {self._checkarg}' + ) != 0: print( f'{Clr.RED}Error checking/updating assets Makefile.f{Clr.RST}') sys.exit(255)