cmake_consistency_check.py revision 3e629e3a567c6b2941b58887c35c8ed8d11a036d
# $Id: cmake_consistency_check.py 36708 2011-05-16 06:11:14Z gsrb3d $
# ***** BEGIN GPL LICENSE BLOCK *****
#
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Contributor(s): Campbell Barton
#
# ***** END GPL LICENSE BLOCK *****
# <pep8 compliant>
IGNORE = (
# dirs
"/cxxtest/",
"/pedro/",
# files
"buildtool.cpp",
"src/2geom/conic_section_clipper_impl.cpp",
"src/2geom/conicsec.cpp",
"src/deptool.cpp",
"src/display/testnr.cpp",
"src/dom/io/httpclient.cpp",
"src/dom/odf/SvgOdg.cpp",
"src/dom/xmlwriter.cpp",
"src/inkview.cpp",
"src/inkview.rc",
"src/io/streamtest.cpp",
"src/svg/test-stubs.cpp",
# header files
# generated files, created by an in-source build
"config.h",
)
import os
print("Scanning:", base)
# skip '.svn'
continue
# extension checking
def is_c_header(filename):
def cmake_get_src(f):
sources_h = []
sources_c = []
i = 0
# print(f)
while it is not None:
while it is not None:
i += 1
try:
except StopIteration:
it = None
break
l = l.strip()
if not l.startswith("#"):
raise Exception("strict formatting not kept 'set(SRC*' %s:%d" % (f, i))
break
if l.endswith(")"):
raise Exception("strict formatting not kept 'list(APPEND SRC...)' on 1 line %s:%d" % (f, i))
break
if found:
cmake_base = dirname(f)
while it is not None:
i += 1
try:
except StopIteration:
it = None
break
l = l.strip()
if not l.startswith("#"):
if ")" in l:
if l.strip() != ")":
raise Exception("strict formatting not kept '*)' %s:%d" % (f, i))
break
# replace dirs
if not l:
pass
elif l.startswith("$"):
# assume if it ends with SRC we know about it
print("Can't use var '%s' %s:%d" % (l, f, i))
raise Exception("Multi-line define '%s' %s:%d" % (l, f, i))
else:
if is_c_header(new_file):
elif l in ("PARENT_SCOPE", ):
# cmake var, ignore
pass
pass
pass
else:
# print(new_file)
'''
if not sources_h and not sources_c:
raise Exception("No sources %s" % f)
sources_h_fs = list(source_list(cmake_base, is_c_header))
sources_c_fs = list(source_list(cmake_base, is_c))
'''
# find missing C files:
'''
for ff in sources_c_fs:
if ff not in sources_c:
print(" missing: " + ff)
'''
def is_ignore(f):
if ig in f:
return True
return False
# First do stupid check, do these files exist?
if f.endswith("dna.c"):
continue
raise Exception("CMake referenced file missing: " + f)
# now check on files not accounted for.
print("\nC/C++ Files CMake doesnt know about...")
print("missing_c: ", cf)
# check if automake builds a corrasponding .o file.
'''
if cf in global_c:
out1 = os.path.splitext(cf)[0] + ".o"
out2 = os.path.splitext(cf)[0] + ".Po"
out2_dir, out2_file = out2 = os.path.split(out2)
out2 = os.path.join(out2_dir, ".deps", out2_file)
if not os.path.exists(out1) and not os.path.exists(out2):
print("bad_c: ", cf)
'''
print("\nC/C++ Headers CMake doesnt know about...")
print("missing_h: ", hf)