-
Notifications
You must be signed in to change notification settings - Fork 989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] (Possibility to) change output path for generated Bazel BUILD files by BazelDeps #14282
Comments
Hi @aander80 Thanks for your suggestion
I don't know enough about Bazel, but I thought that it was kind of restrictive regarding the location of the files and folders, are you sure this is possible? It is pending a whole re-design/refactor of the BazelDeps (cc @franramirez688), we can try to consider and check this, but if you use Bazel and are experienced with it, your feedback will be valuable. |
Hello! Thank you for considering this! I do not have much Bazel experience so I cannot say what the best structure is. However, if I understand the dependencies.bzl and /BUILD files, it should be possible to move the folders into a sub-folder and update dependencies.bzl to reflect this. I tried to run this locally and it seems to work for me. Please try the following commands from the repo root of the test repo that I linked above. # Start from repo root of bazel-test
cd conan
conan create say
cd hello
conan install .
mkdir bazeldeps # Create folder to contain all dependency sub-folders
mv say bazeldeps # Move only existing (generated) dependency files into shared dep folder
sed -i 's/bazel-test\/conan\/hello\/say/bazel-test\/conan\/hello\/bazeldeps\/say/' dependencies.bzl # Update dependencies.bzl to point to the correct path
bazel build //src:hello # hello should now be built using the say requirement from bazeldeps/say/BUILD I think that what might be restrictive is the path to dependencies.bzl, but as long as that exists in the root of the generators folder (which in this case is the source folder due to bazel_layout) it should be fine (although, again, I do not have much Bazel experience to know if this is a good practice or not). |
This issue should be solved by #14958 Using the UPDATED: @aander80 to clarify the final solution, we wanted to keep complete backward compatibility in Conan 1.x, so for now, you can get this doing something like: def layout(self):
# Default generators folder will be "conan" in Conan 2.x
self.folders.generators = "conan"
bazel_layout(self) In Conan 2.x, as the comment shows, |
Closed by #14958 for next 1.62 (and 2.0.14) |
What is your suggestion?
Hello!
I have tried using Bazel using conan 2.0.7. While I can get it running, I have noticed that the dependency BUILD files are in subfolders directly under the build_folder. If bazel_layout is used, this causes
<dep>/BUILD
files to be generated. In git directories, this requires adding to .gitignore for each dependency we may have, which is tedious to maintain. A suggestion for solving this is to either put all of the generated folders per requirement into a subfolder under generators folder (something likegenerators_folder/conandeps/<dep>/BUILD
), or to provide an option when calling BazelDeps to put the generated files into a single subfolder; this would help sorting generated files and avoid missing to add generated files to a git repo.I guess this is related to the changes with regards to #10676.
An example for reproducing this:
Another suggestion for properly maintaining Bazel repos using conan is very much appreciated; I am new to Bazel and am happy to learn!
Have you read the CONTRIBUTING guide?
The text was updated successfully, but these errors were encountered: