diff --git a/src/catkin_lint/checks/build.py b/src/catkin_lint/checks/build.py index 69b243e..f358b27 100644 --- a/src/catkin_lint/checks/build.py +++ b/src/catkin_lint/checks/build.py @@ -394,7 +394,7 @@ def on_catkin_package(info, cmd, args): if ext_includes: info.report(ERROR, "EXTERNAL_INCLUDE_PATH") info.export_libs |= set(opts["LIBRARIES"]) - info.export_includes |= set([d for d in includes if not os.path.isabs(d)]) + info.export_includes |= set(includes) info.export_packages |= set(opts["CATKIN_DEPENDS"]) info.export_targets |= set(opts["EXPORTED_TARGETS"]) @@ -423,8 +423,11 @@ def on_final(info): for incl in info.export_includes - info.build_includes: info.report(WARNING, "UNUSED_INCLUDE_PATH", path=incl, file_location=info.location_of("catkin_package")) for incl in info.export_includes: - if not info.is_existing_path(incl, check=os.path.isdir, require_source_folder=True): + pc = info.path_class(incl) + if pc == PathClass.SOURCE and not info.is_existing_path(incl, check=os.path.isdir): info.report(ERROR, "MISSING_INCLUDE_PATH", path=incl, file_location=info.location_of("catkin_package")) + elif pc == PathClass.BINARY: + info.report(ERROR, "BUILD_INCLUDE_PATH", path=incl, file_location=info.location_of("catkin_package")) includes = info.build_includes | info.export_includes for d1 in includes: if not posixpath.isabs(d1): diff --git a/src/catkin_lint/diagnostics.py b/src/catkin_lint/diagnostics.py index 8441d7f..4f646c6 100644 --- a/src/catkin_lint/diagnostics.py +++ b/src/catkin_lint/diagnostics.py @@ -372,6 +372,14 @@ You have listed an invalid include path in the INCLUDE_DIRS stanza of the catkin_package() command. """), + "BUILD_INCLUDE_PATH": + ("catkin_package() exports build include path", + """\ + You listed a build path below ${CMAKE_BINARY_DIR} in the INCLUDE_DIRS stanza + of your catkin_package() call. These paths are only available for develspace + builds and will be missing for installed packages. + """ + ), "EXTERNAL_INCLUDE_PATH": ("catkin_package() exports non-package include path", """\ diff --git a/src/catkin_lint/linter.py b/src/catkin_lint/linter.py index 9073316..2dde4f4 100644 --- a/src/catkin_lint/linter.py +++ b/src/catkin_lint/linter.py @@ -215,26 +215,28 @@ def is_existing_path(self, path, check=os.path.exists, require_source_folder=Fal if check(os.path.normpath(os.path.join(self.path, self.subdir, tmp))): return True tmp = posixpath.normpath(posixpath.join(self.var["CMAKE_CURRENT_SOURCE_DIR"], path.replace(os.path.sep, "/"))) + print(path, tmp, PathConstants.PACKAGE_BINARY) if tmp.startswith(PathConstants.PACKAGE_SOURCE): if not require_source_folder and not posixpath.isabs(path) and tmp[len(PathConstants.PACKAGE_SOURCE) + 1:] in self.generated_files: return True if not require_source_folder and tmp in self.generated_files: return True return check(os.path.join(self.path, os.path.normpath(tmp[len(PathConstants.PACKAGE_SOURCE) + 1:]))) - if not require_source_folder and tmp.startswith(PathConstants.PACKAGE_BINARY): - return tmp[len(PathConstants.PACKAGE_BINARY) + 1:] in self.generated_files - if not require_source_folder and tmp in self.generated_files: - return True - if not require_source_folder and tmp.startswith(PathConstants.CATKIN_DEVEL): - s = tmp[len(PathConstants.CATKIN_DEVEL) + 1:] - for t in ["include", "lib", "share", "bin"]: - if s.startswith(t): - return True - if not require_source_folder and tmp.startswith(PathConstants.CATKIN_INSTALL): - s = tmp[len(PathConstants.CATKIN_INSTALL) + 1:] - for t in ["include", "lib", "share", "bin"]: - if s.startswith(t): - return True + if not require_source_folder: + if tmp.startswith(PathConstants.PACKAGE_BINARY): + return tmp[len(PathConstants.PACKAGE_BINARY) + 1:] in self.generated_files + if tmp.startswith(PathConstants.CATKIN_DEVEL): + s = tmp[len(PathConstants.CATKIN_DEVEL) + 1:] + for t in ["include", "lib", "share", "bin"]: + if s.startswith(t): + return True + if tmp.startswith(PathConstants.CATKIN_INSTALL): + s = tmp[len(PathConstants.CATKIN_INSTALL) + 1:] + for t in ["include", "lib", "share", "bin"]: + if s.startswith(t): + return True + if tmp in self.generated_files: + return True return tmp.startswith(PathConstants.DISCOVERED_PATH) and discovered_path_ok def is_internal_path(self, path): diff --git a/test/test_checks_build.py b/test/test_checks_build.py index f97c412..7a2be83 100644 --- a/test/test_checks_build.py +++ b/test/test_checks_build.py @@ -1023,7 +1023,7 @@ def test_exports(self): ) """, checks=cc.exports) - self.assertEqual([], result) + self.assertEqual(["BUILD_INCLUDE_PATH"], result) result = mock_lint(env, pkg, """