Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/compile_commands.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ _cc_rules = [

SYSTEM_INCLUDE = "-isystem "
QUOTE_INCLUDE = "-iquote "
EXTERNAL_INCLUDE = "-isystem "

# Function copied from https://gist.github.com/oquenchil/7e2c2bd761aa1341b458cc25608da50c
# NOTE: added local_defines
Expand Down Expand Up @@ -111,6 +112,11 @@ def get_compile_flags(ctx, dep):
if len(quote_include) == 0:
quote_include = "."
options.append(QUOTE_INCLUDE + quote_include)
if hasattr(compilation_context, "external_includes"):
for external_include in compilation_context.external_includes.to_list():
if len(external_include) == 0:
external_include = "."
options.append(EXTERNAL_INCLUDE + external_include)

for attr in SOURCE_ATTR:
if not hasattr(ctx.rule.attr, attr):
Expand All @@ -135,6 +141,12 @@ def get_compile_flags(ctx, dep):
system_include = "."
options.append(SYSTEM_INCLUDE + system_include)

if hasattr(compilation_context, "external_includes"):
for external_include in compilation_context.external_includes.to_list():
if len(external_include) == 0:
external_include = "."
options.append(EXTERNAL_INCLUDE + external_include)

return options

def get_sources(ctx):
Expand Down
8 changes: 3 additions & 5 deletions test/unit/external_repository/test_external_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TestImplDepExternalDep(TestBase):
__test_path__ = os.path.dirname(os.path.abspath(__file__))
BAZEL_BIN_DIR = os.path.join("bazel-bin")
BAZEL_TESTLOGS_DIR = os.path.join("bazel-testlogs")
BAZEL_VERSION = None
BAZEL_VERSION: str = ""
Comment thread
Szelethus marked this conversation as resolved.

@final
@classmethod
Expand Down Expand Up @@ -152,8 +152,7 @@ def test_codechecker_external_include_paths(self):
"--experimental_cc_implementation_deps --enable_bzlmod "
"--features=external_include_paths"
)
# FIXME: Should find nothing.h and finish with exit code 0
self.assertEqual(ret, 1, stderr)
self.assertEqual(ret, 0, stderr)

def test_per_file_external_include_paths(self):
"""
Expand All @@ -168,8 +167,7 @@ def test_per_file_external_include_paths(self):
"--experimental_cc_implementation_deps --enable_bzlmod "
"--features=external_include_paths"
)
# FIXME: Should find nothing.h and finish with exit code 0
self.assertEqual(ret, 3, stderr)
self.assertEqual(ret, 0, stderr)


if __name__ == "__main__":
Expand Down
Loading