mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
rectify_include_paths: warn instead of aborting on duplicate headers
We have two sendme.h files at the moment; we should fix that, but not in this branch.
This commit is contained in:
@@ -3,6 +3,10 @@
|
||||
import os
|
||||
import os.path
|
||||
import re
|
||||
import sys
|
||||
|
||||
def warn(msg):
|
||||
sys.stderr.write("WARNING: %s\n"%msg)
|
||||
|
||||
# Find all the include files, map them to their real names.
|
||||
|
||||
@@ -11,6 +15,8 @@ def exclude(paths, dirnames):
|
||||
if p in dirnames:
|
||||
dirnames.remove(p)
|
||||
|
||||
DUPLICATE = object()
|
||||
|
||||
def get_include_map():
|
||||
includes = { }
|
||||
|
||||
@@ -19,7 +25,10 @@ def get_include_map():
|
||||
|
||||
for fname in fnames:
|
||||
if fname.endswith(".h"):
|
||||
assert fname not in includes
|
||||
if fname in includes:
|
||||
warn("Multiple headers named %s"%fname)
|
||||
includes[fname] = DUPLICATE
|
||||
continue
|
||||
include = os.path.join(dirpath, fname)
|
||||
assert include.startswith("src/")
|
||||
includes[fname] = include[4:]
|
||||
@@ -37,7 +46,7 @@ def fix_includes(inp, out, mapping):
|
||||
if m:
|
||||
include,hdr,rest = m.groups()
|
||||
basehdr = get_base_header_name(hdr)
|
||||
if basehdr in mapping:
|
||||
if basehdr in mapping and mapping[basehdr] is not DUPLICATE:
|
||||
out.write('{}{}{}\n'.format(include,mapping[basehdr],rest))
|
||||
continue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user