mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 08:18:30 +00:00
Introduce Cosmopolitan Templates Library (CTL)
This commit is contained in:
parent
b003888696
commit
4937843f70
16 changed files with 7054 additions and 12 deletions
|
@ -211,7 +211,11 @@
|
|||
(dots (file-relative-name root dir)) ;; e.g. "../"
|
||||
(file (file-relative-name this root)) ;; e.g. "libc/crc32c.c"
|
||||
(name (file-name-sans-extension file)) ;; e.g. "libc/crc32c"
|
||||
(buddy (format "test/%s_test.c" name))
|
||||
(buddy (let ((c-version (format "test/%s_test.c" name))
|
||||
(cc-version (format "test/%s_test.cc" name)))
|
||||
(if (file-exists-p cc-version)
|
||||
cc-version
|
||||
c-version)))
|
||||
(runs (format "o/$m/%s%s V=5 TESTARGS=-b" name runsuffix))
|
||||
(buns (format "o/$m/test/%s_test%s V=5 TESTARGS=-b" name runsuffix)))
|
||||
(cond ((not (member ext '("c" "cc" "cpp" "s" "S" "rl" "f" "cu")))
|
||||
|
@ -761,8 +765,14 @@
|
|||
(concat dots notest ".hookabi.c")
|
||||
(concat dots notest ".h"))))
|
||||
(t
|
||||
(format "%stest/%s_test.c"
|
||||
dots (cosmo-file-name-sans-extensions name))))))
|
||||
(let ((c-version (format "%stest/%s_test.c"
|
||||
dots (cosmo-file-name-sans-extensions name)))
|
||||
(cc-version (format "%stest/%s_test.cc"
|
||||
dots (cosmo-file-name-sans-extensions name))))
|
||||
(if (file-exists-p cc-version)
|
||||
cc-version
|
||||
c-version))
|
||||
))))
|
||||
(when buddy
|
||||
(find-file buddy))))))
|
||||
|
||||
|
|
|
@ -5,23 +5,41 @@ import re
|
|||
import sys
|
||||
|
||||
def GetDeps(path):
|
||||
def Dive(path, depth, visited):
|
||||
visited = set()
|
||||
def Dive(path, inside, depth, that_isnt=None):
|
||||
sys.stdout.write('%s%s' % ('\t' * depth, path))
|
||||
if path in visited:
|
||||
sys.stdout.write(' cycle\n')
|
||||
return
|
||||
sys.stdout.write('\n')
|
||||
if path in visited:
|
||||
return
|
||||
visited.add(path)
|
||||
if not os.path.exists(path):
|
||||
if inside:
|
||||
samedir = os.path.join(os.path.dirname(inside), path)
|
||||
if inside and os.path.exists(samedir) and samedir != that_isnt:
|
||||
path = samedir
|
||||
elif os.path.exists('third_party/libcxx/' + path) and 'third_party/libcxx/' + path != that_isnt:
|
||||
path = 'third_party/libcxx/' + path
|
||||
elif os.path.exists('libc/isystem/' + path):
|
||||
path = 'libc/isystem/' + path
|
||||
else:
|
||||
# sys.stderr.write('not found: %s\n' % (path))
|
||||
return
|
||||
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 dep in re.findall(r'[.#]\s*include\s+[<"]([^">]+)[">]', code):
|
||||
Dive(dep, path, depth + 1)
|
||||
for dep in re.findall(r'[.#]\s*include_next\s+[<"]([^">]+)[">]', code):
|
||||
Dive(dep, path, depth + 1, path)
|
||||
Dive(path, None, 0)
|
||||
|
||||
once = False
|
||||
for arg in sys.argv[1:]:
|
||||
if os.path.isdir(arg):
|
||||
for dirpath, dirs, files in os.walk(arg):
|
||||
for filepath in files:
|
||||
if not once:
|
||||
sys.stdout.write('\n')
|
||||
once = True
|
||||
GetDeps(os.path.join(dirpath, filepath))
|
||||
else:
|
||||
GetDeps(arg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue