mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
ead3fc2b31
It turned out that specifying all SRCS and INCS as dependencies on the pattern rules for all headers, caused `make` memory usage to skyrocket from 40mb ot 160mb. This change also reduces the build graph another 4%.
27 lines
660 B
Python
Executable file
27 lines
660 B
Python
Executable file
#!/usr/bin/env python.com
|
|
|
|
import os
|
|
import re
|
|
import sys
|
|
|
|
def GetDeps(path):
|
|
def Dive(path, depth, visited):
|
|
sys.stdout.write('%s%s' % ('\t' * depth, path))
|
|
if path in visited:
|
|
sys.stdout.write(' cycle\n')
|
|
return
|
|
sys.stdout.write('\n')
|
|
with open(path) as f:
|
|
code = f.read()
|
|
for dep in re.findall(r'[.#]include "([^"]+)"', code):
|
|
Dive(dep, depth + 1, visited + [path])
|
|
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)
|