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 /BuildTools/SCons/SConstruct
parentb3f5d140e336e042724f2e37796d8ba50570d88c (diff)
downloadswift-8853ae3063bc9d3fb5b023352dd0fb4fb6cc277b.zip
swift-8853ae3063bc9d3fb5b023352dd0fb4fb6cc277b.tar.bz2
Provide replace_pragma_once flag.
Diffstat (limited to 'BuildTools/SCons/SConstruct')
-rw-r--r--BuildTools/SCons/SConstruct28
1 files changed, 26 insertions, 2 deletions
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
################################################################################