-
Notifications
You must be signed in to change notification settings - Fork 326
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
feat(bazel): Add Conan dependencies to Bazel's dependency tree #10126
base: main
Are you sure you want to change the base?
feat(bazel): Add Conan dependencies to Bazel's dependency tree #10126
Conversation
4d1e0a4
to
f3c982a
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #10126 +/- ##
============================================
- Coverage 69.59% 69.55% -0.04%
Complexity 1454 1454
============================================
Files 270 270
Lines 9670 9678 +8
Branches 1029 1033 +4
============================================
+ Hits 6730 6732 +2
- Misses 2488 2494 +6
Partials 452 452
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
8d18240
to
1f5e04c
Compare
plugins/package-managers/conan/src/main/kotlin/ConanV2Handler.kt
Outdated
Show resolved
Hide resolved
1f5e04c
to
adec183
Compare
This comment was marked as resolved.
This comment was marked as resolved.
Signed-off-by: Nicolas Nobelis <[email protected]>
adec183
to
8719ccf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mnonnenmacher I'd like you to also have a look.
val conanPackages = mutableSetOf<Package>() | ||
|
||
conanExtension?.let { extension -> | ||
val conanProjectReferences = mutableSetOf<PackageReference>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about moving this whole long block to a function for readability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that resolveConanDependencies
has a lot of parameters to carry on. Do you still think this would be worthwhile ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say it depends on the concrete number... if it's more than 7 parameters, then not, probably.
* Only scan Bazel dependencies and skip reporting Conan packages in the dependency tree. | ||
*/ | ||
@OrtPluginOption(defaultValue = "false") | ||
val bazelDependenciesOnly: Boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to my comment on the previous commit, can't we archive the same by simply disabling Conan as a package manager? Or do you think there are use-cases where there are both Bazel and Conan projects in one repository, but they should be recognized independently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a case with one of our customer: they have a repository with Bazel and Conan definition files + Conan packages in the Bazel project.
Additionally I created the bazelDependenciesOnly
parameter because it also exist in Pub
, so you can see it as some kind of alignment.
@@ -56,6 +56,7 @@ import org.ossreviewtoolkit.plugins.api.OrtPlugin | |||
import org.ossreviewtoolkit.plugins.api.OrtPluginOption | |||
import org.ossreviewtoolkit.plugins.api.PluginDescriptor | |||
import org.ossreviewtoolkit.utils.common.CommandLineTool | |||
import org.ossreviewtoolkit.utils.common.alsoIfNull |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Esp. with this commit, I don't really see why one would need to disable the Bazel <-> Conan interaction.
8719ccf
to
146a501
Compare
146a501
to
9a85c6e
Compare
...ers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-conan-dependencies.yml
Show resolved
Hide resolved
a93baa6
to
b55755a
Compare
b55755a
to
8f426e7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, but I don't know much about Bazel. @sschuberth I assume you would also be fine with merging this as you dismissed your review?
val dependencies: List<BazelModule> = emptyList(), | ||
val extensionUsages: List<BazelExtension> = emptyList() | ||
) | ||
@Serializable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Missing blank line before this one.
I've dismissed my review as I current cannot spend the time to do yet another thorough review. I'm ok if you want to merge. |
It is possible to use Conan dependencies with Bazel. This commit changes the Bazel package manager to list the Conan dependencies with the Conan package manager and complete the Bazel dependency tree with them. The `PackageManagerDependency` approach in Pub/Gradle package manager cannot be used here as the Conan packages have to be filtered in correlation with the 'bazel mod graph' output. The test project has been generated thanks to the documentation at [1]. In addition to the files present in the source repository, the other files were generated by `conan install . --build=missing`. This command requires Conan version 2 and is a prerequisite for having the Conan dependencies available to Bazel. Please note that this command generates the needed Bazel files and builds the Conan dependencies. Consequently, it cannot be run by ORT: it is the responsibility of the repository owner to add the generated *.bazel and *.bzl files to the repository. There is a documentation at [2] about making Conan 1 work with Bazel, however the resulting project does not use `bzlmod` on which ORT relies. [1]: https://docs.conan.io/2/examples/tools/google/bazeltoolchain/build_simple_bazel_7x_project.html#examples-tools-bazel-7x-toolchain-build-simple-bazel-project [2]: https://docs.conan.io/1/integrations/build_system/bazel.html Signed-off-by: Nicolas Nobelis <[email protected]>
Signed-off-by: Nicolas Nobelis <[email protected]>
If a Bazel project uses some Conan packages, the corresponding Conan files should not be picked up by the Conan package manager. Therefore, the Conan file is checked to NOT contain the BazelDeps and BazelToolchain generators. Signed-off-by: Nicolas Nobelis <[email protected]>
8f426e7
to
f0c5148
Compare
Please have a look at the individual commit messages for the details.