-
-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add some transitions for wasi/wasm targets
- Loading branch information
Showing
1 changed file
with
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
"""Some alias rules that transition `--platforms`.""" | ||
|
||
def _wasm_platform_transition(_settings, _attr): | ||
return { | ||
"//command_line_option:platforms": | ||
str(Label("//tests/extra_targets/wasm:wasm")), | ||
} | ||
|
||
wasm_platform_transition = transition( | ||
implementation = _wasm_platform_transition, | ||
inputs = [], | ||
outputs = ["//command_line_option:platforms"], | ||
) | ||
|
||
def _wasm_file_impl(ctx): | ||
wasm_file = ctx.attr.name | ||
wasm_file = ctx.actions.declare_file(wasm_file) | ||
ctx.actions.symlink( | ||
output = wasm_file, | ||
target_file = ctx.executable.src, | ||
is_executable = True, | ||
) | ||
|
||
return [DefaultInfo(files = depset([wasm_file]))] | ||
|
||
wasm_file = rule( | ||
implementation = _wasm_file_impl, | ||
attrs = { | ||
"src": attr.label( | ||
executable = True, | ||
cfg = wasm_platform_transition, | ||
mandatory = True, | ||
doc = "TODO", | ||
), | ||
"_allowlist_function_transition": attr.label( | ||
default = "@bazel_tools//tools/allowlists/function_transition_allowlist" | ||
), | ||
}, | ||
incompatible_use_toolchain_transition = True, | ||
doc = "TODO", | ||
) | ||
|
||
############################################################################### | ||
|
||
def _wasi_platform_transition(_settings, _attr): | ||
return { | ||
"//command_line_option:platforms": | ||
str(Label("//tests/extra_targets/wasm:wasi")), | ||
} | ||
|
||
wasi_platform_transition = transition( | ||
implementation = _wasi_platform_transition, | ||
inputs = [], | ||
outputs = ["//command_line_option:platforms"], | ||
) | ||
|
||
def _wasi_file_impl(ctx): | ||
wasi_file = ctx.attr.name | ||
wasi_file = ctx.actions.declare_file(wasi_file) | ||
ctx.actions.symlink( | ||
output = wasi_file, | ||
target_file = ctx.executable.src, | ||
is_executable = True, | ||
) | ||
|
||
return [DefaultInfo(files = depset([wasi_file]))] | ||
|
||
wasi_file = rule( | ||
implementation = _wasi_file_impl, | ||
attrs = { | ||
"src": attr.label( | ||
executable = True, | ||
cfg = wasi_platform_transition, | ||
mandatory = True, | ||
doc = "TODO", | ||
), | ||
"_allowlist_function_transition": attr.label( | ||
default = "@bazel_tools//tools/allowlists/function_transition_allowlist" | ||
), | ||
}, | ||
incompatible_use_toolchain_transition = True, | ||
doc = "TODO", | ||
) |