aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/buildgen/plugins/expand_filegroups.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/buildgen/plugins/expand_filegroups.py')
-rwxr-xr-xtools/buildgen/plugins/expand_filegroups.py60
1 files changed, 55 insertions, 5 deletions
diff --git a/tools/buildgen/plugins/expand_filegroups.py b/tools/buildgen/plugins/expand_filegroups.py
index 14cb616027..477e69c869 100755
--- a/tools/buildgen/plugins/expand_filegroups.py
+++ b/tools/buildgen/plugins/expand_filegroups.py
@@ -42,7 +42,22 @@ def excluded(filename, exclude_res):
return False
-FILEGROUP_LISTS = ['src', 'headers', 'public_headers']
+def uniquify(lst):
+ out = []
+ for el in lst:
+ if el not in out:
+ out.append(el)
+ return out
+
+
+FILEGROUP_LISTS = ['src', 'headers', 'public_headers', 'deps']
+
+
+FILEGROUP_DEFAULTS = {
+ 'language': 'c',
+ 'boringssl': False,
+ 'zlib': False,
+}
def mako_plugin(dictionary):
@@ -54,10 +69,19 @@ def mako_plugin(dictionary):
"""
libs = dictionary.get('libs')
+ targets = dictionary.get('targets')
filegroups_list = dictionary.get('filegroups')
filegroups = {}
- todo = filegroups_list[:]
+ for fg in filegroups_list:
+ for lst in FILEGROUP_LISTS:
+ fg[lst] = fg.get(lst, [])
+ fg['own_%s' % lst] = list(fg[lst])
+ for attr, val in FILEGROUP_DEFAULTS.iteritems():
+ if attr not in fg:
+ fg[attr] = val
+
+ todo = list(filegroups_list)
skips = 0
while todo:
@@ -91,14 +115,40 @@ def mako_plugin(dictionary):
cur['plugins'] = plugins
filegroups[cur['name']] = cur
+ # build reverse dependency map
+ things = {}
+ for thing in dictionary['libs'] + dictionary['targets'] + dictionary['filegroups']:
+ things[thing['name']] = thing
+ thing['used_by'] = []
+ thing_deps = lambda t: t.get('uses', []) + t.get('filegroups', []) + t.get('deps', [])
+ for thing in things.itervalues():
+ done = set()
+ todo = thing_deps(thing)
+ while todo:
+ cur = todo[0]
+ todo = todo[1:]
+ if cur in done: continue
+ things[cur]['used_by'].append(thing['name'])
+ todo.extend(thing_deps(things[cur]))
+ done.add(cur)
+
# the above expansion can introduce duplicate filenames: contract them here
for fg in filegroups.itervalues():
for lst in FILEGROUP_LISTS:
- fg[lst] = sorted(list(set(fg.get(lst, []))))
+ fg[lst] = uniquify(fg.get(lst, []))
- for lib in libs:
+ for tgt in dictionary['targets']:
+ for lst in FILEGROUP_LISTS:
+ tgt[lst] = tgt.get(lst, [])
+ tgt['own_%s' % lst] = list(tgt[lst])
+
+ for lib in libs + targets:
assert 'plugins' not in lib
plugins = []
+ for lst in FILEGROUP_LISTS:
+ vals = lib.get(lst, [])
+ lib[lst] = list(vals)
+ lib['own_%s' % lst] = list(vals)
for fg_name in lib.get('filegroups', []):
fg = filegroups[fg_name]
for plugin in fg['plugins']:
@@ -113,4 +163,4 @@ def mako_plugin(dictionary):
lib['src'].append('src/core/plugin_registry/%s_plugin_registry.c' %
lib['name'])
for lst in FILEGROUP_LISTS:
- lib[lst] = sorted(list(set(lib.get(lst, []))))
+ lib[lst] = uniquify(lib.get(lst, []))