Skip to content

Commit 460755f

Browse files
committed
Merge.
2 parents c24645b + aa6b3fe commit 460755f

File tree

47 files changed

+945
-509
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+945
-509
lines changed

apps/adm3adrv.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
; force clang version and not the asm.com version
1414

15-
#include "../include/cpm65.inc"
15+
#include "cpm65.inc"
1616
#include "driver.inc"
1717
#include "jumptables.inc"
1818

apps/build.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ def asm(self, name, src: Target = None, deps: Targets = []):
1111
outs=["=out.com"],
1212
deps=["tools/cpmemu", "apps+asm"] + deps,
1313
commands=[
14-
'chronic sh -c "{deps[0]} {deps[1]} -pA=$(dir {ins[0]}) -pB=$(dir {outs[0]})'
15-
+ ' a:$(notdir {ins[0]}) b:$(notdir {outs[0]}); test -f {outs[0]}"'
14+
'chronic sh -c "$[deps[0]] $[deps[1]] -pA=$(dir $[ins[0]]) -pB=$(dir $[outs[0]])'
15+
+ ' a:$(notdir $[ins[0]]) b:$(notdir $[outs[0]]); test -f $[outs[0]]"'
1616
],
1717
label="ASM",
1818
)
@@ -40,7 +40,7 @@ def asm(self, name, src: Target = None, deps: Targets = []):
4040
asm(
4141
name=prog,
4242
src=("./%s.asm" % prog),
43-
deps=["./cpm65.inc", "./drivers.inc"],
43+
deps=["./cpm65.inc", "./drivers.inc", "third_party/lib6502/6502data.h"],
4444
)
4545

4646
# Simple C programs.
@@ -59,7 +59,11 @@ def asm(self, name, src: Target = None, deps: Targets = []):
5959
"submit",
6060
"sys"
6161
]:
62-
llvmprogram(name=prog, srcs=["./%s.c" % prog], deps=["lib+cpm65"])
62+
llvmprogram(
63+
name=prog,
64+
srcs=["./%s.c" % prog],
65+
deps=["lib+cpm65", "third_party/lib6502/6502data.h"],
66+
)
6367

6468
# Source code.
6569

@@ -75,3 +79,11 @@ def asm(self, name, src: Target = None, deps: Targets = []):
7579
"include",
7680
],
7781
)
82+
83+
llvmprogram(
84+
name="scrvt100",
85+
srcs=["./scrvt100.S"],
86+
deps=[
87+
"include",
88+
],
89+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
; -------------------------------------------------------------------------
1010

1111
#include "zif.inc"
12+
13+
; force clang version and not the asm.com version
14+
1215
#include "cpm65.inc"
1316
#include "driver.inc"
1417
#include "jumptables.inc"

build.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,32 +55,25 @@
5555
"images/kim-1-sdcard.zip": "src/arch/kim-1+distro-sdcard",
5656
"images/kim-1-iec.zip": "src/arch/kim-1+distro-iec",
5757
},
58-
deps=[
59-
"tests"
60-
],
58+
deps=["tests"],
6159
)
6260

6361
export(
6462
name="mametest",
6563
deps=[
6664
"src/arch/bbcmicro+mametest",
6765
"src/arch/commodore+c64_mametest",
68-
6966
# MAME's ROM configuration is for the graphics keyboard, but MAME's
7067
# hardware emulates the business keyboard, so we can't interact with the
7168
# system.
72-
#"src/arch/commodore+pet4032_mametest",
73-
69+
# "src/arch/commodore+pet4032_mametest",
7470
# MAME's ROM configuration is for the business keyboard, but MAME's
7571
# hardware emulates the graphics keyboard...
76-
#"src/arch/commodore+pet8032_mametest",
77-
72+
# "src/arch/commodore+pet8032_mametest",
7873
# Works locally, but not on github CI.
79-
#"src/arch/apple2e+mametest",
80-
74+
# "src/arch/apple2e+mametest",
8175
# Fails everywhere.
82-
#"src/arch/atari800+mametest",
83-
76+
# "src/arch/atari800+mametest",
8477
"src/arch/oric+mametest",
8578
],
8679
)

build/_sandbox.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/python3
2+
3+
from os.path import *
4+
import argparse
5+
import os
6+
import shutil
7+
8+
9+
def main():
10+
parser = argparse.ArgumentParser()
11+
parser.add_argument("-s", "--sandbox")
12+
parser.add_argument("-v", "--verbose", action="store_true")
13+
parser.add_argument("-l", "--link", action="store_true")
14+
parser.add_argument("-e", "--export", action="store_true")
15+
parser.add_argument("files", nargs="*")
16+
args = parser.parse_args()
17+
18+
assert args.sandbox, "You must specify a sandbox directory"
19+
assert args.link ^ args.export, "You can't link and export at the same time"
20+
21+
if args.link:
22+
os.makedirs(args.sandbox, exist_ok=True)
23+
for f in args.files:
24+
sf = join(args.sandbox, f)
25+
if args.verbose:
26+
print("link", sf)
27+
os.makedirs(dirname(sf), exist_ok=True)
28+
try:
29+
os.link(abspath(f), sf)
30+
except PermissionError:
31+
shutil.copy(f, sf)
32+
33+
if args.export:
34+
for f in args.files:
35+
sf = join(args.sandbox, f)
36+
if args.verbose:
37+
print("export", sf)
38+
df = dirname(f)
39+
if df:
40+
os.makedirs(df, exist_ok=True)
41+
os.rename(sf, f)
42+
43+
44+
main()

build/_zip.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/python3
2+
3+
from os.path import *
4+
import argparse
5+
import os
6+
from zipfile import ZipFile
7+
8+
9+
def main():
10+
parser = argparse.ArgumentParser()
11+
parser.add_argument("-z", "--zipfile")
12+
parser.add_argument("-v", "--verbose", action="store_true")
13+
parser.add_argument("-f", "--file", nargs=2, action="append")
14+
args = parser.parse_args()
15+
16+
assert args.zipfile, "You must specify a zipfile to create"
17+
18+
with ZipFile(args.zipfile, mode="w") as zf:
19+
for zipname, filename in args.file:
20+
if args.verbose:
21+
print(filename, "->", zipname)
22+
zf.write(filename, arcname=zipname)
23+
24+
25+
main()

build/ab.mk

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,23 @@ endif
88

99
OBJ ?= .obj
1010
PYTHON ?= python3
11-
CC ?= gcc
12-
CXX ?= g++
13-
AR ?= ar
14-
CFLAGS ?= -g -Og
15-
LDFLAGS ?= -g
1611
PKG_CONFIG ?= pkg-config
1712
HOST_PKG_CONFIG ?= $(PKG_CONFIG)
1813
ECHO ?= echo
1914
CP ?= cp
2015

16+
HOSTCC ?= gcc
17+
HOSTCXX ?= g++
18+
HOSTAR ?= ar
19+
HOSTCFLAGS ?= -g -Og
20+
HOSTLDFLAGS ?= -g
21+
22+
CC ?= $(HOSTCC)
23+
CXX ?= $(HOSTCXX)
24+
AR ?= $(HOSTAR)
25+
CFLAGS ?= $(HOSTCFLAGS)
26+
LDFLAGS ?= $(HOSTLDFLAGS)
27+
2128
export PKG_CONFIG
2229
export HOST_PKG_CONFIG
2330

@@ -51,6 +58,8 @@ ifeq ($(OS), Windows_NT)
5158
endif
5259
EXT ?=
5360

61+
CWD=$(shell pwd)
62+
5463
ifeq ($(PROGRESSINFO),)
5564
# The first make invocation here has to have its output discarded or else it
5665
# produces spurious 'Leaving directory' messages... don't know why.

build/ab.py

Lines changed: 68 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
import string
1818
import sys
1919
import hashlib
20+
import re
21+
import ast
22+
from collections import namedtuple
2023

2124
verbose = False
2225
quiet = False
@@ -26,6 +29,22 @@
2629
materialisingStack = []
2730
defaultGlobals = {}
2831

32+
RE_FORMAT_SPEC = re.compile(
33+
r"(?:(?P<fill>[\s\S])?(?P<align>[<>=^]))?"
34+
r"(?P<sign>[- +])?"
35+
r"(?P<pos_zero>z)?"
36+
r"(?P<alt>#)?"
37+
r"(?P<zero_padding>0)?"
38+
r"(?P<width_str>\d+)?"
39+
r"(?P<grouping>[_,])?"
40+
r"(?:(?P<decimal>\.)(?P<precision_str>\d+))?"
41+
r"(?P<type>[bcdeEfFgGnosxX%])?"
42+
)
43+
44+
CommandFormatSpec = namedtuple(
45+
"CommandFormatSpec", RE_FORMAT_SPEC.groupindex.keys()
46+
)
47+
2948
sys.path += ["."]
3049
old_import = builtins.__import__
3150

@@ -80,6 +99,29 @@ def error(message):
8099
raise ABException(message)
81100

82101

102+
class BracketedFormatter(string.Formatter):
103+
def parse(self, format_string):
104+
while format_string:
105+
left, *right = format_string.split("$[", 1)
106+
if not right:
107+
yield (left, None, None, None)
108+
break
109+
right = right[0]
110+
111+
offset = len(right) + 1
112+
try:
113+
ast.parse(right)
114+
except SyntaxError as e:
115+
if not str(e).startswith("unmatched ']'"):
116+
raise e
117+
offset = e.offset
118+
119+
expr = right[0 : offset - 1]
120+
format_string = right[offset:]
121+
122+
yield (left if left else None, expr, None, None)
123+
124+
83125
def Rule(func):
84126
sig = inspect.signature(func)
85127

@@ -166,7 +208,7 @@ def __repr__(self):
166208
return f"Target('{self.name}')"
167209

168210
def templateexpand(selfi, s):
169-
class Formatter(string.Formatter):
211+
class Formatter(BracketedFormatter):
170212
def get_field(self, name, a1, a2):
171213
return (
172214
eval(name, selfi.callback.__globals__, selfi.args),
@@ -358,10 +400,11 @@ def convert(value, target):
358400
def _removesuffix(self, suffix):
359401
# suffix='' should not call self[:-0].
360402
if suffix and self.endswith(suffix):
361-
return self[:-len(suffix)]
403+
return self[: -len(suffix)]
362404
else:
363405
return self[:]
364406

407+
365408
def loadbuildfile(filename):
366409
filename = _removesuffix(filename.replace("/", "."), ".py")
367410
builtins.__import__(filename)
@@ -413,8 +456,9 @@ def emit(*args, into=None):
413456
outputFp.write(s)
414457

415458

416-
def emit_rule(name, ins, outs, cmds=[], label=None):
417-
fins = filenamesof(ins)
459+
def emit_rule(self, ins, outs, cmds=[], label=None):
460+
name = self.name
461+
fins = set(filenamesof(ins))
418462
fouts = filenamesof(outs)
419463
nonobjs = [f for f in fouts if not f.startswith("$(OBJ)")]
420464

@@ -440,8 +484,23 @@ def emit_rule(name, ins, outs, cmds=[], label=None):
440484

441485
if label:
442486
emit("\t$(hide)", "$(ECHO) $(PROGRESSINFO)", label, into=lines)
487+
488+
sandbox = join(self.dir, "sandbox")
489+
emit("\t$(hide)", f"rm -rf {sandbox}", into=lines)
490+
emit(
491+
"\t$(hide)",
492+
f"$(PYTHON) build/_sandbox.py --link -s {sandbox}",
493+
*fins,
494+
into=lines,
495+
)
443496
for c in cmds:
444-
emit("\t$(hide)", c, into=lines)
497+
emit(f"\t$(hide) cd {sandbox} && (", c, ")", into=lines)
498+
emit(
499+
"\t$(hide)",
500+
f"$(PYTHON) build/_sandbox.py --export -s {sandbox}",
501+
*fouts,
502+
into=lines,
503+
)
445504
else:
446505
assert len(cmds) == 0, "rules with no outputs cannot have commands"
447506
emit(name, ":", *fins, into=lines)
@@ -486,10 +545,10 @@ def simplerule(
486545
cs += [self.templateexpand(c)]
487546

488547
emit_rule(
489-
name=self.name,
548+
self=self,
490549
ins=ins + deps,
491550
outs=outs,
492-
label=self.templateexpand("{label} {name}") if label else None,
551+
label=self.templateexpand("$[label] $[name]") if label else None,
493552
cmds=cs,
494553
)
495554

@@ -514,7 +573,7 @@ def export(self, name=None, items: TargetsMap = {}, deps: Targets = []):
514573
cwd=self.cwd,
515574
ins=[srcs[0]],
516575
outs=[destf],
517-
commands=["$(CP) %s %s" % (srcs[0], destf)],
576+
commands=["$(CP) -H %s %s" % (srcs[0], destf)],
518577
label="",
519578
)
520579
subrule.materialise()
@@ -523,7 +582,7 @@ def export(self, name=None, items: TargetsMap = {}, deps: Targets = []):
523582
replaces=self,
524583
ins=outs + deps,
525584
outs=["=sentinel"],
526-
commands=["touch {outs[0]}"],
585+
commands=["touch $[outs[0]]"],
527586
label="EXPORT",
528587
)
529588

0 commit comments

Comments
 (0)