diff --git a/.idea/dictionaries/ericf.xml b/.idea/dictionaries/ericf.xml index 5a433830..ec6ad318 100644 --- a/.idea/dictionaries/ericf.xml +++ b/.idea/dictionaries/ericf.xml @@ -297,6 +297,7 @@ cpplint cpplintcode cpplintcodefull + cpplintfull cpuinfo cpus cpython @@ -375,6 +376,7 @@ dnode doclines docprefix + docshash docslines docstr doctype @@ -674,6 +676,7 @@ hacky halign handlemessage + hashlines hashopenssl hashpath hashstr @@ -990,8 +993,10 @@ myobj myprojname mypy + mypyfull mypyscripts mypyscriptsfull + mysound mytextnode myweakcall mywidget @@ -1230,6 +1235,7 @@ pybuild pycache pycharmbin + pycharmfull pycharmroot pycharmscripts pycharmscriptsfull @@ -1247,6 +1253,8 @@ pylib pylibs pylint + pylintfast + pylintfull pylintplugins pylintrc pylintscripts @@ -1457,6 +1465,7 @@ steelseries stickman storable + storedhash storeitemui stringprep stringptr diff --git a/Makefile b/Makefile index 6dc67f31..fda16817 100644 --- a/Makefile +++ b/Makefile @@ -270,7 +270,7 @@ check: updatecheck @echo ALL CHECKS PASSED! # Same as 'check' plus optional/slow extra checks. check2: updatecheck - @$(MAKE) -j4 cpplint pylint mypy pycharmscripts + @$(MAKE) -j4 cpplint pylint mypy pycharm @echo ALL CHECKS PASSED! # Run faster checks which may occasionally miss things. @@ -279,7 +279,7 @@ checkfast: updatecheck @echo ALL CHECKS PASSED! # Same as 'checkfast' plus optional/slow extra checks. checkfast2: updatecheck - @$(MAKE) -j4 cpplint pylintfast mypy pycharmscripts + @$(MAKE) -j4 cpplint pylintfast mypy pycharm @echo ALL CHECKS PASSED! # Run checks with no caching (all files are checked). @@ -288,7 +288,7 @@ checkfull: updatecheck @echo ALL CHECKS PASSED! # Same as 'checkfull' plus optional/slow extra checks. checkfull2: updatecheck - @$(MAKE) -j4 cpplintfull pylintfull mypyfull pycharmscriptsfull + @$(MAKE) -j4 cpplintfull pylintfull mypyfull pycharmfull @echo ALL CHECKS PASSED! # Run Cpplint checks on all C/C++ code. @@ -323,18 +323,18 @@ mypyfull: prereqs @tools/snippets mypy -full # Run PyCharm checks on all Python code. -pycharmscripts: prereqs - @tools/snippets pycharmscripts +pycharm: prereqs + @tools/snippets pycharm # Run PyCharm checks without caching (all files are checked). -pycharmscriptsfull: prereqs - @tools/snippets pycharmscripts -full +pycharmfull: prereqs + @tools/snippets pycharm -full # Tell make which of these targets don't represent files. .PHONY: format formatfull formatcode formatcodefull formatscripts \ formatscriptsfull check check2 checkfast checkfast2 checkfull checkfull2 \ cpplint cpplintfull pylint pylintfull mypy \ - mypyfull pycharmscripts pycharmscriptsfull + mypyfull pycharm pycharmfull ################################################################################ @@ -358,7 +358,7 @@ updatethencheck: update @echo ALL CHECKS PASSED! # Same as 'updatethencheck' plus optional/slow extra checks. updatethencheck2: update - @$(MAKE) -j4 cpplint pylint mypy pycharmscripts + @$(MAKE) -j4 cpplint pylint mypy pycharm @echo ALL CHECKS PASSED! # 'updatethencheck' without caching (checks all files). @@ -367,7 +367,7 @@ updatethencheckfull: update @echo ALL CHECKS PASSED! # 'updatethencheckfull' plus optional/slow extra checks. updatethencheckfull2: update - @$(MAKE) -j4 cpplintfull pylintfull mypyfull pycharmscriptsfull + @$(MAKE) -j4 cpplintfull pylintfull mypyfull pycharmfull @echo ALL CHECKS PASSED! # Format, update, and check the project; do this before git commits. diff --git a/assets/src/data/scripts/_ba.py b/assets/src/data/scripts/_ba.py index 8770f7c0..dfeadb6b 100644 --- a/assets/src/data/scripts/_ba.py +++ b/assets/src/data/scripts/_ba.py @@ -34,7 +34,7 @@ NOTE: This file was autogenerated by gendummymodule; do not edit by hand. """ # (hash we can use to see if this file is out of date) -# SOURCES_HASH=120456495529909322688635129785556212748 +# SOURCES_HASH=221041082183416610193123748095056578345 # I'm sorry Pylint. I know this file saddens you. Be strong. # pylint: disable=useless-suppression diff --git a/docs/ba_module.md b/docs/ba_module.md index f63aae1d..9c4b3f40 100644 --- a/docs/ba_module.md +++ b/docs/ba_module.md @@ -1,6 +1,8 @@ -

last updated on 2019-11-11 for BallisticaCore version 1.5.0 build 20001

+ + +

last updated on 2019-11-12 for Ballistica version 1.5.0 build 20001

This page documents the Python classes and functions in the 'ba' module, - which are the ones most relevant to modding BallisticaCore. If you come across something you feel should be included here or could be better explained, please let me know. Happy modding!

+ which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please let me know. Happy modding!


Table of Contents

Gameplay Classes

diff --git a/tools/efrotools/code.py b/tools/efrotools/code.py index ca5927a4..a747ce5c 100644 --- a/tools/efrotools/code.py +++ b/tools/efrotools/code.py @@ -684,12 +684,12 @@ def _run_idea_inspections_cached(cachepath: Path, flush=True) -def pycharmscripts(projroot: Path, full: bool, verbose: bool) -> None: +def pycharm(projroot: Path, full: bool, verbose: bool) -> None: """Run pycharm inspections on all our scripts.""" import time - cachepath = Path('config/.cache-pycharmscripts') + cachepath = Path('config/.cache-pycharm') filenames = get_script_filenames(projroot) pycharmroot = Path('/Applications/PyCharm CE.app') pycharmbin = Path(pycharmroot, 'Contents/MacOS/pycharm') diff --git a/tools/efrotools/snippets.py b/tools/efrotools/snippets.py index 6c9c10d6..293612c3 100644 --- a/tools/efrotools/snippets.py +++ b/tools/efrotools/snippets.py @@ -155,12 +155,12 @@ def _spelling(words: List[str]) -> None: def spelling_all() -> None: - """Add all misspellings from a pycharmscripts run.""" + """Add all misspellings from a pycharm run.""" - print('Running "make pycharmscriptsfull"...') + print('Running "make pycharmfull"...') lines = [ line for line in subprocess.run( - ['make', 'pycharmscriptsfull'], check=False, + ['make', 'pycharmfull'], check=False, capture_output=True).stdout.decode().splitlines() if 'Typo: In word' in line ] @@ -262,12 +262,12 @@ def mypy() -> None: code.mypy(PROJROOT, full) -def pycharmscripts() -> None: +def pycharm() -> None: """Run PyCharm checks on our scripts.""" from efrotools import code full = '-full' in sys.argv verbose = '-v' in sys.argv - code.pycharmscripts(PROJROOT, full, verbose) + code.pycharm(PROJROOT, full, verbose) def clioncode() -> None: diff --git a/tools/snippets b/tools/snippets index 594d11b0..85dddf4a 100755 --- a/tools/snippets +++ b/tools/snippets @@ -44,8 +44,8 @@ import efrotools from efrotools.snippets import ( # pylint: disable=unused-import PROJROOT, CleanError, snippets_main, formatcode, formatscripts, formatmakefile, cpplint, pylint, mypy, tool_config_install, sync, sync_all, - scriptfiles, pycharmscripts, clioncode, androidstudiocode, - makefile_target_list, spelling, spelling_all, compile_python_files) + scriptfiles, pycharm, clioncode, androidstudiocode, makefile_target_list, + spelling, spelling_all, compile_python_files) if TYPE_CHECKING: from typing import Optional, List, Sequence @@ -643,6 +643,53 @@ def _vstr(nums: Sequence[int]) -> str: return '.'.join(str(i) for i in nums) +def update_docs_md() -> None: + """Updates docs markdown files if necessary.""" + # pylint: disable=too-many-locals + from efrotools import get_files_hash, run + from efrotools.code import get_script_filenames + + check = ('--check' in sys.argv) + + docs_path = 'docs/ba_module.md' + + # Generate a hash from all c/c++ sources under the python subdir + # as well as all python scripts. + pysources = [] + exts = ['.cc', '.c', '.h'] + for root, _dirs, files in os.walk('src/ballistica/python'): + for fname in files: + if any(fname.endswith(ext) for ext in exts): + pysources.append(os.path.join(root, fname)) + pysources += get_script_filenames(Path('.')) + curhash = get_files_hash(pysources) + print('final2', curhash) + + # Extract the current embedded hash. + with open(docs_path) as infile: + lines = infile.readlines() + hashlines = [l for l in lines if '\n' + f'\n') + docs + with open(docs_path, 'w') as outfile: + outfile.write(docs) + print(f'{docs_path} is up to date.') + + def checkenv() -> None: """Check for tools necessary to build and run the app.""" print('Checking environment...', flush=True) diff --git a/tools/update_project b/tools/update_project index 1da434a3..afe1cb22 100755 --- a/tools/update_project +++ b/tools/update_project @@ -112,7 +112,19 @@ class App: self._apply_line_changes() self._apply_file_changes() self._update_compile_commands_file() - self._update_dummy_module() + + # We only check/update these in core; not spinoff projects. + # That is because they create hashes based on source files + # that get filtered for spinoff projects so always trip + # dirty-checks there. If we want to generate these uniquely per + # spinoff project we would need to start running updates + # independently for those projects as opposed to just using + # things as spinoff creates them. + + # (this will get filtered and be unequal in spinoff projects) + if 'ballistica' + 'core' == 'ballisticacore': + self._update_dummy_module() + self._update_docs_md() if self._check: print('Check-Builds: Everything up to date.') @@ -120,8 +132,8 @@ class App: print('Update-Builds: SUCCESS!') def _update_dummy_module(self) -> None: - # Lastly update our dummy _ba module. - # We need to do this very last because it may run the cmake build + # Update our dummy _ba module. + # We need to do this near the end because it may run the cmake build # so its success may depend on the cmake build files having already # been updated. if os.path.exists('tools/gendummymodule.py'): @@ -129,6 +141,19 @@ class App: print(CLRRED + 'Error checking/updating dummy module' + CLREND) sys.exit(255) + def _update_docs_md(self) -> None: + # Update our docs/*.md files. + # We need to do this near the end because it may run the cmake build + # so its success may depend on the cmake build files having already + # been updated. + # (only do this if gendocs is available) + if os.path.exists('tools/gendocs.py'): + if os.system('tools/snippets update_docs_md' + + self._checkarg) != 0: + print(CLRRED + 'Error checking/updating docs markdown.' + + CLREND) + sys.exit(255) + def _update_compile_commands_file(self) -> None: # Update our local compile-commands file based on any changes to # our cmake stuff. Do this at end so cmake changes already happened. @@ -160,7 +185,8 @@ class App: with open(fname, 'w') as outfile: outfile.write(fcode) if unchanged_project_count > 0: - print(f'All {unchanged_project_count} project files up to date.') + print( + f'All {unchanged_project_count} project files are up to date.') def _apply_line_changes(self) -> None: