How to use Conan in Bazel

Viewed 372

I am new in bazel and conan. I try run conan in bazel use it https://docs.conan.io/en/1.44/integrations/build_system/bazel.html

In WORSPACE file:

load("//third-party/grpc:direct.bzl", "load_conan_dependencies")

In direct.bzl

load("@//conandeps:dependencies.bzl", "load_conan_dependencies")

conanfile.txt

[requires]
grpc/1.45.2

[generators]
cmake

When i try bazel sync then has message:

ERROR: error loading package '': at /Users/a19583433/_WORK/videomix/third-party/grpc/direct.bzl:5:6: Label '//conandeps:dependencies.bzl' is invalid because 'conandeps' is not a package; perhaps you meant to put the colon here: '//:conandeps/dependencies.bzl'?

What am I doing wrong?

1 Answers

The doc is a little bit misleading - In short, conandeps is not a keyword, and you should replace conandeps to the subfolder that holds your conanfile.txt

e.g., you should have your load function like load("@//subfolder1:dependencies.bzl", "load_conan_dependencies") when you have the following folder structure

project
│   WORKSPACE
│   somefile.txt   
│
└───subfolder1
    │   conanfile.txt
    │   somefile.txt

Related