Enabling meta makefile generation in public

This commit is contained in:
Eric Froemling 2021-06-17 11:58:21 -05:00
parent 5a249c8751
commit bb9b4e3872
No known key found for this signature in database
GPG Key ID: 89C93F0F8D6D5A98
9 changed files with 232 additions and 162 deletions

View File

@ -3934,26 +3934,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/e4/48/e34135f62feb4a10de64d8538e51",
"build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/dc/39/6cd24b42d7422b7d9a2fa447862a",
"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/05/ef/7cb33caadbaab0e2ab29d3ee7a00",
"build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a0/ad/cb2d001e239543afbf467f40464b",
"build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/41/ee/f4680b160b298cc2e6cb35391ae9",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a4/5e/12f41945f5e2cd176d68b29e7ddd",
"build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/ad/55/1f53311aa1a7d3f8932c233f7661",
"build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/ee/9c/70939d269276c1e4baaa731b2085",
"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/08/8c/fa8ccd75a84b67813673b94b78c5",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/84/f0/014bd5e247c1026e1c60c6e3bffd",
"build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/3f/69/f5d28ae68a39151fbab5aa3660c5",
"build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/18/e2/59e8036c9d50ca3514b78f8220b0",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/52/09/e123601e2144a78a449191a4d0c1",
"build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/d7/cd/92d13bb751f17c305309e88b50ec",
"build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/a0/dd/b1849f66b671545f60c10ec80fa9",
"build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/93/cc/e902cdd0c4e8713de61196ec689c",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/d4/a1/d208849526332f137e15969be397",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/82/54/f9123180d8d879f2fa373b8011d0",
"build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/f9/17/59d683c5f01a79e5d49d0df61382",
"build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/a3/25/f3596d0fa91c153b0b98481a2311",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/0b/da/83b7d4976c3895e93722c4ad6c3f",
"build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/bd/a2/32f5ada6c76b65f95f12aef79e33",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a4/91/8d8a90a2ccd3aa7e51a62dcd7d7a",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/fb/4f/deef20e32ad1a92c79758cd4252d",
"build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/68/66/747283dbcdf848e0d62a73a82200",
"build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/89/73/9bcb6c8f0a60f6a9c2278c039f58",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/57/0d/9c965a910cfb6514771a0f585de4",
"build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/1d/61/2700666994aa453c37376288675e",
"build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/57/51/afe92d8021fc350f92da28391e46",
"build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/9c/27/5c3e3eef62e64063b9f217212f33",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/6d/e2/bdfb61495e49f5a949863f8cff3e",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/ab/23/4f9cfb8e92e80c18116c4e2dd934",
"build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/73/80/7661e8fc0a40f4d968e8aeabfeb3",
"build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/2d/e7/d028cd75c7d4b9e22919f24c8709",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/19/87/964975a139cee7e17a18d585d54c",
"build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/05/4a/99772931fdc72c7d3deba9e5502a",
"build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/9a/32/bda06e355384dac2fc81c8357812",
"build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/34/f6/b4db57144d47cfdb153dd4de6742",
"build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/53/44/cf4405c2ebe2695d55858129d3fe",
@ -3970,12 +3970,12 @@
"build/prefab/lib/mac_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/b5/5b/0390ee8916f97d302cde3ea356bc",
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/7a/ee/8249ede29becc0cd41178924b6dc",
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/c0/5f/e89024a87dd092f6e0cc43afb707",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/21/51/3409adb1fdf28fcdddbe773b30c2",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/53/2f/308dde889d52a233701c4be39614",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/a5/4a/4518e9c305fd9d728c820168c315",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/6e/4e/9ee2b13fd6a2cd7ce78c477f975e",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/d6/dc/5d52b6f04d92b511ac0afe12d340",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/5e/4c/a2e90eb8c97022c13c04a067b158",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/b5/22/b32bf978a3092c8e7570258b9be7",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/06/57/dccd7d81bee7fa516e6a2157d383"
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/c6/dd/e25f66a0c19c56cb179fddbbc263",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/e9/ca/f4c64ac2c2db2e2a2aa0348ca8ff",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/3a/02/c883737c57cb91244b6866edf587",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/8a/57/2dd931360573cc374d4d86e982b4",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/5e/0b/fcf14570433439d3580dccd96fe8",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/5f/f0/2829f0f7cf045e40ee996d45f5dc",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/cb/b3/ffd40d3ed27d544a6c3bf312a604",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/94/1c/e27d2ac86f2774380221b3ba6961"
}

View File

@ -634,6 +634,7 @@
<w>efro</w>
<w>efrocache</w>
<w>efrocachemap</w>
<w>efrocaching</w>
<w>efroemling</w>
<w>efrogradle</w>
<w>efrohack</w>
@ -1731,6 +1732,7 @@
<w>projdir</w>
<w>projectpath</w>
<w>projectroot</w>
<w>projpath</w>
<w>projroot</w>
<w>projs</w>
<w>promocode</w>

View File

@ -292,6 +292,7 @@
<w>edef</w>
<w>effmult</w>
<w>efro</w>
<w>efrocaching</w>
<w>efrohack</w>
<w>efrohome</w>
<w>elapsedf</w>
@ -785,6 +786,7 @@
<w>prog</w>
<w>proj</w>
<w>projdir</w>
<w>projpath</w>
<w>prolly</w>
<w>psmx</w>
<w>pspec</w>

View File

@ -10,9 +10,7 @@ all: resources
# This section is autogenerated; do not edit by hand.
#__AUTOGENERATED_PRIVATE_BEGIN__
resources: resources-private
resources-private: \
resources: \
../ballisticacore-windows/Generic/BallisticaCore.ico
clean: clean-private
@ -23,10 +21,9 @@ clean-private:
../ballisticacore-windows/Generic/BallisticaCore.ico : ../.efrocachemap
@cd .. && tools/pcommand efrocache_get resources/$@
efrocache-list:
@echo "../ballisticacore-windows/Generic/BallisticaCore.ico"
efrocache-build: resources-private
efrocache-build: resources
#__AUTOGENERATED_PRIVATE_END__

View File

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

View File

@ -1,18 +1,28 @@
# Released under the MIT License. See LICENSE for details.
#
# This file was generated by batools.metamakefile.
all: cpp_sources
PCOMMAND = ../../tools/pcommand
cpp_sources: ../ballistica/generated/python_embedded/binding.inc \
../ballistica/generated/python_embedded/bootstrap.inc
all: sources
clean:
@rm -rf ../ballistica/generated
rm -rf ../ballistica/generated ../../assets/src/ba_data/python/ba/_generated
# This section is autogenerated; do not edit by hand.
#__AUTOGENERATED_PUBLIC_BEGIN__
sources: \
../ballistica/generated/python_embedded/binding.inc \
../ballistica/generated/python_embedded/bootstrap.inc
../ballistica/generated/python_embedded/bootstrap.inc : bameta/python_embedded/bootstrap.py ../../tools/batools/meta.py
@../../tools/pcommand gen_flat_data_code $< $@ bootstrap_code
@$(PCOMMAND) gen_flat_data_code $< $@ bootstrap_code
../ballistica/generated/python_embedded/binding.inc : bameta/python_embedded/binding.py ../../tools/batools/meta.py
@../../tools/pcommand gen_binding_code $< $@
@$(PCOMMAND) gen_binding_code $< $@
#__AUTOGENERATED_PUBLIC_END__
# This section is autogenerated; do not edit by hand.
#__AUTOGENERATED_PRIVATE_BEGIN__
#__AUTOGENERATED_PRIVATE_END__

View File

@ -8,11 +8,14 @@ node types, etc).
from __future__ import annotations
import os
import sys
import subprocess
from pathlib import Path
from typing import TYPE_CHECKING
from dataclasses import dataclass
from efro.error import CleanError
from efro.terminal import Clr
from efrotools import getconfig
if TYPE_CHECKING:
from typing import Optional, Set, List, Dict, Any, Tuple
@ -25,120 +28,176 @@ OUT_DIR_CPP = '../ballistica/generated'
@dataclass
class Target:
"""A target to be added to the makefile."""
"""A target to be added to the Makefile."""
src: List[str]
dst: str
cmd: str
public: bool
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'
return out
def _emit_group_build_lines(targets: List[Target], basename: str) -> List[str]:
"""Gen a group build target."""
del basename # Unused.
out: List[str] = []
if not targets:
return out
all_dsts = set()
for target in targets:
all_dsts.add(target.dst)
out.append('sources: \\\n ' + ' \\\n '.join(
dst.replace(' ', '\\ ') 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
def _add_python_embedded_targets(targets: List[Target]) -> None:
pkg = 'bameta'
for fname in os.listdir(f'src/meta/{pkg}/python_embedded'):
if (not fname.endswith('.py') or fname == '__init__.py'
or 'flycheck' in fname):
continue
name = os.path.splitext(fname)[0]
src = [
f'{pkg}/python_embedded/{name}.py',
os.path.join(TOOLS_DIR, 'batools', 'meta.py')
]
dst = os.path.join(OUT_DIR_CPP, 'python_embedded', f'{name}.inc')
if name == 'binding':
targets.append(
Target(src=src,
dst=dst,
cmd='$(PCOMMAND) gen_binding_code $< $@'))
else:
targets.append(
Target(
src=src,
dst=dst,
cmd=f'$(PCOMMAND) gen_flat_data_code $< $@ {name}_code'))
def _add_python_embedded_targets_internal(targets: List[Target]) -> None:
pkg = 'bametainternal'
for fname in os.listdir(f'src/meta/{pkg}/python_embedded'):
if (not fname.endswith('.py') or fname == '__init__.py'
or 'flycheck' in fname):
continue
name = os.path.splitext(fname)[0]
src = [
f'{pkg}/python_embedded/{name}.py',
os.path.join(TOOLS_DIR, 'batoolsinternal', 'meta.py')
]
dst = os.path.join(OUT_DIR_CPP, 'python_embedded', f'{name}.inc')
targets.append(
Target(src=src,
dst=dst,
cmd='$(PCOMMAND) gen_encrypted_python_code $< $@'))
def _empty_line_if(condition: bool) -> List[str]:
return [''] if condition else []
def update(projroot: str, check: bool) -> None:
"""Update the project meta Makefile."""
from efrotools import get_public_license
# pylint: disable=too-many-locals
# Operate out of root dist dir for consistency.
os.chdir(projroot)
targets = _generate_targets()
public = getconfig(Path('.'))['public']
assert isinstance(public, bool)
# Write Makefile.
fname = 'src/meta/Makefile'
existing: Optional[str]
try:
with open(fname, 'r') as infile:
existing = infile.read()
except Exception:
existing = None
with open(fname) as infile:
original = infile.read()
lines = original.splitlines()
out = (get_public_license('makefile') +
f'\n#\n# This file was generated by {__name__}.\n\n')
public_dsts: Set[str] = set()
private_dsts: Set[str] = set()
for target in targets:
(public_dsts if target.public else private_dsts).add(target.dst)
out += 'all: cpp_sources\n'
out += ('\n'
'cpp_sources: ' + ' \\\n '.join(
dst.replace(' ', '\\ ') for dst in sorted(public_dsts)) + '\n')
out += ('\n'
'#__PUBSYNC_STRIP_BEGIN__\n'
'cpp_sources: ' + ' \\\n '.join(
dst.replace(' ', '\\ ') for dst in sorted(private_dsts)) +
'\n' + '#__PUBSYNC_STRIP_END__\n')
auto_start_public = lines.index('#__AUTOGENERATED_PUBLIC_BEGIN__')
auto_end_public = lines.index('#__AUTOGENERATED_PUBLIC_END__')
auto_start_private = lines.index('#__AUTOGENERATED_PRIVATE_BEGIN__')
auto_end_private = lines.index('#__AUTOGENERATED_PRIVATE_END__')
out += f'\nclean:\n\t@rm -rf {OUT_DIR_CPP}\n\n'
var_num = 1
# Public targets (full sources available in public)
targets: List[Target] = []
basename = 'public'
_add_python_embedded_targets(targets)
our_lines_public = (_empty_line_if(bool(targets)) +
_emit_group_build_lines(targets, basename) +
[t.emit() for t in targets])
for public in [True, False]:
if not public:
out += '#__PUBSYNC_STRIP_BEGIN__\n\n'
for target in targets:
if target.public != public:
continue
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.mkdir else '') + '\n\t@' + target.cmd + '\n\n'
if not public:
out += '#__PUBSYNC_STRIP_END__\n'
# Only rewrite the private section in the private repo; otherwise
# keep the existing one intact.
if public:
our_lines_private = lines[auto_start_private + 1:auto_end_private]
else:
# Private targets (available in public through efrocache)
targets = []
basename = 'private'
our_lines_private_1 = (
_empty_line_if(bool(targets)) +
_emit_group_build_lines(targets, basename) +
['#__EFROCACHE_TARGET__\n' + t.emit() for t in targets] +
_emit_group_efrocache_lines(targets, basename))
# NOTE: currently not efrocaching anything here; we'll need to
# add this makefile to the efrocache update if we ever do.
assert not targets
if out == existing:
print('Meta Makefile is up to date.')
# Private-internal targets (not available at all in public)
targets = []
basename = 'private-internal'
_add_python_embedded_targets_internal(targets)
our_lines_private_2 = (['#__PUBSYNC_STRIP_BEGIN__'] +
_empty_line_if(bool(targets)) +
_emit_group_build_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:
print(Clr.SRED + 'ERROR: file out of date: ' + fname + Clr.RST)
sys.exit(255)
print(Clr.SBLU + 'Generating: ' + fname + Clr.RST)
raise CleanError(f"ERROR: file is out of date: '{fname}'.")
print(f'{Clr.SBLU}Updating {fname} (and cleaning existing output).'
f'{Clr.RST}')
with open(fname, 'w') as outfile:
outfile.write(out)
def _generate_targets() -> List[Target]:
targets: List[Target] = []
# Manually define a few entries and automatically add one for each
# of our ba_embedded_*.py files.
for pkg, public in [('bameta', True), ('bametainternal', False)]:
entries: List[Tuple[str, str]] = []
for fname in os.listdir(f'src/meta/{pkg}/python_embedded'):
if (fname.endswith('.py') and fname != '__init__.py'
and 'flycheck' not in fname):
entries.append((os.path.splitext(fname)[0],
'BINDING' if fname == 'binding.py' else
'FLAT_DATA' if public else 'ENCRYPTED_DATA'))
# Generate targets from our entries.
for name, out_type in entries:
extra_sources: List[str] = []
if out_type == 'FLAT_DATA':
cmd = os.path.join(
TOOLS_DIR,
f'pcommand gen_flat_data_code $< $@ {name}_code')
extra_sources.append(os.path.join(TOOLS_DIR,
'batools/meta.py'))
elif out_type == 'BINDING':
cmd = os.path.join(TOOLS_DIR,
'pcommand gen_binding_code $< $@')
extra_sources.append(os.path.join(TOOLS_DIR,
'batools/meta.py'))
else:
cmd = os.path.join(TOOLS_DIR,
'pcommand gen_encrypted_python_code $< $@')
extra_sources.append(
os.path.join(TOOLS_DIR, 'batoolsinternal/meta.py'))
targets.append(
Target(src=[f'{pkg}/python_embedded/{name}.py'] +
extra_sources,
dst=os.path.join(OUT_DIR_CPP, 'python_embedded',
f'{name}.inc'),
cmd=cmd,
public=public))
return targets
# Also clean existing meta output every time the Makefile changes;
# this should minimize the chance of orphan outputs hanging around
# causing trouble.
subprocess.run(['make', 'clean'], cwd='src/meta', check=True)

View File

@ -630,15 +630,12 @@ class Updater:
sys.exit(255)
def _update_meta_makefile(self) -> None:
# FIXME: should support running this in public too.
if not self._public:
try:
subprocess.run(['tools/pcommand', 'update_meta_makefile'] +
self._checkarglist,
check=True)
except Exception as exc:
raise CleanError(
'Error checking/updating meta Makefile.') from exc
try:
subprocess.run(['tools/pcommand', 'update_meta_makefile'] +
self._checkarglist,
check=True)
except Exception as exc:
raise CleanError('Error checking/updating meta Makefile.') from exc
def _update_resources_makefile(self) -> None:
try:

View File

@ -21,31 +21,31 @@ if TYPE_CHECKING:
@dataclass
class Target:
"""Info about a makefile target."""
"""A target to be added to the Makefile."""
src: List[str]
dst: str
cmd: str
mkdir: bool = False
def emit(self) -> str:
"""Gen a makefile target."""
"""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'
'"') if self.mkdir else '') + '\n\t@' + self.cmd + '\n'
return out
def _emit_group_build_lines(targets: List[Target], basename: str) -> List[str]:
"""Gen a group build target."""
del basename # Unused.
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(
out.append('resources: \\\n ' + ' \\\n '.join(
dst.replace(' ', '\\ ') for dst in sorted(all_dsts)) + '\n')
return out
@ -65,8 +65,7 @@ def _emit_group_clean_lines(targets: List[Target], basename: str) -> List[str]:
return out
def _emit_group_efrocache_lines(targets: List[Target],
basename: str) -> List[str]:
def _emit_group_efrocache_lines(targets: List[Target]) -> List[str]:
"""Gen a group clean target."""
out: List[str] = []
if not targets:
@ -83,7 +82,7 @@ def _emit_group_efrocache_lines(targets: List[Target],
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')
out.append('efrocache-build: resources\n')
return out
@ -345,6 +344,10 @@ def _add_google_vr_icon(targets: List[Target]) -> None:
targets.append(Target(src=[src], dst=dst, cmd=cmd, mkdir=True))
def _empty_line_if(condition: bool) -> List[str]:
return [''] if condition else []
def update(projroot: str, check: bool) -> None:
"""main script entry point"""
# pylint: disable=too-many-locals
@ -370,13 +373,13 @@ def update(projroot: str, check: bool) -> None:
# 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) +
our_lines_public = (_empty_line_if(bool(targets)) +
_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.
# Only rewrite the private section in the private repo; otherwise
# keep the existing one intact.
if public:
our_lines_private = lines[auto_start_private + 1:auto_end_private]
else:
@ -384,12 +387,12 @@ def update(projroot: str, check: bool) -> None:
targets = []
basename = 'private'
_add_windows_icon(targets, generic=True, oculus=False, inputs=False)
our_lines_private_1 = (
_empty_line_if(bool(targets)) +
_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))
['#__EFROCACHE_TARGET__\n' + t.emit()
for t in targets] + _emit_group_efrocache_lines(targets))
# Private-internal targets (not available at all in public)
targets = []
@ -406,13 +409,13 @@ def update(projroot: str, check: bool) -> None:
_add_apple_tv_3d_icon(targets)
_add_apple_tv_store_icon(targets)
_add_google_vr_icon(targets)
our_lines_private_2 = (['#__PUBSYNC_STRIP_BEGIN__'] +
_empty_line_if(bool(targets)) +
_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
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] +