update to cmake checker script to also check if our include paths are ok
This commit is contained in:
@@ -35,6 +35,21 @@ global_c = set()
|
|||||||
global_refs = {}
|
global_refs = {}
|
||||||
|
|
||||||
|
|
||||||
|
def replace_line(f, i, text, keep_indent=True):
|
||||||
|
file_handle = open(f, 'r')
|
||||||
|
data = file_handle.readlines()
|
||||||
|
file_handle.close()
|
||||||
|
|
||||||
|
l = data[i]
|
||||||
|
ws = l[:len(l) - len(l.lstrip())]
|
||||||
|
|
||||||
|
data[i] = "%s%s\n" % (ws, text)
|
||||||
|
|
||||||
|
file_handle = open(f, 'w')
|
||||||
|
file_handle.writelines(data)
|
||||||
|
file_handle.close()
|
||||||
|
|
||||||
|
|
||||||
def source_list(path, filename_check=None):
|
def source_list(path, filename_check=None):
|
||||||
for dirpath, dirnames, filenames in os.walk(path):
|
for dirpath, dirnames, filenames in os.walk(path):
|
||||||
|
|
||||||
@@ -77,7 +92,20 @@ def cmake_get_src(f):
|
|||||||
found = False
|
found = False
|
||||||
i = 0
|
i = 0
|
||||||
# print(f)
|
# print(f)
|
||||||
|
|
||||||
|
def is_definition(l, f, i, name):
|
||||||
|
if ('set(%s' % name) in l or ('set(' in l and l.endswith(name)):
|
||||||
|
if len(l.split()) > 1:
|
||||||
|
raise Exception("strict formatting not kept 'set(%s*' %s:%d" % (name, f, i))
|
||||||
|
return True
|
||||||
|
|
||||||
|
if ("list(APPEND %s" % name) in l or ('list(APPEND ' in l and l.endswith(name)):
|
||||||
|
if l.endswith(")"):
|
||||||
|
raise Exception("strict formatting not kept 'list(APPEND %s...)' on 1 line %s:%d" % (name, f, i))
|
||||||
|
return True
|
||||||
|
|
||||||
while it is not None:
|
while it is not None:
|
||||||
|
context_name = ""
|
||||||
while it is not None:
|
while it is not None:
|
||||||
i += 1
|
i += 1
|
||||||
try:
|
try:
|
||||||
@@ -87,16 +115,13 @@ def cmake_get_src(f):
|
|||||||
break
|
break
|
||||||
l = l.strip()
|
l = l.strip()
|
||||||
if not l.startswith("#"):
|
if not l.startswith("#"):
|
||||||
if 'set(SRC' in l or ('set(' in l and l.endswith("SRC")):
|
found = is_definition(l, f, i, "SRC")
|
||||||
if len(l.split()) > 1:
|
if found:
|
||||||
raise Exception("strict formatting not kept 'set(SRC*' %s:%d" % (f, i))
|
context_name = "SRC"
|
||||||
found = True
|
|
||||||
break
|
break
|
||||||
|
found = is_definition(l, f, i, "INC")
|
||||||
if "list(APPEND SRC" in l or ('list(APPEND ' in l and l.endswith("SRC")):
|
if found:
|
||||||
if l.endswith(")"):
|
context_name = "INC"
|
||||||
raise Exception("strict formatting not kept 'list(APPEND SRC...)' on 1 line %s:%d" % (f, i))
|
|
||||||
found = True
|
|
||||||
break
|
break
|
||||||
|
|
||||||
if found:
|
if found:
|
||||||
@@ -125,29 +150,44 @@ def cmake_get_src(f):
|
|||||||
if not l:
|
if not l:
|
||||||
pass
|
pass
|
||||||
elif l.startswith("$"):
|
elif l.startswith("$"):
|
||||||
# assume if it ends with SRC we know about it
|
if context_name == "SRC":
|
||||||
if not l.split("}")[0].endswith("SRC"):
|
# assume if it ends with context_name we know about it
|
||||||
print("Can't use var '%s' %s:%d" % (l, f, i))
|
if not l.split("}")[0].endswith(context_name):
|
||||||
|
print("Can't use var '%s' %s:%d" % (l, f, i))
|
||||||
elif len(l.split()) > 1:
|
elif len(l.split()) > 1:
|
||||||
raise Exception("Multi-line define '%s' %s:%d" % (l, f, i))
|
raise Exception("Multi-line define '%s' %s:%d" % (l, f, i))
|
||||||
else:
|
else:
|
||||||
new_file = normpath(join(cmake_base, l))
|
new_file = normpath(join(cmake_base, l))
|
||||||
|
|
||||||
if is_c_header(new_file):
|
if context_name == "SRC":
|
||||||
sources_h.append(new_file)
|
if is_c_header(new_file):
|
||||||
global_refs.setdefault(new_file, []).append((f, i))
|
sources_h.append(new_file)
|
||||||
elif is_c(new_file):
|
global_refs.setdefault(new_file, []).append((f, i))
|
||||||
sources_c.append(new_file)
|
elif is_c(new_file):
|
||||||
global_refs.setdefault(new_file, []).append((f, i))
|
sources_c.append(new_file)
|
||||||
elif l in ("PARENT_SCOPE", ):
|
global_refs.setdefault(new_file, []).append((f, i))
|
||||||
# cmake var, ignore
|
elif l in ("PARENT_SCOPE", ):
|
||||||
pass
|
# cmake var, ignore
|
||||||
elif new_file.endswith(".list"):
|
pass
|
||||||
pass
|
elif new_file.endswith(".list"):
|
||||||
elif new_file.endswith(".def"):
|
pass
|
||||||
pass
|
elif new_file.endswith(".def"):
|
||||||
else:
|
pass
|
||||||
raise Exception("unknown file type - not c or h %s -> %s" % (f, new_file))
|
else:
|
||||||
|
raise Exception("unknown file type - not c or h %s -> %s" % (f, new_file))
|
||||||
|
|
||||||
|
elif context_name == "INC":
|
||||||
|
if os.path.isdir(new_file):
|
||||||
|
new_path_rel = os.path.relpath(new_file, cmake_base)
|
||||||
|
|
||||||
|
if new_path_rel != l:
|
||||||
|
print("overly relative path:\n %s:%d\n %s\n %s" % (f, i, l, new_path_rel))
|
||||||
|
|
||||||
|
## Save time. just replace the line
|
||||||
|
# replace_line(f, i - 1, new_path_rel)
|
||||||
|
|
||||||
|
else:
|
||||||
|
raise Exception("non existant include %s:%d -> %s" % (f, i, new_file))
|
||||||
|
|
||||||
# print(new_file)
|
# print(new_file)
|
||||||
|
|
||||||
@@ -167,6 +207,10 @@ def cmake_get_src(f):
|
|||||||
print(" missing: " + ff)
|
print(" missing: " + ff)
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
# reset
|
||||||
|
sources_h[:] = []
|
||||||
|
sources_c[:] = []
|
||||||
|
|
||||||
filen.close()
|
filen.close()
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user