Skip to content

Commit

Permalink
Update ab.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgiven committed Nov 10, 2024
1 parent 6c6f185 commit a9fb272
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
14 changes: 11 additions & 3 deletions build/ab.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@

class PathFinderImpl(PathFinder):
def find_spec(self, fullname, path, target=None):
if not path:
# The second test here is needed for Python 3.9.
if not path or not path[0]:
path = ["."]
if len(path) != 1:
return None
Expand Down Expand Up @@ -114,7 +115,7 @@ def wrapper(*, name=None, replaces=None, **kwargs):
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"]
Expand Down Expand Up @@ -354,8 +355,15 @@ def convert(value, target):
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)


Expand Down
10 changes: 9 additions & 1 deletion build/c.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ def cxxfile(
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 findsources(name, srcs, deps, cflags, filerule, cwd):
for f in filenamesof(srcs):
if f.endswith(".h") or f.endswith(".hh"):
Expand All @@ -90,7 +96,7 @@ def findsources(name, srcs, deps, cflags, filerule, cwd):
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)),
Expand All @@ -102,6 +108,8 @@ def findsources(name, srcs, deps, cflags, filerule, cwd):
or f.endswith(".cpp")
or f.endswith(".S")
or f.endswith(".s")
or f.endswith(".m")
or f.endswith(".mm")
]
if any(f.endswith(".o") for f in filenamesof([s])):
objs += [s]
Expand Down
2 changes: 1 addition & 1 deletion src/arch/snes/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
items={
"0:ccp.sys@sr": "src+ccp",
"0:bdos.sys@sr": "src/bdos",
"0:cls.com": "apps+cls",
"0:cls.com": "apps+cls"
}
| MINIMAL_APPS
| MINIMAL_APPS_SRCS
Expand Down

0 comments on commit a9fb272

Please sign in to comment.