From c4c5c48fb14798f6bc23bb58a8052f2e63cade2b Mon Sep 17 00:00:00 2001 From: Xavier MARCELET Date: Sun, 4 Feb 2018 10:12:16 +0100 Subject: [PATCH] Prepare version 1.3.1 (#33) * added missing iwyu dependency in global report target * fix relative path in iwyu running with ninja * fix computed library name in dependency_tracking using ninja * fix iwyu loader that was creating rule despite missing dependencies * adds iwyu to quickstart doc --- debian/changelog | 18 ++++++++++++++++++ docs/quickstart.rst | 7 +++++++ src/interface/FindReports.cmake | 2 +- src/iwyu/FindIwyuRule.cmake | 22 +++++++++++++++------- src/iwyu/analyze.py | 17 ++++++++++++++--- src/tracking/ar_wrapper | 3 ++- 6 files changed, 57 insertions(+), 12 deletions(-) diff --git a/debian/changelog b/debian/changelog index 07846cd..86452e2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,21 @@ +xtdmake (1.3.1ppa1~xenial) xenial; urgency=medium + + * bug fixes + + -- Xavier MARCELET Sun, 04 Feb 2018 09:55:36 +0100 + +xtdmake (1.3.1ppa1~trusty) trusty; urgency=medium + + * bug fixes + + -- Xavier MARCELET Sun, 04 Feb 2018 09:55:36 +0100 + +xtdmake (1.3.1ppa1~precise) precise; urgency=medium + + * bug fixes + + -- Xavier MARCELET Sun, 04 Feb 2018 09:55:36 +0100 + xtdmake (1.3.0ppa1~xenial) xenial; urgency=medium * adds ninja generator compatibility diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 179659e..52c6e02 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -44,6 +44,10 @@ In your root CMakeLists.txt CodeDupRule REQUIRED Reports REQUIRED) + # make XTDMake aware of current cmake project + xtdmake_init_project( ${PROJECT_BINARY_DIR}) + + # (optional) configure XTDMake to injects dependency tracking informations in binaries and libraries enable_tracking() # --------------------------- @@ -111,6 +115,9 @@ In your module CMakelists.txt, example core/CMakeLists.txt : # enable code duplication report add_codedup(core) + # enable code duplication report + add_iwyu(core) + Adds some unittests ------------------- diff --git a/src/interface/FindReports.cmake b/src/interface/FindReports.cmake index e8f147f..94ffcc5 100644 --- a/src/interface/FindReports.cmake +++ b/src/interface/FindReports.cmake @@ -2,7 +2,7 @@ add_custom_target(reports-update) add_custom_target(reports-show) add_custom_target(reports-graph) add_custom_target(reports - DEPENDS doc doc-coverage cloc cppcheck check cov memcheck codedup) + DEPENDS doc doc-coverage cloc cppcheck check cov memcheck codedup iwyu) add_custom_target(reports-clean DEPENDS doc-clean doc-coverage-clean cloc-clean cppcheck-clean check-clean cov-clean memcheck-clean codedup-clean iwyu-clean) diff --git a/src/iwyu/FindIwyuRule.cmake b/src/iwyu/FindIwyuRule.cmake index 8ab0e53..645ab3c 100644 --- a/src/iwyu/FindIwyuRule.cmake +++ b/src/iwyu/FindIwyuRule.cmake @@ -1,6 +1,11 @@ add_custom_target(iwyu) add_custom_target(iwyu-clean) +set(IwyuRule_DEFAULT_EXCLUDE_PATTERN "\${CMAKE_CURRENT_SOURCE_DIR}/unit/*" CACHE STRING "IwyuRule default pattern to exclude source from analysis") +set(IwyuRule_DEFAULT_JOBS "4" CACHE STRING "IwyuRule default number of concurrent jobs") +set(IwyuRule_DEFAULT_MAPPING "\${XTDMake_HOME}/iwyu/mapping.imp" CACHE STRING "IwyuRule default mapping file") +set(IwyuRule_DEFAULT_VERBOSE "FALSE" CACHE STRING "IwyuRule default verbose status") + xtdmake_find_program(Iwyu NAMES include-what-you-use DOC "Include-what-you-use header analyzer" @@ -18,20 +23,23 @@ xtdmake_find_python_module(Mako VERSION_MEMBER "__version__" VERSION_POS 0) - -set(IwyuRule_FOUND 0) if (NOT CMAKE_EXPORT_COMPILE_COMMANDS) message(STATUS "Found module IwyuRule_FOUND : FALSE (CMAKE_EXPORT_COMPILE_COMMANDS is mandatory)") if (IwyuRule_FIND_REQUIRED) message(FATAL_ERROR "Unable to find compile commands") endif() endif() -set(IwyuRule_FOUND 1) -set(IwyuRule_DEFAULT_EXCLUDE_PATTERN "\${CMAKE_CURRENT_SOURCE_DIR}/unit/*" CACHE STRING "IwyuRule default pattern to exclude source from analysis") -set(IwyuRule_DEFAULT_JOBS "4" CACHE STRING "IwyuRule default number of concurrent jobs") -set(IwyuRule_DEFAULT_MAPPING "\${XTDMake_HOME}/iwyu/mapping.imp" CACHE STRING "IwyuRule default mapping file") -set(IwyuRule_DEFAULT_VERBOSE "FALSE" CACHE STRING "IwyuRule default verbose status") +if (NOT CMAKE_EXPORT_COMPILE_COMMANDS OR NOT Mako_FOUND OR NOT Iwyu_FOUND) + set(IwyuRule_FOUND 0) + message(STATUS "Found module IwyuRule : FALSE (unmet required dependencies : mako, include-what-you-use, compile-commands)") + if (IwyuRule_FIND_REQUIRED) + message(FATAL_ERROR "Unable to load required module IwyuRule") + endif() +else() + set(IwyuRule_FOUND 1) + message(STATUS "Found module IwyuRule_FOUND : TRUE") +endif() if (NOT IwyuRule_FOUND) function(add_iwyu module) diff --git a/src/iwyu/analyze.py b/src/iwyu/analyze.py index 0504701..c6428cf 100755 --- a/src/iwyu/analyze.py +++ b/src/iwyu/analyze.py @@ -19,7 +19,13 @@ def __init__(self, p_queue, p_app): self.m_app = p_app self.m_result = {} - def analyze(self, p_data): + + def normPath(self, p_file, p_dir): + l_joined = os.path.join(p_dir, p_file) + l_normed = os.path.normpath(l_joined) + return os.path.relpath(l_normed, self.m_app.src_dir) + + def analyze(self, p_data, p_dir): l_fullTok = "The full include-list for " l_addTok = " should add these lines:" l_rmTok = " should remove these lines:" @@ -31,6 +37,7 @@ def analyze(self, p_data): for c_line in l_lines: if c_line.startswith(l_fullTok): l_newFile = c_line.replace(l_fullTok, "")[:-1] + l_newFile = self.normPath(l_newFile, p_dir) if l_newFile != l_file: l_file = l_newFile l_res[l_file] = { "full" : [], "errors" : False, "add" : [], "rm" : [] } @@ -39,6 +46,7 @@ def analyze(self, p_data): if c_line.endswith(l_addTok): l_newFile = c_line.replace(l_addTok, "") + l_newFile = self.normPath(l_newFile, p_dir) if l_newFile != l_file: l_file = l_newFile l_res[l_file] = { "full" : [], "errors" : False, "add" : [], "rm" : [] } @@ -47,6 +55,7 @@ def analyze(self, p_data): if c_line.endswith(l_rmTok): l_newFile = c_line.replace(l_rmTok, "") + l_newFile = self.normPath(l_newFile, p_dir) if l_newFile != l_file: l_file = l_newFile l_res[l_file] = { "full" : [], "errors" : False, "add" : [], "rm" : [] } @@ -55,6 +64,7 @@ def analyze(self, p_data): if l_okTok in c_line: l_newFile = c_line.replace(l_okTok, "")[1:-1] + l_newFile = self.normPath(l_newFile, p_dir) if l_newFile != l_file: l_file = l_newFile l_res[l_file] = { "full" : [], "errors" : False, "add" : [], "rm" : [] } @@ -77,6 +87,7 @@ def analyze(self, p_data): def processItem(self, p_item): l_file = p_item["file"] l_cmd = p_item["command"] + l_dir = p_item["directory"] l_cmd = re.sub(r'-D(.*)=\\"(.*)\\"', r'-D\1="\2"', l_cmd) l_args = [ self.m_app.iwyu_bin ] l_args += l_cmd.split("-o")[0].split(" ")[1:] @@ -85,7 +96,7 @@ def processItem(self, p_item): l_args = filter(lambda x:len(x) > 0, l_args) if self.m_app.verbose: print(" -> running : %s" % " ".join(l_args)) - l_proc = subprocess.Popen(l_args, stderr=subprocess.PIPE, stdout=subprocess.PIPE) + l_proc = subprocess.Popen(l_args, stderr=subprocess.PIPE, stdout=subprocess.PIPE, cwd=l_dir) l_proc.wait() l_content = l_proc.stderr.read() if self.m_app.verbose: @@ -94,7 +105,7 @@ def processItem(self, p_item): l_code = l_proc.returncode if l_code == -6: return { l_file : { "full" : [], "errors" : l_content, "add" : [], "rm" : [] } } - return self.analyze(l_content) + return self.analyze(l_content, l_dir) def run(self): while True: diff --git a/src/tracking/ar_wrapper b/src/tracking/ar_wrapper index 914cc74..004f734 100755 --- a/src/tracking/ar_wrapper +++ b/src/tracking/ar_wrapper @@ -107,7 +107,8 @@ function add_info function generate_archive { - l_libName=${l_target%.*} + l_libFile=$(basename ${l_target}) + l_libName=${l_libFile%.*} l_tmpDir=$(mktemp -d) l_tmpFile=${l_tmpDir}/.version