summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2012-07-15 08:56:48 (GMT)
committerRemko Tronçon <git@el-tramo.be>2012-07-15 09:38:40 (GMT)
commit8853ae3063bc9d3fb5b023352dd0fb4fb6cc277b (patch)
tree86261f1621615c340791839a434ae6162ee9baaa
parentb3f5d140e336e042724f2e37796d8ba50570d88c (diff)
downloadswift-contrib-8853ae3063bc9d3fb5b023352dd0fb4fb6cc277b.zip
swift-contrib-8853ae3063bc9d3fb5b023352dd0fb4fb6cc277b.tar.bz2
Provide replace_pragma_once flag.
-rw-r--r--.gitignore1
-rw-r--r--3rdParty/HippoMocks/hippomocks.h (renamed from 3rdParty/hippomocks.h)0
-rw-r--r--BuildTools/SCons/SConscript.boot2
-rw-r--r--BuildTools/SCons/SConstruct28
-rw-r--r--BuildTools/SCons/Tools/ReplacePragmaOnce.py25
-rw-r--r--BuildTools/SCons/Tools/WriteVal.py5
-rw-r--r--QA/Checker/SConscript1
-rw-r--r--Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp2
-rw-r--r--Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp2
-rw-r--r--Swiften/Parser/PayloadParsers/JingleFileTransferReceivedParser.cpp4
10 files changed, 61 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index b681968..58a75e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -44,6 +44,7 @@ VERSION.*
cppcheck.log
/build
/.settings/
+/include/
/nbproject/private/
3rdParty/LibMiniUPnPc/src/miniupnpc/miniupnpcstrings.h
*.sublime-workspace
diff --git a/3rdParty/hippomocks.h b/3rdParty/HippoMocks/hippomocks.h
index 273f7d2..273f7d2 100644
--- a/3rdParty/hippomocks.h
+++ b/3rdParty/HippoMocks/hippomocks.h
diff --git a/BuildTools/SCons/SConscript.boot b/BuildTools/SCons/SConscript.boot
index c246bf6..1cfa962 100644
--- a/BuildTools/SCons/SConscript.boot
+++ b/BuildTools/SCons/SConscript.boot
@@ -62,7 +62,7 @@ vars.Add(BoolVariable("set_iterator_debug_level", "Set _ITERATOR_DEBUG_LEVEL=0",
# Set up default build & configure environment
################################################################################
-env = Environment(CPPPATH = ["#"], ENV = {
+env = Environment(ENV = {
'PATH' : os.environ['PATH'],
'LD_LIBRARY_PATH' : os.environ.get("LD_LIBRARY_PATH", ""),
}, variables = vars)
diff --git a/BuildTools/SCons/SConstruct b/BuildTools/SCons/SConstruct
index 5640877..cd7a25a 100644
--- a/BuildTools/SCons/SConstruct
+++ b/BuildTools/SCons/SConstruct
@@ -71,8 +71,6 @@ def checkObjCHeader(context, header) :
# Platform configuration
################################################################################
-env.Append(CPPPATH = [root])
-
if ARGUMENTS.get("force-configure", 0) :
SCons.SConf.SetCacheMode("force")
@@ -493,6 +491,31 @@ if env.Dir("#/.git").exists() :
if not env.GetOption("clean") :
env.Install("#/.git/hooks", Glob("#/BuildTools/Git/Hooks/*"))
+
+################################################################################
+# Replace #pragma once with proper guards on platforms that require it
+################################################################################
+
+if ARGUMENTS.get("replace_pragma_once", False) :
+ env.Tool("ReplacePragmaOnce", toolpath = ["#/BuildTools/SCons/Tools"])
+
+ def relpath(path, start) :
+ i = len(os.path.commonprefix([path, start]))
+ return path[i+1:]
+
+ for actual_root, dirs, files in os.walk(root) :
+ if "3rdParty" in actual_root :
+ continue
+ for file in files :
+ if not file.endswith(".h") :
+ continue
+ include = relpath(os.path.join(actual_root, file), root)
+ env.ReplacePragmaOnce("#/include/" + include, "#/" + include)
+ env.Append(CPPPATH = ["#/include"])
+else :
+ env.Append(CPPPATH = [root])
+
+
################################################################################
# Project files
################################################################################
@@ -528,6 +551,7 @@ if ARGUMENTS.get("sloccount", False) :
for project in env["PROJECTS"] :
env.SLOCCount("#/" + project)
+
################################################################################
# Print summary
################################################################################
diff --git a/BuildTools/SCons/Tools/ReplacePragmaOnce.py b/BuildTools/SCons/Tools/ReplacePragmaOnce.py
new file mode 100644
index 0000000..466c31e
--- /dev/null
+++ b/BuildTools/SCons/Tools/ReplacePragmaOnce.py
@@ -0,0 +1,25 @@
+import SCons.Util, os.path
+
+def generate(env) :
+ root = env.Dir("#").abspath
+ def relpath(path, start) :
+ i = len(os.path.commonprefix([path, start]))
+ return path[i+1:]
+
+ def replacePragmaOnce(env, target, source) :
+ guard = relpath(source[0].abspath, root).replace("/", "_").replace(".", "_").upper()
+ data = source[0].get_contents()
+ f = open(str(target[0]), 'wb')
+ if "#pragma once" in data :
+ f.write(data.replace("#pragma once", "#ifndef %(guard)s\n#define %(guard)s" % {"guard": guard}))
+ f.write("\n#endif\n")
+ else :
+ f.write(data)
+ f.close()
+
+ env["BUILDERS"]["ReplacePragmaOnce"] = SCons.Builder.Builder(
+ action = SCons.Action.Action(replacePragmaOnce, cmdstr = "$GENCOMSTR"),
+ single_source = True)
+
+def exists(env) :
+ return True
diff --git a/BuildTools/SCons/Tools/WriteVal.py b/BuildTools/SCons/Tools/WriteVal.py
index e39ad82..0a1e1ad 100644
--- a/BuildTools/SCons/Tools/WriteVal.py
+++ b/BuildTools/SCons/Tools/WriteVal.py
@@ -1,14 +1,15 @@
import SCons.Util
def generate(env) :
- def writeVal(env, target, source) :
+ def replacePragmaOnce(env, target, source) :
f = open(str(target[0]), 'wb')
f.write(source[0].get_contents())
f.close()
env["BUILDERS"]["WriteVal"] = SCons.Builder.Builder(
- action = SCons.Action.Action(writeVal, cmdstr = "$GENCOMSTR"),
+ action = SCons.Action.Action(replacePragmaOnce, cmdstr = "$GENCOMSTR"),
single_source = True)
def exists(env) :
return True
+
diff --git a/QA/Checker/SConscript b/QA/Checker/SConscript
index ed17be5..63bd924 100644
--- a/QA/Checker/SConscript
+++ b/QA/Checker/SConscript
@@ -3,6 +3,7 @@ Import("env")
if env["TEST"] :
if env["SCONS_STAGE"] == "flags" :
env["CHECKER_FLAGS"] = {
+ "CPPPATH" : ["#/3rdParty/HippoMocks"],
"LIBS": ["Checker"],
"LIBPATH": [Dir(".")],
"LINKFLAGS": ["/SUBSYSTEM:CONSOLE"] if env["PLATFORM"] == "win32" else []
diff --git a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp
index 3d2db7d..11d0ce2 100644
--- a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp
+++ b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp
@@ -6,7 +6,7 @@
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
-#include "3rdParty/hippomocks.h"
+#include <hippomocks.h>
#include <boost/bind.hpp>
diff --git a/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp b/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp
index 04fc2f7..76e716b 100644
--- a/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp
+++ b/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp
@@ -7,7 +7,7 @@
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <boost/algorithm/string.hpp>
-#include "3rdParty/hippomocks.h"
+#include <hippomocks.h>
#include "Swift/Controllers/XMPPEvents/EventController.h"
#include "Swiften/Presence/DirectedPresenceSender.h"
diff --git a/Swiften/Parser/PayloadParsers/JingleFileTransferReceivedParser.cpp b/Swiften/Parser/PayloadParsers/JingleFileTransferReceivedParser.cpp
index 20ad73e..ae56981 100644
--- a/Swiften/Parser/PayloadParsers/JingleFileTransferReceivedParser.cpp
+++ b/Swiften/Parser/PayloadParsers/JingleFileTransferReceivedParser.cpp
@@ -4,11 +4,11 @@
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
-#include "JingleFileTransferReceivedParser.h"
-#include "StreamInitiationFileInfoParser.h"
+#include <Swiften/Parser/PayloadParsers/JingleFileTransferReceivedParser.h>
#include <boost/shared_ptr.hpp>
#include <Swiften/Parser/PayloadParsers/StreamInitiationFileInfoParser.h>
+#include <Swiften/Parser/PayloadParsers/StreamInitiationFileInfoParser.h>
#include <Swiften/Parser/GenericPayloadParserFactory.h>
#include <Swiften/Parser/PayloadParserFactory.h>