-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-rust-benchmark
- Loading branch information
Showing
14 changed files
with
203 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,7 @@ PAGES = dict([ | |
"rust_benchmark", | ||
"rust_test", | ||
"rust_test_suite", | ||
"extra_rustc_flags", | ||
], | ||
), | ||
page( | ||
|
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
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,5 @@ | ||
load(":extra_rustc_flags_test.bzl", "extra_rustc_flags_test_suite") | ||
|
||
extra_rustc_flags_test_suite( | ||
name = "extra_rustc_flags_test_suite", | ||
) |
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,94 @@ | ||
"""Unittest to verify compile_data (attribute) propagation""" | ||
|
||
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") | ||
load("//rust:defs.bzl", "rust_library") | ||
load("//test/unit:common.bzl", "assert_argv_contains", "assert_argv_contains_not") | ||
|
||
EXTRA_FLAG = "--codegen=linker-plugin-lto" | ||
|
||
def target_action_contains_not_flag(env, target): | ||
action = target.actions[0] | ||
asserts.equals(env, "Rustc", action.mnemonic) | ||
|
||
assert_argv_contains_not( | ||
env = env, | ||
action = action, | ||
flag = EXTRA_FLAG, | ||
) | ||
|
||
def target_action_contains_flag(env, target): | ||
action = target.actions[0] | ||
asserts.equals(env, "Rustc", action.mnemonic) | ||
|
||
assert_argv_contains( | ||
env = env, | ||
action = action, | ||
flag = EXTRA_FLAG, | ||
) | ||
|
||
def _extra_rustc_flags_not_present_test(ctx): | ||
env = analysistest.begin(ctx) | ||
target = analysistest.target_under_test(env) | ||
target_action_contains_not_flag(env, target) | ||
|
||
return analysistest.end(env) | ||
|
||
def _extra_rustc_flags_present_test(ctx): | ||
env = analysistest.begin(ctx) | ||
target = analysistest.target_under_test(env) | ||
target_action_contains_flag(env, target) | ||
|
||
# Check the exec configuration target does NOT contain. | ||
target = ctx.attr.lib_exec | ||
target_action_contains_not_flag(env, target) | ||
|
||
return analysistest.end(env) | ||
|
||
extra_rustc_flags_not_present_test = analysistest.make(_extra_rustc_flags_not_present_test) | ||
extra_rustc_flags_present_test = analysistest.make( | ||
_extra_rustc_flags_present_test, | ||
attrs = { | ||
"lib_exec": attr.label( | ||
mandatory = True, | ||
cfg = "exec", | ||
), | ||
}, | ||
config_settings = { | ||
"//:extra_rustc_flags": [EXTRA_FLAG], | ||
}, | ||
) | ||
|
||
def _define_test_targets(): | ||
rust_library( | ||
name = "lib", | ||
srcs = ["lib.rs"], | ||
edition = "2018", | ||
) | ||
|
||
def extra_rustc_flags_test_suite(name): | ||
"""Entry-point macro called from the BUILD file. | ||
Args: | ||
name (str): Name of the macro. | ||
""" | ||
|
||
_define_test_targets() | ||
|
||
extra_rustc_flags_not_present_test( | ||
name = "extra_rustc_flags_not_present_test", | ||
target_under_test = ":lib", | ||
) | ||
|
||
extra_rustc_flags_present_test( | ||
name = "extra_rustc_flags_present_test", | ||
target_under_test = ":lib", | ||
lib_exec = ":lib", | ||
) | ||
|
||
native.test_suite( | ||
name = name, | ||
tests = [ | ||
":extra_rustc_flags_not_present_test", | ||
":extra_rustc_flags_present_test", | ||
], | ||
) |
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 @@ | ||
pub fn call() {} |