Make build with the new ab --- but the tests fail.

This commit is contained in:
David Given
2025-03-17 22:33:54 +01:00
parent 0f763fe06b
commit 15a69f6dcb
57 changed files with 220 additions and 148 deletions

View File

@@ -1,6 +1,6 @@
#include "lib/core/globals.h"
#include "lib/decoders/decoders.h"
#include "aeslanier.h"
#include "arch/aeslanier/aeslanier.h"
#include "lib/core/crc.h"
#include "lib/data/fluxmap.h"
#include "lib/data/fluxmapreader.h"

View File

@@ -1,6 +1,6 @@
#include "lib/core/globals.h"
#include "lib/decoders/decoders.h"
#include "agat.h"
#include "arch/agat/agat.h"
#include "lib/core/bytes.h"
#include "fmt/format.h"

View File

@@ -1,6 +1,6 @@
#include "lib/core/globals.h"
#include "lib/decoders/decoders.h"
#include "agat.h"
#include "arch/agat/agat.h"
#include "lib/core/crc.h"
#include "lib/data/fluxmap.h"
#include "lib/data/fluxmapreader.h"

View File

@@ -2,7 +2,7 @@
#include "lib/core/utils.h"
#include "lib/decoders/decoders.h"
#include "lib/encoders/encoders.h"
#include "agat.h"
#include "arch/agat/agat.h"
#include "lib/core/crc.h"
#include "lib/data/image.h"
#include "lib/data/layout.h"

View File

@@ -1,6 +1,6 @@
#include "lib/core/globals.h"
#include "lib/decoders/decoders.h"
#include "amiga.h"
#include "arch/amiga/amiga.h"
#include "lib/core/bytes.h"
#include "fmt/format.h"

View File

@@ -5,7 +5,7 @@
#include "protocol.h"
#include "lib/decoders/decoders.h"
#include "lib/data/sector.h"
#include "amiga.h"
#include "arch/amiga/amiga.h"
#include "lib/core/bytes.h"
#include "fmt/format.h"
#include "lib/decoders/decoders.pb.h"

View File

@@ -2,7 +2,7 @@
#include "lib/core/utils.h"
#include "lib/decoders/decoders.h"
#include "lib/encoders/encoders.h"
#include "amiga.h"
#include "arch/amiga/amiga.h"
#include "lib/core/crc.h"
#include "lib/data/image.h"
#include "arch/amiga/amiga.pb.h"

View File

@@ -5,7 +5,7 @@
#include "protocol.h"
#include "lib/decoders/decoders.h"
#include "lib/data/sector.h"
#include "apple2.h"
#include "arch/apple2/apple2.h"
#include "arch/apple2/apple2.pb.h"
#include "lib/decoders/decoders.pb.h"
#include "lib/core/bytes.h"

View File

@@ -18,7 +18,7 @@
#include "arch/rolandd20/rolandd20.h"
#include "arch/smaky6/smaky6.h"
#include "arch/tartu/tartu.h"
#include "arch/tids990/tids990.h"
#include "arch/tids990/tids990"
#include "arch/victor9k/victor9k.h"
#include "arch/zilogmcz/zilogmcz.h"
#include "arch/arch.h"

View File

@@ -4,7 +4,7 @@
#include "lib/data/fluxpattern.h"
#include "lib/decoders/decoders.h"
#include "lib/encoders/encoders.h"
#include "brother.h"
#include "arch/brother/brother.h"
#include "lib/data/sector.h"
#include "lib/core/bytes.h"
#include "lib/core/crc.h"

View File

@@ -2,7 +2,7 @@
#include "lib/core/utils.h"
#include "lib/decoders/decoders.h"
#include "lib/encoders/encoders.h"
#include "brother.h"
#include "arch/brother/brother.h"
#include "lib/core/crc.h"
#include "lib/data/image.h"
#include "arch/brother/brother.pb.h"

View File

@@ -46,6 +46,7 @@ cxxlibrary(
"./apple2/encoder.cc",
"./brother/decoder.cc",
"./brother/encoder.cc",
"./brother/header_gcr.h",
"./c64/c64.cc",
"./c64/decoder.cc",
"./c64/encoder.cc",
@@ -55,6 +56,7 @@ cxxlibrary(
"./ibm/encoder.cc",
"./macintosh/decoder.cc",
"./macintosh/encoder.cc",
"./macintosh/data_gcr.h",
"./micropolis/decoder.cc",
"./micropolis/encoder.cc",
"./mx/decoder.cc",
@@ -76,7 +78,7 @@ cxxlibrary(
"arch/apple2/apple2.h": "./apple2/apple2.h",
"arch/amiga/amiga.h": "./amiga/amiga.h",
"arch/smaky6/smaky6.h": "./smaky6/smaky6.h",
"arch/tids990/tids990.h": "./tids990/tids990.h",
"arch/tids990/tids990": "./tids990/tids990.h",
"arch/zilogmcz/zilogmcz.h": "./zilogmcz/zilogmcz.h",
"arch/amiga/amiga.h": "./amiga/amiga.h",
"arch/f85/data_gcr.h": "./f85/data_gcr.h",

View File

@@ -1,5 +1,5 @@
#include "lib/core/globals.h"
#include "c64.h"
#include "arch/c64/c64.h"
/*
* Track Sectors/track # Sectors Storage in Bytes Clock rate

View File

@@ -5,7 +5,7 @@
#include "protocol.h"
#include "lib/decoders/decoders.h"
#include "lib/data/sector.h"
#include "c64.h"
#include "arch/c64/c64.h"
#include "lib/core/crc.h"
#include "lib/core/bytes.h"
#include "fmt/format.h"

View File

@@ -2,7 +2,7 @@
#include "lib/core/utils.h"
#include "lib/decoders/decoders.h"
#include "lib/encoders/encoders.h"
#include "c64.h"
#include "arch/c64/c64.h"
#include "lib/core/crc.h"
#include "lib/data/sector.h"
#include "lib/data/image.h"

View File

@@ -5,7 +5,7 @@
#include "protocol.h"
#include "lib/decoders/decoders.h"
#include "lib/data/sector.h"
#include "f85.h"
#include "arch/f85/f85.h"
#include "lib/core/crc.h"
#include "lib/core/bytes.h"
#include "fmt/format.h"

View File

@@ -5,7 +5,7 @@
#include "protocol.h"
#include "lib/decoders/decoders.h"
#include "lib/data/sector.h"
#include "fb100.h"
#include "arch/fb100/fb100.h"
#include "lib/core/crc.h"
#include "lib/core/bytes.h"
#include "lib/decoders/rawbits.h"

View File

@@ -1,6 +1,6 @@
#include "lib/core/globals.h"
#include "lib/decoders/decoders.h"
#include "ibm.h"
#include "arch/ibm/ibm.h"
#include "lib/core/crc.h"
#include "lib/data/fluxmap.h"
#include "lib/data/fluxmapreader.h"

View File

@@ -2,7 +2,7 @@
#include "lib/config/config.h"
#include "lib/decoders/decoders.h"
#include "lib/encoders/encoders.h"
#include "ibm.h"
#include "arch/ibm/ibm.h"
#include "lib/core/crc.h"
#include "lib/data/image.h"
#include "arch/ibm/ibm.pb.h"

View File

@@ -5,7 +5,7 @@
#include "protocol.h"
#include "lib/decoders/decoders.h"
#include "lib/data/sector.h"
#include "macintosh.h"
#include "arch/macintosh/macintosh.h"
#include "lib/core/bytes.h"
#include "fmt/format.h"
#include <string.h>

View File

@@ -2,7 +2,7 @@
#include "lib/core/utils.h"
#include "lib/decoders/decoders.h"
#include "lib/encoders/encoders.h"
#include "macintosh.h"
#include "arch/macintosh/macintosh.h"
#include "lib/core/crc.h"
#include "lib/data/image.h"
#include "fmt/format.h"

View File

@@ -4,7 +4,7 @@
#include "lib/data/fluxpattern.h"
#include "lib/decoders/decoders.h"
#include "lib/data/sector.h"
#include "micropolis.h"
#include "arch/micropolis/micropolis.h"
#include "lib/core/bytes.h"
#include "fmt/format.h"
#include "lib/decoders/decoders.pb.h"

View File

@@ -1,5 +1,5 @@
#include "lib/core/globals.h"
#include "micropolis.h"
#include "arch/micropolis/micropolis.h"
#include "lib/data/sector.h"
#include "lib/decoders/decoders.h"
#include "lib/encoders/encoders.h"

View File

@@ -17,7 +17,7 @@
#include "lib/data/fluxpattern.h"
#include "lib/decoders/decoders.h"
#include "lib/data/sector.h"
#include "northstar.h"
#include "arch/northstar/northstar.h"
#include "lib/core/bytes.h"
#include "lib/decoders/decoders.pb.h"
#include "fmt/format.h"

View File

@@ -1,5 +1,5 @@
#include "lib/core/globals.h"
#include "northstar.h"
#include "arch/northstar/northstar.h"
#include "lib/data/sector.h"
#include "lib/core/bytes.h"
#include "lib/decoders/decoders.h"

View File

@@ -6,7 +6,7 @@
#include "lib/data/fluxpattern.h"
#include "lib/data/sector.h"
#include "lib/core/bytes.h"
#include "rolandd20.h"
#include "arch/rolandd20/rolandd20.h"
#include <string.h>
/* Sector header record:

View File

@@ -5,7 +5,7 @@
#include "protocol.h"
#include "lib/decoders/decoders.h"
#include "lib/data/sector.h"
#include "smaky6.h"
#include "arch/smaky6/smaky6.h"
#include "lib/core/bytes.h"
#include "lib/core/crc.h"
#include "fmt/format.h"

View File

@@ -1,7 +1,7 @@
#include "lib/core/globals.h"
#include "lib/decoders/decoders.h"
#include "lib/encoders/encoders.h"
#include "arch/tids990/tids990.h"
#include "arch/tids990/tids990"
#include "lib/core/crc.h"
#include "lib/data/fluxmap.h"
#include "lib/data/fluxmapreader.h"

View File

@@ -1,7 +1,7 @@
#include "lib/core/globals.h"
#include "lib/decoders/decoders.h"
#include "lib/encoders/encoders.h"
#include "tids990.h"
#include "arch/tids990/tids990"
#include "lib/core/crc.h"
#include "lib/data/image.h"
#include "arch/tids990/tids990.pb.h"

View File

@@ -5,7 +5,7 @@
#include "protocol.h"
#include "lib/decoders/decoders.h"
#include "lib/data/sector.h"
#include "victor9k.h"
#include "arch/victor9k/victor9k.h"
#include "lib/core/crc.h"
#include "lib/core/bytes.h"
#include "fmt/format.h"

View File

@@ -2,7 +2,7 @@
#include "lib/core/utils.h"
#include "lib/decoders/decoders.h"
#include "lib/encoders/encoders.h"
#include "victor9k.h"
#include "arch/victor9k/victor9k.h"
#include "lib/core/crc.h"
#include "lib/data/sector.h"
#include "lib/data/image.h"

View File

@@ -5,7 +5,7 @@
#include "protocol.h"
#include "lib/decoders/decoders.h"
#include "lib/data/sector.h"
#include "zilogmcz.h"
#include "arch/zilogmcz/zilogmcz.h"
#include "lib/core/bytes.h"
#include "lib/core/crc.h"
#include "fmt/format.h"

View File

@@ -79,15 +79,15 @@ else:
ins=["src+fluxengine"],
deps=["scripts/encodedecodetest.sh"],
commands=[
"{deps[0]} "
"$[deps[0]] "
+ c[0]
+ " "
+ format
+ " {ins[0]} '"
+ " $[ins[0]] '"
+ c[1]
+ "' '"
+ c[2]
+ "' $(dir {outs[0]}) > /dev/null"
+ "' $(dir $[outs[0]]) > /dev/null"
],
label="CORPUSTEST",
)

View File

@@ -51,6 +51,8 @@ ifeq ($(OS), Windows_NT)
endif
EXT ?=
CWD=$(shell pwd)
ifeq ($(PROGRESSINFO),)
# The first make invocation here has to have its output discarded or else it
# produces spurious 'Leaving directory' messages... don't know why.

View File

@@ -17,6 +17,9 @@ import inspect
import string
import sys
import hashlib
import re
import ast
from collections import namedtuple
verbose = False
quiet = False
@@ -26,6 +29,22 @@ unmaterialisedTargets = {} # dict, not set, to get consistent ordering
materialisingStack = []
defaultGlobals = {}
RE_FORMAT_SPEC = re.compile(
r"(?:(?P<fill>[\s\S])?(?P<align>[<>=^]))?"
r"(?P<sign>[- +])?"
r"(?P<pos_zero>z)?"
r"(?P<alt>#)?"
r"(?P<zero_padding>0)?"
r"(?P<width_str>\d+)?"
r"(?P<grouping>[_,])?"
r"(?:(?P<decimal>\.)(?P<precision_str>\d+))?"
r"(?P<type>[bcdeEfFgGnosxX%])?"
)
CommandFormatSpec = namedtuple(
"CommandFormatSpec", RE_FORMAT_SPEC.groupindex.keys()
)
sys.path += ["."]
old_import = builtins.__import__
@@ -80,6 +99,29 @@ def error(message):
raise ABException(message)
class BracketedFormatter(string.Formatter):
def parse(self, format_string):
while format_string:
left, *right = format_string.split("$[", 1)
if not right:
yield (left, None, None, None)
break
right = right[0]
offset = len(right) + 1
try:
ast.parse(right)
except SyntaxError as e:
if not str(e).startswith("unmatched ']'"):
raise e
offset = e.offset
expr = right[0 : offset - 1]
format_string = right[offset:]
yield (left if left else None, expr, None, None)
def Rule(func):
sig = inspect.signature(func)
@@ -115,7 +157,7 @@ def Rule(func):
t.callback = func
t.traits.add(func.__name__)
if "args" in kwargs:
t.args |= kwargs["args"]
t.args.update(kwargs["args"])
del kwargs["args"]
if "traits" in kwargs:
t.traits |= kwargs["traits"]
@@ -166,7 +208,7 @@ class Target:
return f"Target('{self.name}')"
def templateexpand(selfi, s):
class Formatter(string.Formatter):
class Formatter(BracketedFormatter):
def get_field(self, name, a1, a2):
return (
eval(name, selfi.callback.__globals__, selfi.args),
@@ -355,8 +397,16 @@ class TargetsMap:
return output
def _removesuffix(self, suffix):
# suffix='' should not call self[:-0].
if suffix and self.endswith(suffix):
return self[: -len(suffix)]
else:
return self[:]
def loadbuildfile(filename):
filename = filename.replace("/", ".").removesuffix(".py")
filename = _removesuffix(filename.replace("/", "."), ".py")
builtins.__import__(filename)
@@ -406,8 +456,9 @@ def emit(*args, into=None):
outputFp.write(s)
def emit_rule(name, ins, outs, cmds=[], label=None):
fins = filenamesof(ins)
def emit_rule(self, ins, outs, cmds=[], label=None):
name = self.name
fins = set(filenamesof(ins))
fouts = filenamesof(outs)
nonobjs = [f for f in fouts if not f.startswith("$(OBJ)")]
@@ -433,8 +484,23 @@ def emit_rule(name, ins, outs, cmds=[], label=None):
if label:
emit("\t$(hide)", "$(ECHO) $(PROGRESSINFO)", label, into=lines)
sandbox = join(self.dir, "sandbox")
emit("\t$(hide)", f"rm -rf {sandbox}", into=lines)
emit(
"\t$(hide)",
f"$(PYTHON) build/_sandbox.py --link -s {sandbox}",
*fins,
into=lines,
)
for c in cmds:
emit("\t$(hide)", c, into=lines)
emit(f"\t$(hide) cd {sandbox} && (", c, ")", into=lines)
emit(
"\t$(hide)",
f"$(PYTHON) build/_sandbox.py --export -s {sandbox}",
*fouts,
into=lines,
)
else:
assert len(cmds) == 0, "rules with no outputs cannot have commands"
emit(name, ":", *fins, into=lines)
@@ -479,10 +545,10 @@ def simplerule(
cs += [self.templateexpand(c)]
emit_rule(
name=self.name,
self=self,
ins=ins + deps,
outs=outs,
label=self.templateexpand("{label} {name}") if label else None,
label=self.templateexpand("$[label] $[name]") if label else None,
cmds=cs,
)
@@ -507,7 +573,7 @@ def export(self, name=None, items: TargetsMap = {}, deps: Targets = []):
cwd=self.cwd,
ins=[srcs[0]],
outs=[destf],
commands=["$(CP) %s %s" % (srcs[0], destf)],
commands=["$(CP) -H %s %s" % (srcs[0], destf)],
label="",
)
subrule.materialise()
@@ -516,7 +582,7 @@ def export(self, name=None, items: TargetsMap = {}, deps: Targets = []):
replaces=self,
ins=outs + deps,
outs=["=sentinel"],
commands=["touch {outs[0]}"],
commands=["touch $[outs[0]]"],
label="EXPORT",
)

View File

@@ -20,6 +20,7 @@ endif
"""
)
def _combine(list1, list2):
r = list(list1)
for i in list2:
@@ -27,6 +28,7 @@ def _combine(list1, list2):
r.append(i)
return r
def _indirect(deps, name):
r = []
for d in deps:
@@ -61,7 +63,7 @@ def cfile(
deps: Targets = None,
cflags=[],
suffix=".o",
commands=["$(CC) -c -o {outs[0]} {ins[0]} $(CFLAGS) {cflags}"],
commands=["$(CC) -c -o $[outs[0]] $[ins[0]] $(CFLAGS) $[cflags]"],
label="CC",
):
cfileimpl(self, name, srcs, deps, suffix, commands, label, cflags)
@@ -75,33 +77,49 @@ def cxxfile(
deps: Targets = None,
cflags=[],
suffix=".o",
commands=["$(CXX) -c -o {outs[0]} {ins[0]} $(CFLAGS) {cflags}"],
commands=["$(CXX) -c -o $[outs[0]] $[ins[0]] $(CFLAGS) $[cflags]"],
label="CXX",
):
cfileimpl(self, name, srcs, deps, suffix, commands, label, cflags)
def _removeprefix(self, prefix):
if self.startswith(prefix):
return self[len(prefix) :]
else:
return self[:]
def _isSourceFile(f):
return (
f.endswith(".c")
or f.endswith(".cc")
or f.endswith(".cpp")
or f.endswith(".S")
or f.endswith(".s")
or f.endswith(".m")
or f.endswith(".mm")
)
def findsources(name, srcs, deps, cflags, filerule, cwd):
for f in filenamesof(srcs):
if f.endswith(".h") or f.endswith(".hh"):
if not _isSourceFile(f):
cflags = cflags + [f"-I{dirname(f)}"]
deps = deps + [f]
objs = []
for s in flatten(srcs):
objs += [
filerule(
name=join(name, f.removeprefix("$(OBJ)/")),
name=join(name, _removeprefix(f, "$(OBJ)/")),
srcs=[f],
deps=deps,
cflags=sorted(set(cflags)),
cwd=cwd,
)
for f in filenamesof([s])
if f.endswith(".c")
or f.endswith(".cc")
or f.endswith(".cpp")
or f.endswith(".S")
or f.endswith(".s")
if _isSourceFile(f)
]
if any(f.endswith(".o") for f in filenamesof([s])):
objs += [s]
@@ -140,7 +158,7 @@ def libraryimpl(
len(s) == 1
), "the target of a header must return exactly one file"
cs += ["$(CP) {ins[" + str(i) + "]} {outs[" + str(i) + "]}"]
cs += [f"$(CP) $[ins[{i}]] $[outs[{i}]]"]
outs += ["=" + dest]
i = i + 1
@@ -194,7 +212,7 @@ def clibrary(
caller_ldflags=[],
cflags=[],
ldflags=[],
commands=["rm -f {outs[0]} && $(AR) cqs {outs[0]} {ins}"],
commands=["rm -f $[outs[0]] && $(AR) cqs $[outs[0]] $[ins]"],
label="LIB",
cfilerule=cfile,
):
@@ -225,7 +243,7 @@ def cxxlibrary(
caller_ldflags=[],
cflags=[],
ldflags=[],
commands=["rm -f {outs[0]} && $(AR) cqs {outs[0]} {ins}"],
commands=["rm -f $[outs[0]] && $(AR) cqs $[outs[0]] $[ins]"],
label="CXXLIB",
cxxfilerule=cxxfile,
):
@@ -290,7 +308,7 @@ def cprogram(
cflags=[],
ldflags=[],
commands=[
"$(CC) -o {outs[0]} $(STARTGROUP) {ins} {ldflags} $(LDFLAGS) $(ENDGROUP)"
"$(CC) -o $[outs[0]] $(STARTGROUP) $[ins] $[ldflags] $(LDFLAGS) $(ENDGROUP)"
],
label="CLINK",
cfilerule=cfile,
@@ -317,7 +335,7 @@ def cxxprogram(
cflags=[],
ldflags=[],
commands=[
"$(CXX) -o {outs[0]} $(STARTGROUP) {ins} {ldflags} $(LDFLAGS) $(ENDGROUP)"
"$(CXX) -o $[outs[0]] $(STARTGROUP) $[ins] $[ldflags] $(LDFLAGS) $(ENDGROUP)"
],
label="CXXLINK",
cxxfilerule=cxxfile,

View File

@@ -50,7 +50,7 @@ def _package(self, name, package, fallback, pkgconfig):
assert (
fallback
), f"Required package '{package}' not installed when materialising target '{name}'"
), f"Required package '{package}' not installed when materialising target '$[name]'"
if "cheader_deps" in fallback.args:
self.args["cheader_deps"] = fallback.args["cheader_deps"]

View File

@@ -31,7 +31,7 @@ def proto(self, name, srcs: Targets = [], deps: Targets = []):
]
)
dirs = sorted({"{dir}/" + dirname(f) for f in filenamesof(srcs)})
dirs = sorted({"$[dir]/" + dirname(f) for f in filenamesof(srcs)})
simplerule(
replaces=self,
ins=srcs,
@@ -39,9 +39,9 @@ def proto(self, name, srcs: Targets = [], deps: Targets = []):
deps=protodeps,
commands=(
["mkdir -p " + (" ".join(dirs))]
+ [f"$(CP) {f} {{dir}}/{f}" for f in filenamesof(srcs)]
+ [f"$(CP) {f} $[dir]/{f}" for f in filenamesof(srcs)]
+ [
"cd {dir} && "
"cd $[dir] && "
+ (
" ".join(
[
@@ -55,7 +55,7 @@ def proto(self, name, srcs: Targets = [], deps: Targets = []):
if descriptorlist
else []
)
+ ["{ins}"]
+ ["$[ins]"]
)
)
]
@@ -96,7 +96,7 @@ def protocc(self, name, srcs: Targets = [], deps: Targets = []):
outs=outs,
deps=protodeps,
commands=[
"cd {dir} && "
"cd $[dir] && "
+ (
" ".join(
[
@@ -146,8 +146,8 @@ def protojava(self, name, srcs: Targets = [], deps: Targets = []):
outs=[f"={self.localname}.srcjar"],
deps=srcs + deps,
commands=[
"mkdir -p {dir}/srcs",
"cd {dir} && "
"mkdir -p $[dir]/srcs",
"cd $[dir]/srcs && "
+ (
" ".join(
[
@@ -159,7 +159,7 @@ def protojava(self, name, srcs: Targets = [], deps: Targets = []):
+ protos
)
),
"$(JAR) cf {outs[0]} -C {dir}/srcs .",
"$(JAR) cf $[outs[0]] -C $[dir]/srcs .",
],
traits={"srcjar"},
label="PROTOJAVA",

View File

@@ -58,7 +58,7 @@ def objectify(self, name, src: Target, symbol):
replaces=self,
ins=["build/_objectify.py", src],
outs=[f"={basename(filenameof(src))}.h"],
commands=["$(PYTHON) {ins[0]} {ins[1]} " + symbol + " > {outs}"],
commands=["$(PYTHON) $[ins[0]] $[ins[1]] " + symbol + " > $[outs]"],
label="OBJECTIFY",
)
@@ -78,7 +78,7 @@ def test(
replaces=self,
ins=[command],
outs=["=sentinel"],
commands=["{ins[0]}", "touch {outs}"],
commands=["$[ins[0]]", "touch $[outs]"],
deps=deps,
label=label,
)
@@ -87,7 +87,7 @@ def test(
replaces=self,
ins=ins,
outs=["=sentinel"],
commands=commands + ["touch {outs}"],
commands=commands + ["touch $[outs]"],
deps=deps,
label=label,
)

View File

@@ -3,14 +3,6 @@ from build.ab import (
simplerule,
TargetsMap,
filenameof,
emit,
)
emit(
"""
ZIP ?= zip
ZIPNOTE ?= zipnote
"""
)
@@ -18,20 +10,18 @@ ZIPNOTE ?= zipnote
def zip(
self, name, flags="", items: TargetsMap = {}, extension="zip", label="ZIP"
):
cs = ["rm -f {outs[0]}"]
cs = ["$(PYTHON) build/_zip.py -z $[outs]"]
ins = []
for k, v in items.items():
cs += [
"cat %s | $(ZIP) -q %s {outs[0]} -" % (filenameof(v), flags),
"printf '@ -\\n@=%s\\n' | $(ZIPNOTE) -w {outs[0]}" % k,
]
cs += [f"-f {k} {filenameof(v)}"]
ins += [v]
simplerule(
replaces=self,
ins=ins,
deps=["build/_zip.py"],
outs=[f"={self.localname}." + extension],
commands=cs,
commands=[" ".join(cs)],
label=label,
)

View File

@@ -4,17 +4,28 @@ clibrary(
name="hfsutils",
srcs=[
"./libhfs/block.c",
"./libhfs/block.h",
"./libhfs/btree.c",
"./libhfs/btree.h",
"./libhfs/data.c",
"./libhfs/data.h",
"./libhfs/file.c",
"./libhfs/file.h",
"./libhfs/hfs.c",
"./libhfs/hfs.h",
"./libhfs/low.c",
"./libhfs/low.h",
"./libhfs/medium.c",
"./libhfs/medium.h",
"./libhfs/memcmp.c",
"./libhfs/node.c",
"./libhfs/node.h",
"./libhfs/record.c",
"./libhfs/record.h",
"./libhfs/version.c",
"./libhfs/version.h",
"./libhfs/volume.c",
"./libhfs/volume.h",
],
hdrs={
"apple.h": "./libhfs/apple.h",

View File

@@ -19,8 +19,8 @@ simplerule(
ins=["./icon.png"],
outs=["=fluxengine.iconset"],
commands=[
"mkdir -p {outs[0]}",
"sips -z 64 64 {ins[0]} --out {outs[0]}/icon_32x32@2x.png > /dev/null",
"mkdir -p $[outs[0]]",
"sips -z 64 64 $[ins[0]] --out $[outs[0]]/icon_32x32@2x.png > /dev/null",
],
label="ICONSET",
)
@@ -29,7 +29,7 @@ simplerule(
name="fluxengine_icns",
ins=[".+fluxengine_iconset"],
outs=["=fluxengine.icns"],
commands=["iconutil -c icns -o {outs[0]} {ins[0]}"],
commands=["iconutil -c icns -o $[outs[0]] $[ins[0]]"],
label="ICONUTIL",
)
@@ -37,6 +37,6 @@ simplerule(
name="fluxengine_ico",
ins=["./icon.png"],
outs=["=fluxengine.ico"],
commands=["png2ico {outs[0]} {ins[0]}"],
commands=["png2ico $[outs[0]] $[ins[0]]"],
label="MAKEICON",
)

View File

@@ -1,7 +1,7 @@
#include "lib/core/globals.h"
#include "protocol.h"
#include "lib/core/bytes.h"
#include "greaseweazle.h"
#include "lib/external/greaseweazle.h"
Bytes fluxEngineToGreaseweazle(const Bytes& fldata, nanoseconds_t clock)
{

View File

@@ -4,8 +4,8 @@
#include "lib/core/bytes.h"
#include "lib/usb/usb.pb.h"
#include "lib/core/utils.h"
#include "serial.h"
#include "usb.h"
#include "lib/usb/serial.h"
#include "lib/usb/usb.h"
#include "lib/data/fluxmapreader.h"
#include <unistd.h>

View File

@@ -16,6 +16,6 @@ cxxlibrary(
"./usb.cc",
"./usbfinder.cc",
],
hdrs={"lib/usb/usb.h": "./usb.h", "lib/usb/usbfinder.h": "./usbfinder.h"},
hdrs={"lib/usb/usb.h": "./usb.h", "lib/usb/usbfinder.h": "./usbfinder.h", "lib/usb/serial.h": "./serial.h"},
deps=["lib/core", "lib/config", "lib/external", "dep/libusbp", "+protocol"],
)

View File

@@ -1,5 +1,5 @@
#include "lib/core/globals.h"
#include "usb.h"
#include "lib/usb/usb.h"
#include "protocol.h"
#include "lib/data/fluxmap.h"
#include "lib/core/bytes.h"

View File

@@ -4,8 +4,8 @@
#include "lib/core/bytes.h"
#include "lib/usb/usb.pb.h"
#include "lib/external/greaseweazle.h"
#include "serial.h"
#include "usb.h"
#include "lib/usb/serial.h"
#include "lib/usb/usb.h"
#include <unistd.h>
static const char* gw_error(int e)

View File

@@ -1,9 +1,9 @@
#include "lib/core/globals.h"
#include "usb.h"
#include "lib/usb/usb.h"
#include "protocol.h"
#include "lib/data/fluxmap.h"
#include "lib/core/bytes.h"
#include "serial.h"
#include "lib/usb/serial.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>

View File

@@ -1,14 +1,14 @@
#include "lib/core/globals.h"
#include "lib/config/config.h"
#include "lib/config/flags.h"
#include "usb.h"
#include "lib/usb/usb.h"
#include "libusbp_config.h"
#include "libusbp.hpp"
#include "protocol.h"
#include "lib/data/fluxmap.h"
#include "lib/core/bytes.h"
#include "lib/config/proto.h"
#include "usbfinder.h"
#include "lib/usb/usbfinder.h"
#include "lib/core/logger.h"
#include "lib/external/applesauce.h"
#include "lib/external/greaseweazle.h"

View File

@@ -1,8 +1,8 @@
#include "lib/core/globals.h"
#include "lib/config/flags.h"
#include "usb.h"
#include "lib/usb/usb.h"
#include "lib/core/bytes.h"
#include "usbfinder.h"
#include "lib/usb/usbfinder.h"
#include "lib/external/applesauce.h"
#include "lib/external/greaseweazle.h"
#include "protocol.h"

View File

@@ -1,6 +1,6 @@
#include "lib/core/globals.h"
#include "lib/config/config.h"
#include "vfs.h"
#include "lib/vfs/vfs.h"
#include "lib/config/proto.h"
#include "lib/config/layout.pb.h"
#include "lib/data/layout.h"

View File

@@ -30,7 +30,7 @@ def protoencode_single(self, name, srcs: Targets, proto, symbol):
ins=srcs,
outs=[f"={name}.cc"],
deps=[r],
commands=["{deps[0]} {ins} {outs} " + symbol],
commands=["$[deps[0]] $[ins] $[outs] " + symbol],
label="PROTOENCODE",
)
@@ -51,7 +51,7 @@ def protoencode(self, name, proto, srcs: TargetsMap, symbol):
replaces=self,
ins=encoded,
outs=[f"={name}.cc"],
commands=["cat {ins} > {outs}"],
commands=["cat $[ins] > $[outs]"],
label="CONCAT",
)

View File

@@ -4,6 +4,7 @@ cxxprogram(
name="fluxengine",
srcs=[
"./fluxengine.cc",
"./fluxengine.h",
"./fe-analysedriveresponse.cc",
"./fe-analyselayout.cc",
"./fe-format.cc",
@@ -27,6 +28,7 @@ cxxprogram(
"./fe-testvoltages.cc",
"./fe-write.cc",
"./fileutils.cc",
"./fileutils.h",
],
cflags=["-I."],
deps=[

View File

@@ -47,7 +47,7 @@ simplerule(
deps=["scripts/mktable.sh"],
outs=["=table.cc"],
commands=[
"sh scripts/mktable.sh formats " + (" ".join(formats)) + " > {outs}"
"sh scripts/mktable.sh formats " + (" ".join(formats)) + " > $[outs]"
],
label="MKTABLE",
)
@@ -72,7 +72,7 @@ export(
name=f"{f}_doc",
ins=["scripts+mkdoc"],
outs=[f"=disk-{f}.md"],
commands=["{ins[0]} " + f + " | tr -d '\\r' > {outs[0]}"],
commands=["$[ins[0]] " + f + " | tr -d '\\r' > $[outs[0]]"],
label="MKDOC",
)
for f in formats

View File

@@ -1,5 +1,6 @@
from build.ab import emit, simplerule
from build.c import cxxprogram
from glob import glob
import config
emit(
@@ -23,35 +24,15 @@ if config.windows:
ins=["./windres.rc"],
outs=["=rc.o"],
deps=["./manifest.xml", "extras+fluxengine_ico"],
commands=["$(WINDRES) {ins[0]} {outs[0]}"],
commands=["$(WINDRES) $[ins[0]] $[outs[0]]"],
label="WINDRES",
)
]
cxxprogram(
name="gui",
srcs=[
"./browserpanel.cc",
"./context.cc",
"./context.h",
"./customstatusbar.cc",
"./explorerpanel.cc",
"./filesystemmodel.cc",
"./fileviewerwindow.cc",
"./fluxviewercontrol.cc",
"./fluxviewerwindow.cc",
"./histogramviewer.cc",
"./iconbutton.cc",
"./idlepanel.cc",
"./imagerpanel.cc",
"./jobqueue.cc",
"./main.cc",
"./mainwindow.cc",
"./texteditorwindow.cc",
"./textviewerwindow.cc",
"./visualisationcontrol.cc",
"./layout.cpp",
]
srcs=glob("*.c", root_dir="src/gui") +
glob("*.h", root_dir="src/gui")
+ extrasrcs,
cflags=["$(WX_CFLAGS)"],
ldflags=["$(WX_LDFLAGS)"],
@@ -82,7 +63,7 @@ if config.osx:
ins=[".+fluxengine_app"],
outs=["=FluxEngine.pkg"],
commands=[
"pkgbuild --quiet --install-location /Applications --component {ins[0]} {outs[0]}"
"pkgbuild --quiet --install-location /Applications --component $[ins[0]] $[outs[0]]"
],
label="PKGBUILD",
)
@@ -96,21 +77,21 @@ if config.osx:
],
outs=["=FluxEngine.app"],
commands=[
"rm -rf {outs[0]}",
"cp -a {ins[2]} {outs[0]}",
"touch {outs[0]}",
"cp {ins[0]} {outs[0]}/Contents/MacOS/fluxengine-gui",
"mkdir -p {outs[0]}/Contents/Resources",
"cp {ins[1]} {outs[0]}/Contents/Resources/FluxEngine.icns",
"dylibbundler -of -x {outs[0]}/Contents/MacOS/fluxengine-gui -b -d {outs[0]}/Contents/libs -cd > /dev/null",
"cp $$(brew --prefix wxwidgets)/README.md {outs[0]}/Contents/libs/wxWidgets.md",
"cp $$(brew --prefix protobuf)/LICENSE {outs[0]}/Contents/libs/protobuf.txt",
"cp $$(brew --prefix fmt)/LICENSE* {outs[0]}/Contents/libs/fmt.rst",
"cp $$(brew --prefix libpng)/LICENSE {outs[0]}/Contents/libs/libpng.txt",
"cp $$(brew --prefix libjpeg)/README {outs[0]}/Contents/libs/libjpeg.txt",
"cp $$(brew --prefix abseil)/LICENSE {outs[0]}/Contents/libs/abseil.txt",
"cp $$(brew --prefix libtiff)/LICENSE.md {outs[0]}/Contents/libs/libtiff.txt",
"cp $$(brew --prefix zstd)/LICENSE {outs[0]}/Contents/libs/zstd.txt",
"rm -rf $[outs[0]]",
"cp -a $[ins[2]] $[outs[0]]",
"touch $[outs[0]]",
"cp $[ins[0]] $[outs[0]]/Contents/MacOS/fluxengine-gui",
"mkdir -p $[outs[0]]/Contents/Resources",
"cp $[ins[1]] $[outs[0]]/Contents/Resources/FluxEngine.icns",
"dylibbundler -of -x $[outs[0]]/Contents/MacOS/fluxengine-gui -b -d $[outs[0]]/Contents/libs -cd > /dev/null",
"cp $$(brew --prefix wxwidgets)/README.md $[outs[0]]/Contents/libs/wxWidgets.md",
"cp $$(brew --prefix protobuf)/LICENSE $[outs[0]]/Contents/libs/protobuf.txt",
"cp $$(brew --prefix fmt)/LICENSE* $[outs[0]]/Contents/libs/fmt.rst",
"cp $$(brew --prefix libpng)/LICENSE $[outs[0]]/Contents/libs/libpng.txt",
"cp $$(brew --prefix libjpeg)/README $[outs[0]]/Contents/libs/libjpeg.txt",
"cp $$(brew --prefix abseil)/LICENSE $[outs[0]]/Contents/libs/abseil.txt",
"cp $$(brew --prefix libtiff)/LICENSE.md $[outs[0]]/Contents/libs/libtiff.txt",
"cp $$(brew --prefix zstd)/LICENSE $[outs[0]]/Contents/libs/zstd.txt",
],
label="MKAPP",
)

View File

@@ -16,7 +16,7 @@ simplerule(
commands=[
"sh scripts/mktable.sh drivetypes "
+ (" ".join(drivetypes))
+ " > {outs}"
+ " > $[outs]"
],
label="MKTABLE",
)

View File

@@ -83,7 +83,7 @@ export(
name=f"{n}_test",
command=cxxprogram(
name=f"{n}_test_exe",
srcs=[f"./{n}.cc"],
srcs=[f"./{n}.cc", "./tests.h"],
deps=[
"lib/external+fl2_proto_lib",
"+fmt_lib",