summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2013-01-06 14:56:17 (GMT)
committerRemko Tronçon <git@el-tramo.be>2013-01-13 10:06:37 (GMT)
commit188fc285c6555eadd3c9d50ab8a94adcade78d89 (patch)
treef02f5e249f8b511300d55a826d3b727f9d8d844f /BuildTools
parentd5cab0388f6a40db6156a993e5f00acf9e63b577 (diff)
downloadswift-188fc285c6555eadd3c9d50ab8a94adcade78d89.zip
swift-188fc285c6555eadd3c9d50ab8a94adcade78d89.tar.bz2
Fix more warnings.
Fix sign conversion warnings. Removing heavy unnecessary includes. Change-Id: I992f43065498823098a875badb020c7c84fc4797
Diffstat (limited to 'BuildTools')
-rwxr-xr-xBuildTools/CheckHeaders.py43
-rwxr-xr-xBuildTools/Git/Hooks/pre-commit4
-rw-r--r--BuildTools/SCons/SConscript.boot5
3 files changed, 38 insertions, 14 deletions
diff --git a/BuildTools/CheckHeaders.py b/BuildTools/CheckHeaders.py
index 73f49db..ce907c5 100755
--- a/BuildTools/CheckHeaders.py
+++ b/BuildTools/CheckHeaders.py
@@ -2,20 +2,41 @@
import os, sys
+FORBIDDEN_INCLUDES = [
+ ("iostream", ["Swiften/Base/format.h"]),
+ ("Base/Log.h", []),
+ ("Base/format.h", []),
+ ("algorithm", ["Swiften/Base/Algorithm.h", "Swiften/Base/SafeAllocator.h"]),
+ ("boost/bind.hpp", []),
+ ("boost/filesystem.hpp", []),
+ ("Base/foreach.h", []),
+ ("boost/date_time/date_time.hpp", []),
+ ("boost/filesystem/filesystem.hpp", []),
+
+ # To avoid
+ ("Base/Algorithm.h", ["Swiften/StringCodecs/HMAC.h"]),
+]
+
foundBadHeaders = False
-for (path, dirs, files) in os.walk(".") :
- if "3rdParty" in path or ".sconf" in path or ".framework" in path :
+filename = sys.argv[1]
+
+if "3rdParty" in filename or ".sconf" in filename or ".framework" in filename or not filename.endswith(".h") :
+ sys.exit(0)
+if not "Swiften" in filename :
+ sys.exit(0)
+if filename.endswith("Swiften.h") :
+ sys.exit(0)
+
+file = open(filename, "r")
+for line in file.readlines() :
+ if not "#include" in line :
continue
- if not "Swiften" in path :
+ if "Base/Log.h" in filename :
continue
-
- for filename in [os.path.join(path, file) for file in files if file.endswith(".h")] :
- file = open(filename, "r")
- for line in file.readlines() :
- for include in ["iostream", "algorithm", "cassert", "boost/bind.hpp", "boost/filesystem.hpp", "Base/foreach.h", "Base/Log.h", "boost/date_time/date_time.hpp", "boost/filesystem/filesystem.hpp"] :
- if "#include" in line and include in line and not "Base/Log" in filename :
- print "Found " + include + " include in " + filename
- foundBadHeaders = True
+ for forbiddenInclude, ignores in FORBIDDEN_INCLUDES :
+ if forbiddenInclude in line and len([x for x in ignores if x in filename]) == 0 :
+ print "Found " + forbiddenInclude + " include in " + filename
+ foundBadHeaders = True
sys.exit(foundBadHeaders)
diff --git a/BuildTools/Git/Hooks/pre-commit b/BuildTools/Git/Hooks/pre-commit
index 11f0c2d..ad0945e 100755
--- a/BuildTools/Git/Hooks/pre-commit
+++ b/BuildTools/Git/Hooks/pre-commit
@@ -16,4 +16,8 @@ for file in $(git diff --cached --name-only); do
echo "ERROR: '$file' has a copyright error. Aborting commit."
exit -1
fi
+ if ! BuildTools/CheckHeaders.py $file; then
+ echo "ERROR: '$file' failed header sanity test. Aborting commit."
+ exit -1
+ fi
done
diff --git a/BuildTools/SCons/SConscript.boot b/BuildTools/SCons/SConscript.boot
index e6e1661..8e8aecf 100644
--- a/BuildTools/SCons/SConscript.boot
+++ b/BuildTools/SCons/SConscript.boot
@@ -227,12 +227,11 @@ else :
env.Append(CXXFLAGS = [
"-Weverything",
"-Wno-unknown-warning-option", # To stay compatible between CLang versions
- "-Wno-sign-conversion", # We have this a lot. Not sure if we should allow this or not.
- "-Wno-weak-vtables", # Virtually none of our elements have outlined methods
+ "-Wno-weak-vtables", # Virtually none of our elements have outlined methods. This also seems to affect classes in .cpp files, which in turn affects all our tests, which may need fixing in CLang
"-Wno-shadow", # Also warns for shadowing on constructor arguments, which we do a lot
"-Wno-exit-time-destructors", # Used a lot in e.g. CPPUnit
"-Wno-c++98-compat-pedantic", # We do different things that violate this, but they could be fixed
- "-Wno-global-constructors",
+ "-Wno-global-constructors", # We depend on this for e.g. string constants
"-Wno-padded",
])
else :