This commit is contained in:
Eric Froemling 2020-05-02 17:45:31 -07:00
parent 2f52ecb54c
commit f6566bae27
3 changed files with 42 additions and 19 deletions

View File

@ -4140,8 +4140,8 @@
"build/prefab/mac-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/e2/ab/b22ebe07c4342beb4dba33d5f7a5", "build/prefab/mac-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/e2/ab/b22ebe07c4342beb4dba33d5f7a5",
"build/prefab/mac/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/80/24/b24a5a26ce61719456479f0c452d", "build/prefab/mac/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/80/24/b24a5a26ce61719456479f0c452d",
"build/prefab/mac/release/ballisticacore": "https://files.ballistica.net/cache/ba1/13/5f/7dff6b239258c1a1151df24eec19", "build/prefab/mac/release/ballisticacore": "https://files.ballistica.net/cache/ba1/13/5f/7dff6b239258c1a1151df24eec19",
"build/prefab/windows-server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/9b/9e/4db687b4f06579dafe4f1f9cf389", "build/prefab/windows-server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/50/8b/8d342ad7bc729c5e536367df1b5e",
"build/prefab/windows-server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/16/16/ac342d48eb3964472eabb6854bd8", "build/prefab/windows-server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/5c/c2/f9f81aa79da92bcc424727c45027",
"build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/c3/5e/42852af8d746f60999139e7069cd", "build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/4f/f9/a2f9a45c36a8355da03fd744f1c1",
"build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/34/d3/a51b67800857a8271d6f1d947f5a" "build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/90/4c/627bead0b20e019539fb906cb772"
} }

View File

@ -26,14 +26,12 @@ be imported into projects' snippets script for easy reuse.
""" """
from __future__ import annotations from __future__ import annotations
import os # Note: import as little as possible here at the module level to keep
# launch times fast for small snippets.
import sys import sys
from pathlib import Path from pathlib import Path
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from efro.error import CleanError
from efro.terminal import Clr
if TYPE_CHECKING: if TYPE_CHECKING:
from typing import Dict, Any, List from typing import Dict, Any, List
@ -48,6 +46,8 @@ def snippets_main(globs: Dict[str, Any]) -> None:
the one corresponding to the first passed arg. the one corresponding to the first passed arg.
""" """
import types import types
from efro.error import CleanError
from efro.terminal import Clr
funcs = dict(((name, obj) for name, obj in globs.items() funcs = dict(((name, obj) for name, obj in globs.items()
if not name.startswith('_') and name != 'snippets_main' if not name.startswith('_') and name != 'snippets_main'
and isinstance(obj, types.FunctionType))) and isinstance(obj, types.FunctionType)))
@ -174,6 +174,7 @@ def check_clean_safety() -> None:
Use to avoid losing work if we accidentally do a clean without Use to avoid losing work if we accidentally do a clean without
adding something. adding something.
""" """
import os
import subprocess import subprocess
if len(sys.argv) != 2: if len(sys.argv) != 2:
raise Exception('invalid arguments') raise Exception('invalid arguments')
@ -357,8 +358,11 @@ def sync_all() -> None:
This assumes that there is a 'sync-full' and 'sync-list' Makefile target This assumes that there is a 'sync-full' and 'sync-list' Makefile target
under each project. under each project.
""" """
import os
import subprocess import subprocess
import concurrent.futures import concurrent.futures
from efro.error import CleanError
from efro.terminal import Clr
print(f'{Clr.SBLU}Updating formatting for all projects...{Clr.RST}') print(f'{Clr.SBLU}Updating formatting for all projects...{Clr.RST}')
projects_str = os.environ.get('EFROTOOLS_SYNC_PROJECTS') projects_str = os.environ.get('EFROTOOLS_SYNC_PROJECTS')
if projects_str is None: if projects_str is None:
@ -427,6 +431,7 @@ def compile_python_files() -> None:
the built-in scripts directly (or go through the asset build system which the built-in scripts directly (or go through the asset build system which
properly recreates the .pyc files). properly recreates the .pyc files).
""" """
import os
import py_compile import py_compile
for arg in sys.argv[2:]: for arg in sys.argv[2:]:
mode = py_compile.PycInvalidationMode.UNCHECKED_HASH mode = py_compile.PycInvalidationMode.UNCHECKED_HASH
@ -439,9 +444,11 @@ def compile_python_files() -> None:
def pytest() -> None: def pytest() -> None:
"""Run pytest with project environment set up properly.""" """Run pytest with project environment set up properly."""
import os
import platform import platform
import subprocess import subprocess
from efrotools import get_config, PYTHON_BIN from efrotools import get_config, PYTHON_BIN
from efro.error import CleanError
# Grab our python paths for the project and stuff them in PYTHONPATH. # Grab our python paths for the project and stuff them in PYTHONPATH.
pypaths = get_config(PROJROOT).get('python_paths') pypaths = get_config(PROJROOT).get('python_paths')
@ -468,6 +475,7 @@ def makefile_target_list() -> None:
Takes a single argument: a path to a Makefile. Takes a single argument: a path to a Makefile.
""" """
from dataclasses import dataclass from dataclasses import dataclass
from efro.terminal import Clr
@dataclass @dataclass
class _Entry: class _Entry:

View File

@ -30,19 +30,18 @@ to functionality contained in efrotools or other standalone tool modules.
""" """
from __future__ import annotations from __future__ import annotations
import os # Note: import as little as possible here at the module level to
# keep launch times fast for small snippets.
import sys import sys
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import efrotools
# Pull in some standard snippets we want to expose. # Pull in some standard snippets we want to expose.
# noinspection PyUnresolvedReferences # noinspection PyUnresolvedReferences
from efrotools.snippets import ( # pylint: disable=unused-import from efrotools.snippets import ( # pylint: disable=unused-import
PROJROOT, CleanError, snippets_main, formatcode, formatscripts, PROJROOT, snippets_main, formatcode, formatscripts, formatmakefile,
formatmakefile, cpplint, pylint, mypy, dmypy, tool_config_install, sync, cpplint, pylint, mypy, dmypy, tool_config_install, sync, sync_all,
sync_all, scriptfiles, pycharm, clioncode, androidstudiocode, scriptfiles, pycharm, clioncode, androidstudiocode, makefile_target_list,
makefile_target_list, spelling, spelling_all, compile_python_files, pytest) spelling, spelling_all, compile_python_files, pytest)
if TYPE_CHECKING: if TYPE_CHECKING:
from typing import Optional from typing import Optional
@ -103,6 +102,8 @@ def resize_image() -> None:
args: xres, yres, src, dst args: xres, yres, src, dst
""" """
import os
import efrotools
if len(sys.argv) != 6: if len(sys.argv) != 6:
raise Exception('expected 5 args') raise Exception('expected 5 args')
width = int(sys.argv[2]) width = int(sys.argv[2])
@ -114,8 +115,7 @@ def resize_image() -> None:
if not src.endswith('.png'): if not src.endswith('.png'):
raise Exception('src must be a png') raise Exception('src must be a png')
print('Creating: ' + os.path.basename(dst), file=sys.stderr) print('Creating: ' + os.path.basename(dst), file=sys.stderr)
efrotools.run('convert "' + src + '" -resize ' + str(width) + 'x' + efrotools.run(f'convert "{src}" -resize {width}x{height} "{dst}"')
str(height) + ' "' + dst + '"')
def check_clean_safety() -> None: def check_clean_safety() -> None:
@ -124,6 +124,7 @@ def check_clean_safety() -> None:
Use to avoid losing work if we accidentally do a clean without Use to avoid losing work if we accidentally do a clean without
adding something. adding something.
""" """
import os
from efrotools.snippets import check_clean_safety as std_snippet from efrotools.snippets import check_clean_safety as std_snippet
# First do standard checks. # First do standard checks.
@ -166,6 +167,7 @@ def androidaddr() -> None:
command line args: archive_dir architecture addr command line args: archive_dir architecture addr
""" """
import batools.android import batools.android
from efro.error import CleanError
if len(sys.argv) != 5: if len(sys.argv) != 5:
raise CleanError(f'ERROR: expected 3 args; got {len(sys.argv) - 2}\n' raise CleanError(f'ERROR: expected 3 args; got {len(sys.argv) - 2}\n'
f'Usage: "tools/snippets android_addr' f'Usage: "tools/snippets android_addr'
@ -188,6 +190,7 @@ def python_build_apple_debug() -> None:
def _python_build_apple(debug: bool) -> None: def _python_build_apple(debug: bool) -> None:
"""Build an embeddable python for macOS/iOS/tvOS.""" """Build an embeddable python for macOS/iOS/tvOS."""
import os
from efrotools import pybuild from efrotools import pybuild
os.chdir(PROJROOT) os.chdir(PROJROOT)
archs = ('mac', 'ios', 'tvos') archs = ('mac', 'ios', 'tvos')
@ -212,6 +215,7 @@ def python_build_android_debug() -> None:
def _python_build_android(debug: bool) -> None: def _python_build_android(debug: bool) -> None:
import os
from efrotools import pybuild from efrotools import pybuild
os.chdir(PROJROOT) os.chdir(PROJROOT)
archs = ('arm', 'arm64', 'x86', 'x86_64') archs = ('arm', 'arm64', 'x86', 'x86_64')
@ -227,6 +231,7 @@ def _python_build_android(debug: bool) -> None:
def python_android_patch() -> None: def python_android_patch() -> None:
"""Patches Python to prep for building for Android.""" """Patches Python to prep for building for Android."""
import os
from efrotools import pybuild from efrotools import pybuild
os.chdir(sys.argv[2]) os.chdir(sys.argv[2])
pybuild.android_patch() pybuild.android_patch()
@ -237,6 +242,7 @@ def python_gather() -> None:
This assumes all embeddable py builds have been run successfully. This assumes all embeddable py builds have been run successfully.
""" """
import os
from efrotools import pybuild from efrotools import pybuild
os.chdir(PROJROOT) os.chdir(PROJROOT)
pybuild.gather() pybuild.gather()
@ -244,7 +250,9 @@ def python_gather() -> None:
def clean_orphaned_assets() -> None: def clean_orphaned_assets() -> None:
"""Remove asset files that are no longer part of the build.""" """Remove asset files that are no longer part of the build."""
import os
import json import json
import efrotools
# Operate from dist root.. # Operate from dist root..
os.chdir(PROJROOT) os.chdir(PROJROOT)
@ -268,7 +276,9 @@ def clean_orphaned_assets() -> None:
def py_examine() -> None: def py_examine() -> None:
"""Run a python examination at a given point in a given file.""" """Run a python examination at a given point in a given file."""
import os
from pathlib import Path from pathlib import Path
import efrotools
if len(sys.argv) != 7: if len(sys.argv) != 7:
print('ERROR: expected 7 args') print('ERROR: expected 7 args')
sys.exit(255) sys.exit(255)
@ -297,12 +307,12 @@ def py_examine() -> None:
def push_ipa() -> None: def push_ipa() -> None:
"""Construct and push ios IPA for testing.""" """Construct and push ios IPA for testing."""
from pathlib import Path from pathlib import Path
from efrotools import ios import efrotools.ios
root = Path(sys.argv[0], '../..').resolve() root = Path(sys.argv[0], '../..').resolve()
if len(sys.argv) != 3: if len(sys.argv) != 3:
raise Exception('expected 1 arg (debug or release)') raise Exception('expected 1 arg (debug or release)')
modename = sys.argv[2] modename = sys.argv[2]
ios.push_ipa(root, modename) efrotools.ios.push_ipa(root, modename)
def fix_mac_ssh() -> None: def fix_mac_ssh() -> None:
@ -383,6 +393,7 @@ def get_modern_make() -> None:
def warm_start_asset_build() -> None: def warm_start_asset_build() -> None:
"""Prep asset builds to run faster.""" """Prep asset builds to run faster."""
import os
import subprocess import subprocess
from pathlib import Path from pathlib import Path
from efrotools import get_config from efrotools import get_config
@ -426,6 +437,7 @@ def install_pip_reqs() -> None:
def checkenv() -> None: def checkenv() -> None:
"""Check for tools necessary to build and run the app.""" """Check for tools necessary to build and run the app."""
import batools.build import batools.build
from efro.error import CleanError
try: try:
batools.build.checkenv() batools.build.checkenv()
except RuntimeError as exc: except RuntimeError as exc:
@ -435,6 +447,7 @@ def checkenv() -> None:
def ensure_prefab_platform() -> None: def ensure_prefab_platform() -> None:
"""Ensure we are running on a particular prefab platform.""" """Ensure we are running on a particular prefab platform."""
import batools.build import batools.build
from efro.error import CleanError
if len(sys.argv) != 3: if len(sys.argv) != 3:
raise CleanError('Expected 1 platform name arg.') raise CleanError('Expected 1 platform name arg.')
needed = sys.argv[2] needed = sys.argv[2]
@ -487,6 +500,7 @@ def lazybuild() -> None:
"""Run a build command only if an input has changed.""" """Run a build command only if an input has changed."""
import subprocess import subprocess
import batools.build import batools.build
from efro.error import CleanError
if len(sys.argv) < 5: if len(sys.argv) < 5:
raise CleanError('Expected at least 3 args') raise CleanError('Expected at least 3 args')
try: try:
@ -504,6 +518,7 @@ def lazybuild() -> None:
def filter_server_config() -> None: def filter_server_config() -> None:
"""Add commented-out config options to a server config.""" """Add commented-out config options to a server config."""
import batools.build import batools.build
from efro.error import CleanError
if len(sys.argv) != 4: if len(sys.argv) != 4:
raise CleanError('Expected 2 args (infile and outfile).') raise CleanError('Expected 2 args (infile and outfile).')
batools.build.filter_server_config(str(PROJROOT), sys.argv[2], sys.argv[3]) batools.build.filter_server_config(str(PROJROOT), sys.argv[2], sys.argv[3])