From 66693c11d1eee743cfb1e4a4eec0ccee904481fd Mon Sep 17 00:00:00 2001 From: Eric Froemling Date: Tue, 15 Oct 2019 10:14:34 -0700 Subject: [PATCH] added general prefab make targets and misc tidying --- Makefile | 91 ++++++++++++++++++++----------------- tools/efrotools/snippets.py | 7 ++- tools/snippets | 29 ++++++++++++ 3 files changed, 84 insertions(+), 43 deletions(-) diff --git a/Makefile b/Makefile index 5f49118e..50bf65b0 100644 --- a/Makefile +++ b/Makefile @@ -28,42 +28,6 @@ # Prefix used for output of docs/changelogs/etc targets for use in webpages. DOCPREFIX = "ballisticacore_" -# Print help by default -all: help - -# Tell make which of these targets don't represent files. -.PHONY: all - - -################################################################################ -# # -# Prefab # -# # -################################################################################ - -# Prebuilt binaries for various platforms. - -prefab-mac: prefab-mac-build - @cd build/prefab/mac/debug && ./ballisticacore - -prefab-mac-build: assets-cmake build/prefab/mac/debug/ballisticacore - @${STAGE_ASSETS} -cmake build/prefab/mac/debug - -build/prefab/mac/debug/ballisticacore: .efrocachemap - @tools/snippets efrocache_get $@ - -prefab-mac-release: prefab-mac-release-build - @cd build/prefab-mac/release && ./ballisticacore - -prefab-mac-release-build: assets-cmake build/prefab/mac/release/ballisticacore - @${STAGE_ASSETS} -cmake build/prefab/mac/release - -build/prefab/mac/release/ballisticacore: .efrocachemap - @tools/snippets efrocache_get $@ - -# Tell make which of these targets don't represent files. -.PHONY: prefab-mac prefab-mac-build prefab-mac-release prefab-mac-release-build - ################################################################################ # # @@ -77,12 +41,9 @@ PREREQS = .dir-locals.el .mypy.ini .pycheckers \ .pylintrc .style.yapf .clang-format \ .projectile .editorconfig -# List the targets in this Makefile and basic descriptions for them. -list: - @tools/snippets makefile_target_list Makefile - -# Same as 'list' +# List targets in this Makefile and basic descriptions for them. help: list + @tools/snippets makefile_target_list Makefile prereqs: ${PREREQS} @@ -151,6 +112,54 @@ cleanlist: clean cleanlist +################################################################################ +# # +# Prefab # +# # +################################################################################ + +# Prebuilt binaries for various platforms. + +# Download/assemble/run a debug build for this platform. +prefab: + @tools/snippets make_prefab debug + +# Download/assemble/run a release build for this platform. +prefab-release: + @tools/snippets make_prefab release + +# Download/assemble a debug build for this platform. +prefab-build: + @tools/snippets make_prefab debug-build + +# Download/assemble a release build for this platform. +prefab-release-build: + @tools/snippets make_prefab release-build + +# Specific platform prefab targets: + +prefab-mac: prefab-mac-build + @cd build/prefab/mac/debug && ./ballisticacore + +prefab-mac-build: assets-cmake build/prefab/mac/debug/ballisticacore + @${STAGE_ASSETS} -cmake build/prefab/mac/debug + +build/prefab/mac/debug/ballisticacore: .efrocachemap + @tools/snippets efrocache_get $@ + +prefab-mac-release: prefab-mac-release-build + @cd build/prefab/mac/release && ./ballisticacore + +prefab-mac-release-build: assets-cmake build/prefab/mac/release/ballisticacore + @${STAGE_ASSETS} -cmake build/prefab/mac/release + +build/prefab/mac/release/ballisticacore: .efrocachemap + @tools/snippets efrocache_get $@ + +# Tell make which of these targets don't represent files. +.PHONY: prefab-mac prefab-mac-build prefab-mac-release prefab-mac-release-build + + ################################################################################ # # # Formatting / Checking # diff --git a/tools/efrotools/snippets.py b/tools/efrotools/snippets.py index 05c6e7d1..47ba9f7a 100644 --- a/tools/efrotools/snippets.py +++ b/tools/efrotools/snippets.py @@ -421,7 +421,7 @@ def makefile_target_list() -> None: print('--------------------------\n' 'Available Makefile Targets\n' - '--------------------------\n') + '--------------------------') entries: List[_Entry] = [] for i, line in enumerate(lines): @@ -438,8 +438,11 @@ def makefile_target_list() -> None: entries.append( _Entry(kind='section', line=i, title=line[1:-2].strip())) - for entry in entries: + for i, entry in enumerate(entries): if entry.kind == 'section': + # Don't print headers for empty sections. + if i + 1 >= len(entries) or entries[i + 1].kind == 'section': + continue print('\n' + entry.title + '\n' + '-' * len(entry.title)) elif entry.kind == 'target': print(CLRHDR + entry.title + CLRBLU + _docstr(lines, entry.line) + diff --git a/tools/snippets b/tools/snippets index eaa11385..2caa18e4 100755 --- a/tools/snippets +++ b/tools/snippets @@ -649,5 +649,34 @@ def warm_start_asset_build() -> None: check=True) +def make_prefab() -> None: + """Run prefab builds for the current platform.""" + from efrotools import run + import platform + + if platform.system() == 'Darwin': + base = 'mac' + else: + raise RuntimeError('Prefab not supported on this platform.') + + if len(sys.argv) != 3: + raise RuntimeError('Expected one argument') + + arg = sys.argv[2] + + if arg == 'debug': + target = f'prefab-{base}' + elif arg == 'debug-build': + target = f'prefab-{base}-build' + elif arg == 'release': + target = f'prefab-{base}-release' + elif arg == 'release-build': + target = f'prefab-{base}-release-build' + else: + raise RuntimeError(f'Invalid target: {arg}') + + run(f'make {target}') + + if __name__ == '__main__': snippets_main(globals())