mirror of
https://github.com/Z3Prover/z3
synced 2025-04-22 16:45:31 +00:00
make include paths uniformly use path relative to src. #534
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
71d80ab47f
commit
b19f94ae5b
1370 changed files with 5964 additions and 5901 deletions
63
scripts/update_include.py
Normal file
63
scripts/update_include.py
Normal file
|
@ -0,0 +1,63 @@
|
|||
# Copyright (c) 2017 Microsoft Corporation
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
is_include = re.compile("#include \"(.*)\"")
|
||||
is_include2 = re.compile("#include\"(.*)\"")
|
||||
|
||||
|
||||
def fix_include(file, paths):
|
||||
print(file)
|
||||
tmp = "%s.tmp" % file
|
||||
ins = open(file)
|
||||
ous = open(tmp,'w')
|
||||
line = ins.readline()
|
||||
found = False
|
||||
while line:
|
||||
m = is_include.search(line)
|
||||
if m and m.group(1) in paths:
|
||||
ous.write("#include \"")
|
||||
ous.write(paths[m.group(1)])
|
||||
ous.write("\"\n")
|
||||
found = True
|
||||
line = ins.readline()
|
||||
continue
|
||||
m = is_include2.search(line)
|
||||
if m and m.group(1) in paths:
|
||||
ous.write("#include \"")
|
||||
ous.write(paths[m.group(1)])
|
||||
ous.write("\"\n")
|
||||
found = True
|
||||
line = ins.readline()
|
||||
continue
|
||||
ous.write(line)
|
||||
line = ins.readline()
|
||||
ins.close()
|
||||
ous.close()
|
||||
if found:
|
||||
os.system("move %s %s" % (tmp, file))
|
||||
else:
|
||||
os.system("del %s" % tmp)
|
||||
|
||||
def find_paths(dir):
|
||||
paths = {}
|
||||
for root, dirs, files in os.walk(dir):
|
||||
root1 = root.replace("\\","/")[4:]
|
||||
for f in files:
|
||||
if f.endswith('.h'):
|
||||
path = "%s/%s" % (root1, f)
|
||||
paths[f] = path
|
||||
return paths
|
||||
|
||||
paths = find_paths('src')
|
||||
|
||||
def fixup(dir):
|
||||
for root, dirs, files in os.walk(dir):
|
||||
for f in files:
|
||||
if f.endswith('.h') or f.endswith('.cpp'):
|
||||
path = "%s\\%s" % (root, f)
|
||||
fix_include(path, paths)
|
||||
|
||||
|
||||
fixup('src')
|
Loading…
Add table
Add a link
Reference in a new issue