Skip to content

Commit cf60105

Browse files
authored
Ensures the determinism of vfsoverlay file (#912)
hdrs, private_hdrs and swiftmodules of the same framework may be in different order when building with different build settings in Bazel 7. This change will ensure that the vfsoverlay file will be always the same for the same dependency graph.
1 parent 9b3ba29 commit cf60105

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

rules/framework/vfs_overlay.bzl

+8-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ in-memory tree roots, it pre-pends the prefix of the `vfsoverlay` path
99
to each of the entries.
1010
"""
1111

12-
load("//rules:providers.bzl", "FrameworkInfo")
13-
load("//rules:features.bzl", "feature_names")
1412
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain")
1513
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_common")
14+
load("//rules:features.bzl", "feature_names")
15+
load("//rules:providers.bzl", "FrameworkInfo")
1616

1717
FRAMEWORK_SEARCH_PATH = "/build_bazel_rules_ios/frameworks"
1818

@@ -376,6 +376,12 @@ def make_vfsoverlay(ctx, hdrs, module_map, private_hdrs, has_swift, swiftmodules
376376
vfs_parent_len = len(vfs_parent.split("/")) - 1
377377
vfs_prefix = _make_relative_prefix(vfs_parent_len)
378378

379+
# Ensures the determinism of vfsoverlay file
380+
# hdrs, private_hdrs and swiftmodules of the same framework may be in different order.
381+
hdrs = sorted(hdrs)
382+
private_hdrs = sorted(private_hdrs)
383+
swiftmodules = sorted(swiftmodules)
384+
379385
data = struct(
380386
bin_dir_path = ctx.bin_dir.path,
381387
build_file_path = ctx.build_file_path,

0 commit comments

Comments
 (0)