summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'BuildTools')
-rw-r--r--BuildTools/CLang/.gitignore4
-rw-r--r--BuildTools/CLang/CLangDiagnosticsFlagsTool.cpp228
-rw-r--r--BuildTools/CLang/SConscript15
-rwxr-xr-xBuildTools/CheckHeaders.py43
-rwxr-xr-xBuildTools/FilterScanBuildResults.py28
-rwxr-xr-xBuildTools/Git/Hooks/pre-commit4
-rw-r--r--BuildTools/MSVS/.gitignore4
-rw-r--r--BuildTools/MSVS/GenerateProjects.py100
-rw-r--r--BuildTools/MSVS/Swift.sln26
-rw-r--r--BuildTools/SCons/SConscript.boot90
-rw-r--r--BuildTools/SCons/SConstruct4
-rw-r--r--BuildTools/SCons/Tools/Flags.py5
12 files changed, 121 insertions, 430 deletions
diff --git a/BuildTools/CLang/.gitignore b/BuildTools/CLang/.gitignore
deleted file mode 100644
index df682c0..0000000
--- a/BuildTools/CLang/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-CLangDiagnosticsFlags
-CLangDiagnosticsFlagsTool.sh
-CLangDiagnosticsFlagsTool
-clang-diagnostics-overview.*
diff --git a/BuildTools/CLang/CLangDiagnosticsFlagsTool.cpp b/BuildTools/CLang/CLangDiagnosticsFlagsTool.cpp
deleted file mode 100644
index ccd5925..0000000
--- a/BuildTools/CLang/CLangDiagnosticsFlagsTool.cpp
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright (c) 2011 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#include <iostream>
-#include <set>
-#include <vector>
-#include <cassert>
-#include <boost/algorithm/string/predicate.hpp>
-#include <boost/graph/graph_traits.hpp>
-#include <boost/graph/adjacency_list.hpp>
-#include <boost/graph/topological_sort.hpp>
-#include <boost/graph/topological_sort.hpp>
-#include <boost/graph/graphviz.hpp>
-
-// -----------------------------------------------------------------------------
-// Include diagnostics data from CLang
-// -----------------------------------------------------------------------------
-
-#define DIAG(name, a, b, c, d, e, f, g) name,
-
-namespace diag {
- enum LexKinds {
-#include <clang/Basic/DiagnosticLexKinds.inc>
-#include <clang/Basic/DiagnosticParseKinds.inc>
-#include <clang/Basic/DiagnosticCommonKinds.inc>
-#include <clang/Basic/DiagnosticDriverKinds.inc>
-#include <clang/Basic/DiagnosticFrontendKinds.inc>
-#include <clang/Basic/DiagnosticSemaKinds.inc>
- };
-}
-
-#define GET_DIAG_ARRAYS
-#include <clang/Basic/DiagnosticGroups.inc>
-#undef GET_DIAG_ARRAYS
-
-struct DiagTableEntry {
- const char* name;
- const short* array;
- const short* group;
-};
-
-static const DiagTableEntry diagnostics[] = {
-#define GET_DIAG_TABLE
-#include <clang/Basic/DiagnosticGroups.inc>
-#undef GET_DIAG_TABLE
-};
-static const size_t diagnostics_count = sizeof(diagnostics) / sizeof(diagnostics[0]);
-
-// -----------------------------------------------------------------------------
-
-using namespace boost;
-
-struct Properties {
- Properties() : have(false), implicitHave(false), dontWant(false), implicitDontWant(false), ignored(false), available(false), missing(false), redundant(false), alreadyCovered(false) {
- }
-
- std::string name;
- bool have;
- bool implicitHave;
- bool dontWant;
- bool implicitDontWant;
- bool ignored;
- bool available;
- bool missing;
- bool redundant;
- bool alreadyCovered;
-};
-
-class GraphVizLabelWriter {
- public:
- GraphVizLabelWriter(const std::vector<Properties>& properties) : properties(properties) {
- }
-
- template <class VertexOrEdge>
- void operator()(std::ostream& out, const VertexOrEdge& v) const {
- std::string color;
- if (properties[v].missing) {
- color = "orange";
- }
- else if (properties[v].redundant) {
- color = "lightblue";
- }
- else if (properties[v].have) {
- color = "darkgreen";
- }
- else if (properties[v].implicitHave) {
- color = "green";
- }
- else if (properties[v].dontWant) {
- color = "red";
- }
- else if (properties[v].implicitDontWant) {
- color = "pink";
- }
- else if (properties[v].ignored) {
- color = "white";
- }
- else if (properties[v].available) {
- color = "yellow";
- }
- else {
- assert(false);
- }
- out << "[label=" << escape_dot_string(properties[v].name) << " fillcolor=\"" << color << "\" style=filled]";
- }
-
- private:
- const std::vector<Properties> properties;
-};
-
-int main(int argc, char* argv[]) {
- // Parse command-line arguments
- std::set<std::string> have;
- std::set<std::string> dontWant;
- std::string outputDir;
- for (int i = 1; i < argc; ++i) {
- std::string arg(argv[i]);
- if (starts_with(arg, "-W")) {
- have.insert(arg.substr(2, arg.npos));
- }
- else if (starts_with(arg, "-w")) {
- dontWant.insert(arg.substr(2, arg.npos));
- }
- else if (starts_with(arg, "-O")) {
- outputDir = arg.substr(2, arg.npos) + "/";
- }
- }
-
- // Build the graph and initialize properties
- typedef adjacency_list<vecS, vecS, bidirectionalS> Graph;
- typedef graph_traits<Graph>::vertex_descriptor Vertex;
- Graph g(diagnostics_count);
- std::vector<Properties> properties(num_vertices(g));
- for (size_t i = 0; i < diagnostics_count; ++i) {
- std::string name(diagnostics[i].name);
- properties[i].name = name;
- properties[i].implicitHave = properties[i].have = have.find(name) != have.end();
- properties[i].implicitDontWant = properties[i].dontWant = dontWant.find(name) != dontWant.end();
- properties[i].ignored = diagnostics[i].group == 0 && diagnostics[i].array == 0;
- properties[i].alreadyCovered = false;
- properties[i].available = true;
- for (const short* j = diagnostics[i].group; j && *j != -1; ++j) {
- add_edge(i, *j, g);
- }
- }
-
- // Sort the diagnostics
- std::list<Vertex> sortedDiagnostics;
- boost::topological_sort(g, std::front_inserter(sortedDiagnostics));
-
- // Propagate dontWant and have properties down
- for(std::list<Vertex>::const_iterator i = sortedDiagnostics.begin(); i != sortedDiagnostics.end(); ++i) {
- graph_traits<Graph>::adjacency_iterator adjacentIt, adjacentEnd;
- for (tie(adjacentIt, adjacentEnd) = adjacent_vertices(*i, g); adjacentIt != adjacentEnd; ++adjacentIt) {
- properties[*adjacentIt].implicitDontWant = properties[*i].implicitDontWant || properties[*adjacentIt].implicitDontWant;
- properties[*adjacentIt].implicitHave = properties[*i].implicitHave || properties[*adjacentIt].implicitHave;
- }
- }
-
- // Propagate 'available' property upwards
- for(std::list<Vertex>::const_reverse_iterator i = sortedDiagnostics.rbegin(); i != sortedDiagnostics.rend(); ++i) {
- properties[*i].available = properties[*i].available && !properties[*i].implicitDontWant;
- graph_traits<Graph>::in_edge_iterator edgesIt, edgesEnd;
- graph_traits<Graph>::edge_descriptor edge;
- for (tie(edgesIt, edgesEnd) = in_edges(*i, g); edgesIt != edgesEnd; ++edgesIt) {
- properties[source(*edgesIt, g)].available = properties[source(*edgesIt, g)].available && properties[*i].available;
- }
- }
-
- // Collect missing & redundant flags
- std::set<std::string> missing;
- std::set<std::string> redundant;
- for(std::list<Vertex>::const_iterator i = sortedDiagnostics.begin(); i != sortedDiagnostics.end(); ++i) {
- bool markChildrenCovered = true;
- if (properties[*i].alreadyCovered) {
- if (properties[*i].have) {
- properties[*i].redundant = true;
- redundant.insert(properties[*i].name);
- }
- }
- else {
- if (properties[*i].available) {
- if (!properties[*i].implicitHave && !properties[*i].ignored) {
- properties[*i].missing = true;
- missing.insert(properties[*i].name);
- }
- }
- else {
- markChildrenCovered = false;
- }
- }
- if (markChildrenCovered) {
- graph_traits<Graph>::adjacency_iterator adjacentIt, adjacentEnd;
- for (tie(adjacentIt, adjacentEnd) = adjacent_vertices(*i, g); adjacentIt != adjacentEnd; ++adjacentIt) {
- properties[*adjacentIt].alreadyCovered = true;
- }
- }
- }
-
- // Write information
- if (!missing.empty()) {
- std::cout << "Missing diagnostic flags: ";
- for(std::set<std::string>::const_iterator i = missing.begin(); i != missing.end(); ++i) {
- std::cout << "-W" << *i << " ";
- }
- std::cout<< std::endl;
- }
-
- if (!redundant.empty()) {
- std::cout << "Redundant diagnostic flags: ";
- for(std::set<std::string>::const_iterator i = redundant.begin(); i != redundant.end(); ++i) {
- std::cout << "-W" << *i << " ";
- }
- std::cout<< std::endl;
- }
-
- // Write graphviz file
- if (!outputDir.empty()) {
- std::ofstream f((outputDir + "clang-diagnostics-overview.dot").c_str());
- write_graphviz(f, g, GraphVizLabelWriter(properties));
- f.close();
- }
-
- return 0;
-}
diff --git a/BuildTools/CLang/SConscript b/BuildTools/CLang/SConscript
deleted file mode 100644
index 850c35c..0000000
--- a/BuildTools/CLang/SConscript
+++ /dev/null
@@ -1,15 +0,0 @@
-Import("env")
-
-#myenv = Environment()
-#myenv.Append(CPPPATH = ["."])
-#myenv.Program("CLangDiagnosticsFlagsTool", ["CLangDiagnosticsFlagsTool.cpp"])
-#
-#disabledDiagnostics = ["-wunreachable-code", "-wunused-macros", "-wmissing-noreturn", "-wlong-long", "-wcast-align", "-wglobal-constructors", "-wmissing-prototypes", "-wpadded", "-wshadow"]
-#clangDiagnosticsFlagsToolCommand = "BuildTools/CLang/CLangDiagnosticsFlagsTool -O" + env.Dir(".").abspath + " " + " ".join(disabledDiagnostics) + " "
-#clangDiagnosticsFlagsToolCommand += " ".join([flag for flag in env["CXXFLAGS"] if flag.startswith("-W")])
-#clangDiagnosticsFlagsToolCommand += "\n"
-#clangDiagnosticsFlagsToolCommand += "dot -Tpng " + env.Dir(".").abspath + "/clang-diagnostics-overview.dot > " + env.Dir(".").abspath + "/clang-diagnostics-overview.png\n"
-#v = env.WriteVal("#/BuildTools/CLang/CLangDiagnosticsFlagsTool.sh", env.Value(clangDiagnosticsFlagsToolCommand))
-#env.AddPostAction(v, Chmod(v[0], 0755))
-#
-#
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/FilterScanBuildResults.py b/BuildTools/FilterScanBuildResults.py
new file mode 100755
index 0000000..53a345f
--- /dev/null
+++ b/BuildTools/FilterScanBuildResults.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+
+import os, os.path, sys, re
+
+resultsDir = sys.argv[1]
+resultDirs = [ d for d in os.listdir(resultsDir) if os.path.isdir(os.path.join(resultsDir, d)) ]
+resultDirs.sort()
+if len(resultDirs) > 0 :
+ resultDir = os.path.join(resultsDir, resultDirs[-1])
+ resultFileName = os.path.join(resultDir, "index.html")
+ resultData = []
+ f = open(resultFileName, "r")
+ skipLines = 0
+ for line in f.readlines() :
+ if skipLines > 0 :
+ skipLines -= 1
+ else :
+ if ("3rdParty" in line or "SHA1.cpp" in line or "lua.c" in line) :
+ m = re.match(".*(report-.*\.html)", line)
+ os.remove(os.path.join(resultDir, m.group(1)))
+ skipLines = 2
+ else :
+ resultData.append(line)
+ f.close()
+
+ f = open(resultFileName, "w")
+ f.writelines(resultData)
+ f.close()
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/MSVS/.gitignore b/BuildTools/MSVS/.gitignore
deleted file mode 100644
index 95a4834..0000000
--- a/BuildTools/MSVS/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-*.suo
-*.ncp
-Slimber
-Swift
diff --git a/BuildTools/MSVS/GenerateProjects.py b/BuildTools/MSVS/GenerateProjects.py
deleted file mode 100644
index d13df08..0000000
--- a/BuildTools/MSVS/GenerateProjects.py
+++ /dev/null
@@ -1,100 +0,0 @@
-import os, os.path
-
-projects = [("Swift", "Swift\QtUI\Swift.exe"), ("Slimber", "Slimber\Qt\Slimber.exe")]
-
-for (project, outputbin) in projects :
- if not os.path.exists(project) :
- os.mkdir(project)
- output = open(os.path.join(project, project + ".vcproj"), "w")
-
- headers = []
- sources = []
- for root, dirs, files in os.walk(os.path.join("..", "..", project)) :
- for file in files :
- if file.endswith(".h") :
- headers.append('<File RelativePath="' + os.path.join("..", root, file) + '" />')
- elif file.endswith(".cpp") :
- sources.append('<File RelativePath="' + os.path.join("..", root, file) + '" />')
-
- output.write("""<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="%(project)s"
- Keyword="MakeFileProj"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="0"
- >
- <Tool
- Name="VCNMakeTool"
- BuildCommandLine="cd ..\..\..\ &amp;&amp; scons debug=1 %(project)s"
- ReBuildCommandLine=""
- CleanCommandLine="cd ..\..\..\ &amp;&amp; scons -c debug=1 %(project)s"
- Output="..\..\..\%(output)s"
- PreprocessorDefinitions="WIN32;_DEBUG"
- IncludeSearchPath=""
- ForcedIncludes=""
- AssemblySearchPath=""
- ForcedUsingAssemblies=""
- CompileAsManaged=""
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="0"
- >
- <Tool
- Name="VCNMakeTool"
- BuildCommandLine="cd ..\..\..\ &amp;&amp; scons %(project)s"
- ReBuildCommandLine=""
- CleanCommandLine="cd ..\..\..\ &amp;&amp; scons -c %(project)s"
- Output="..\..\..\%(output)s"
- PreprocessorDefinitions="WIN32;NDEBUG"
- IncludeSearchPath=""
- ForcedIncludes=""
- AssemblySearchPath=""
- ForcedUsingAssemblies=""
- CompileAsManaged=""
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- >
- %(sources)s
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- >
- %(headers)s
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
- >
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>""" % { "project": project, "output" : outputbin, "headers" : '\n'.join(headers), "sources": '\n'.join(sources) })
- output.close()
diff --git a/BuildTools/MSVS/Swift.sln b/BuildTools/MSVS/Swift.sln
deleted file mode 100644
index 2724f81..0000000
--- a/BuildTools/MSVS/Swift.sln
+++ /dev/null
@@ -1,26 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual C++ Express 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Swift", "Swift\Swift.vcproj", "{C67C3A5B-1382-4B4A-88F7-3BFC98DA43A2}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Slimber", "Slimber\Slimber.vcproj", "{597242B2-A667-47A1-B69E-D2C4281183D0}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {C67C3A5B-1382-4B4A-88F7-3BFC98DA43A2}.Debug|Win32.ActiveCfg = Debug|Win32
- {C67C3A5B-1382-4B4A-88F7-3BFC98DA43A2}.Debug|Win32.Build.0 = Debug|Win32
- {C67C3A5B-1382-4B4A-88F7-3BFC98DA43A2}.Release|Win32.ActiveCfg = Release|Win32
- {C67C3A5B-1382-4B4A-88F7-3BFC98DA43A2}.Release|Win32.Build.0 = Release|Win32
- {597242B2-A667-47A1-B69E-D2C4281183D0}.Debug|Win32.ActiveCfg = Debug|Win32
- {597242B2-A667-47A1-B69E-D2C4281183D0}.Debug|Win32.Build.0 = Debug|Win32
- {597242B2-A667-47A1-B69E-D2C4281183D0}.Release|Win32.ActiveCfg = Release|Win32
- {597242B2-A667-47A1-B69E-D2C4281183D0}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/BuildTools/SCons/SConscript.boot b/BuildTools/SCons/SConscript.boot
index 361004f..8e8aecf 100644
--- a/BuildTools/SCons/SConscript.boot
+++ b/BuildTools/SCons/SConscript.boot
@@ -8,12 +8,11 @@ sys.path.append(Dir("#/BuildTools/SCons").abspath)
vars = Variables(os.path.join(Dir("#").abspath, "config.py"))
vars.Add('cc', "C compiler")
vars.Add('cxx', "C++ compiler")
-vars.Add('ccflags', "Extra C(++) compiler flags")
+vars.Add('ccflags', "Extra C/C++/ObjC compiler flags")
+vars.Add('cxxflags', "Extra C++ compiler flags")
vars.Add('link', "Linker")
vars.Add('linkflags', "Extra linker flags")
vars.Add(BoolVariable("ccache", "Use CCache", "no"))
-vars.Add(BoolVariable("distcc", "Use DistCC", "no"))
-vars.Add('distcc_hosts', "DistCC hosts (overrides DISTCC_HOSTS)")
vars.Add(EnumVariable("test", "Compile and run tests", "none", ["none", "all", "unit", "system"]))
vars.Add(BoolVariable("optimize", "Compile with optimizations turned on", "no"))
vars.Add(BoolVariable("debug", "Compile with debug information", "yes"))
@@ -58,7 +57,7 @@ vars.Add(PathVariable("docbook_xml", "DocBook XML", None, PathVariable.PathAccep
vars.Add(PathVariable("docbook_xsl", "DocBook XSL", None, PathVariable.PathAccept))
vars.Add(BoolVariable("build_examples", "Build example programs", "yes"))
vars.Add(BoolVariable("enable_variants", "Build in a separate dir under build/, depending on compile flags", "no"))
-vars.Add(BoolVariable("experimental", "Build experimental features", "no"))
+vars.Add(BoolVariable("experimental", "Build experimental features", "yes"))
vars.Add(BoolVariable("set_iterator_debug_level", "Set _ITERATOR_DEBUG_LEVEL=0", "yes"))
################################################################################
@@ -68,6 +67,7 @@ vars.Add(BoolVariable("set_iterator_debug_level", "Set _ITERATOR_DEBUG_LEVEL=0",
env_ENV = {
'PATH' : os.environ['PATH'],
'LD_LIBRARY_PATH' : os.environ.get("LD_LIBRARY_PATH", ""),
+ 'TERM' : os.environ.get("TERM", ""),
}
if "MSVC_VERSION" in ARGUMENTS :
env = Environment(ENV = env_ENV, variables = vars, MSVC_VERSION = ARGUMENTS["MSVC_VERSION"])
@@ -104,33 +104,43 @@ if env["max_jobs"] :
except ImportError :
pass
-# Default compiler flags
-if env.get("distcc", False) :
- env["ENV"]["HOME"] = os.environ["HOME"]
- env["ENV"]["DISTCC_HOSTS"] = os.environ.get("DISTCC_HOSTS", "")
- if "distcc_hosts" in env :
- env["ENV"]["DISTCC_HOSTS"] = env["distcc_hosts"]
- env["CC"] = "distcc gcc"
- env["CXX"] = "distcc g++"
+# Set the default compiler to CLang on OS X, and set the necessary flags
+if env["PLATFORM"] == "darwin" :
+ if "cc" not in env :
+ env["CC"] = "clang"
+ if platform.machine() == "x86_64" :
+ env["CCFLAGS"] = ["-arch", "x86_64"]
+ if "cxx" not in env :
+ env["CXX"] = "clang++"
+ env["CXXFLAGS"] = ["-std=c++11"]
+ if "link" not in env :
+ env["LINK"] = "clang"
+ if platform.machine() == "x86_64" :
+ env.Append(LINKFLAGS = ["-arch", "x86_64"])
+
+# Check whether we are running inside scan-build, and override compiler if so
+if "CCC_ANALYZER_HTML" in os.environ :
+ for key, value in os.environ.items() :
+ if key.startswith("CCC_") or key.startswith("CLANG") :
+ env["ENV"][key] = value
+ env["CC"] = os.environ["CC"]
+ env["CXX"] = os.environ["CXX"]
+
+# Override the compiler with custom variables set at config time
if "cc" in env :
env["CC"] = env["cc"]
if "cxx" in env :
env["CXX"] = env["cxx"]
-ccflags = env.get("ccflags", [])
-if isinstance(ccflags, str) :
- # FIXME: Make the splitting more robust
- env["CCFLAGS"] = ccflags.split(" ")
-else :
- env["CCFLAGS"] = ccflags
if "link" in env :
env["SHLINK"] = env["link"]
env["LINK"] = env["link"]
-linkflags = env.get("linkflags", [])
-if isinstance(linkflags, str) :
- # FIXME: Make the splitting more robust
- env["LINKFLAGS"] = linkflags.split(" ")
-else :
- env["LINKFLAGS"] = linkflags
+for flags_type in ["ccflags", "cxxflags", "linkflags"] :
+ if flags_type in env :
+ if isinstance(env[flags_type], str) :
+ # FIXME: Make the splitting more robust
+ env[flags_type.upper()] = env[flags_type].split(" ")
+ else :
+ env[flags_type.upper()] = env[flags_type]
# This isn't a real flag (yet) AFAIK. Be sure to append it to the CXXFLAGS
# where you need it
env["OBJCCFLAGS"] = []
@@ -146,7 +156,7 @@ if env["target"] == "xcode" and os.environ["CONFIGURATION"] == "Release" :
if env["debug"] :
if env["PLATFORM"] == "win32" :
- env.Append(CCFLAGS = ["/Z7"])
+ env.Append(CCFLAGS = ["/Zi"])
env.Append(LINKFLAGS = ["/DEBUG"])
if env["set_iterator_debug_level"] :
env.Append(CPPDEFINES = ["_ITERATOR_DEBUG_LEVEL=0"])
@@ -213,20 +223,24 @@ if env["PLATFORM"] == "win32" :
#env.Append(CCFLAGS = ["/Wall"])
pass
else :
- env.Append(CXXFLAGS = ["-Wextra", "-Wall", "-Wnon-virtual-dtor", "-Wundef", "-Wold-style-cast", "-Wno-long-long", "-Woverloaded-virtual", "-Wfloat-equal", "-Wredundant-decls"])
+ if "clang" in env["CXX"] :
+ env.Append(CXXFLAGS = [
+ "-Weverything",
+ "-Wno-unknown-warning-option", # To stay compatible between CLang versions
+ "-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", # We depend on this for e.g. string constants
+ "-Wno-padded",
+ ])
+ else :
+ env.Append(CXXFLAGS = ["-Wextra", "-Wall", "-Wnon-virtual-dtor", "-Wundef", "-Wold-style-cast", "-Wno-long-long", "-Woverloaded-virtual", "-Wfloat-equal", "-Wredundant-decls", "-Wno-unknown-pragmas"])
+ gccVersion = env.get("CCVERSION", "0.0.0").split(".")
+ if gccVersion >= ["4", "5", "0"] and not "clang" in env["CC"] :
+ env.Append(CXXFLAGS = ["-Wlogical-op"])
if not env.get("allow_warnings", False) :
env.Append(CXXFLAGS = ["-Werror"])
- gccVersion = env.get("CCVERSION", "0.0.0").split(".")
- if gccVersion >= ["4", "5", "0"] and not "clang" in env["CC"] :
- env.Append(CXXFLAGS = ["-Wlogical-op"])
- if "clang" in env["CC"] :
- env.Append(CXXFLAGS = ["-W#warnings", "-Wc++0x-compat", "-Waddress-of-temporary", "-Wambiguous-member-template", "-Warray-bounds", "-Watomic-properties", "-Wbind-to-temporary-copy", "-Wbuiltin-macro-redefined", "-Wc++-compat", "-Wc++0x-extensions", "-Wcomments", "-Wconditional-uninitialized", "-Wconstant-logical-operand", "-Wdeclaration-after-statement", "-Wdeprecated", "-Wdeprecated-implementations", "-Wdeprecated-writable-strings", "-Wduplicate-method-arg", "-Wempty-body", "-Wendif-labels", "-Wenum-compare", "-Wformat=2", "-Wfour-char-constants", "-Wgnu", "-Wincomplete-implementation", "-Winvalid-noreturn", "-Winvalid-offsetof", "-Winvalid-token-paste", "-Wlocal-type-template-args", "-Wmethod-signatures", "-Wmicrosoft", "-Wmissing-declarations", "-Wnon-pod-varargs", "-Wnull-dereference", "-Wout-of-line-declaration", "-Woverlength-strings", "-Wpacked", "-Wpointer-arith", "-Wpointer-sign", "-Wprotocol", "-Wreadonly-setter-attrs", "-Wselector", "-Wshift-overflow", "-Wshift-sign-overflow", "-Wstrict-selector-match", "-Wsuper-class-method-mismatch", "-Wtautological-compare", "-Wtypedef-redefinition", "-Wundeclared-selector", "-Wunknown-warning-option", "-Wunnamed-type-template-args", "-Wunused-exception-parameter", "-Wunused-member-function", "-Wused-but-marked-unused", "-Wvariadic-macros", "-Wno-c++11-extensions"])
-# To enable:
-# "-Wnonfragile-abi2" -> deprecated, is now -Warc-abi i think
-# "-Wheader-hygiene"
-# "-Wnon-gcc",
-# "-Wweak-vtables",
-# "-Wlarge-by-value-copy",
if env.get("coverage", 0) :
assert(env["PLATFORM"] != "win32")
@@ -235,7 +249,7 @@ if env.get("coverage", 0) :
if env["PLATFORM"] == "win32" :
env.Append(LIBS = ["user32", "crypt32", "dnsapi", "iphlpapi", "ws2_32", "wsock32", "Advapi32"])
- env.Append(CCFLAGS = ["/EHsc", "/nologo"])
+ env.Append(CCFLAGS = ["/EHsc", "/nologo", "/Zm256"])
env.Append(LINKFLAGS = ["/INCREMENTAL:no", "/NOLOGO"])
if int(env["MSVS_VERSION"].split(".")[0]) < 10 :
env["LINKCOM"] = [env["LINKCOM"], 'mt.exe -nologo -manifest ${TARGET}.manifest -outputresource:$TARGET;1']
diff --git a/BuildTools/SCons/SConstruct b/BuildTools/SCons/SConstruct
index a0a6e8d..3f02106 100644
--- a/BuildTools/SCons/SConstruct
+++ b/BuildTools/SCons/SConstruct
@@ -42,6 +42,7 @@ if int(ARGUMENTS.get("V", 0)) == 0:
env["SHLINKCOMSTR"] = colorize("LINK", "$TARGET", "red")
env["ARCOMSTR"] = colorize("AR", "$TARGET", "red")
env["RANLIBCOMSTR"] = colorize("RANLIB", "$TARGET", "red")
+ env["PCHCOMSTR"] = colorize("PCH", "$TARGET", "blue")
env["QT4_RCCCOMSTR"] = colorize("RCC", "$TARGET", "blue")
env["QT4_UICCOMSTR"] = colorize("UIC", "$TARGET", "blue")
env["QT4_MOCFROMHCOMSTR"] = colorize("MOC", "$TARGET", "blue")
@@ -524,9 +525,6 @@ else :
# Project files
################################################################################
-# Build tools
-env.SConscript(dirs = ["#/BuildTools/CLang"])
-
# Modules
modules = []
for dir in os.listdir(Dir("#/3rdParty").abspath) :
diff --git a/BuildTools/SCons/Tools/Flags.py b/BuildTools/SCons/Tools/Flags.py
index 13fbb32..c130faf 100644
--- a/BuildTools/SCons/Tools/Flags.py
+++ b/BuildTools/SCons/Tools/Flags.py
@@ -3,7 +3,10 @@ import SCons.Util
def generate(env) :
def useFlags(env, flags) :
for flag in flags :
- env[flag] = env.get(flag, []) + flags[flag]
+ if flag in env :
+ env[flag] = env[flag] + flags[flag]
+ else :
+ env[flag] = flags[flag]
env.AddMethod(useFlags, "UseFlags")
def exists(env) :