es-ude / EmbeddedSystemsBuildScripts

Bazel build scripts used for all projects of the embedded systems department
MIT License
4 stars 5 forks source link

convert mock from macro to rule #1

Open glencoe opened 5 years ago

glencoe commented 5 years ago

The use of macros is discouraged since macros are expanded before the loading phase. This makes debugging more difficult. Create a mock rule, that returns a provider similar to the filegroup rule to allow usage as follows.

mock(
  name = "MyMock",
  hdr = "include/header.h",
  library = ["//:LibProvidingHeader"]
)

mock(
  name = "OtherMock",
  hdr = "package_relative_path_to_hdr.h"
)

cc_test(
  name = "Test",
  srcs = [":MyMock", ":OtherMock", "Test.c"],
  deps = ["//:LibContainingCodeUnderTest"]
)