mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 13:52:28 +00:00
Reduce build graph by another eight percent
This commit is contained in:
parent
367d06d9e4
commit
0ea0d33a77
249 changed files with 889 additions and 988 deletions
27
tool/scripts/explain-deps.py
Executable file
27
tool/scripts/explain-deps.py
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env python.com
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
def GetDeps(path):
|
||||
deps = set()
|
||||
def Dive(path, depth):
|
||||
if path in deps:
|
||||
return
|
||||
deps.add(path)
|
||||
sys.stdout.write('%s%s\n' % ('\t' * depth, path))
|
||||
with open(path) as f:
|
||||
code = f.read()
|
||||
for dep in re.findall(r'[.#]include "([^"]+)"', code):
|
||||
Dive(dep, depth + 1)
|
||||
Dive(path, 0)
|
||||
sys.stdout.write('\n')
|
||||
|
||||
for arg in sys.argv[1:]:
|
||||
if os.path.isdir(arg):
|
||||
for dirpath, dirs, files in os.walk(arg):
|
||||
for filepath in files:
|
||||
GetDeps(os.path.join(dirpath, filepath))
|
||||
else:
|
||||
GetDeps(arg)
|
Loading…
Add table
Add a link
Reference in a new issue