From 2b7f55a30b07f08d32bccd3ea0a72ffd8c820c20 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Sun, 9 Dec 2012 17:20:55 +0100
Subject: Use precompiled header in EchoBot variants.

This slightly speeds up compilation on Windows. Adding this mostly
as demonstrating/documentation purposes.

Change-Id: Ic50aaef04589c79b926a0dcb4bb8d00284fd5a21

diff --git a/.gitignore b/.gitignore
index 1d3dc51..b24578d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,6 +13,7 @@
 *.so
 *.pdb
 *.swp
+*.pch
 *.nib
 *.exe
 *.syms
diff --git a/BuildTools/SCons/SConscript.boot b/BuildTools/SCons/SConscript.boot
index 0c33f06..acbe736 100644
--- a/BuildTools/SCons/SConscript.boot
+++ b/BuildTools/SCons/SConscript.boot
@@ -238,7 +238,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..f18adc5 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")
diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/.gitignore b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/.gitignore
index 91c939b..aca6fe1 100644
--- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/.gitignore
+++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/.gitignore
@@ -2,3 +2,4 @@ EchoBot?
 *.cpp.xml
 *.h.xml
 EchoComponent
+Swiften.cpp
diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/SConscript b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/SConscript
index b267e80..84cc80b 100644
--- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/SConscript
+++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/SConscript
@@ -4,6 +4,18 @@ example_env = env.Clone()
 example_env.UseFlags(example_env["SWIFTEN_FLAGS"])
 example_env.UseFlags(example_env["SWIFTEN_DEP_FLAGS"])
 
+# Precompile Swiften header
+# This is useful to slightly speed up compilation.
+if example_env["PLATFORM"] == "win32":
+	# Precompiled headers don't work with /Z7. We don't really need /Z7 here, so using
+	# the more standard /Zi.
+	if example_env["debug"] :
+		example_env.Replace(CCFLAGS = [flag for flag in env["CCFLAGS"] if flag != "/Z7"])
+		example_env.Append(CCFLAGS = "/Zi")
+	example_env.WriteVal("Swiften.cpp", example_env.Value("#include <Swiften/Swiften.h>\n"))
+	example_env["PCH"] = example_env.PCH("Swiften.cpp")[0]
+	example_env["PCHSTOP"] = "Swiften/Swiften.h"
+
 for i in range(1,7) :
 	example_env.Program("EchoBot" + str(i), ["EchoBot" + str(i) + ".cpp"])
 example_env.Program("EchoComponent", "EchoComponent.cpp")
-- 
cgit v0.10.2-6-g49f6