Skip to content

Commit

Permalink
Prepare version 1.3.1 (#33)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
psycofdj committed Feb 4, 2018
1 parent 7f57a17 commit c4c5c48
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 12 deletions.
18 changes: 18 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
xtdmake (1.3.1ppa1~xenial) xenial; urgency=medium

* bug fixes

-- Xavier MARCELET <xavier@marcelet.com> Sun, 04 Feb 2018 09:55:36 +0100

xtdmake (1.3.1ppa1~trusty) trusty; urgency=medium

* bug fixes

-- Xavier MARCELET <xavier@marcelet.com> Sun, 04 Feb 2018 09:55:36 +0100

xtdmake (1.3.1ppa1~precise) precise; urgency=medium

* bug fixes

-- Xavier MARCELET <xavier@marcelet.com> Sun, 04 Feb 2018 09:55:36 +0100

xtdmake (1.3.0ppa1~xenial) xenial; urgency=medium

* adds ninja generator compatibility
Expand Down
7 changes: 7 additions & 0 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ In your root CMakeLists.txt
CodeDupRule REQUIRED
Reports REQUIRED)
# make XTDMake aware of current cmake project
xtdmake_init_project(<project_name> ${PROJECT_BINARY_DIR})
# (optional) configure XTDMake to injects dependency tracking informations in binaries and libraries
enable_tracking()
# ---------------------------
Expand Down Expand Up @@ -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
-------------------

Expand Down
2 changes: 1 addition & 1 deletion src/interface/FindReports.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
22 changes: 15 additions & 7 deletions src/iwyu/FindIwyuRule.cmake
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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)
Expand Down
17 changes: 14 additions & 3 deletions src/iwyu/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
Expand All @@ -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" : [] }
Expand All @@ -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" : [] }
Expand All @@ -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" : [] }
Expand All @@ -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" : [] }
Expand All @@ -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:]
Expand All @@ -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:
Expand All @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion src/tracking/ar_wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c4c5c48

Please sign in to comment.