I am new in Bazel and trying to build a cc_binary with cc_library from another repository. Lets assume we have two repos: repA repB
in repA:
-uart.c
-uart.h
-BUILD
the content of BUILD is the following:
package(default_visibility = ["//visibility:public"])
cc_library(
name = "uart",
srcs = [
"uart.c",
],
hdrs = [
"uart.h",
],
)
in repB:
-hello_world.c
-hello_world.h
-main.c
-BUILD
the content of BUILD is the following:
cc_binary(
name = "main",
srcs = [
"main.c",
],
deps = [
":hello_world",
],
)
cc_library(
name = "hello_world",
srcs = [
"hello_world.c",
],
hdrs = [
"hello_world.h",
],
deps = [
"//repA:uart",
],
)
If try to build hello_world it gives me the following error (the same applies if building main binary):
/gcc-compiler/bin/riscv64-unknown-elf-gcc -MD -MF bazel-out/k8-fastbuild/bin/repB/_objs/hello_world/hello_world.d '-frandom-seed=bazel-out/k8-fastbuild/bin/sw/testlist/Debug/_objs/hello_world/hello_world.o' '-DBAZEL_CURRENT_REPOSITORY=""' -iquote . -iquote bazel-out/k8-fastbuild/bin '-std=gnu11' -c repB/hello_world.c -o bazel-out/k8-fastbuild/bin/repB/_objs/hello_world/hello_world.o)
# Configuration: 0f8097b1395089db7bf8bb7a71ae2834bd242d8064325600934daade0dbae90f
# Execution platform: @local_config_platform//:host
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
repB/hello_world.c:3:10: fatal error: uart.h: No such file or directory
3 | #include "uart.h"
| ^~~~~~~~
However, if i put all files in the same repo, it builds successfully
Seems to me I am missing something very tiny...
Any help would be greatly appreciated