-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathack.py
More file actions
85 lines (70 loc) · 2.29 KB
/
ack.py
File metadata and controls
85 lines (70 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from build.ab import targetof, filenameof, filenamesof
from build.toolchain import Toolchain
from build.c import cfile, clibrary, cprogram
from build.utils import collectattrs
from os.path import *
class AckToolchain(Toolchain):
PREFIX = "ACK"
CC = [
"ACKDIR=$(INSDIR) $(INSDIR)/bin/ack $(ACKCFLAGS) $[cflags] -m$[plat] -c -o $[outs[0]] $[ins]"
]
CLINK = [
"ACKDIR=$(INSDIR) $(INSDIR)/bin/ack -m$[plat] -.$[lang] -o $[outs[0]] $[ins] $(ACKLDFLAGS) $[ldflags]"
]
AR = ["$(INSDIR)/bin/aal qc $[outs] $[ins]"]
def is_source_file(f):
return (
f.endswith(".c")
or f.endswith(".S")
or f.endswith(".s")
or f.endswith(".e")
or f.endswith(".mod")
or f.endswith(".bas")
or f.endswith(".p")
)
def ackcfile(name, plat=None, **kwargs):
assert plat
kwargs["deps"] = kwargs.get("deps", []) + [
f"plat/{plat}+tools",
f"plat/{plat}/include",
"+common",
]
kwargs["args"] = kwargs.get("args", {}) | {"plat": plat}
return cfile(name=name, toolchain=AckToolchain, **kwargs)
def ackclibrary(name, plat=None, **kwargs):
assert plat
kwargs["deps"] = kwargs.get("deps", []) + [
f"plat/{plat}+tools",
f"plat/{plat}/include",
"+common",
]
kwargs["args"] = kwargs.get("args", {}) | {"plat": plat}
return clibrary(name=name, toolchain=AckToolchain, **kwargs)
def ackcprogram(name, lang, plat=None, **kwargs):
assert plat
kwargs["deps"] = kwargs.get("deps", []) + [
f"plat/{plat}+all",
"+common",
]
kwargs["args"] = kwargs.get("args", {}) | {"plat": plat, "lang": lang}
return cprogram(name=name, toolchain=AckToolchain, **kwargs)
def _combine(list1, list2):
r = list(list1)
for i in list2:
if i not in r:
r.append(i)
return r
def _indirect(deps, name):
r = []
for d in deps:
r = _combine(r, d.args.get(name, [d]))
return r
def exportheaders(lib, prefix=""):
lib = targetof(lib)
hdrdeps = collectattrs(targets=[lib], name="cheader_deps")
hh = {}
for h in collectattrs(targets=hdrdeps, name="cheader_files"):
for f in filenamesof([h]):
r = relpath(f, h.dir)
hh[join(prefix, r)] = f
return hh