forked from bazelbuild/rules_docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
By defaults, stamp only under --stamp configuration.
This follows the example of rules_go and rules_nodejs. It means we don't produce cache-busting outputs unless the user explicitly requests non-deteriminism in the build with --stamp. BREAKING CHANGE: - To get stamped outputs, users must now call bazel with `--stamp` - the stamp attribute is removed from some providers - the stamp attribute is now trinary Fixes bazelbuild#1451
- Loading branch information
Showing
10 changed files
with
116 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"Helpers to determine when to stamp build outputs" | ||
|
||
load(":stamp.bzl", "stamp_setting") | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
# Detect if the build is running under --stamp | ||
config_setting( | ||
name = "stamp", | ||
values = {"stamp": "true"}, | ||
) | ||
|
||
# Enable stamping based on the --stamp flag | ||
stamp_setting( | ||
name = "use_stamp_flag", | ||
stamp = select({ | ||
"@io_bazel_rules_docker//stamp:stamp": True, | ||
"//conditions:default": False, | ||
}), | ||
) | ||
|
||
stamp_setting( | ||
name = "always", | ||
stamp = True, | ||
) | ||
|
||
stamp_setting( | ||
name = "never", | ||
stamp = False, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"Helper for determining when to stamp build outputs" | ||
|
||
load("@io_bazel_rules_docker//container:providers.bzl", "StampSettingInfo") | ||
|
||
def _impl(ctx): | ||
return [StampSettingInfo(value = ctx.attr.stamp)] | ||
|
||
# Modelled after go_context_data in rules_go | ||
# Works around github.com/bazelbuild/bazel/issues/1054 | ||
stamp_setting = rule( | ||
implementation = _impl, | ||
attrs = { | ||
"stamp": attr.bool(mandatory = True), | ||
}, | ||
doc = """Determines whether build outputs should be stamped with version control info. | ||
Stamping causes outputs to be non-deterministic, resulting in cache misses.""", | ||
) |
Oops, something went wrong.