forked from bazel-contrib/toolchains_llvm
-
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.
tests: test that
.dwp
targets can be built
This has some things we'll eventually want to remove; see bazel-contrib#109 for some context.
- Loading branch information
Showing
2 changed files
with
85 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
"""Helper transitions for tests.""" | ||
|
||
def _fission_transition_impl(settings, attr): | ||
features = settings["//command_line_option:features"] | ||
if "per_object_debug_info" in features: | ||
features.remove("per_object_debug_info") | ||
|
||
enable_per_object_debug_info = attr.per_object_debug_info | ||
if enable_per_object_debug_info: | ||
features.append("per_object_debug_info") | ||
|
||
return { | ||
"//command_line_option:fission": attr.fission, | ||
"//command_line_option:features": features, | ||
} | ||
|
||
fission_transition = transition( | ||
implementation = _fission_transition_impl, | ||
inputs = ["//command_line_option:features"], | ||
outputs = [ | ||
"//command_line_option:features", | ||
"//command_line_option:fission", | ||
], | ||
) | ||
|
||
def _dwp_file_impl(ctx): | ||
file = ctx.attr.name | ||
file = ctx.actions.declare_file(file) | ||
ctx.actions.symlink( | ||
output = file, | ||
target_file = ctx.attr.src[0][DebugPackageInfo].dwp_file, | ||
) | ||
|
||
return [DefaultInfo(files = depset([file]))] | ||
|
||
dwp_file = rule( | ||
implementation = _dwp_file_impl, | ||
attrs = { | ||
"src": attr.label( | ||
cfg = fission_transition, | ||
mandatory = True, | ||
doc = "The actual target to build and grab the .dwp file from.", | ||
providers = [DebugPackageInfo], | ||
), | ||
# NOTE: we should eventually be able to remove this (see #109). | ||
"per_object_debug_info": attr.bool( | ||
default = True, | ||
), | ||
"fission": attr.string( | ||
default = "yes", | ||
values = ["yes", "no", "dbg", "fastbuild", "opt"], | ||
), | ||
"_allowlist_function_transition": attr.label( | ||
default = "@bazel_tools//tools/allowlists/function_transition_allowlist" | ||
), | ||
}, | ||
incompatible_use_toolchain_transition = True, | ||
) |