From bef6e53a3e56f538c9aabf0ea9708ca36f52267c Mon Sep 17 00:00:00 2001 From: Eric Froemling Date: Sat, 5 Oct 2019 12:51:58 -0700 Subject: [PATCH] more sync work --- Makefile | 665 +----------------------------------- tools/efrotools/makefile.py | 99 ++++++ tools/efrotools/snippets.py | 14 + tools/snippets | 6 +- 4 files changed, 123 insertions(+), 661 deletions(-) create mode 100644 tools/efrotools/makefile.py diff --git a/Makefile b/Makefile index 9a78183c..6895cd84 100644 --- a/Makefile +++ b/Makefile @@ -119,44 +119,7 @@ dummymodule: ################################################################################ # # -# Syncing # -# # -################################################################################ - -# Sync files to/from local related projects. -# Used for some scripts/etc. where git submodules would be overkill. -# 'sync' pulls files in, 'syncfull' also pushes out, 'synclist' prints a dry -# run, 'syncforce' pulls without looking, 'synccheck' ensures files haven't -# changed since synced, 'syncall' runs syncfull for colon-separated project -# paths defined in the EFTOOLS_SYNC_PROJECTS environment variable.. -sync: - tools/snippets sync - -syncfull: - tools/snippets sync full - -synclist: - tools/snippets sync list - -syncforce: - tools/snippets sync force - -synccheck: - tools/snippets sync check - -syncall: - tools/snippets sync_all - -syncalllist: - tools/snippets sync_all list - -# Tell make which of these targets don't represent files. -.PHONY: sync syncfull synclist syncforce synccheck syncall syncalllist - - -################################################################################ -# # -# Formatting / Checking # +# Formatting / Checking # # # ################################################################################ @@ -168,12 +131,12 @@ syncalllist: # Run formatting on all files in the project considered 'dirty'. format: - @make -j2 formatcode formatscripts + @make -j3 formatcode formatscripts formatmakefile @echo Formatting complete! # Same but always formats; ignores dirty state. formatfull: - @make -j2 formatcodefull formatscriptsfull + @make -j3 formatcodefull formatscriptsfull formatmakefile @echo Formatting complete! # Run formatting for compiled code sources (.cc, .h, etc.). @@ -192,6 +155,9 @@ formatscripts: prereqs formatscriptsfull: prereqs @tools/snippets formatscripts -full +formatmakefile: prereqs + @tools/snippets formatmakefile + # Note: the '2' varieties include extra inspections such as PyCharm. # These are useful, but can take significantly longer and/or be a bit flaky. @@ -255,7 +221,7 @@ pylintscriptsfast: prereqs ################################################################################ # # -# Updating / Preflighting # +# Updating / Preflighting # # # ################################################################################ @@ -327,401 +293,12 @@ preflightfull2: preflightfull preflightfull2 -################################################################################ -# # -# Mac # -# # -################################################################################ - -# Build and run generic mac xcode version. -mac: - # (build_mac handles assets, resources, code) - @tools/build_mac -nospeak - -# Just build; don't run. -mac-build: - # (build_mac handles assets, resources, code) - tools/build_mac -nospeak -norun - -# Clean it. -mac-clean: - @tools/build_mac -clean -nospeak - -# Build and run mac-app-store build. -mac-appstore: - # (build_mac handles assets, resources, code) - @tools/build_mac -appstore -nospeak - -# Build and run mac-app-store build (release config). -mac-appstore-release: - # (build_mac handles assets, resources, code) - @tools/build_mac -appstore -release -nospeak - -# Just build; don't run. -mac-appstore-build: - # (build_mac handles assets, resources, code) - @tools/build_mac -appstore -nospeak -norun - -# Just build; don't run (opt version). -mac-appstore-release-build: - # (build_mac handles assets, resources, code) - @tools/build_mac -appstore -release -nospeak -norun - -# Clean it. -mac-appstore-clean: - @tools/build_mac -appstore -clean -nospeak - -# Build the new mac xcode version. -mac-new-build: assets-desktop resources code - @xcodebuild -project ballisticacore-xcode/BallisticaCore.xcodeproj \ - -scheme "BallisticaCore macOS" -configuration Debug - -# Clean new xcode version. -mac-new-clean: - @xcodebuild -project ballisticacore-xcode/BallisticaCore.xcodeproj \ - -scheme "BallisticaCore macOS" -configuration Debug clean - -# Assemble a mac test-build package. -mac-package: assets-desktop resources code - @rm -f ${DIST_DIR}/${MAC_PACKAGE_NAME}.zip - @xcodebuild -project ballisticacore-mac.xcodeproj \ - -scheme "BallisticaCoreTest macOS Legacy" \ - -configuration Release clean build - @cd ${MAC_DIST_BUILD_DIR} && rm -f ${MAC_PACKAGE_NAME}.zip && zip -rq \ - ${MAC_PACKAGE_NAME}.zip \ - BallisticaCoreTest.app && mkdir -p ${DIST_DIR} && mv \ - ${MAC_PACKAGE_NAME}.zip ${DIST_DIR} - @echo SUCCESS! - created ${MAC_PACKAGE_NAME}.zip - -# Build a server version. -# FIXME: Switch this to the cmake version. -mac-server-build: assets-desktop resources code - @xcodebuild -project ballisticacore-mac.xcodeproj \ - -scheme "bs_headless macOS Legacy" -configuration Debug - -# Clean the mac build. -# It lives outside of our dir so we can't use 'git clean'. -mac-server-clean: - @xcodebuild -project ballisticacore-mac.xcodeproj \ - -scheme "bs_headless macOS Legacy" -configuration Debug clean - -MAC_SERVER_BUILD_DIR = ${DIST_DIR}/${MAC_SERVER_PACKAGE_NAME}_build -MAC_SERVER_PACKAGE_DIR = ${DIST_DIR}/${MAC_SERVER_PACKAGE_NAME} - -mac-server-package: assets-desktop resources code - @rm -rf ${DIST_DIR}/${MAC_SERVER_PACKAGE_NAME}.zip \ - ${MAC_SERVER_BUILD_DIR} ${MAC_SERVER_PACKAGE_DIR} \ - ${MAC_SERVER_PACKAGE_DIR}.tar.gz - @mkdir -p ${MAC_SERVER_BUILD_DIR} ${MAC_SERVER_PACKAGE_DIR} ${DIST_DIR} - @cd ${MAC_SERVER_BUILD_DIR} && cmake -DCMAKE_BUILD_TYPE=Release \ - -DHEADLESS=true ${ROOT_DIR}/ballisticacore-cmake && make -j${JOBS} - @cd ${MAC_SERVER_PACKAGE_DIR} \ - && cp ${MAC_SERVER_BUILD_DIR}/ballisticacore \ - ./bs_headless \ - && cp ${ROOT_DIR}/assets/src/server/server.py \ - ./ballisticacore_server \ - && cp ${ROOT_DIR}/assets/src/server/README.txt ./README.txt \ - && cp ${ROOT_DIR}/assets/src/server/config.py ./config.py \ - && cp ${ROOT_DIR}/CHANGELOG.md ./CHANGELOG.txt \ - && ${STAGE_ASSETS} -cmake-server . - @cd ${MAC_SERVER_PACKAGE_DIR}/.. && zip -rq \ - ${MAC_SERVER_PACKAGE_NAME}.zip ${MAC_SERVER_PACKAGE_NAME} - @rm -rf ${MAC_SERVER_BUILD_DIR} ${MAC_SERVER_PACKAGE_DIR} - @echo SUCCESS! - created ${MAC_SERVER_PACKAGE_NAME}.zip - -# Tell make which of these targets don't represent files. -.PHONY: mac mac-build mac-clean mac-appstore mac-appstore-release \ - mac-appstore-build mac-appstore-release-build mac-appstore-clean \ - mac-new-build mac-new-clean mac-package mac-server-build mac-server-clean \ - mac-server-package - - -################################################################################ -# # -# Windows # -# # -################################################################################ - -# Set these env vars from the command line to influence the build: - -# Can be empty, Headless, or Oculus -WINDOWS_PROJECT ?= - -# Can be Win32 or x64 -WINDOWS_PLATFORM ?= Win32 - -# Can be Debug or Release -WINDOWS_CONFIGURATION ?= Debug - -# Builds win version via VM. Doesn't launch but leaves VM running. -# (hopefully can figure out how to launch at some point) -windows: windows-staging - @VMSHELL_SUSPEND=0 VMSHELL_SHOW=1 tools/vmshell win7 ${WIN_MSBUILD_EXE} \ - \"__INTERNAL_PATH__\\ballisticacore-windows\\BallisticaCore.sln\" \ - /t:BallisticaCore$(WINPRJ) /p:Configuration=$(WINCFG) \ - ${VISUAL_STUDIO_VERSION} && echo WINDOWS $(WINCFG) BUILD SUCCESSFULL! \ - && echo NOW LAUNCH: \ - ballisticacore-windows\\$(WINCFG)\\BallisticaCore$(WINPRJ).exe - -# Build but don't run (shuts down the vm). -windows-build: windows-staging - @tools/vmshell win7 $(WIN_MSBUILD_EXE) \ - \"__INTERNAL_PATH__\\ballisticacore-windows\\BallisticaCore.sln\"\ - /t:BallisticaCore$(WINPRJ) /p:Configuration=$(WINCFG) \ - ${VISUAL_STUDIO_VERSION} && echo WINDOWS $(WINPRJ)$(WINPLT)$(WINCFG) \ - REBUILD SUCCESSFULL! - -windows-rebuild: windows-staging - @tools/vmshell win7 $(WIN_MSBUILD_EXE) \ - \"__INTERNAL_PATH__\\ballisticacore-windows\\BallisticaCore.sln\"\ - /t:BallisticaCore$(WINPRJ):Rebuild /p:Configuration=$(WINCFG) \ - ${VISUAL_STUDIO_VERSION} && echo WINDOWS $(WINPRJ)$(WINPLT)$(WINCFG) \ - REBUILD SUCCESSFULL! - -# Stage assets and other files so a built binary will run. -windows-staging: assets-desktop resources code - ${STAGE_ASSETS} -win-$(WINPLT) \ - ballisticacore-windows/Build/$(WINCFG)_$(WINPLT) - -# Remove all non-git-managed files in windows subdir. -windows-clean: - @${CHECK_CLEAN_SAFETY} - git clean -dfx ballisticacore-windows - -# Show what would be cleaned. -windows-cleanlist: - @${CHECK_CLEAN_SAFETY} - git clean -dnx ballisticacore-windows - -windows-package: - WINDOWS_PROJECT= WINDOWS_PLATFORM=Win32 WINDOWS_CONFIGURATION=Release \ - make _windows-package - -windows-server-package: - WINDOWS_PROJECT=Headless WINDOWS_PLATFORM=Win32 \ - WINDOWS_CONFIGURATION=Release make _windows-server-package - -windows-oculus-package: - WINDOWS_PROJECT=Oculus WINDOWS_PLATFORM=Win32 WINDOWS_CONFIGURATION=Release \ - make _windows-oculus-package - -# Tell make which of these targets don't represent files. -.PHONY: windows windows-build windows-rebuild windows-staging windows-clean \ - windows-cleanlist windows-package windows-server-package \ - windows-oculus-package - - -################################################################################ -# # -# iOS # -# # -################################################################################ - -# Build all dependencies. -# If building/running directly from xcode, run this first. -ios-deps: assets-ios resources code - -# Just build; don't install or run. -ios-build: ios-deps - xcodebuild -project ballisticacore-ios.xcodeproj \ - -scheme "BallisticaCore iOS Legacy" -configuration Debug - -ios-build-release: ios-deps - xcodebuild -project ballisticacore-ios.xcodeproj \ - -scheme "BallisticaCore iOS Legacy" -configuration Release - -ios-clean: - xcodebuild -project ballisticacore-ios.xcodeproj \ - -scheme "BallisticaCore iOS Legacy" -configuration Debug clean - -# Build and push debug build to staging server. -# (Used for iterating, not final releases) -ios-push: ios-build - @tools/snippets push_ipa debug - -# Build and push release build to staging server. -# (Used for iterating, not final releases) -ios-push-release: ios-build-release - @tools/snippets push_ipa release - -# Build and run new ios xcode version. -ios-new-build: ios-deps - @xcodebuild -project ballisticacore-xcode/BallisticaCore.xcodeproj \ - -scheme "BallisticaCore iOS" -configuration Debug - -# Clean new xcode version. -ios-new-clean: - @xcodebuild -project ballisticacore-xcode/BallisticaCore.xcodeproj \ - -scheme "BallisticaCore iOS" -configuration Debug clean - -# Tell make which of these targets don't represent files. -.PHONY: ios-deps ios-build ios-build-release ios-clean ios-push \ - ios-push-release ios-new-build ios-new-clean - - -################################################################################ -# # -# tvOS # -# # -################################################################################ - -# Build all dependencies. -# If building/running directly from xcode, run this first. -tvos-deps: assets-ios resources code - -# Just build; don't install or run. -tvos-build: tvos-deps - xcodebuild -project ballisticacore-xcode/BallisticaCore.xcodeproj \ - -scheme "BallisticaCore tvOS" -configuration Debug - -tvos-clean: - xcodebuild -project ballisticacore-xcode/BallisticaCore.xcodeproj \ - -scheme "BallisticaCore tvOS" -configuration Debug clean - -# Tell make which of these targets don't represent files. -.PHONY: tvos-deps tvos-build tvos-clean - - -################################################################################ -# # -# Android # -# # -################################################################################ - -# Set these env vars from the command line to influence the build: - -# Subplatform: 'google', 'amazon', etc. -ANDROID_PLATFORM ?= generic - -# Build all archs: 'prod'. Build single: 'arm', 'arm64', 'x86', 'x86_64'. -ANDROID_MODE ?= arm - -# 'full' includes all assets; 'none' gives none and 'scripts' only scripts. -# Excluding assets can speed up iterations, but requires the full apk to -# have been installed/run first (which extracts all assets to the device). -ANDROID_ASSETS ?= full - -# Build type: can be debug or release -ANDROID_BUILDTYPE ?= debug - -# FIXME - should probably not require these here -ANDROID_APPID ?= "com.ericfroemling.ballisticacore" -ANDROID_MAIN_ACTIVITY ?= ".MainActivity" - -# Stage, build, install, and run a full apk. -android: android-build - make android-install - make android-run - -# Stage and build but don't install or run. -android-build: android-staging - cd ballisticacore-android && $(AN_ASSEMBLE_CMD) - -# Stage only (assembles/gathers assets & other files). -# Run this before using Android Studio to build/run. -android-staging: _android-sdk assets resources code - cd $(AN_PLATFORM_DIR) && ${STAGE_ASSETS} -android -${ANDROID_ASSETS} - -# Display filtered logs. -# Most of the standard targets do this already but some such as the -# debugger-attach ones don't so it can be handy to run this in a -# separate terminal concurrently. -android-log: - ${ANDROID_ADB} logcat -c - ${ANDROID_FILTERED_LOGCAT} - -# Run whatever is already installed. -android-run: - ${ANDROID_ADB} logcat -c - ${ANDROID_ADB} shell "$(AN_STRT) $(ANDROID_APPID)/${ANDROID_MAIN_ACTIVITY}" - ${ANDROID_FILTERED_LOGCAT} - -# Stop the game if its running. -android-stop: - ${ANDROID_ADB} shell am force-stop $(ANDROID_APPID) - -# Install the game. -android-install: - ${ANDROID_ADB} install -r $(AN_APK) - -# Uninstall the game. -android-uninstall: - ${ANDROID_ADB} uninstall $(ANDROID_APPID) - -# Clean the android build while leaving workspace intact. -# This includes Android Studio workspace files and built resources intact. -android-clean: - cd ballisticacore-android && ./gradlew clean - @echo Cleaning staged assets... - rm -rf ballisticacore-android/BallisticaCore/src/*/assets/ballistica_files - @echo Cleaning things gradle may have left behind... - rm -rf ballisticacore-android/build - rm -rf ballisticacore-android/*/build - rm -rf ballisticacore-android/*/.cxx - rm -rf ballisticacore-android/.idea/caches - -# Remove ALL non-git-managed files in the android subdir. -# This will blow away most IDEA related files, though they should -# be auto-regenerated when opening the project again. -# IMPORTANT: Doing a full re-import of the gradle project in -# android studio will blow away the few intellij files that we *do* -# want to keep, so be careful to undo those changes via git after. -# (via 'git checkout -- .' or whatnot) -android-fullclean: - @${CHECK_CLEAN_SAFETY} - git clean -dfx ballisticacore-android - -# Show what *would* be cleaned. -android-fullcleanlist: - @${CHECK_CLEAN_SAFETY} - git clean -dnx ballisticacore-android - -# Package up a generic android test-build apk. -android-package: - ANDROID_PLATFORM=generic ANDROID_MODE=prod ANDROID_BUILDTYPE=release\ - make _android-package - -# Build and archive a google play apk. -android-archive-google: - ANDROID_PLATFORM=google ANDROID_MODE=prod ANDROID_BUILDTYPE=release\ - make _android-bundle-archive - -# Build and archive a demo apk. -android-archive-demo: - ANDROID_PLATFORM=demo ANDROID_MODE=prod ANDROID_BUILDTYPE=release\ - make _android-archive - -# Build and archive an amazon apk. -android-archive-amazon: - ANDROID_PLATFORM=amazon ANDROID_MODE=prod ANDROID_BUILDTYPE=release\ - make _android-archive - -# Build and archive a cardboard apk. -android-archive-cardboard: - ANDROID_PLATFORM=cardboard ANDROID_MODE=prod ANDROID_BUILDTYPE=release\ - make _android-archive - -# Tell make which of these targets don't represent files. -.PHONY: android android-build android-staging \ - android-log android-run android-stop android-install \ - android-uninstall android-clean android-fullclean android-fullcleanlist \ - android-package android-archive-google android-archive-demo \ - android-archive-amazon android-archive-cardboard - - ################################################################################ # # # CMake # # # ################################################################################ -# VMshell configs to use when building; override to use your own. -# (just make sure the 32/64-bit-ness matches). -LINUX64_FLAVOR ?= linux64-u18 - -# At some point before long we can stop bothering with 32 bit linux builds. -LINUX32_FLAVOR ?= linux32-u16 - # Build and run the cmake build. cmake: cmake-build @cd ballisticacore-cmake/build/debug && ./ballisticacore @@ -768,233 +345,6 @@ cmake-server-clean: cmake-server cmake-server-build cmake-server-clean -################################################################################ -# # -# Linux # -# # -################################################################################ - -# Build and run 64 bit linux version via VM. -# Note: this leaves the vm running when it is done. -linux64: assets-desktop resources code - @${STAGE_ASSETS} -cmake build/linux64 - @VMSHELL_INTERACTIVE=1 VMSHELL_SUSPEND=0 VMSHELL_SHOW=1 \ - tools/vmshell ${LINUX64_FLAVOR} \ - cd __INTERNAL_PATH__ \&\& make _linux - -# Just build; don't run (also kills vm after). -linux64-build: assets-desktop resources code - @${STAGE_ASSETS} -cmake build/linux64 - @tools/vmshell ${LINUX64_FLAVOR} cd __INTERNAL_PATH__ \ - \&\& make _linux-build - -# Clean the 64 bit linux version from mac. -linux64-clean: - rm -rf build/linux64 - -# Assemble a complete 64 bit linux package via vm. -linux64-package: assets-desktop resources code - @tools/vmshell ${LINUX64_FLAVOR} cd __INTERNAL_PATH__ \ - \&\& make _linux-package-build - @ARCH=x86_64 make _linux-package-assemble - -# Assemble a complete 32 bit linux package via vm. -linux32-package: assets-desktop resources code - @tools/vmshell ${LINUX32_FLAVOR} cd __INTERNAL_PATH__ \ - \&\& make _linux-package-build - @ARCH=i386 make _linux-package-assemble - -# Build and run 32 bit linux version from mac (requires vmware) -# note: this leaves the vm running when it is done. -linux32: assets-desktop resources code - @VMSHELL_INTERACTIVE=1 VMSHELL_SUSPEND=0 VMSHELL_SHOW=1 \ - tools/vmshell ${LINUX32_FLAVOR} \ - cd __INTERNAL_PATH__ \&\& make _linux - -# Just build; don't run (also kills vm after). -linux32-build: assets-desktop resources code - @${STAGE_ASSETS} -cmake build/linux32 - @tools/vmshell ${LINUX32_FLAVOR} cd __INTERNAL_PATH__ \ - \&\& make _linux-build - -# Clean the 32 bit linux version from mac. -linux32-clean: - rm -rf build/linux32 - -# Just build; don't run (also kills vm after). -linux64-server-build: assets-desktop resources code - @${STAGE_ASSETS} -cmake-server build/linux64_server - @tools/vmshell ${LINUX64_FLAVOR} cd __INTERNAL_PATH__ \ - \&\& make _linux-server-build - -# Clean the 64 bit linux server version from mac. -linux64-server-clean: - rm -rf build/linux64_server - -# Assemble complete 64 bit linux server package via vm. -linux64-server-package: assets-desktop resources code - @tools/vmshell ${LINUX64_FLAVOR} cd __INTERNAL_PATH__ \ - \&\& make _linux-server-package-build - @ARCH=x86_64 make _linux-server-package-assemble - -# Just build; don't run (also kills vm after). -linux32-server-build: assets-desktop resources code - @${STAGE_ASSETS} -cmake-server build/linux32_server - @tools/vmshell ${LINUX32_FLAVOR} cd __INTERNAL_PATH__ \ - \&\& make _linux-server-build - -# Clean the 32 bit linux server version from mac. -linux32-server-clean: - rm -rf build/linux32_server - -# Assemble complete 32 bit linux server package via vm. -linux32-server-package: assets-desktop resources code - @tools/vmshell ${LINUX32_FLAVOR} cd __INTERNAL_PATH__ \ - \&\& make _linux-server-package-build - @ARCH=x86_32 make _linux-server-package-assemble - -# Assemble a raspberry pi server package. -raspberry-pi-server-package: assets resources code - @tools/build_raspberry_pi - @mkdir -p ${DIST_DIR} && cd ${DIST_DIR} && rm -rf ${RPI_SERVER_PACKAGE_NAME} \ - ${RPI_SERVER_PACKAGE_NAME}.tar.gz && mkdir -p ${RPI_SERVER_PACKAGE_NAME} \ - && cd ${RPI_SERVER_PACKAGE_NAME} && mv ${ROOT_DIR}/build/bs_headless_rpi \ - ./bs_headless && cp ${ROOT_DIR}/assets/src/server/server.py \ - ./ballisticacore_server \ - && cp ${ROOT_DIR}/assets/src/server/README.txt ./README.txt \ - && cp ${ROOT_DIR}/CHANGELOG.md ./CHANGELOG.txt \ - && cp ${ROOT_DIR}/assets/src/server/config.py ./config.py\ - && ${STAGE_ASSETS} -cmake-server . && cd .. \ - && COPYFILE_DISABLE=1 tar -zcf ${RPI_SERVER_PACKAGE_NAME}.tar.gz \ - ${RPI_SERVER_PACKAGE_NAME} && rm -rf ${RPI_SERVER_PACKAGE_NAME} - @echo SUCCESS! - created ${RPI_SERVER_PACKAGE_NAME} - -# Tell make which of these targets don't represent files. -.PHONY: linux64 linux64-build linux64-clean linux64-package linux32-package \ - linux32 linux32-build linux32-clean linux64-server-build \ - linux64-server-clean linux64-server-package linux32-server-build \ - linux32-server-clean linux32-server-package raspberry-pi-server-package - - -################################################################################ -# # -# Admin # -# # -################################################################################ - -# Build and push just the linux64 server. -# For use with our server-manager setup. -# This expects the package to have been built already. -push-server-package: - test ballisticacore = bombsquad # Only allow this from bombsquad spinoff atm. - cd ${DIST_DIR} && tar -xf \ - ${LINUX_SERVER_PACKAGE_BASE_NAME}_64bit_${VERSION}.tar.gz \ - && mv ${LINUX_SERVER_PACKAGE_BASE_NAME}_64bit_${VERSION} ${BUILD_NUMBER} \ - && tar -zcf ${BUILD_NUMBER}.tar.gz ${BUILD_NUMBER} \ - && rm -rf ${BUILD_NUMBER} - scp ${SSH_BATCH_ARGS} ${DIST_DIR}/${BUILD_NUMBER}.tar.gz \ - ${STAGING_SERVER}:files.ballistica.net/test/bsb - rm ${DIST_DIR}/${BUILD_NUMBER}.tar.gz - rm ${DIST_DIR}/${LINUX_SERVER_PACKAGE_BASE_NAME}_64bit_${VERSION}.tar.gz - @echo LINUX64 SERVER ${BUILD_NUMBER} BUILT AND PUSHED! - -# Push and clear our test-build packages. -# This expects them all to have been built already. -push-all-test-packages: - test ballisticacore = bombsquad # Only allow this from bombsquad spinoff atm. - scp ${SSH_BATCH_ARGS} ${ALL_TEST_PACKAGE_FILES} CHANGELOG.md \ - ${STAGING_SERVER}:${STAGING_SERVER_BUILDS_DIR} - rm ${ALL_TEST_PACKAGE_FILES} - ${ARCHIVE_OLD_PUBLIC_BUILDS} - @echo ALL TEST PACKAGES BUILT AND PUSHED! - -# Push and clear our server packages. -# This expects them all to have been built already. -push-all-server-packages: - test ballisticacore = bombsquad # Only allow this from bombsquad spinoff atm. - scp ${SSH_BATCH_ARGS} ${ALL_SERVER_PACKAGE_FILES} CHANGELOG.md \ - ${STAGING_SERVER}:${STAGING_SERVER_BUILDS_DIR} - rm ${ALL_SERVER_PACKAGE_FILES} - ${ARCHIVE_OLD_PUBLIC_BUILDS} - @echo ALL SERVERS PUSHED! - -# Tell make which of these targets don't represent files. -.PHONY: push-server-package push-all-test-packages push-all-server-packages - - -################################################################################ -# # -# Python # -# # -################################################################################ - -# Targets for wrangling special embedded builds of python for platform such -# as iOS and Android. - -# Build all Pythons and gather them into src. -python-all: - make -j${JOBS} python-apple python-android - tools/snippets python_gather - -python-apple: python-mac python-mac-debug \ - python-ios python-ios-debug \ - python-tvos python-tvos-debug - -python-android: python-android-arm python-android-arm-debug \ - python-android-arm64 python-android-arm64-debug \ - python-android-x86 python-android-x86-debug \ - python-android-x86-64 python-android-x86-64-debug - -python-mac: - tools/snippets python_build_apple mac - -python-mac-debug: - tools/snippets python_build_apple_debug mac - -python-ios: - tools/snippets python_build_apple ios - -python-ios-debug: - tools/snippets python_build_apple_debug ios - -python-tvos: - tools/snippets python_build_apple tvos - -python-tvos-debug: - tools/snippets python_build_apple_debug tvos - -python-android-arm: - tools/snippets python_build_android arm - -python-android-arm-debug: - tools/snippets python_build_android_debug arm - -python-android-arm64: - tools/snippets python_build_android arm64 - -python-android-arm64-debug: - tools/snippets python_build_android_debug arm64 - -python-android-x86: - tools/snippets python_build_android x86 - -python-android-x86-debug: - tools/snippets python_build_android_debug x86 - -python-android-x86-64: - tools/snippets python_build_android x86_64 - -python-android-x86-64-debug: - tools/snippets python_build_android_debug x86_64 - -# Tell make which of these targets don't represent files. -.PHONY: python-all python-apple python-android python-mac python-mac-debug \ - python-ios python-ios-debug python-tvos python-tvos-debug \ - python-android-arm python-android-arm-debug python-android-arm64 \ - python-android-x86 python-android-x86-debug python-android-x86-64 \ - python-android-x86-64-debug - - ################################################################################ # # # Auxiliary # @@ -1395,4 +745,3 @@ ALL_SERVER_PACKAGE_FILES = \ _linux-server-build _linux-server-package-build \ _linux-server-package-assemble spinoff-upgrade-push-all pushchangelog \ docs pushdocs asset_cache_refresh verify_staging_server_auth - diff --git a/tools/efrotools/makefile.py b/tools/efrotools/makefile.py new file mode 100644 index 00000000..7b005ae9 --- /dev/null +++ b/tools/efrotools/makefile.py @@ -0,0 +1,99 @@ +"""Tools for parsing/filtering makefiles.""" + +from __future__ import annotations + +import copy +from dataclasses import dataclass +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from typing import Optional, List + + +@dataclass +class Section: + """Represents a section of a Makefile.""" + name: Optional[str] + paragraphs: List[Paragraph] + + +@dataclass +class Paragraph: + """Represents a continuous set of non-blank lines in a Makefile.""" + contents: str + + +class Makefile: + """Represents an entire Makefile.""" + + header_line_full = '#' * 80 + header_line_empty = '#' + ' ' * 78 + '#' + + def __init__(self, contents: str): + + self.sections: List[Section] = [] + + self._original = copy.copy(contents) + + lines = contents.splitlines() + + paragraphs: List[Paragraph] = [] + + # First off, break into paragraphs (continuous sets of lines) + plines: List[str] = [] + for line in lines: + + if line.strip() == '': + if plines: + paragraphs.append(Paragraph(contents='\n'.join(plines))) + plines = [] + continue + plines.append(line) + if plines: + paragraphs.append(Paragraph(contents='\n'.join(plines))) + plines = [] + + # Now break all paragraphs into sections. + section = Section(name=None, paragraphs=[]) + self.sections.append(section) + for paragraph in paragraphs: + + # Look for our very particular section headers and start + # a new section whenever we come across one. + plines = paragraph.contents.splitlines() + # pylint: disable=too-many-boolean-expressions + if (len(plines) == 5 and plines[0] == self.header_line_full + and plines[1] == self.header_line_empty + and len(plines[2]) == 80 and plines[2][0] == '#' + and plines[2][-1] == '#' + and plines[3] == self.header_line_empty + and plines[4] == self.header_line_full): + section = Section(name=plines[2][1:-1].strip(), paragraphs=[]) + self.sections.append(section) + else: + section.paragraphs.append(paragraph) + + def get_output(self) -> str: + """Generate a Makefile from the current state.""" + + output = '' + for section in self.sections: + did_first_entry = False + if section.name is not None: + output += '\n\n' + self.header_line_full + '\n' + output += self.header_line_empty + '\n' + spacelen = 78 - len(section.name) + output += '#' + ' ' * (spacelen // 2) + section.name + spacelen -= spacelen // 2 + output += ' ' * spacelen + '#\n' + output += self.header_line_empty + '\n' + output += self.header_line_full + '\n' + did_first_entry = True + for paragraph in section.paragraphs: + if did_first_entry: + output += '\n' + output += paragraph.contents + '\n' + did_first_entry = True + # print(output) + + return output diff --git a/tools/efrotools/snippets.py b/tools/efrotools/snippets.py index f491eec0..aaf53dd7 100644 --- a/tools/efrotools/snippets.py +++ b/tools/efrotools/snippets.py @@ -155,6 +155,20 @@ def formatscripts() -> None: code.formatscripts(PROJROOT, full) +def formatmakefile() -> None: + """Format the main makefile.""" + from efrotools.makefile import Makefile + with open('Makefile') as infile: + original = infile.read() + + formatted = Makefile(original).get_output() + + # Only write if it changed. + if formatted != original: + with open('Makefile', 'w') as outfile: + outfile.write(formatted) + + def cpplintcode() -> None: """Run lint-checking on all code deemed lint-able.""" from efrotools import code diff --git a/tools/snippets b/tools/snippets index 6e5b5c67..9c27a31e 100755 --- a/tools/snippets +++ b/tools/snippets @@ -21,9 +21,9 @@ import efrotools # Pull in some standard snippets we want to expose. # noinspection PyUnresolvedReferences from efrotools.snippets import ( # pylint: disable=unused-import - PROJROOT, snippets_main, formatcode, formatscripts, cpplintcode, - pylintscripts, mypyscripts, tool_config_install, sync, sync_all, - scriptfiles, pycharmscripts, clioncode, androidstudiocode, + PROJROOT, snippets_main, formatcode, formatscripts, formatmakefile, + cpplintcode, pylintscripts, mypyscripts, tool_config_install, sync, + sync_all, scriptfiles, pycharmscripts, clioncode, androidstudiocode, makefile_target_list, spelling) if TYPE_CHECKING: