Enabling resources makefile updates in public

This commit is contained in:
Eric Froemling 2021-06-16 09:42:00 -05:00
parent 0f05f5d1ee
commit c801cffdd6
No known key found for this signature in database
GPG Key ID: 89C93F0F8D6D5A98
9 changed files with 260 additions and 152 deletions

View File

@ -3933,27 +3933,26 @@
"assets/build/windows/Win32/ucrtbased.dll": "https://files.ballistica.net/cache/ba1/f5/8b/14895df9caf46f326a3c939b34a4",
"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/4f/e0/5a5aef75cf5f05fd8282ad92d1eb",
"build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/6c/4a/ea20aa40a0336346481db7a3e7cc",
"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/c1/c8/92f9a0bf8969fcbd22927734606e",
"build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/e6/14/560fd83f1c5a0928611a76fde770",
"build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/19/0e/d45bdd5617d5b4404e76ca1cb214",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/79/a4/151c407676751226822b7f3fea28",
"build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/20/af/c30bf81152b21bd3e659dbc5ad98",
"build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/a4/c5/f80651437601406ed7fc851e04de",
"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/fd/d2/6afb31906b505245196190546e51",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/91/0f/ab8b884c63ced885a6cf7630e8d9",
"build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/b1/c9/2edbce55fa83d915f50af4523b4c",
"build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/cc/9b/9356a25f110fa3d4e8605b9e2904",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/c6/d9/ee13d5b6d8c3b2b096ce13366d2c",
"build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/1e/fa/ad873063e48b4d24edf4e4aeb7cc",
"build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/38/23/99b9fea9267c57a814ed067c0599",
"build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/37/a8/798f929264b3d557b2ba88f2894d",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/47/6e/cfc416c65015d620acb094b46f30",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/cf/be/f4df8928742323c928e2c8415d75",
"build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/a5/d9/a00b0aed327dba3cff775f6d15ec",
"build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/b0/e6/9dc9200fddfe9dc756021a5a9540",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/50/44/b8a7a25e95b9d2fa948c07a3abf8",
"build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/84/6f/9d762749a51107e5f157fb78408b",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a8/3f/7cbb7f9e5d683bff4998adaaf90e",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/14/62/e9048f67d7fd8e2b16ce19bd5f62",
"build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/9a/35/1bda678f84232eda0f1a2725e055",
"build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/42/73/3cde5ac6f418bc51056c66688f9c",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a6/0a/6c825e16fd7c38b333a1990a5284",
"build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/22/74/c198da8f0a9f2c5b635bc6dba1eb",
"build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/72/2b/ec334129de9d4f178be5edde6bee",
"build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/9e/50/d602765c67c81a5facbb2b664782",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/65/ad/7d6f7fd1d37f5ea04bb0c7cddb4b",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a9/b3/8b9a84ef02d04c2cd7af03ca2ccf",
"build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/d5/0c/5ac1824e4ac58feeb406a245d519",
"build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/d2/72/f6e138e469270e3755c129280ff4",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/2c/43/08f790d0825208e1aef8bc4f0108",
"build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/00/44/a30d83adcc04eb9814f2fa482e8d",
"build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/7d/b6/475f313a5e1163d8b18f81fda053",
"build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/6c/78/4d4cd81c4b925a202fe4d961ab69",
"build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ce/42/dabc253464415881a92d09a5cbcb",
@ -3977,5 +3976,6 @@
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/36/05/bdbffaab5039230c2fbcb7d8c878",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/e7/c4/324bb33d12a37d46c6a38da7a63d",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/2a/d8/77387d2781de3bb624538c80a2cc",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/b1/51/67daef6f5638ddf3ebeb61186539"
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/b1/51/67daef6f5638ddf3ebeb61186539",
"resources/../ballisticacore-windows/Generic/BallisticaCore.ico": "https://files.ballistica.net/cache/ba1/c8/8e/2b54b5f52bf21e27a893aeef75c9"
}

1
.gitignore vendored
View File

@ -129,6 +129,7 @@ xcuserdata/
/ballisticacore-android/BallisticaCore/src/cardboard/res/drawable-*/icon.png
/ballisticacore-android/BallisticaCore/src/main/res/drawable-*/banner.png
/ballisticacore-android/BallisticaCore/src/main/res/mipmap-*/ic_launcher*.png
/ballisticacore-android/BallisticaCore/src/cardboard/res/mipmap-*/ic_launcher*.png
BallisticaCore.ico
/ballisticacore-xcode/BallisticaCore Shared/Assets.xcassets/AppIcon iOS.appiconset/icon_*.png
/ballisticacore-xcode/BallisticaCore Shared/Assets.xcassets/AppIcon macOS.appiconset/icon_*.png

View File

@ -787,8 +787,7 @@ windows-release: windows-release-build
# Build a debug windows build (from WSL).
windows-debug-build: \
build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib \
build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb \
ballisticacore-windows/Generic/BallisticaCore.ico
build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb
@tools/pcommand ensure_prefab_platform windows_x86
@tools/pcommand wsl_build_check_win_drive
WINDOWS_CONFIGURATION=Debug WINDOWS_PLATFORM=Win32 $(MAKE) windows-staging
@ -798,8 +797,7 @@ windows-debug-build: \
# Rebuild a debug windows build (from WSL).
windows-debug-rebuild: \
build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib \
build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb \
ballisticacore-windows/Generic/BallisticaCore.ico
build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb
@tools/pcommand ensure_prefab_platform windows_x86
@tools/pcommand wsl_build_check_win_drive
WINDOWS_CONFIGURATION=Debug WINDOWS_PLATFORM=Win32 $(MAKE) windows-staging
@ -809,8 +807,7 @@ windows-debug-rebuild: \
# Build a release windows build (from WSL).
windows-release-build: \
build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib \
build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb \
ballisticacore-windows/Generic/BallisticaCore.ico
build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb
@tools/pcommand ensure_prefab_platform windows_x86
@tools/pcommand wsl_build_check_win_drive
WINDOWS_CONFIGURATION=Release WINDOWS_PLATFORM=Win32 $(MAKE) windows-staging
@ -820,17 +817,13 @@ windows-release-build: \
# Rebuild a release windows build (from WSL).
windows-release-rebuild: \
build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib \
build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb \
ballisticacore-windows/Generic/BallisticaCore.ico
build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb
@tools/pcommand ensure_prefab_platform windows_x86
@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
ballisticacore-windows/Generic/BallisticaCore.ico: .efrocachemap
@tools/pcommand efrocache_get $@
# Remove all non-git-managed files in windows subdir.
windows-clean:
@${CHECK_CLEAN_SAFETY}

View File

@ -1558,7 +1558,7 @@ SCRIPT_TARGETS_PYC_PRIVATE_APPLE = \
# Rule to copy src asset scripts to dst.
# (and make non-writable so I'm less likely to accidentally edit them there)
$(SCRIPT_TARGETS_PY_PRIVATE_APPLE) : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get assets/$@
@cd .. && tools/pcommand efrocache_get resources/$@
# These are too complex to define in a pattern rule;
# Instead we generate individual targets in a loop.
@ -2430,7 +2430,7 @@ SCRIPT_TARGETS_PYC_PRIVATE_ANDROID = \
# Rule to copy src asset scripts to dst.
# (and make non-writable so I'm less likely to accidentally edit them there)
$(SCRIPT_TARGETS_PY_PRIVATE_ANDROID) : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get assets/$@
@cd .. && tools/pcommand efrocache_get resources/$@
# These are too complex to define in a pattern rule;
# Instead we generate individual targets in a loop.
@ -2482,7 +2482,7 @@ SCRIPT_TARGETS_PYC_PRIVATE_COMMON = \
# Rule to copy src asset scripts to dst.
# (and make non-writable so I'm less likely to accidentally edit them there)
$(SCRIPT_TARGETS_PY_PRIVATE_COMMON) : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get assets/$@
@cd .. && tools/pcommand efrocache_get resources/$@
# These are too complex to define in a pattern rule;
# Instead we generate individual targets in a loop.
@ -3362,7 +3362,7 @@ SCRIPT_TARGETS_PYC_PRIVATE_WIN_WIN32 = \
# Rule to copy src asset scripts to dst.
# (and make non-writable so I'm less likely to accidentally edit them there)
$(SCRIPT_TARGETS_PY_PRIVATE_WIN_WIN32) : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get assets/$@
@cd .. && tools/pcommand efrocache_get resources/$@
# These are too complex to define in a pattern rule;
# Instead we generate individual targets in a loop.
@ -4242,7 +4242,7 @@ SCRIPT_TARGETS_PYC_PRIVATE_WIN_X64 = \
# Rule to copy src asset scripts to dst.
# (and make non-writable so I'm less likely to accidentally edit them there)
$(SCRIPT_TARGETS_PY_PRIVATE_WIN_X64) : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get assets/$@
@cd .. && tools/pcommand efrocache_get resources/$@
# These are too complex to define in a pattern rule;
# Instead we generate individual targets in a loop.
@ -6895,7 +6895,7 @@ EXTRAS_TARGETS_WIN_WIN32 = \
# Rule to copy src extras to build.
$(EXTRAS_TARGETS_WIN_WIN32) : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get assets/$@
@cd .. && tools/pcommand efrocache_get resources/$@
EXTRAS_TARGETS_WIN_X64 = \
@ -6982,53 +6982,53 @@ EXTRAS_TARGETS_WIN_X64 = \
# Rule to copy src extras to build.
$(EXTRAS_TARGETS_WIN_X64) : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get assets/$@
@cd .. && tools/pcommand efrocache_get resources/$@
#__AUTOGENERATED_END_PRIVATE__
ASSET_TARGETS_COMMON += $(MODEL_TARGETS)
build/%.bob : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get assets/$@
@cd .. && tools/pcommand efrocache_get resources/$@
build/%.cob : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get assets/$@
@cd .. && tools/pcommand efrocache_get resources/$@
build/%.ogg : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get assets/$@
@cd .. && tools/pcommand efrocache_get resources/$@
build/%.fdata : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get assets/$@
@cd .. && tools/pcommand efrocache_get resources/$@
# Langdata one-off json file.
build/ba_data/data/langdata.json : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get assets/$@
@cd .. && tools/pcommand efrocache_get resources/$@
# Languages json files.
build/ba_data/data/languages/%.json : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get assets/$@
@cd .. && tools/pcommand efrocache_get resources/$@
# Map json files.
build/ba_data/data/maps/%.json : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get assets/$@
@cd .. && tools/pcommand efrocache_get resources/$@
src/ba_data/%.tex2d.png : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get assets/$@
@cd .. && tools/pcommand efrocache_get resources/$@
src/ba_data/%_+x.tex2d.png : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get assets/$@
@cd .. && tools/pcommand efrocache_get resources/$@
build/ba_data/%_preview.png : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get assets/$@
@cd .. && tools/pcommand efrocache_get resources/$@
build/%.dds : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get assets/$@
@cd .. && tools/pcommand efrocache_get resources/$@
build/%.pvr : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get assets/$@
@cd .. && tools/pcommand efrocache_get resources/$@
build/%.ktx : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get assets/$@
@cd .. && tools/pcommand efrocache_get resources/$@
audio: $(AUDIO_TARGETS)
clean-audio:

View File

@ -1,8 +1,32 @@
# Released under the MIT License. See LICENSE for details.
# Dummy resources makefile; nothing here for now.
all: resources
resources:
# This section is autogenerated; do not edit by hand.
#__AUTOGENERATED_BEGIN_PUBLIC__
#__AUTOGENERATED_END_PUBLIC__
clean:
# This section is autogenerated; do not edit by hand.
#__AUTOGENERATED_BEGIN_PRIVATE__
resources: resources-private
resources-private: \
../ballisticacore-windows/Generic/BallisticaCore.ico
clean: clean-private
clean-private:
rm -f "../ballisticacore-windows/Generic/BallisticaCore.ico"
../ballisticacore-windows/Generic/BallisticaCore.ico : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get assets/$@
efrocache-list:
@echo "../ballisticacore-windows/Generic/BallisticaCore.ico"
efrocache-build: resources-private
#__AUTOGENERATED_END_PRIVATE__

View File

@ -21,7 +21,7 @@
namespace ballistica {
// These are set automatically via script; don't modify them here.
const int kAppBuildNumber = 20381;
const int kAppBuildNumber = 20382;
const char* kAppVersion = "1.6.4";
// Our standalone globals.

View File

@ -388,7 +388,7 @@ def upper() -> None:
def efrocache_update() -> None:
"""Build & push files to efrocache for public access."""
from efrotools.efrocache import update_cache
makefile_dirs = ['', 'assets']
makefile_dirs = ['', 'assets', 'resources']
update_cache(makefile_dirs)

View File

@ -641,16 +641,13 @@ class Updater:
'Error checking/updating meta Makefile.') from exc
def _update_resources_makefile(self) -> None:
# FIXME: should support running this in public too.
if not self._public:
try:
subprocess.run(
['tools/pcommand', 'update_resources_makefile'] +
self._checkarglist,
check=True)
except Exception as exc:
raise CleanError(
'Error checking/updating resources Makefile.') from exc
try:
subprocess.run(['tools/pcommand', 'update_resources_makefile'] +
self._checkarglist,
check=True)
except Exception as exc:
raise CleanError(
'Error checking/updating resources Makefile.') from exc
def _update_python_enums_module(self) -> None:
# FIXME: should support running this in public too.

View File

@ -8,14 +8,86 @@
from __future__ import annotations
import os
import sys
from pathlib import Path
from typing import TYPE_CHECKING
from dataclasses import dataclass
from efro.error import CleanError
from efro.terminal import Clr
if TYPE_CHECKING:
from typing import Optional, List, Dict
@dataclass
class Target:
"""Info about a makefile target."""
src: List[str]
dst: str
cmd: str
mkdir: bool = False
def emit(self) -> str:
"""Gen a makefile target."""
out: str = self.dst.replace(' ', '\\ ')
out += ' : ' + ' '.join(s for s in self.src) + (
('\n\t@mkdir -p "' + os.path.dirname(self.dst) +
'"') if self.mkdir else '') + '\n\t@' + self.cmd + '\n\n'
return out
def _emit_group_build_lines(targets: List[Target], basename: str) -> List[str]:
"""Gen a group build target."""
out: List[str] = []
if not targets:
return out
out.append(f'resources: resources-{basename}\n')
all_dsts = set()
for target in targets:
all_dsts.add(target.dst)
out.append(f'resources-{basename}: \\\n ' + ' \\\n '.join(
dst.replace(' ', '\\ ') for dst in sorted(all_dsts)) + '\n')
return out
def _emit_group_clean_lines(targets: List[Target], basename: str) -> List[str]:
"""Gen a group clean target."""
out: List[str] = []
if not targets:
return out
out.append(f'clean: clean-{basename}\n')
all_dsts = set()
for target in targets:
all_dsts.add(target.dst)
out.append(f'clean-{basename}:\n\trm -f ' +
' \\\n '.join('"' + dst + '"'
for dst in sorted(all_dsts)) + '\n')
return out
def _emit_group_efrocache_lines(targets: List[Target],
basename: str) -> List[str]:
"""Gen a group clean target."""
out: List[str] = []
if not targets:
return out
all_dsts = set()
for target in targets:
# We may need to make pipeline adjustments if/when we get filenames
# with spaces in them.
if ' ' in target.dst:
raise CleanError('FIXME: need to account for spaces in filename'
f' "{target.dst}".')
all_dsts.add(target.dst)
out.append('efrocache-list:\n\t@echo ' +
' \\\n '.join('"' + dst + '"'
for dst in sorted(all_dsts)) + '\n')
out.append(f'efrocache-build: resources-{basename}\n')
return out
# These paths need to be relative to the dir we're writing the Makefile to.
TOOLS_DIR = '../tools'
ROOT_DIR = '..'
@ -23,9 +95,9 @@ RES_DIR = '.'
RESIZE_CMD = os.path.join(TOOLS_DIR, 'pcommand resize_image')
def _add_windows_icon(targets: List[Dict]) -> None:
def _add_windows_icon(targets: List[Target], generic: bool, oculus: bool,
inputs: bool) -> None:
# Windows Icon
sizes = [256, 128, 96, 64, 48, 32, 16]
all_icons = []
for size in sizes:
@ -38,19 +110,23 @@ def _add_windows_icon(targets: List[Dict]) -> None:
str(size), '"' + src + '"', '"' + dst + '"'
])
all_icons.append(dst)
targets.append({'src': [src], 'dst': dst, 'cmd': cmd, 'mkdir': True})
if inputs:
targets.append(Target(src=[src], dst=dst, cmd=cmd, mkdir=True))
# Assemble all the bits we just made into .ico files.
for path in [
ROOT_DIR + '/ballisticacore-windows/Generic/BallisticaCore.ico',
ROOT_DIR + '/ballisticacore-windows/Oculus/BallisticaCore.ico',
for path, enable in [
(ROOT_DIR + '/ballisticacore-windows/Generic/BallisticaCore.ico',
generic),
(ROOT_DIR + '/ballisticacore-windows/Oculus/BallisticaCore.ico',
oculus),
]:
cmd = ('convert ' + ''.join([' "' + f + '"'
for f in all_icons]) + ' "' + path + '"')
targets.append({'src': all_icons, 'dst': path, 'cmd': cmd})
if enable:
targets.append(Target(src=all_icons, dst=path, cmd=cmd))
def _add_ios_app_icon(targets: List[Dict]) -> None:
def _add_ios_app_icon(targets: List[Target]) -> None:
sizes = [(20, 2), (20, 3), (29, 2), (29, 3), (40, 2), (40, 3), (60, 2),
(60, 3), (20, 1), (29, 1), (40, 1), (76, 1), (76, 2), (83.5, 2),
(1024, 1)]
@ -65,10 +141,10 @@ def _add_ios_app_icon(targets: List[Dict]) -> None:
[RESIZE_CMD,
str(res),
str(res), '"' + src + '"', '"' + dst + '"'])
targets.append({'src': [src], 'dst': dst, 'cmd': cmd})
targets.append(Target(src=[src], dst=dst, cmd=cmd))
def _add_macos_app_icon(targets: List[Dict]) -> None:
def _add_macos_app_icon(targets: List[Target]) -> None:
sizes = [(16, 1), (16, 2), (32, 1), (32, 2), (128, 1), (128, 2), (256, 1),
(256, 2), (512, 1), (512, 2)]
for size in sizes:
@ -86,10 +162,10 @@ def _add_macos_app_icon(targets: List[Dict]) -> None:
[RESIZE_CMD,
str(res),
str(res), '"' + src + '"', '"' + dst + '"'])
targets.append({'src': [src], 'dst': dst, 'cmd': cmd})
targets.append(Target(src=[src], dst=dst, cmd=cmd))
def _add_android_app_icon(targets: List[Dict],
def _add_android_app_icon(targets: List[Target],
src_name: str = 'icon_clipped.png',
variant_name: str = 'main') -> None:
sizes = [('mdpi', 48), ('hdpi', 72), ('xhdpi', 96), ('xxhdpi', 144),
@ -104,10 +180,10 @@ def _add_android_app_icon(targets: List[Dict],
[RESIZE_CMD,
str(res),
str(res), '"' + src + '"', '"' + dst + '"'])
targets.append({'src': [src], 'dst': dst, 'cmd': cmd, 'mkdir': True})
targets.append(Target(src=[src], dst=dst, cmd=cmd, mkdir=True))
def _add_android_app_icon_new(targets: List[Dict],
def _add_android_app_icon_new(targets: List[Target],
src_fg_name: str = 'icon_android_layered_fg.png',
src_bg_name: str = 'icon_android_layered_bg.png',
variant_name: str = 'main') -> None:
@ -125,7 +201,7 @@ def _add_android_app_icon_new(targets: List[Dict],
[RESIZE_CMD,
str(res),
str(res), '"' + src + '"', '"' + dst + '"'])
targets.append({'src': [src], 'dst': dst, 'cmd': cmd, 'mkdir': True})
targets.append(Target(src=[src], dst=dst, cmd=cmd, mkdir=True))
# Background component.
src = os.path.join(RES_DIR, 'src', 'icon', src_bg_name)
@ -136,22 +212,22 @@ def _add_android_app_icon_new(targets: List[Dict],
[RESIZE_CMD,
str(res),
str(res), '"' + src + '"', '"' + dst + '"'])
targets.append({'src': [src], 'dst': dst, 'cmd': cmd, 'mkdir': True})
targets.append(Target(src=[src], dst=dst, cmd=cmd, mkdir=True))
def _add_android_cardboard_app_icon(targets: List[Dict]) -> None:
def _add_android_cardboard_app_icon(targets: List[Target]) -> None:
_add_android_app_icon(targets=targets,
src_name='icon_clipped_vr.png',
variant_name='cardboard')
def _add_android_cardboard_app_icon_new(targets: List[Dict]) -> None:
def _add_android_cardboard_app_icon_new(targets: List[Target]) -> None:
_add_android_app_icon_new(targets=targets,
src_fg_name='icon_android_layered_fg_vr.png',
variant_name='cardboard')
def _add_android_tv_banner(targets: List[Dict]) -> None:
def _add_android_tv_banner(targets: List[Target]) -> None:
res = (320, 180)
src = os.path.join(RES_DIR, 'src', 'banner', 'banner_16x9.png')
dst = os.path.join(
@ -169,10 +245,10 @@ def _add_android_tv_banner(targets: List[Dict]) -> None:
str(res[0]),
str(res[1]), '"' + src + '"', '"' + dst + '"'
])
targets.append({'src': [src], 'dst': dst, 'cmd': cmd, 'mkdir': True})
targets.append(Target(src=[src], dst=dst, cmd=cmd, mkdir=True))
def _add_apple_tv_top_shelf(targets: List[Dict]) -> None:
def _add_apple_tv_top_shelf(targets: List[Target]) -> None:
instances = [('24x9', '', '', 1920, 720),
('29x9', ' Wide', '_wide', 2320, 720)]
for instance in instances:
@ -194,10 +270,10 @@ def _add_apple_tv_top_shelf(targets: List[Dict]) -> None:
str(res[0]),
str(res[1]), '"' + src + '"', '"' + dst + '"'
])
targets.append({'src': [src], 'dst': dst, 'cmd': cmd})
targets.append(Target(src=[src], dst=dst, cmd=cmd))
def _add_apple_tv_3d_icon(targets: List[Dict]) -> None:
def _add_apple_tv_3d_icon(targets: List[Target]) -> None:
res = (400, 240)
for layer in ['Layer1', 'Layer2', 'Layer3', 'Layer4', 'Layer5']:
for scale in [1, 2]:
@ -219,10 +295,10 @@ def _add_apple_tv_3d_icon(targets: List[Dict]) -> None:
str(res[0] * scale),
str(res[1] * scale), '"' + src + '"', '"' + dst + '"'
])
targets.append({'src': [src], 'dst': dst, 'cmd': cmd})
targets.append(Target(src=[src], dst=dst, cmd=cmd))
def _add_apple_tv_store_icon(targets: List[Dict]) -> None:
def _add_apple_tv_store_icon(targets: List[Target]) -> None:
res = (1280, 768)
for layer in ['Layer1', 'Layer2', 'Layer3', 'Layer4', 'Layer5']:
for scale in [1]:
@ -244,10 +320,10 @@ def _add_apple_tv_store_icon(targets: List[Dict]) -> None:
str(res[0] * scale),
str(res[1] * scale), '"' + src + '"', '"' + dst + '"'
])
targets.append({'src': [src], 'dst': dst, 'cmd': cmd})
targets.append(Target(src=[src], dst=dst, cmd=cmd))
def _add_google_vr_icon(targets: List[Dict]) -> None:
def _add_google_vr_icon(targets: List[Target]) -> None:
res = (512, 512)
for layer in ['vr_icon_background', 'vr_icon']:
src = os.path.join(RES_DIR, 'src', 'icon_googlevr', layer + '.png')
@ -266,71 +342,88 @@ def _add_google_vr_icon(targets: List[Dict]) -> None:
str(res[0]),
str(res[1]), '"' + src + '"', '"' + dst + '"'
])
targets.append({'src': [src], 'dst': dst, 'cmd': cmd, 'mkdir': True})
def _write_makefile(fname: str, targets: List[Dict], check: bool) -> None:
from efrotools import get_public_license
existing: Optional[str]
try:
with open(fname, 'r') as infile:
existing = infile.read()
except Exception:
existing = None
out = (get_public_license('makefile') +
f'\n# Generated by {__name__}; do not hand-edit.\n\n')
all_dsts = set()
for target in targets:
all_dsts.add(target['dst'])
out += 'all: resources\n\nresources: ' + ' \\\n '.join(
dst.replace(' ', '\\ ') for dst in sorted(all_dsts)) + '\n\n'
out += 'clean:\n\trm -f ' + ' \\\n '.join(
'"' + dst + '"' for dst in sorted(all_dsts)) + '\n\n'
var_num = 1
for target in targets:
if bool(False) and ' ' in target['dst']:
out += 'TARGET_' + str(var_num) + ' = ' + target['dst'].replace(
' ', '\\ ') + '\n${TARGET_' + str(var_num) + '}'
var_num += 1
else:
out += target['dst'].replace(' ', '\\ ')
out += ' : ' + ' '.join(s for s in target['src']) + (
('\n\t@mkdir -p "' +
os.path.dirname(target['dst']) + '"') if target.get(
'mkdir', False) else '') + '\n\t@' + target['cmd'] + '\n\n'
if out == existing:
print('Resources Makefile is up to date.')
else:
if check:
print(Clr.SRED + 'ERROR: file out of date: ' + fname + Clr.RST)
sys.exit(255)
print(Clr.SBLU + 'Generating: ' + fname + Clr.RST)
with open(fname, 'w') as outfile:
outfile.write(out)
targets.append(Target(src=[src], dst=dst, cmd=cmd, mkdir=True))
def update(projroot: str, check: bool) -> None:
"""main script entry point"""
# pylint: disable=too-many-locals
from efrotools import getconfig
# Operate out of root dist dir for consistency.
os.chdir(projroot)
targets: List[Dict] = []
public = getconfig(Path('.'))['public']
assert isinstance(public, bool)
_add_windows_icon(targets)
_add_ios_app_icon(targets)
_add_macos_app_icon(targets)
_add_android_app_icon(targets)
_add_android_app_icon_new(targets)
_add_android_cardboard_app_icon(targets)
_add_android_cardboard_app_icon_new(targets)
_add_android_tv_banner(targets)
_add_apple_tv_top_shelf(targets)
_add_apple_tv_3d_icon(targets)
_add_apple_tv_store_icon(targets)
_add_google_vr_icon(targets)
fname = 'resources/Makefile'
with open(fname) as infile:
original = infile.read()
lines = original.splitlines()
# Write makefile (or print if nothing has changed).
_write_makefile('resources/Makefile', targets, check)
auto_start_public = lines.index('#__AUTOGENERATED_BEGIN_PUBLIC__')
auto_end_public = lines.index('#__AUTOGENERATED_END_PUBLIC__')
auto_start_private = lines.index('#__AUTOGENERATED_BEGIN_PRIVATE__')
auto_end_private = lines.index('#__AUTOGENERATED_END_PRIVATE__')
# Public targets (full sources available in public)
targets: List[Target] = []
basename = 'public'
# Always generate the public section.
our_lines_public = (_emit_group_build_lines(targets, basename) +
_emit_group_clean_lines(targets, basename) +
[t.emit() for t in targets])
# Only generate the private section in the private repo.
if public:
our_lines_private = lines[auto_start_private + 1:auto_end_private]
else:
# Private targets (available in public through efrocache)
targets = []
basename = 'private'
_add_windows_icon(targets, generic=True, oculus=False, inputs=False)
our_lines_private_1 = (
_emit_group_build_lines(targets, basename) +
_emit_group_clean_lines(targets, basename) +
['#__EFROCACHE_TARGET__\n' + t.emit() for t in targets] +
_emit_group_efrocache_lines(targets, basename))
# Private-internal targets (not available at all in public)
targets = []
basename = 'private-internal'
_add_windows_icon(targets, generic=False, oculus=True, inputs=True)
_add_ios_app_icon(targets)
_add_macos_app_icon(targets)
_add_android_app_icon(targets)
_add_android_app_icon_new(targets)
_add_android_cardboard_app_icon(targets)
_add_android_cardboard_app_icon_new(targets)
_add_android_tv_banner(targets)
_add_apple_tv_top_shelf(targets)
_add_apple_tv_3d_icon(targets)
_add_apple_tv_store_icon(targets)
_add_google_vr_icon(targets)
our_lines_private_2 = (['#__PUBSYNC_STRIP_BEGIN__'] +
_emit_group_build_lines(targets, basename) +
_emit_group_clean_lines(targets, basename) +
[t.emit()
for t in targets] + ['#__PUBSYNC_STRIP_END__'])
our_lines_private = [''] + our_lines_private_1 + our_lines_private_2
filtered = (lines[:auto_start_public + 1] + our_lines_public +
lines[auto_end_public:auto_start_private + 1] +
our_lines_private + lines[auto_end_private:])
out = '\n'.join(filtered) + '\n'
if out == original:
print(f'{fname} is up to date.')
else:
if check:
raise CleanError(f"ERROR: file is out of date: '{fname}'.")
print(f'{Clr.SBLU}Updating: {fname}{Clr.RST}')
with open(fname, 'w') as outfile:
outfile.write(out)