Open Wyverald opened 1 month ago
I would like to get rid of workspace_root
as well, with a suitably named replacement. Otherwise we would still have mentions of workspace
stick around that would require another flag migration to get rid of.
What's a good replacement? exec_root
or some such?
I would say repo_root
or repo_path
. I would prefer the latter as File#root
returns a special starlark type, not a string.
Also, aren't most incompatible flags set up so that they are flipped from off to on? I could see a "disable" version of this being a better fit for .bazelrc
files.
Motivation
Several old Starlark APIs related to labels had confusing names and/or behavior. This change deprecates those old APIs in favor of new ones with clearer names and intent.
Description
When
--incompatible_enable_deprecated_label_apis
is set to False:native.repository_name()
is removed. Usenative.repo_name()
instead, which has a shorter name, and doesn't include a leading@
.Label.workspace_name
is removed. UseLabel.repo_name
instead, which has a clearer name, and behaves identically as the removed field.Label.relative()
is removed. It has never functioned well with repo mapping. Instead, use the new methodLabel.same_package_label()
, alongside the existingnative.package_relative_label()
andLabel()
.Incompatible Flag
--incompatible_enable_deprecated_label_apis
Migration Guide
native.repository_name()
can be replaced with'@' + native.repo_name()
.Label.workspace_name
can be replaced withLabel.repo_name
.Label.relative()
can be replaced with::foo
), useLabel.same_package_label('foo')
instaed.native.package_relative_label()
instead.Label()
instead.The newer APIs are only available in 7.1.0+. If backwards compatibility is a concern, use
hasattr()
.In which Bazel LTS version will this incompatible change be enabled?
Bazel 8
Additional Context
No response
TODO List