# Copyright 2025 The Pigweed Authors # # Licensed under the Apache License, Version 2.0 (the "License"); you may not # use this file except in compliance with the License. You may obtain a copy of # the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations under # the License. load("@rules_cc//cc:cc_binary.bzl", "cc_binary") load("@rules_cc//cc:cc_library.bzl", "cc_library") load("@rules_platform//platform_data:defs.bzl", "platform_data") load("//pw_ide/bazel/compile_commands:pw_cc_compile_commands_aspect.bzl", "pw_cc_compile_commands_fragments") package( default_testonly = True, ) # All the build targets in this directory are in service of the # compile_commands_test suite that ensures various edge cases are properly # captured in collected compile commands. # Basic coverage of a library with virtual includes. cc_library( name = "basic_library_virtual_includes", srcs = ["basic_source_virt_test.cc"], hdrs = ["public/virtual_included_header.h"], # Virtual include path. strip_include_prefix = "public", ) # Basic coverage of a library with headers/cc files. cc_library( name = "basic_library_direct_includes", srcs = ["basic_source_test.cc"], hdrs = ["public/real_included_header.h"], includes = ["public"], ) # Coverage of a library that has deps, but no headers/includes/srcs. cc_library( name = "shim_library", implementation_deps = [":basic_library_virtual_includes"], ) # Coverage of a binary's transitive dependencies. cc_binary( name = "basic_binary", srcs = ["basic_binary_test.cc"], deps = [ ":basic_library_direct_includes", # We should still get compile commands for the transitive dependencies. ":shim_library", ], ) # Coverage of dependencies that aren't remotely related to C/C++. cc_library( name = "non_cpp_deps", # This is nonsense, but shouldn't break anything. data = [ "@pigweed_python_packages//sphinx", ], ) # Coverage of platform_data. platform_data( name = "mcu_transition", platform = "//targets/rp2040", target = ":basic_binary", ) # This ensures that things like module map files are generated before # we integration test against clangd. filegroup( name = "test_compile_commands_outputs", srcs = [ ":basic_library_direct_includes", ":basic_library_virtual_includes", ":mcu_transition", ":non_cpp_deps", ], visibility = ["//pw_ide/bazel:__subpackages__"], ) pw_cc_compile_commands_fragments( name = "test_compile_commands", targets = [ ":test_compile_commands_outputs", ], visibility = ["//pw_ide/bazel:__subpackages__"], )