Skip to content

Commit

Permalink
unpin buildifier (#1135)
Browse files Browse the repository at this point in the history
* Fixed cdylib_has_native_dep_and_alwayslink_test

* unpin buildifier

* Fixed buildifier defects
  • Loading branch information
UebelAndre committed Feb 15, 2022
1 parent f427b89 commit e7a9b8b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 27 deletions.
6 changes: 1 addition & 5 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,5 @@ tasks:
# TODO: fix test targets in `crate_universe_windows_targets`
test_targets: *crate_universe_windows_targets
buildifier:
# TODO: Version 5.0.0 introduced a ton of unused variable warnings in cases
# that should have been accounted for by `_` prefixes on the variable. Buildifier
# should ignore `_` prefixed variables when checking if something is unused
# https://github.com/bazelbuild/buildtools/issues/1044
version: 4.2.5
version: latest
warnings: "all"
3 changes: 0 additions & 3 deletions rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1133,9 +1133,6 @@ def _make_link_flags_default(linker_input):
ret.extend(_portable_link_flags(lib))
return ret

def _libraries_dirnames(linker_input):
return [get_preferred_artifact(lib).dirname for lib in linker_input.libraries]

def _add_native_link_flags(args, dep_info, linkstamp_outs, crate_type, toolchain, cc_toolchain, feature_configuration):
"""Adds linker flags for all dependencies of the current target.
Expand Down
13 changes: 3 additions & 10 deletions rust/private/rustdoc_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ load("//rust/private:common.bzl", "rust_common")
load("//rust/private:rustdoc.bzl", "rustdoc_compile_action")
load("//rust/private:utils.bzl", "dedent", "find_toolchain")

def _construct_writer_arguments(ctx, test_runner, action, crate_info, rust_toolchain):
def _construct_writer_arguments(ctx, test_runner, action, crate_info):
"""Construct arguments and environment variables specific to `rustdoc_test_writer`.
This is largely solving for the fact that tests run from a runfiles directory
Expand All @@ -30,28 +30,22 @@ def _construct_writer_arguments(ctx, test_runner, action, crate_info, rust_toolc
test_runner (File): The test_runner output file declared by `rustdoc_test`.
action (struct): Action arguments generated by `rustdoc_compile_action`.
crate_info (CrateInfo): The provider of the crate who's docs are being tested.
rust_toolchain (rust_toolchain): The currently configured `rust_toolchain`.
Returns:
tuple: A tuple of `rustdoc_test_writer` specific inputs
- Args: Arguments for the test writer
- dict: Required environment variables
"""

# Set the SYSROOT to the directory of the rust_lib files passed to the toolchain
env = {
"SYSROOT": "${{pwd}}/{}".format(rust_toolchain.sysroot),
}

writer_args = ctx.actions.args()

# Track the output path where the test writer should write the test
writer_args.add("--output={}".format(test_runner.path))

# Track what environment variables should be written to the test runner
writer_args.add("--action_env=DEVELOPER_DIR")
writer_args.add("--action_env=SDKROOT")
writer_args.add("--action_env=PATHEXT")
writer_args.add("--action_env=SDKROOT")
writer_args.add("--action_env=SYSROOT")
for var in action.env.keys():
writer_args.add("--action_env={}".format(var))
Expand Down Expand Up @@ -113,7 +107,7 @@ def _rust_doc_test_impl(ctx):

action = rustdoc_compile_action(
ctx = ctx,
toolchain = find_toolchain(ctx),
toolchain = toolchain,
crate_info = crate_info,
rustdoc_flags = rustdoc_flags,
is_test = True,
Expand All @@ -126,7 +120,6 @@ def _rust_doc_test_impl(ctx):
test_runner = test_runner,
action = action,
crate_info = crate_info,
rust_toolchain = toolchain,
)

# Allow writer environment variables to override those from the action.
Expand Down
18 changes: 9 additions & 9 deletions test/unit/native_deps/native_deps_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def _additional_deps_test():
cc_library(
name = "additional_deps_cc",
srcs = ["native_dep.cc"],
linkopts = ["-L$(location :dynamic.lds)"],
linkopts = ["-L$(execpath :dynamic.lds)"],
deps = [":dynamic.lds"],
)

Expand Down Expand Up @@ -372,16 +372,16 @@ def native_deps_test_suite(name):
native.test_suite(
name = name,
tests = [
":rlib_has_no_native_libs_test",
":staticlib_has_native_libs_test",
":cdylib_has_native_libs_test",
":proc_macro_has_native_libs_test",
":bin_has_native_libs_test",
":bin_has_native_dep_and_alwayslink_test",
":cdylib_has_native_dep_and_alwayslink_test",
":native_linkopts_propagate_test",
":bin_has_additional_deps_test",
":bin_has_native_dep_and_alwayslink_test",
":bin_has_native_libs_test",
":cdylib_has_additional_deps_test",
":cdylib_has_native_dep_and_alwayslink_test",
":cdylib_has_native_libs_test",
":lib_has_no_additional_deps_test",
":native_linkopts_propagate_test",
":proc_macro_has_native_libs_test",
":rlib_has_no_native_libs_test",
":staticlib_has_native_libs_test",
],
)

0 comments on commit e7a9b8b

Please sign in to comment.