From 9e8b739282f68d4940bd9c1a40fc61dbd712151c Mon Sep 17 00:00:00 2001 From: Eric Froemling Date: Sun, 12 Jul 2020 22:30:29 -0700 Subject: [PATCH] Moved the update_project script into the batools package --- .efrocachemap | 4 ++-- Makefile | 4 ++-- tools/batools/pcommand.py | 9 +++++++++ .../updateproject.py} | 19 +++++++++---------- tools/pcommand | 2 +- 5 files changed, 23 insertions(+), 15 deletions(-) rename tools/{update_project => batools/updateproject.py} (98%) diff --git a/.efrocachemap b/.efrocachemap index aca4202a..a1972ebf 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -4145,6 +4145,6 @@ "build/prefab/mac/release/ballisticacore": "https://files.ballistica.net/cache/ba1/b9/c6/ac98c7aad5847fea5a37087d5aa0", "build/prefab/windows-server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/4e/59/c8cbb6d6909ab853bfa61a5160ce", "build/prefab/windows-server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/26/cd/737e2615e116d110aac319a3e293", - "build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/45/28/ff409cd1913fc71bf9b677b87df0", - "build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/a4/15/f823745542ea46f679552669b131" + "build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/94/c1/efd04026c6a251c288511ce3b037", + "build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/b4/50/b5fe4c0946537354fdc80aec5bb9" } \ No newline at end of file diff --git a/Makefile b/Makefile index 59dc4290..8e682f73 100644 --- a/Makefile +++ b/Makefile @@ -464,11 +464,11 @@ prefab-clean: # Update any project files that need it (does NOT build projects). update: prereqs - @tools/update_project + @tools/pcommand update_project # Don't update but fail if anything needs it. update-check: prereqs - @tools/update_project --check + @tools/pcommand update_project --check # Tell make which of these targets don't represent files. .PHONY: update update-check diff --git a/tools/batools/pcommand.py b/tools/batools/pcommand.py index 9e1e519a..9a848be5 100644 --- a/tools/batools/pcommand.py +++ b/tools/batools/pcommand.py @@ -710,3 +710,12 @@ def update_assets_makefile() -> None: from batools.assetsmakefile import update_assets_makefile as uam check = ('--check' in sys.argv) uam(projroot=str(PROJROOT), check=check) + + +def update_project() -> None: + """Update project files.""" + from batools.updateproject import Updater + check = '--check' in sys.argv + fix = '--fix' in sys.argv + + Updater(check=check, fix=fix).run() diff --git a/tools/update_project b/tools/batools/updateproject.py similarity index 98% rename from tools/update_project rename to tools/batools/updateproject.py index ef2d15c1..d1aede13 100755 --- a/tools/update_project +++ b/tools/batools/updateproject.py @@ -63,14 +63,14 @@ class LineChange: can_auto_update: bool -class App: +class Updater: """Context for an app run.""" - def __init__(self) -> None: + def __init__(self, check: bool, fix: bool) -> None: from efrotools import getconfig, getlocalconfig from pathlib import Path - self._check = ('--check' in sys.argv) - self._fix = ('--fix' in sys.argv) + self._check = check + self._fix = fix self._checkarg = ' --check' if self._check else '' # We behave differently in the public repo @@ -239,10 +239,9 @@ class App: lines = infile.read().splitlines() line = lines[change[1].line_number] print(f'{Clr.RED} Found "{line}"{Clr.RST}') - print(Clr.RED + - f'All {len(auto_changes)} errors are auto-fixable;' - ' run tools/update_project --fix to apply corrections.' + - Clr.RST) + print(f'{Clr.RED}All {len(auto_changes)} errors are' + f' auto-fixable; run tools/pcommand update_project' + f' --fix to apply corrections. {Clr.RST}') sys.exit(255) else: for i, change in enumerate(auto_changes): @@ -665,5 +664,5 @@ class App: sys.exit(255) -if __name__ == '__main__': - App().run() +# if __name__ == '__main__': +# App().run() diff --git a/tools/pcommand b/tools/pcommand index 1e349cf6..8019c1c5 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, update_assets_makefile) + efro_gradle, stage_assets, update_assets_makefile, update_project) # pylint: enable=unused-import if TYPE_CHECKING: