From cc4ce85b1d5a4d0fe47690c2aa0748cc964a6cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Sun, 12 Sep 2010 12:19:33 +0200 Subject: Added SLOCCount to scons. diff --git a/.gitignore b/.gitignore index e9b5482..6ea93ba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store *.pyc +*.sloccount *.gcov *.gcda *.gcno diff --git a/BuildTools/SCons/SConstruct b/BuildTools/SCons/SConstruct index feb50d0..a67817a 100644 --- a/BuildTools/SCons/SConstruct +++ b/BuildTools/SCons/SConstruct @@ -62,6 +62,7 @@ if env["PLATFORM"] == "win32" : #So we don't need to escalate with UAC if "TMP" is os.environ.keys() : env['ENV']['TMP'] = os.environ['TMP'] +env.Tool("SLOCCount", toolpath = ["#/BuildTools/SCons/Tools"]) # Override SConscript to handle tests oldSConscript = SConscript @@ -497,6 +498,11 @@ for stage in ["flags", "build", "test"] : env["SCONS_STAGE"] = stage SConscript(dirs = map(lambda x : "#/" + x, modules)) +# SLOCCount +if ARGUMENTS.get("sloccount", False) : + for project in env["PROJECTS"] : + env.SLOCCount("#/" + project) + ################################################################################ # Print summary ################################################################################ diff --git a/BuildTools/SCons/Tools/SLOCCount.py b/BuildTools/SCons/Tools/SLOCCount.py new file mode 100644 index 0000000..fd09abe --- /dev/null +++ b/BuildTools/SCons/Tools/SLOCCount.py @@ -0,0 +1,17 @@ +import SCons.Util, os.path, os + +def generate(env) : + def createSLOCCount(env, source) : + myenv = env.Clone() + myenv["ENV"]["HOME"] = os.environ["HOME"] + source = myenv.Dir(source) + target = myenv.File("#/" + source.path + ".sloccount") + # FIXME: There's probably a better way to force building the .sc + if os.path.exists(target.abspath) : + os.unlink(target.abspath) + return myenv.Command(target, source, [SCons.Action.Action("sloccount --duplicates --wide --details " + source.path + " > $TARGET", cmdstr = "$GENCOMSTR")]) + + env.AddMethod(createSLOCCount, "SLOCCount") + +def exists(env) : + return True -- cgit v0.10.2-6-g49f6