Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed test launcher's install script in favor of ctx.actions.symlink #609

Merged
merged 2 commits into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 5 additions & 27 deletions rust/private/rust.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -284,34 +284,20 @@ def _create_test_launcher(ctx, toolchain, output, providers):
list: A list of providers similar to `rustc_compile_action` but with modified default info
"""

args = ctx.actions.args()

# TODO: It's unclear if the toolchain is in the same configuration as the `_launcher` attribute
# This should be investigated but for now, we generally assume if the target environment is windows,
# the execution environment is windows.
if toolchain.os == "windows":
launcher = ctx.actions.declare_file(name_to_crate_name(ctx.label.name + ".launcher.exe"))

# Because the windows target is a batch file, it expects native windows paths (with backslashes)
args.add_all([
ctx.executable._launcher.path.replace("/", "\\"),
launcher.path.replace("/", "\\"),
])
else:
launcher = ctx.actions.declare_file(name_to_crate_name(ctx.label.name + ".launcher"))
args.add_all([
ctx.executable._launcher,
launcher,
])

# Because returned executables must be created from the same rule, the
# launcher target is simply copied and exposed.
ctx.actions.run(
outputs = [launcher],
tools = [ctx.executable._launcher],
mnemonic = "GeneratingLauncher",
executable = ctx.executable._launcher_installer,
arguments = [args],
# launcher target is simply symlinked and exposed.
ctx.actions.symlink(
output = launcher,
target_file = ctx.executable._launcher,
is_executable = True,
)

# Get data attribute
Expand Down Expand Up @@ -667,14 +653,6 @@ _rust_test_attrs = {
and ensuring the variables are set for the underlying test executable.
"""),
),
"_launcher_installer": attr.label(
executable = True,
default = Label("//util/launcher:installer"),
cfg = "exec",
doc = _tidy("""
A helper script for creating an installer within the test rule.
"""),
),
}

rust_library = rule(
Expand Down
11 changes: 1 addition & 10 deletions util/launcher/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
load("//rust:rust.bzl", "rust_binary")
load(":installer.bzl", "installer")

package(default_visibility = ["//visibility:public"])

rust_binary(
name = "launcher",
srcs = ["launcher_main.rs"],
edition = "2018",
srcs = ["launcher_main.rs"]
)

installer(
name = "installer",
src = select({
"//rust/platform:windows": "launcher_installer.bat",
"//conditions:default": "launcher_installer.sh",
}),
)
36 changes: 0 additions & 36 deletions util/launcher/installer.bzl

This file was deleted.

5 changes: 0 additions & 5 deletions util/launcher/launcher_installer.bat

This file was deleted.

5 changes: 0 additions & 5 deletions util/launcher/launcher_installer.sh

This file was deleted.