Skip to content

Commit

Permalink
deterministic_output -> hardcode_permissions_for_deterministic_output
Browse files Browse the repository at this point in the history
Summary: I think it's important that people know the trade-off here, so let's make it clear what this flag is doing.

Reviewed By: christolliday

Differential Revision: D67449762

fbshipit-source-id: 7d4fcf93951b8858332872c771ab5d69d9fa7ef6
  • Loading branch information
Ian Childs authored and facebook-github-bot committed Dec 20, 2024
1 parent a1a6368 commit 6e8e562
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions decls/core_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1485,10 +1485,9 @@ zip_file = prelude_rule(
The regexes must be defined using `java.util.regex.Pattern` syntax.
"""),
"deterministic_output": attrs.option(attrs.bool(), default = None, doc = """
If set to true, Buck ensures that all files in the generated zip and their associated metadata are
consistent across all platforms, resulting in an identical zip file everywhere. Note that this might
come at the expense of losing some otherwise relevant metadata, like file permissions and timestamps.
"hardcode_permissions_for_deterministic_output": attrs.option(attrs.bool(), default = None, doc = """
If set to true, Buck hardcodes the permissions in order to ensures that all files have the same
permissions regardless of the platform on which the zip was generated.
"""),
"on_duplicate_entry": attrs.enum(OnDuplicateEntry, default = "overwrite", doc = """
Action performed when Buck detects that zip\\_file input contains multiple entries with the same
Expand Down
6 changes: 3 additions & 3 deletions zip_file/zip_file.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _zip_file_impl(ctx: AnalysisContext) -> list[Provider]:

on_duplicate_entry = ctx.attrs.on_duplicate_entry
entries_to_exclude = ctx.attrs.entries_to_exclude
deterministic_output = ctx.attrs.deterministic_output
hardcode_permissions_for_deterministic_output = ctx.attrs.hardcode_permissions_for_deterministic_output
zip_srcs = ctx.attrs.zip_srcs
srcs = ctx.attrs.srcs

Expand Down Expand Up @@ -60,8 +60,8 @@ def _zip_file_impl(ctx: AnalysisContext) -> list[Provider]:
create_zip_cmd.append("--entries_to_exclude")
create_zip_cmd.append(entries_to_exclude)

if deterministic_output:
create_zip_cmd.append("--deterministic_output")
if hardcode_permissions_for_deterministic_output:
create_zip_cmd.append("--hardcode_permissions_for_deterministic_output")

ctx.actions.run(cmd_args(create_zip_cmd), category = "zip")

Expand Down

0 comments on commit 6e8e562

Please # to comment.