Files
VCCPlusOSS/tools/toolchain/prepare-coco-letters-project.py
Brian Holman 5534005799 Sync VCC Plus 3.7.1 build 67 source
Refresh reviewed MCP output export, four-drive owned playtests, bounded BASIC readiness, and pinned CMOC 0.1.101 source/patches. Preserve independent source-edition identity, empty libraries, notices and privacy boundaries.

Validated 74 export/privacy checks, pinned dependency sources, and an independent unsigned universal Release build. A subsequent documentation-only correction removes an excluded qualification link; all build inputs remain identical.
2026-11-17 08:42:27 -07:00

96 lines
4.9 KiB
Python

#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0-or-later
"""Prepare the real CoCo Letters Make project for local VCC Plus qualification.
This is a test fixture, not an application resource. The explicitly supplied
private standalone disk source and generated game stay in the chosen local
output folder and are never copied into the public toolchain or Git snapshot.
"""
import argparse
import hashlib
import json
from pathlib import Path
import shutil
import subprocess
import sys
ROOT = Path(__file__).resolve().parents[2]
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--output', type=Path, required=True)
parser.add_argument('--standalone-disk-source', type=Path, required=True)
args = parser.parse_args()
output = args.output.resolve()
if output.exists(): parser.error('Choose a fresh project directory')
if output == ROOT or ROOT / 'third_party' == output or ROOT / 'third_party' in output.parents:
parser.error('Choose local test storage outside the source snapshots')
record = json.loads((ROOT / 'third_party/manifests/cmoc.json').read_text())
expected = record['excludedFileSHA256']['src/stdlib/dskcon-standalone.c']
if hashlib.sha256(args.standalone_disk_source.read_bytes()).hexdigest() != expected:
parser.error('Private disk source does not match the reviewed CMOC release')
subprocess.run([sys.executable, ROOT / 'tools/toolchain/verify-sources.py'], check=True)
shutil.copytree(ROOT / 'third_party/examples/coco-letters', output)
# A grouped target makes the upstream two-output dictionary recipe safe when
# GNU Make runs in parallel. The vendored source itself remains unchanged.
upstream = (output / 'Makefile').read_text()
original = '$(DATA_FILENAME) $(WORD_LENGTH_FILENAME): $(BUILD_DATA)'
if upstream.count(original) != 1: raise SystemExit('Review updated dictionary generation rule')
upstream = upstream.replace('--allocate-before-dir','--allocate-forward')
upstream = upstream.replace(original, '$(DATA_FILENAME) $(WORD_LENGTH_FILENAME) &: $(BUILD_DATA)')
(output / 'Game.mk').write_text(upstream)
for name in ('decbfile', 'bcontrol', 'bsound'):
shutil.copytree(ROOT / 'third_party/cmoc-libraries' / name, output / 'libraries' / name)
(output / 'private').mkdir()
shutil.copyfile(args.standalone_disk_source, output / 'private/dskcon-standalone.c')
(output / 'Makefile').write_text('''# VCC Plus local qualification wrapper. GPL-3.0-or-later.
# Game.mk is the upstream game Makefile, with its dictionary recipe grouped.
override DECBFILE_LIB_DIR = libraries/decbfile
override BCONTROL_LIB_DIR = libraries/bcontrol
override BSOUND_LIB_DIR = libraries/bsound
include Game.mk
.DEFAULT_GOAL := all
INTERMEDIATE = --intermediate
LIBS += private/dskcon-standalone.o
$(BIN): private/dskcon-standalone.o
private/dskcon-standalone.o: private/dskcon-standalone.c
\t$(CMOC) --coco --intermediate -O2 -c -o $@ $<
libraries/decbfile/libdecbfile.a: $(wildcard libraries/decbfile/*.c libraries/decbfile/*.h) libraries/decbfile/Makefile
\t$(MAKE) -C libraries/decbfile libdecbfile.a
libraries/bcontrol/libbcontrol.a: $(wildcard libraries/bcontrol/*.c libraries/bcontrol/*.h) libraries/bcontrol/Makefile
\t$(MAKE) -C libraries/bcontrol libbcontrol.a
libraries/bsound/libbsound.a: $(wildcard libraries/bsound/*.c libraries/bsound/*.h) libraries/bsound/Makefile
\t$(MAKE) -C libraries/bsound libbsound.a
.PHONY: clean-libraries
clean: clean-libraries
clean-libraries:
\t$(MAKE) -C libraries/decbfile clean
\t$(MAKE) -C libraries/bcontrol clean
\t$(MAKE) -C libraries/bsound clean
\trm -f private/*.o private/*.s private/*.lst $(DSK)
''')
(output / 'vccplus-project.json').write_text(json.dumps({
'entrySource': 'main.c', 'makefile': 'Makefile', 'buildTarget': 'all',
'cleanTarget': 'clean', 'diskTarget': 'all', 'binary': 'letters.bin',
'diskImage': 'coco-letters-0.1.0.dsk', 'launchMode': 'disk',
'launchCommands': ['DOS'], 'jobs': 4,
'configurations': [{'name': 'Debug', 'makeArguments': ['INTERMEDIATE=--intermediate']},
{'name': 'Release', 'makeArguments': []}]
}, indent=2) + '\n')
(output / '.gitignore').write_text('private/\n*.bin\n*.dsk\n*.dat\n*.o\n*.s\n*.lst\n*.map\n*.link\n*.d\nword-length-index.c\n')
(output / 'VCC-QUALIFICATION.txt').write_text(
'Local qualification fixture. Includes separately supplied private disk source.\n'
'Do not distribute this folder as part of VCC Plus or its public toolchain.\n'
'Open the folder in C Development, build the all target, then mount/boot its disk.\n'
'Requires CoCo 3, at least 128 KB, floppy controller with Disk BASIC, and RGB video.\n'
'The original optimization flags are retained to fit its memory map.\n'
'Source breakpoints are available only where exact executable mappings are verified.\n')
print('Prepared local Make project:', output)
if __name__ == '__main__': main()