@@ -559,6 +559,7 @@ def _generate_hub_and_spokes(
559559 splicing_config ,
560560 lockfile ,
561561 skip_cargo_lockfile_overwrite ,
562+ strip_internal_dependencies_from_cargo_lockfile ,
562563 cargo_lockfile = None ,
563564 manifests = {},
564565 packages = {}):
@@ -575,6 +576,11 @@ def _generate_hub_and_spokes(
575576 skip_cargo_lockfile_overwrite (bool): Whether to skip writing the cargo lockfile back after resolving.
576577 You may want to set this if your dependency versions are maintained externally through a non-trivial set-up.
577578 But you probably don't want to set this.
579+ strip_internal_dependencies_from_cargo_lockfile (bool): Whether to strip internal dependencies from the cargo lockfile.
580+ You may want to use this if you want to maintain a cargo lockfile for bazel only.
581+ Bazel only requires external dependencies to be present in the lockfile.
582+ By removing internal dependencies, the lockfile changes less frequently which reduces merge conflicts
583+ in other lockfiles where the cargo lockfile's sha is stored.
578584 cargo_lockfile (path): Path to Cargo.lock, if we have one.
579585 manifests (dict): The set of Cargo.toml manifests that apply to this closure, if any, keyed by path.
580586 packages (dict): The set of extra cargo crate tags that apply to this closure, if any, keyed by package name.
@@ -684,6 +690,7 @@ def _generate_hub_and_spokes(
684690 paths_to_track_file = paths_to_track_file ,
685691 warnings_output_file = warnings_output_file ,
686692 skip_cargo_lockfile_overwrite = skip_cargo_lockfile_overwrite ,
693+ strip_internal_dependencies_from_cargo_lockfile = strip_internal_dependencies_from_cargo_lockfile ,
687694 ** kwargs
688695 )
689696
@@ -1169,6 +1176,7 @@ def _crate_impl(module_ctx):
11691176 manifests = manifests ,
11701177 packages = packages ,
11711178 skip_cargo_lockfile_overwrite = cfg .skip_cargo_lockfile_overwrite ,
1179+ strip_internal_dependencies_from_cargo_lockfile = cfg .strip_internal_dependencies_from_cargo_lockfile ,
11721180 )
11731181
11741182 metadata_kwargs = {}
@@ -1210,6 +1218,16 @@ _FROM_COMMON_ATTRS = {
12101218 ),
12111219 default = False ,
12121220 ),
1221+ "strip_internal_dependencies_from_cargo_lockfile" : attr .bool (
1222+ doc = (
1223+ "Whether to strip internal dependencies from the cargo lockfile. " +
1224+ "You may want to use this if you want to maintain a cargo lockfile for bazel only. " +
1225+ "Bazel only requires external dependencies to be present in the lockfile. " +
1226+ "By removing internal dependencies, the lockfile changes less frequently which reduces merge conflicts " +
1227+ "in other lockfiles where the cargo lockfile's sha is stored."
1228+ ),
1229+ default = False ,
1230+ ),
12131231 "supported_platform_triples" : attr .string_list (
12141232 doc = "A set of all platform triples to consider when generating dependencies." ,
12151233 default = SUPPORTED_PLATFORM_TRIPLES ,
0 commit comments