35 lines
1.8 KiB
Python
35 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
"""Build the reviewed CoCo Letters source and a DOS-bootable DSK without downloading."""
|
|
import argparse
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import shutil
|
|
import subprocess
|
|
ROOT=Path(__file__).resolve().parents[2]
|
|
|
|
def main():
|
|
parser=argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('--toolchain', type=Path, required=True)
|
|
parser.add_argument('--output', type=Path, default=ROOT/'.build/coco-letters')
|
|
args=parser.parse_args()
|
|
prefix=args.toolchain.resolve();out=args.output.resolve()
|
|
features=json.loads((prefix/'VCC-toolchain.json').read_text())
|
|
if not features['standaloneDisk']:
|
|
raise SystemExit('CoCo Letters requires the optional private standalone disk source; see docs/development/TOOLCHAIN.md')
|
|
if out.exists(): raise SystemExit('Choose a fresh --output directory')
|
|
out.mkdir(parents=True)
|
|
env=dict(os.environ, PATH=str(prefix/'bin')+os.pathsep+os.environ['PATH'])
|
|
env.setdefault('DEVELOPER_DIR','/Applications/Xcode.app/Contents/Developer')
|
|
for name in ('decbfile','bcontrol','bsound'):
|
|
shutil.copytree(ROOT/'third_party/cmoc-libraries'/name,out/name)
|
|
subprocess.run(['make','-j4',f'lib{name}.a'],cwd=out/name,env=env,check=True)
|
|
game=out/'game';shutil.copytree(ROOT/'third_party/examples/coco-letters',game)
|
|
# Upstream generates two outputs in one rule; serial make avoids duplicate writes.
|
|
subprocess.run(['make','DECBFILE_LIB_DIR=../decbfile','BCONTROL_LIB_DIR=../bcontrol','BSOUND_LIB_DIR=../bsound'],cwd=game,env=env,check=True)
|
|
disk=game/'coco-letters-0.1.0.dsk'
|
|
if disk.stat().st_size!=35*18*256: raise SystemExit('Unexpected disk geometry')
|
|
print(f'Built disk: {disk}\nMount in FD0, select RGB, then type DOS. Requires CoCo 3, 128 KB or more.')
|
|
if __name__=='__main__': main()
|