From 1227b9d9b5ccfde57e9c7e946275907391d17ce1 Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Fri, 24 Jul 2015 17:44:39 +0200 Subject: Add 'check_headers' flag to scons for missing include detection Running './scons check_headers=1 will compile each header file as an object file. Test-Information: Tested on OS X 10.9.5 and Elementary OS 0.2. Change-Id: Ia429ccc6dc0a5bd76c08a2c2e91bf192c6ad2901 diff --git a/BuildTools/SCons/SConscript.boot b/BuildTools/SCons/SConscript.boot index 2415fde..babd585 100644 --- a/BuildTools/SCons/SConscript.boot +++ b/BuildTools/SCons/SConscript.boot @@ -99,6 +99,7 @@ vars.Add(BoolVariable("experimental_ft", "Build experimental file transfer", "ye vars.Add(BoolVariable("experimental", "Build experimental features", "no")) vars.Add(BoolVariable("set_iterator_debug_level", "Set _ITERATOR_DEBUG_LEVEL=0", "yes")) vars.Add(BoolVariable("unbound", "Build bundled ldns and unbound. Use them for DNS lookup.", "no")) +vars.Add(BoolVariable("check_headers", "Independently build compilation units for all Swiften headers for detecting missing dependencies.", "no")) vars.Add(BoolVariable("install_git_hooks", "Install git hooks", "true")) diff --git a/Swiften/SConscript b/Swiften/SConscript index de71849..aff1478 100644 --- a/Swiften/SConscript +++ b/Swiften/SConscript @@ -1,4 +1,4 @@ -import os, re, Version, os.path, time +import os, re, Version, os.path, time, urllib Import("env") @@ -541,6 +541,7 @@ if env["SCONS_STAGE"] == "build" : return path[i+1:] swiften_header = "#pragma once\n" swiften_includes = [] + swiften_public_includes = [] top_path = env.Dir("..").abspath for root, dirs, files in os.walk(env.Dir(".").abspath) : if root.endswith("UnitTest") : @@ -568,6 +569,7 @@ if env["SCONS_STAGE"] == "build" : if file == "Swiften.h" or file == "foreach.h" or file == "Log.h" or file == "format.h" : continue swiften_header += "#include <" + include + ">\n" + swiften_public_includes.append(include) swiften_includes.append(include) swiften_env.WriteVal("Swiften.h", swiften_env.Value(swiften_header)) swiften_includes.append("Swiften/Swiften.h") @@ -578,6 +580,18 @@ if env["SCONS_STAGE"] == "build" : swiften_env.WriteVal("Version.h", swiften_env.Value(version_header)) swiften_includes.append("Swiften/Version.h") + # Check headers + if env["check_headers"] : + test_env = swiften_env.Clone() + for header in swiften_public_includes: + program_text = "#include <%s>\n" % (header) + filename = Dir('#/.sconf_temp').abspath + ("/%s.cpp" % (urllib.quote(header, '') )) + text_file = open(filename, "w") + text_file.write(program_text) + text_file.close() + test_obj = test_env.Object(File("#/.sconf_temp/%s.cpp" % (urllib.quote(header, '') ))) + test_env.Default(test_obj) + # Install swiften if swiften_env.get("SWIFTEN_INSTALLDIR", "") : swiften_env.Install(os.path.join(swiften_env["SWIFTEN_INSTALLDIR"], "lib"), swiften_lib) -- cgit v0.10.2-6-g49f6