-
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
[Bazel][Part 1]: Bazel/BazelToolchain refactor #14845
[Bazel][Part 1]: Bazel/BazelToolchain refactor #14845
Conversation
454905f
to
5b3dbba
Compare
@@ -9,12 +9,12 @@ | |||
class {{package_name}}Recipe(ConanFile): | |||
name = "{{name}}" | |||
version = "{{version}}" | |||
package_type = "library" | |||
package_type = "static-library" |
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.
static one as Bazel, AFAIK, has no dynamic way to build a shared/static library. It has options as --dynamic_mode=fully
but it's not working as expected. The only way that I got it was to add linkshared=True
to the BUILD file in the test_package but it made useless the use of shared=True
dynamically
self.strip = 'sometimes' # 'always', 'sometimes', 'never' | ||
self.compilation_mode = "fastbuild" # 'fastbuild', 'dbg', 'opt' |
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.
Checking the docs I think we don't need to define strip
because it has a default of sometimes
in Bazel, that will only strip the debug information for fastbuild
mode and fastbuild
mode I think that should only be defined by the user because it does not directly correspond to neither Debug or Release of our settings. So I would propose setting something like:
self.strip = None
self.compilation_mode = {'Release': 'opt',
'Debug': 'dbg'}.get(self.settings.build_type)
The user will be able to change this in case they have another custom build type defined.
self.force_pic = fpic if (not shared and fpic is not None) else None | ||
# FIXME: Keeping this option but it's not working as expected. It's not creating the shared | ||
# libraries at all. | ||
self.dynamic_mode = "fully" if shared else "off" |
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.
As I commented above, it's not working as expected because it depends on the user's BUILD file. I've asked in the official Bazel Slack channel to know more about this.
subproject = conanfile.folders.subproject | ||
conanfile.folders.source = src_folder if not subproject else os.path.join(subproject, src_folder) | ||
conanfile.folders.build = "." # Bazel always build the whole project in the root folder | ||
conanfile.folders.generators = "bazel-conan-tools" # one |
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.
Minor thing, but what about changing the name of the folder to conan
or generators
like in other generators layouts?
conanfile.folders.generators = "bazel-conan-tools" # one | |
conanfile.folders.generators = "conan" # one |
Superseded by #14958 |
Changelog: Feature: BazelToolchain creates a
conan_bzl.rc
file which defines theconan-config
configuration. If it exists, Bazel helper will use it automatically.Changelog: Global refactor in BazelToolchain and Bazel conan.tools.google classes.
Docs: https://github.com/conan-io/docs/pull/XXXX
Closes: #14282 #14519
Summary:
bazel_layout is now creating all the Conan-generated files inside another folder,
bazel-conan-tools
.BazelToolchain is generating a
conan_bzl.rc
file with abuild:conan-config
configuration depending on your settings/options.BazelToolchain is not generating a real Bazel toolchain (https://bazel.build/extending/toolchains) because they require much more knowledge and expertise in Bazel to make a dynamic Bazel toolchain per user configuration.
Bazel is moving forward to platforms (https://bazel.build/extending/platforms) for future releases instead of toolchains but it does not imply that BazelToolchain could be incompatible but some changes to inject those platforms constraints in our conan-config configuration.