Moved the update_project script into the batools package

This commit is contained in:
Eric Froemling 2020-07-12 22:30:29 -07:00
parent 057717598d
commit 9e8b739282
5 changed files with 23 additions and 15 deletions

View File

@ -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"
}

View File

@ -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

View File

@ -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()

View File

@ -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()

View File

@ -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: