This repository has been archived by the owner on Jan 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
units.lua
161 lines (139 loc) · 3.51 KB
/
units.lua
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
-- Based on FGlob, this globber supports filtering into multiple configurations, and does so in the order specified
local function MGlob(args)
-- Use the regular glob to fetch the file list.
local files = Glob(args)
local pats = {}
local result = {}
-- Construct a mapping from { Pattern = ..., Configs = ... }
-- to { Pattern = { { Config = ... }, ... } } with new arrays per config that can be
-- embedded in the source result.
for _, fitem in ipairs(args.Filters) do
local tabs = {}
for _, citem in ipairs(fitem.Configs) do
local tab = { Config = assert(citem) }
tabs[#tabs + 1] = tab
end
pats[assert(fitem.Pattern)] = tabs
result[#result + 1] = tabs
end
-- Traverse all files and see if they match any configuration filters. If
-- they do, stick them in matching list. Otherwise, just keep them in the
-- main list. This has the effect of returning an array such as this:
-- {
-- { "foo.c"; Config = "abc-*-*" },
-- { "bar.c"; Config = "*-*-def" },
-- "baz.c", "qux.m"
-- }
for _, f in ipairs(files) do
local filtered = false
for _, fitem in ipairs(args.Filters) do
if f:match(fitem.Pattern) then
filtered = true
for _, litem in ipairs(pats[fitem.Pattern]) do
litem[#litem + 1] = f
end
break
end
end
if not filtered then
result[#result + 1] = f
end
end
return result
end
StaticLibrary
{
Name = "streamer",
SubConfig = { "ee"; Config = "ps2-*-*-*" },
Sources = {
{
MGlob {
Dir = "src/streamer",
Extensions = { ".c" },
Filters = {
{ Pattern = "/win32/", Configs = { "win*-*-*-*" } },
{ Pattern = "/ee/", Configs = { "ps2-*-*-*" } },
{ Pattern = "/unix/", Configs = { "macosx-*-*-*", "linux-*-*-*" } },
{ Pattern = "/iop/", Configs = {"ps2-*-*-iop*" } },
{ Pattern = "/backend/", Configs = { "win*-*-*-*", "macosx-*-*-*", "linux-*-*-*" } }
}
},
MGlob {
Dir = "src/contrib/fastlz",
Extensions = { ".c" },
Filters = {
{ Pattern = "/", Configs = { "win*-*-*-*", "macosx-*-*-*", "linux-*-*-*" } }
}
}
}
},
Propagate = {
Libs = {
{ "pthread"; Config = "linux-*-*-*" },
{ "pthread"; Config = "macosx-*-*-*" },
},
},
Env = {
CPPPATH = {
"src/contrib"
},
},
}
-- PS2 IOP streaming IRX
SharedLibrary
{
Name = "iopstrmr",
SubConfig = "iop",
Config = "ps2-*-*-*",
Sources = {
FGlob {
Dir = "src/streamer/backend",
Extensions = { ".c" },
Filters = {
{ Pattern = "/iop/"; Config = "ps2-*-*-*" }
}
},
Glob {
Dir = "src/contrib/fastlz", Extensions = { ".c" }
}
},
Env = {
CPPPATH = {
"src/contrib"
}
},
}
StaticLibrary
{
Name = "contrib.sha1",
Sources = {
Glob { Dir = "src/contrib/sha1", Extensions = { ".c" } }
}
}
-------------
-- Samples --
-------------
Program
{
Name = "sample.simple",
Sources = {
Glob { Dir = "src/samples/simple", Extensions = { ".c" } }
},
Env = {
CPPPATH = "src"
},
Depends = { "streamer", "contrib.fastlz" }
}
Program
{
Name = "sample.hash",
Sources = {
Glob { Dir = "src/samples/hash", Extensions = { ".c" } }
},
Env = {
CPPPATH = { "src", "src/contrib" }
},
Depends = { "streamer", "contrib.fastlz", "contrib.sha1" }
}
Default "streamer"
Default "iopstrmr"