Open knzivid opened 2 years ago
Here's a hacky workaround
From f979f6274d73dea9a7e412696a8a46270ad95d64 Mon Sep 17 00:00:00 2001
From: Karthik Nishanth <karthik.nishanth@zivid.com>
Date: Wed, 20 Oct 2021 09:56:05 +0200
Subject: [PATCH] add label customization to BazelDeps
---
conan/tools/google/bazeldeps.py | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/conan/tools/google/bazeldeps.py b/conan/tools/google/bazeldeps.py
index 8df952a8d5..a2dd698801 100644
--- a/conan/tools/google/bazeldeps.py
+++ b/conan/tools/google/bazeldeps.py
@@ -105,21 +105,21 @@ def _get_dependency_buildfile_content(self, dependency):
def _create_new_local_repository(self, dependency, dependency_buildfile_name):
snippet = textwrap.dedent("""
native.new_local_repository(
- name="{}",
- path="{}",
- build_file="{}",
+ name="{name}",
+ path="{path}",
+ build_file=label_func("{build_file}") if label_func else "{build_file}",
)
""").format(
- dependency.ref.name,
- dependency.package_folder,
- dependency_buildfile_name
+ name=dependency.ref.name,
+ path=dependency.package_folder,
+ build_file=dependency_buildfile_name,
)
return snippet
def _get_main_buildfile_content(self, local_repositories):
template = textwrap.dedent("""
- def load_conan_dependencies():
+ def load_conan_dependencies(label_func = None):
{}
""")
Any update on this yet?
I have a
repository_rule
that wrapsconan install ...
with BazelDeps as the generator. However,conandeps/dependencies.bzl
hardcodes the path tobuild_file
asconandeps/<pkg>/BUILD
. When I callload_conan_dependencies
from@custom-repo//conandeps:dependencies.bzl
, thebuild_file
turns out to be incorrect.My suggestion is to allow a
conandeps_root
parameter toload_conan_dependencies
to allow customization.