diff --git a/.efrocachemap b/.efrocachemap index 050744ca..616fc944 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -3933,26 +3933,26 @@ "assets/build/windows/Win32/vc_redist.x86.exe": "https://files.ballistica.net/cache/ba1/1c/e1/4a1a2eddda2f4aebd5f8b64ab08e", "assets/build/windows/Win32/vcruntime140d.dll": "https://files.ballistica.net/cache/ba1/50/8d/bc2600ac9491f1b14d659709451f", "ballisticacore-windows/Generic/BallisticaCore.ico": "https://files.ballistica.net/cache/ba1/89/c0/e32c7d2a35dc9aef57cc73b0911a", - "build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/e8/15/872df30172235c867eda63d89589", + "build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/b0/49/0d242e1c81141be0ee561a184d88", "build/prefab/full/linux_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/74/1d/fc9e33e565475daaac80da5252f0", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/78/4f/3c6279192f18688bd84bb6a4411b", - "build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/72/09/88243a2824d7367ad0828fba84b6", - "build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/62/f6/aa4a3dc1fca82b269d86b481bcb1", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/dc/87/b9f0c806997f9a7a2ca1ef951fa1", + "build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/55/84/9518f657254defb0ef73c851398d", + "build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/df/69/682d4c7c7e84d061b98994bc99b9", "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/4b/64/b2ddd98e877794b3a47942a0dde5", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/bf/3d/ddca25182c6a76cf299b3e93eb3c", - "build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/5f/81/fb4afce0d09fe9f645b768824fd1", - "build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/97/ee/ac6204b2ffab83307b1c290ae415", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/73/30/c7eaf5ad343369861bf6a9eb013d", - "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/f8/b4/8a2165fad347af56ba3ec1bf7245", - "build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/97/a1/37ed4f3db4efd65b2b65cf7767b1", - "build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/af/d7/ea785c5a3cb974311c071b1e4570", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/d9/8d/d65fcf33eb6d33cf5201bd832c11", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/99/3c/8be98acc89f793f458aa61e050c2", - "build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/3f/9f/2f4750d796e57a19de0ffd9a6b02", - "build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/02/01/97181feb54a1788002020de362a2", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/e3/03/85e4eae1bb8231864e1e46554913", - "build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/60/79/2e0070b506a3d9e9370d735c79b4", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/cd/dc/37d0300f47f401c15d132e294f2e", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/7b/5e/da03ccf4a7ebab8c46b95b469367", + "build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/ea/17/500370ba461c0f7227b76cde2204", + "build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/66/bd/2e3b4d3e269b9e3e65e9300232b7", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/21/c6/1e10d70c2568b56913890568537a", + "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/96/a1/d839bc70d0f55d4004836a7e176e", + "build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/f8/51/b7c3284e399104333e92df77e4a7", + "build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/8d/3c/6ccc8358ee11f2db98759b23cb46", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/fe/36/8c17984b5b81d1dd8b20d7137e15", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/6d/62/68ccb9541b572031affc826cc7ce", + "build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/7f/1d/8183153d8a03b7176dbc406ce067", + "build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/d0/b4/eb830b468a4ce0bce93f12d54cab", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/fd/da/292850ec6a6a5281d56065b4de0c", + "build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/2f/b7/22991b860126043b5fdf95ebfe35", "build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/f0/d3/e88910c0724d5d5828598a55b3ac", "build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/72/71/edc3f08a87cc22c1bf069f9b40a2", "build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/a3/a8/c243af3492cfd3dd85a8c48e539b", diff --git a/.idea/dictionaries/ericf.xml b/.idea/dictionaries/ericf.xml index e050c0db..0879715a 100644 --- a/.idea/dictionaries/ericf.xml +++ b/.idea/dictionaries/ericf.xml @@ -553,6 +553,7 @@ dline dlldir dlls + dmake dmitry dmodule dmypy @@ -754,6 +755,7 @@ fileinfo fileinput filelist + filelock filenames filepath fileselector @@ -1292,6 +1294,8 @@ makebob makedeps makedirs + makeflags + makelevel makesetup malformatted malhotra @@ -1352,6 +1356,7 @@ mios mipmap mipmaps + mkflags mline mmapmodule mmult @@ -1599,7 +1604,9 @@ pickletools pickupmats pipestatus + piplist pipname + pipvers pkey pkgutil playercast @@ -1751,6 +1758,8 @@ putfiles pval pvars + pver + pverraw pvrtc pvrtcbest pvrtcfast diff --git a/Makefile b/Makefile index 885f06ee..61da1026 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,17 @@ # Targets in this top level Makefile do not expect -jX to be passed to them # and generally handle spawning an appropriate number of child jobs themselves. +# Can be used in place of the recommended $(MAKE) to suppress various +# warnings about the jobserver being disabled due to -jX options being +# passed to sub-makes. Generally passing -jX as part of a recursive make +# instantiation is frowned upon, but we treat this Makefile as a high level +# orchestration layer and we want to handle details like that for the user, +# so we try to pick smart -j values ourselves. We can't really rely on the +# jobserver anyway to balance our loads since we often call out to other +# systems (XCode, Gradle, Visual Studio, etc.) which wrangle jobs in their +# own ways. +DMAKE = $(MAKE) MAKEFLAGS= MKFLAGS= MAKELEVEL= + # Prefix used for output of docs/changelogs/etc. targets for use in webpages. DOCPREFIX = "ballisticacore_" @@ -40,61 +51,61 @@ prereqs-clean: # Build all assets for all platforms. assets: prereqs - cd assets && make -j${CPUS} + cd assets && $(MAKE) -j$(CPUS) # Build assets required for cmake builds (linux, mac) assets-cmake: prereqs - cd assets && ${MAKE} -j${CPUS} cmake + cd assets && $(MAKE) -j$(CPUS) cmake # Build assets required for WINDOWS_PLATFORM windows builds. assets-windows: prereqs - cd assets && ${MAKE} -j${CPUS} win-${WINDOWS_PLATFORM} + cd assets && $(MAKE) -j$(CPUS) win-${WINDOWS_PLATFORM} # Build assets required for Win32 windows builds. assets-windows-Win32: prereqs - cd assets && ${MAKE} -j${CPUS} win-Win32 + cd assets && $(MAKE) -j$(CPUS) win-Win32 # Build assets required for x64 windows builds. assets-windows-x64: prereqs - cd assets && ${MAKE} -j${CPUS} win-x64 + cd assets && $(MAKE) -j$(CPUS) win-x64 # Build assets required for mac xcode builds assets-mac: prereqs - cd assets && ${MAKE} -j${CPUS} mac + cd assets && $(MAKE) -j$(CPUS) mac # Build assets required for ios. assets-ios: prereqs - cd assets && ${MAKE} -j${CPUS} ios + cd assets && $(MAKE) -j$(CPUS) ios # Build assets required for android. assets-android: prereqs - cd assets && ${MAKE} -j${CPUS} android + cd assets && $(MAKE) -j$(CPUS) android # Clean all assets. assets-clean: - cd assets && ${MAKE} clean + cd assets && $(MAKE) clean # Build resources. resources: prereqs tools/pcommand lazybuild resources_src ${LAZYBUILDDIR}/resources \ - cd resources \&\& ${MAKE} -j${CPUS} resources + cd resources \&\& $(MAKE) -j$(CPUS) resources # Clean resources. resources-clean: - cd resources && ${MAKE} clean + cd resources && $(MAKE) clean rm -f ${LAZYBUILDDIR}/resources -# Build our generated code. +# Build our generated sources. # TODO: should perhaps make this a more standard component, including it # in other standard targets such as checks and tests (at least once we're # generating things that can affect the outcome of said checks/tests). code: prereqs tools/pcommand lazybuild code_gen_src ${LAZYBUILDDIR}/code \ - cd src/generated_src \&\& ${MAKE} -j${CPUS} generated_code + cd src/generated_src \&\& $(MAKE) -j$(CPUS) generated_code -# Clean our generated code. +# Clean our generated sources. code-clean: - cd src/generated_src && ${MAKE} clean + cd src/generated_src && $(MAKE) clean rm -f ${LAZYBUILDDIR}/code # Remove ALL files and directories that aren't managed by git @@ -562,12 +573,12 @@ update-check: prereqs # Run formatting on all files in the project considered 'dirty'. format: - @${MAKE} -j3 format-code format-scripts format-makefile + @$(MAKE) -j$(CPUS) format-code format-scripts format-makefile @tools/pcommand echo BLD Formatting complete! # Same but always formats; ignores dirty state. format-full: - @${MAKE} -j3 format-code-full format-scripts-full format-makefile + @$(MAKE) -j$(CPUS) format-code-full format-scripts-full format-makefile @tools/pcommand echo BLD Formatting complete! # Run formatting for compiled code sources (.cc, .h, etc.). @@ -601,23 +612,24 @@ format-makefile: prereqs ################################################################################ # Run all project checks. (static analysis) -check: update-check - @${MAKE} -j3 cpplint pylint mypy +check: + @${DMAKE} -j$(CPUS) update-check cpplint pylint mypy @tools/pcommand echo SGRN BLD ALL CHECKS PASSED! # Same as check but no caching (all files are checked). -check-full: update-check - @${MAKE} -j3 cpplint-full pylint-full mypy-full +check-full: + @${DMAKE} -j$(CPUS) update-check cpplint-full pylint-full mypy-full @tools/pcommand echo SGRN BLD ALL CHECKS PASSED! # Same as 'check' plus optional/slow extra checks. -check2: update-check - @${MAKE} -j4 cpplint pylint mypy pycharm +check2: + @${DMAKE} -j$(CPUS) update-check cpplint pylint mypy pycharm @tools/pcommand echo SGRN BLD ALL CHECKS PASSED! # Same as check2 but no caching (all files are checked). -check2-full: update-check - @${MAKE} -j4 cpplint-full pylint-full mypy-full pycharm-full +check2-full: + @${DMAKE} -j$(CPUS) update-check cpplint-full pylint-full mypy-full \ + pycharm-full @tools/pcommand echo SGRN BLD ALL CHECKS PASSED! # Run Cpplint checks on all C/C++ code. @@ -707,30 +719,30 @@ test-entity: # Format, update, check, & test the project. Do this before commits. preflight: - @${MAKE} format - @${MAKE} update - @${MAKE} -j4 cpplint pylint mypy test + @$(MAKE) format + @$(MAKE) update + @$(MAKE) -j$(CPUS) cpplint pylint mypy test @tools/pcommand echo SGRN BLD PREFLIGHT SUCCESSFUL! # Same as 'preflight' without caching (all files are visited). preflight-full: - @${MAKE} format-full - @${MAKE} update - @${MAKE} -j4 cpplint-full pylint-full mypy-full test-full + @$(MAKE) format-full + @$(MAKE) update + @$(MAKE) -j$(CPUS) cpplint-full pylint-full mypy-full test-full @tools/pcommand echo SGRN BLD PREFLIGHT SUCCESSFUL! # Same as 'preflight' plus optional/slow extra checks. preflight2: - @${MAKE} format - @${MAKE} update - @${MAKE} -j5 cpplint pylint mypy pycharm test + @$(MAKE) format + @$(MAKE) update + @$(MAKE) -j$(CPUS) cpplint pylint mypy pycharm test @tools/pcommand echo SGRN BLD PREFLIGHT SUCCESSFUL! # Same as 'preflight2' but without caching (all files visited). preflight2-full: - @${MAKE} format-full - @${MAKE} update - @${MAKE} -j5 cpplint-full pylint-full mypy-full pycharm-full test-full + @$(MAKE) format-full + @$(MAKE) update + @$(MAKE) -j$(CPUS) cpplint-full pylint-full mypy-full pycharm-full test-full @tools/pcommand echo SGRN BLD PREFLIGHT SUCCESSFUL! # Tell make which of these targets don't represent files. @@ -778,7 +790,7 @@ windows-debug-build: \ @tools/pcommand wsl_build_check_win_drive WINDOWS_CONFIGURATION=Debug WINDOWS_PLATFORM=Win32 $(MAKE) windows-staging WINDOWS_PROJECT=Generic WINDOWS_CONFIGURATION=Debug WINDOWS_PLATFORM=Win32 \ - ${MAKE} _windows-wsl-build + $(MAKE) _windows-wsl-build # Rebuild a debug windows build (from WSL). windows-debug-rebuild: \ @@ -789,7 +801,7 @@ windows-debug-rebuild: \ @tools/pcommand wsl_build_check_win_drive WINDOWS_CONFIGURATION=Debug WINDOWS_PLATFORM=Win32 $(MAKE) windows-staging WINDOWS_PROJECT=Generic WINDOWS_CONFIGURATION=Debug WINDOWS_PLATFORM=Win32 \ - ${MAKE} _windows-wsl-rebuild + $(MAKE) _windows-wsl-rebuild # Build a release windows build (from WSL). windows-release-build: \ @@ -800,7 +812,7 @@ windows-release-build: \ @tools/pcommand wsl_build_check_win_drive WINDOWS_CONFIGURATION=Release WINDOWS_PLATFORM=Win32 $(MAKE) windows-staging WINDOWS_PROJECT=Generic WINDOWS_CONFIGURATION=Release WINDOWS_PLATFORM=Win32 \ - ${MAKE} _windows-wsl-build + $(MAKE) _windows-wsl-build # Rebuild a release windows build (from WSL). windows-release-rebuild: \ @@ -811,7 +823,7 @@ windows-release-rebuild: \ @tools/pcommand wsl_build_check_win_drive WINDOWS_CONFIGURATION=Release WINDOWS_PLATFORM=Win32 $(MAKE) windows-staging WINDOWS_PROJECT=Generic WINDOWS_CONFIGURATION=Release WINDOWS_PLATFORM=Win32 \ - ${MAKE} _windows-wsl-rebuild + $(MAKE) _windows-wsl-rebuild ballisticacore-windows/Generic/BallisticaCore.ico: .efrocachemap @tools/pcommand efrocache_get $@ @@ -852,7 +864,7 @@ cmake-build: assets-cmake resources code @cd build/cmake/$(CM_BT_LC) && test -f Makefile \ || cmake -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) \ ${PWD}/ballisticacore-cmake - @cd build/cmake/$(CM_BT_LC) && ${MAKE} -j${CPUS} + @cd build/cmake/$(CM_BT_LC) && $(MAKE) -j$(CPUS) cmake-clean: rm -rf build/cmake/$(CM_BT_LC) @@ -867,7 +879,7 @@ cmake-server-build: assets-cmake resources code @cd build/cmake/server-$(CM_BT_LC)/dist && test -f Makefile \ || cmake -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) -DHEADLESS=true \ ${PWD}/ballisticacore-cmake - @cd build/cmake/server-$(CM_BT_LC)/dist && ${MAKE} -j${CPUS} + @cd build/cmake/server-$(CM_BT_LC)/dist && $(MAKE) -j$(CPUS) @cd build/cmake/server-$(CM_BT_LC)/dist && test -f ballisticacore_headless \ || ln -sf ballisticacore ballisticacore_headless @@ -963,14 +975,14 @@ ballisticacore-cmake/.clang-format: .clang-format # Simple target for CI to build a binary but not download/assemble assets/etc. _cmake-simple-ci-server-build: - SKIP_ENV_CHECKS=1 ${MAKE} code + SKIP_ENV_CHECKS=1 $(MAKE) code rm -rf build/cmake_simple_ci_server_build mkdir -p build/cmake_simple_ci_server_build tools/pcommand update_cmake_prefab_lib \ server debug build/cmake_simple_ci_server_build cd build/cmake_simple_ci_server_build && \ cmake -DCMAKE_BUILD_TYPE=Debug -DHEADLESS=true ${PWD}/ballisticacore-cmake - cd build/cmake_simple_ci_server_build && ${MAKE} -j${CPUS} + cd build/cmake_simple_ci_server_build && $(MAKE) -j$(CPUS) # Irony in emacs requires us to use cmake to generate a full # list of compile commands for all files; lets try to keep it up to date diff --git a/assets/src/ba_data/python/_ba.py b/assets/src/ba_data/python/_ba.py index 01776ff3..1d4a6e84 100644 --- a/assets/src/ba_data/python/_ba.py +++ b/assets/src/ba_data/python/_ba.py @@ -3610,7 +3610,7 @@ def set_replay_speed_exponent(speed: int) -> None: (internal) - Set replay speed. Actual displayed speed is pow(2,speed). + Set replay speed. Actual displayed speed is pow(2, speed). """ return None diff --git a/ballisticacore-cmake/.idea/dictionaries/ericf.xml b/ballisticacore-cmake/.idea/dictionaries/ericf.xml index 7db0fc8c..c3d98232 100644 --- a/ballisticacore-cmake/.idea/dictionaries/ericf.xml +++ b/ballisticacore-cmake/.idea/dictionaries/ericf.xml @@ -259,6 +259,7 @@ dlfcn dlife dllpath + dmake dname dncm dobell @@ -347,6 +348,7 @@ fieldname fieldpath fifteenbits + filelock filterstr filterval finishedptr @@ -578,6 +580,8 @@ magoogan magua mainmenu + makeflags + makelevel malhotra mallocs manualtab @@ -602,6 +606,7 @@ minsdl mipmapcount mipmaps + mkflags mmask mmdevapi modder @@ -729,6 +734,8 @@ pflag pflags pgmout + piplist + pipvers pixelformat playpause playsound @@ -780,6 +787,8 @@ putbits putbitshigh pval + pver + pverraw pvrtc pycommand pyconfig diff --git a/config/toolconfigsrc/mypy.ini b/config/toolconfigsrc/mypy.ini index 61e23421..37649b56 100644 --- a/config/toolconfigsrc/mypy.ini +++ b/config/toolconfigsrc/mypy.ini @@ -21,9 +21,6 @@ no_implicit_reexport = False [mypy-pylint.*] ignore_missing_imports = True -[mypy-cpplint.*] -ignore_missing_imports = True - [mypy-ansiwrap.*] ignore_missing_imports = True diff --git a/docs/ba_module.md b/docs/ba_module.md index 908eb8c1..57324f4a 100644 --- a/docs/ba_module.md +++ b/docs/ba_module.md @@ -1,5 +1,5 @@ -

last updated on 2021-05-30 for Ballistica version 1.6.4 build 20369

+

last updated on 2021-06-09 for Ballistica version 1.6.4 build 20374

This page documents the Python classes and functions in the 'ba' module, 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!


diff --git a/src/ballistica/ballistica.cc b/src/ballistica/ballistica.cc index 60f68ed1..ab0424e4 100644 --- a/src/ballistica/ballistica.cc +++ b/src/ballistica/ballistica.cc @@ -21,7 +21,7 @@ namespace ballistica { // These are set automatically via script; don't modify them here. -const int kAppBuildNumber = 20374; +const int kAppBuildNumber = 20375; const char* kAppVersion = "1.6.4"; // Our standalone globals. diff --git a/src/ballistica/python/methods/python_methods_gameplay.cc b/src/ballistica/python/methods/python_methods_gameplay.cc index f0a008bc..d4d8825e 100644 --- a/src/ballistica/python/methods/python_methods_gameplay.cc +++ b/src/ballistica/python/methods/python_methods_gameplay.cc @@ -625,7 +625,7 @@ auto PythonMethodsGameplay::GetMethods() -> std::vector { "\n" "(internal)\n" "\n" - "Set replay speed. Actual displayed speed is pow(2,speed)."}, + "Set replay speed. Actual displayed speed is pow(2, speed)."}, {"get_replay_speed_exponent", PyGetReplaySpeedExponent, METH_VARARGS, "get_replay_speed_exponent() -> int\n" diff --git a/tools/batools/build.py b/tools/batools/build.py index a16e3567..c28f13e5 100644 --- a/tools/batools/build.py +++ b/tools/batools/build.py @@ -23,22 +23,28 @@ if TYPE_CHECKING: @dataclass class PipRequirement: """A pip package required by our project.""" - modulename: str + modulename: Optional[str] = None minversion: Optional[List[int]] = None # None implies no min version. pipname: Optional[str] = None # None implies same as modulename. +# Note: we look directly for modules when possible instead of just pip +# entries; this accounts for manual installations or other nonstandard setups. PIP_REQUIREMENTS = [ PipRequirement(modulename='pylint', minversion=[2, 8, 2]), - PipRequirement(modulename='mypy', minversion=[0, 812]), + PipRequirement(modulename='mypy', minversion=[0, 901]), PipRequirement(modulename='yapf', minversion=[0, 31, 0]), PipRequirement(modulename='cpplint', minversion=[1, 5, 5]), PipRequirement(modulename='pytest', minversion=[6, 2, 4]), - PipRequirement(modulename='typing_extensions'), PipRequirement(modulename='pytz'), PipRequirement(modulename='ansiwrap'), PipRequirement(modulename='yaml', pipname='PyYAML'), PipRequirement(modulename='requests'), + PipRequirement(pipname='typing-extensions', minversion=[3, 10, 0, 0]), + PipRequirement(pipname='types-filelock', minversion=[0, 1, 3]), + PipRequirement(pipname='types-requests', minversion=[0, 1, 9]), + PipRequirement(pipname='types-pytz', minversion=[0, 1, 0]), + PipRequirement(pipname='types-PyYAML', minversion=[0, 1, 6]), ] # Parts of full-tests suite we only run on particular days. @@ -507,6 +513,7 @@ def _vstr(nums: Sequence[int]) -> str: def checkenv() -> None: """Check for tools necessary to build and run the app.""" # pylint: disable=too-many-branches + # pylint: disable=too-many-statements from efrotools import PYTHON_BIN print(f'{Clr.BLD}Checking environment...{Clr.RST}', flush=True) @@ -537,56 +544,92 @@ def checkenv() -> None: 'it via apt, brew, etc.') # Make sure they've got pip for that python version. - if subprocess.run(f'{PYTHON_BIN} -m pip --version', - shell=True, + if subprocess.run([PYTHON_BIN, '-m', 'pip', '--version'], check=False, capture_output=True).returncode != 0: raise CleanError( f'pip (for {PYTHON_BIN}) is required; please install it.') + # Parse package names and versions from pip. + piplist = subprocess.run( + [PYTHON_BIN, '-m', 'pip', 'list'], check=True, + capture_output=True).stdout.decode().strip().splitlines() + assert 'Package' in piplist[0] and 'Version' in piplist[0] + assert '--------' in piplist[1] + piplist = piplist[2:] + pipvers: Dict[str, List[int]] = {} + for line in piplist: + pname, pverraw = line.split() + pver = [int(x) if x.isdigit() else 0 for x in pverraw.split('.')] + pipvers[pname] = pver + # Check for some required python modules. # FIXME: since all of these come from pip now, we should just use # pip --list to check versions on everything instead of doing it ad-hoc. for req in PIP_REQUIREMENTS: modname = req.modulename minver = req.minversion - packagename = req.pipname - if packagename is None: - packagename = modname - if minver is not None: - results = subprocess.run(f'{PYTHON_BIN} -m {modname} --version', - shell=True, - check=False, - capture_output=True) - else: - results = subprocess.run(f'{PYTHON_BIN} -c "import {modname}"', - shell=True, - check=False, - capture_output=True) - if results.returncode != 0: - raise CleanError(f'{packagename} (for {PYTHON_BIN}) is required.\n' - f'To install it, try: "{PYTHON_BIN}' - f' -m pip install {packagename}"\n' - f'Alternately, "tools/pcommand install_pip_reqs"' - f' will update all pip requirements.') - if minver is not None: - # Note: some modules such as pytest print their version to stderr, - # so grab both. - verlines = (results.stdout + results.stderr).decode().splitlines() - if verlines[0].startswith('Cpplint fork'): - verlines = verlines[1:] - ver_line = verlines[0] - assert modname in ver_line - vnums = [int(x) for x in ver_line.split()[-1].split('.')] - assert len(vnums) == len(minver) - if vnums < minver: + pipname = req.pipname + if modname is None: + assert pipname is not None + if pipname not in pipvers: raise CleanError( - f'{packagename} ver. {_vstr(minver)} or newer is required;' - f' found {_vstr(vnums)}.\n' - f'To upgrade it, try: "{PYTHON_BIN}' - f' -m pip install --upgrade {packagename}".\n' - 'Alternately, "tools/pcommand install_pip_reqs"' - ' will update all pip requirements.') + f'{pipname} (for {PYTHON_BIN}) is required.\n' + f'To install it, try: "{PYTHON_BIN}' + f' -m pip install {pipname}"\n' + f'Alternately, "tools/pcommand install_pip_reqs"' + f' will update all pip requirements.') + if minver is not None: + vnums = pipvers[pipname] + assert len(vnums) == len(minver) + if vnums < minver: + raise CleanError( + f'{pipname} ver. {_vstr(minver)} or newer' + f' is required; found {_vstr(vnums)}.\n' + f'To upgrade it, try: "{PYTHON_BIN}' + f' -m pip install --upgrade {pipname}".\n' + 'Alternately, "tools/pcommand install_pip_reqs"' + ' will update all pip requirements.') + else: + if pipname is None: + pipname = modname + if minver is not None: + results = subprocess.run( + f'{PYTHON_BIN} -m {modname} --version', + shell=True, + check=False, + capture_output=True) + else: + results = subprocess.run(f'{PYTHON_BIN} -c "import {modname}"', + shell=True, + check=False, + capture_output=True) + if results.returncode != 0: + raise CleanError( + f'{pipname} (for {PYTHON_BIN}) is required.\n' + f'To install it, try: "{PYTHON_BIN}' + f' -m pip install {pipname}"\n' + f'Alternately, "tools/pcommand install_pip_reqs"' + f' will update all pip requirements.') + if minver is not None: + # Note: some modules such as pytest print + # their version to stderr, so grab both. + verlines = (results.stdout + + results.stderr).decode().splitlines() + if verlines[0].startswith('Cpplint fork'): + verlines = verlines[1:] + ver_line = verlines[0] + assert modname in ver_line + vnums = [int(x) for x in ver_line.split()[-1].split('.')] + assert len(vnums) == len(minver) + if vnums < minver: + raise CleanError( + f'{pipname} ver. {_vstr(minver)} or newer' + f' is required; found {_vstr(vnums)}.\n' + f'To upgrade it, try: "{PYTHON_BIN}' + f' -m pip install --upgrade {pipname}".\n' + 'Alternately, "tools/pcommand install_pip_reqs"' + ' will update all pip requirements.') print(f'{Clr.BLD}Environment ok.{Clr.RST}', flush=True) diff --git a/tools/batools/updateproject.py b/tools/batools/updateproject.py index 6f18f1a0..388ac21b 100755 --- a/tools/batools/updateproject.py +++ b/tools/batools/updateproject.py @@ -77,7 +77,7 @@ class Updater: if not os.path.isdir('config') or not os.path.isdir('tools'): raise Exception('This must be run from a project root.') - # NOTE: Do py-enums before updating asset deps since it is an asset. + # NOTE: Do py-enums before updating asset deps since it *is* an asset. self._update_python_enums_module() self._update_resources_makefile() self._update_generated_code_makefile() @@ -101,7 +101,10 @@ class Updater: # by the above stuff. self._apply_line_changes() self._apply_file_changes() - self._update_compile_commands_file() + + # This keeps our compile-commands list up to date with any + # source files we just added or removed. + self._update_prereqs() # We only check/update these in core; not spinoff projects. # That is because they create hashes based on source files @@ -179,11 +182,11 @@ class Updater: f' docs markdown.{Clr.RST}') sys.exit(255) - def _update_compile_commands_file(self) -> None: + def _update_prereqs(self) -> None: # This will update our prereqs which may include compile-commands # files (.cache/irony/compile_commands.json, etc) - subprocess.run(['make', 'prereqs'], check=True) + subprocess.run(['make', '-j8', 'prereqs'], check=True) def _apply_file_changes(self) -> None: # Now write out any project files that have changed @@ -687,7 +690,3 @@ class Updater: print(f'{Clr.RED}Error checking/updating' f' python enums module.{Clr.RST}') sys.exit(255) - - -# if __name__ == '__main__': -# App().run() diff --git a/tools/efro/terminal.py b/tools/efro/terminal.py index aafa34fd..2fad6898 100644 --- a/tools/efro/terminal.py +++ b/tools/efro/terminal.py @@ -125,7 +125,7 @@ def _windows_enable_color() -> bool: mode = mask = ENABLE_VIRTUAL_TERMINAL_PROCESSING try: return set_conout_mode(mode, mask) - except WindowsError as exc: + except WindowsError as exc: # type: ignore if exc.winerror == ERROR_INVALID_PARAMETER: raise NotImplementedError from exc raise