From fdb5cfa83a9ad56d96ea6771b4e12f226356cd57 Mon Sep 17 00:00:00 2001 From: Eric Froemling Date: Thu, 10 Jun 2021 13:57:26 -0500 Subject: [PATCH] tools consolidation --- .efrocachemap | 16 ++++----- .idea/dictionaries/ericf.xml | 2 ++ .../.idea/dictionaries/ericf.xml | 2 ++ src/meta/Makefile | 4 +-- tools/batools/build.py | 2 +- tools/batools/genchangelog.py | 34 +++++++++++++++++++ tools/batools/{codegen.py => meta.py} | 2 +- tools/batools/pcommand.py | 14 +++++--- tools/batools/updateproject.py | 14 ++++---- tools/pcommand | 2 +- 10 files changed, 69 insertions(+), 23 deletions(-) create mode 100755 tools/batools/genchangelog.py rename tools/batools/{codegen.py => meta.py} (98%) diff --git a/.efrocachemap b/.efrocachemap index 66b74a81..6fdbf248 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -3941,18 +3941,18 @@ "build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/9c/7b/ac1a200be0f37078af0991faca3b", "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/33/63/382b5d03b6859de55c252e1bc53f", "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/5a/90/b6ff7f753011448bd1ef10f98525", - "build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/54/e1/e946d71c83ae5aeb60957c6afba8", + "build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/a1/a6/59d250814162a6277d828c910fb2", "build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/be/2d/6f7814c61e2cdf64196badcc66ff", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/2e/cb/d5bb1384fef2ef9555ce4860b223", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/3d/7f/d4a740b66e707e7ce5777e1e6d05", "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/95/8c/bb66f5c95dfad4d1e065a1c6ec65", - "build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/9a/95/ef4cce689188a298a06fd8b91f8f", + "build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/92/f1/a5e76f90c630e2b0353ab17403e6", "build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/ee/12/6e765384e0bdc251c83f49d8f4be", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/84/6c/ba6569adf15bb4e8dba4f4368e3f", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/ba/e0/65c4d633bcb6b2108ede1b318a10", "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a1/09/37cae1308d189851acc4f4be7e1b", - "build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/36/22/df6c0eb6ea71cd58ce0c6d104c8b", - "build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/e9/c6/cda6cff37de9b551c0945cef06d3", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/e8/61/823ab754444032a53f7d3471a6f1", - "build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/c1/9c/7bbcb97e759e71f8c0839324e8b9", + "build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/6c/cb/5b24a85c69eb42f42a1855bfb45b", + "build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/46/dc/dfbc5d0bace55610f9a5bccd48bc", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/ac/98/e1116b5b7adbed6309b21baf796d", + "build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/3e/21/ce34c716ff3b0c286312fb84a3eb", "build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/17/8a/3e4eec6be82a7d51ec68c2cd9134", "build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/18/27/4063e018845b61a43d3fb975dda9", "build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/94/8e/b57d1b16f9a97ae6b75f6aa64d24", diff --git a/.idea/dictionaries/ericf.xml b/.idea/dictionaries/ericf.xml index d864afea..78b74c8e 100644 --- a/.idea/dictionaries/ericf.xml +++ b/.idea/dictionaries/ericf.xml @@ -337,6 +337,7 @@ chdir cheadersline checkarg + checkarglist checkboxwidget checkchisel checkenv @@ -886,6 +887,7 @@ gameutils gbytecount gearvr + genchangelog gendocs gendummymodule genericpath diff --git a/ballisticacore-cmake/.idea/dictionaries/ericf.xml b/ballisticacore-cmake/.idea/dictionaries/ericf.xml index 8a09826a..8f3bef90 100644 --- a/ballisticacore-cmake/.idea/dictionaries/ericf.xml +++ b/ballisticacore-cmake/.idea/dictionaries/ericf.xml @@ -166,6 +166,7 @@ charstr chatmessage chdir + checkarglist checkboxwidget checkchisel childanntype @@ -399,6 +400,7 @@ gbus gcc's gearvr + genchangelog getactivity getattro getattrofunc diff --git a/src/meta/Makefile b/src/meta/Makefile index 34b6c3cf..4c30164a 100644 --- a/src/meta/Makefile +++ b/src/meta/Makefile @@ -10,9 +10,9 @@ cpp_sources: ../ballistica/generated/python_embedded/binding.inc \ clean: @rm -rf ../ballistica/generated -../ballistica/generated/python_embedded/bootstrap.inc : bameta/python_embedded/bootstrap.py ../../tools/batools/codegen.py +../ballistica/generated/python_embedded/bootstrap.inc : bameta/python_embedded/bootstrap.py ../../tools/batools/meta.py @../../tools/pcommand gen_flat_data_code $< $@ bootstrap_code -../ballistica/generated/python_embedded/binding.inc : bameta/python_embedded/binding.py ../../tools/batools/codegen.py +../ballistica/generated/python_embedded/binding.inc : bameta/python_embedded/binding.py ../../tools/batools/meta.py @../../tools/pcommand gen_binding_code $< $@ diff --git a/tools/batools/build.py b/tools/batools/build.py index 93fe768e..e1d90ef6 100644 --- a/tools/batools/build.py +++ b/tools/batools/build.py @@ -175,7 +175,7 @@ def lazybuild(target: str, category: SourceCategory, command: str) -> None: # Everything possibly affecting meta builds. if category is SourceCategory.META: paths = [ - 'Makefile', 'tools/generate_code', 'tools/batools/codegen.py', + 'Makefile', 'tools/generate_code', 'tools/batools/meta.py', 'src/meta' ] diff --git a/tools/batools/genchangelog.py b/tools/batools/genchangelog.py new file mode 100755 index 00000000..a361885c --- /dev/null +++ b/tools/batools/genchangelog.py @@ -0,0 +1,34 @@ +# Released under the MIT License. See LICENSE for details. +# +"""Generates a pretty html changelog from our markdown.""" + +import os +import subprocess + + +def generate(projroot: str) -> None: + """Main script entry point.""" + + # Make sure we start from root dir (one above this script). + os.chdir(projroot) + + out_path = 'build/changelog.html' + out_path_tmp = out_path + '.md' + + # Do some filtering of our raw changelog. + with open('CHANGELOG.md') as infile: + lines = infile.read().splitlines() + + # Strip out anything marked internal. + lines = [ + line for line in lines if not line.strip().startswith('- (internal)') + ] + + with open(out_path_tmp, 'w') as outfile: + outfile.write('\n'.join(lines)) + + subprocess.run(f'pandoc -f markdown {out_path_tmp} > {out_path}', + shell=True, + check=True) + print(f'Generated changelog at \'{out_path}\'.') + os.unlink(out_path_tmp) diff --git a/tools/batools/codegen.py b/tools/batools/meta.py similarity index 98% rename from tools/batools/codegen.py rename to tools/batools/meta.py index 72a50bc8..1a77ddca 100644 --- a/tools/batools/codegen.py +++ b/tools/batools/meta.py @@ -1,6 +1,6 @@ # Released under the MIT License. See LICENSE for details. # -"""Functionality related to code generation.""" +"""Functionality used in meta-builds (dynamically generated sources).""" from __future__ import annotations import os diff --git a/tools/batools/pcommand.py b/tools/batools/pcommand.py index d43cb624..cf276136 100644 --- a/tools/batools/pcommand.py +++ b/tools/batools/pcommand.py @@ -804,24 +804,24 @@ def cmake_prep_dir() -> None: def gen_binding_code() -> None: """Generate binding.inc file.""" from efro.error import CleanError - import batools.codegen + import batools.meta if len(sys.argv) != 4: raise CleanError('Expected 2 args (srcfile, dstfile)') inpath = sys.argv[2] outpath = sys.argv[3] - batools.codegen.gen_binding_code(str(PROJROOT), inpath, outpath) + batools.meta.gen_binding_code(str(PROJROOT), inpath, outpath) def gen_flat_data_code() -> None: """Generate a C++ include file from a Python file.""" from efro.error import CleanError - import batools.codegen + import batools.meta if len(sys.argv) != 5: raise CleanError('Expected 3 args (srcfile, dstfile, varname)') inpath = sys.argv[2] outpath = sys.argv[3] varname = sys.argv[4] - batools.codegen.gen_flat_data_code(str(PROJROOT), inpath, outpath, varname) + batools.meta.gen_flat_data_code(str(PROJROOT), inpath, outpath, varname) def win_ci_binary_build() -> None: @@ -849,3 +849,9 @@ def win_ci_binary_build() -> None: check=True, ) print('so far so good 4', flush=True) + + +def genchangelog() -> None: + """Gen a pretty html changelog.""" + from batools.genchangelog import generate + generate(projroot=str(PROJROOT)) diff --git a/tools/batools/updateproject.py b/tools/batools/updateproject.py index 40521c96..57e06309 100755 --- a/tools/batools/updateproject.py +++ b/tools/batools/updateproject.py @@ -53,6 +53,7 @@ class Updater: self._check = check self._fix = fix self._checkarg = ' --check' if self._check else '' + self._checkarglist: List[str] = ['--check'] if self._check else [] # We behave differently in the public repo self._public = getconfig(Path('.'))['public'] @@ -79,8 +80,8 @@ class Updater: # NOTE: Do py-enums before updating asset deps since it *is* an asset. self._update_python_enums_module() - self._update_resources_makefile() self._update_meta_makefile() + self._update_resources_makefile() self._update_assets_makefile() self._check_makefiles() @@ -176,11 +177,12 @@ class Updater: # been updated. # (only do this if gendocs is available) if os.path.exists('tools/gendocs.py'): - if os.system('tools/pcommand update_docs_md' + - self._checkarg) != 0: - print(f'{Clr.RED}Error checking/updating' - f' docs markdown.{Clr.RST}') - sys.exit(255) + try: + subprocess.run(['tools/pcommand', 'update_docs_md'] + + self._checkarglist, + check=True) + except Exception as exc: + raise CleanError('Error checking/updating docs') from exc def _update_prereqs(self) -> None: diff --git a/tools/pcommand b/tools/pcommand index 331a7238..3b858c97 100755 --- a/tools/pcommand +++ b/tools/pcommand @@ -39,7 +39,7 @@ from batools.pcommand import ( efro_gradle, stage_assets, update_assets_makefile, update_project, update_cmake_prefab_lib, cmake_prep_dir, gen_binding_code, gen_flat_data_code, wsl_path_to_win, wsl_build_check_win_drive, - win_ci_binary_build) + win_ci_binary_build, genchangelog) # pylint: enable=unused-import if TYPE_CHECKING: