From 8285e73db76b916aff838c07bec9d77e245185b1 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 20 Aug 2015 13:18:28 -0400 Subject: Cope with a cmake idiosyncracy. --- deheader | 6 +++++- deheader.xml | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/deheader b/deheader index 0d66ed4..f328ef8 100755 --- a/deheader +++ b/deheader @@ -30,7 +30,7 @@ on interrupt or after processing with its original timestamp, unless the The last line of the output is a statistical summary of operations. """ -import sys, os, getopt, time, re, operator, commands +import sys, os, getopt, time, re, operator, commands, subprocess BATON_DEBUG = 1 PROGRESS_DEBUG = 2 @@ -1359,6 +1359,8 @@ def testcompile(source, maker, msg="", verbosity=0, showerrs=False): derived = stem + ".o" if os.path.exists(derived): os.remove(derived) + elif os.path.exists("CMakeList.txt"): + subprocess.call(["make","clean"]) command = maker + " " + derived start = time.time() (status, output) = commands.getstatusoutput(command) @@ -1375,6 +1377,8 @@ def testcompile(source, maker, msg="", verbosity=0, showerrs=False): print "deheader: %s%s %s." % (source, msg, explain) if os.path.exists(derived): os.remove(derived) + elif os.path.exists("CMakeList.txt"): + subprocess.call(["make","clean"]) return (status, end - start) def c_analyze(sourcefile, maker, includes, requires, verbosity): diff --git a/deheader.xml b/deheader.xml index c375279..2ade657 100644 --- a/deheader.xml +++ b/deheader.xml @@ -36,10 +36,14 @@ This tool takes a list of C or C++ sourcefiles and generates a report on which #includes can be omitted from them; also, what standard inclusions may be required for portability. The test, for -each foo.c or foo.cc or foo.cpp, is simply whether 'rm foo.o; make -foo.o' returns a zero status (but the build command may be +each foo.c or foo.cc or foo.cpp, is simply whether "rm foo.o; make +foo.o" returns a zero status (but the build command may be overridden). +Exception: Under cmake, foo.o is a phoney target. Therefore, +when a "CMakeList.txt" is detected, "make clean" is done rather than +"rm foo.o". + Optionally, with the switch, the unneeded headers are removed from the sourcefiles. Don't use this option unless you have your sourcefiles safely under version -- cgit v1.2.3-70-g09d2