Skip to content

Commit

Permalink
Run buildifier over bzl files
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Nov 12, 2019
1 parent bee5ee2 commit edfbeed
Show file tree
Hide file tree
Showing 21 changed files with 168 additions and 159 deletions.
4 changes: 2 additions & 2 deletions dotnet/merge-assemblies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def _merged_assembly_impl(ctx):
executable = ctx.executable.merge_tool,
arguments = args,
inputs = ctx.attr.src_assembly.files,
outputs = [ctx.outputs.out]
outputs = [ctx.outputs.out],
)

runfiles = ctx.runfiles(
Expand Down Expand Up @@ -57,7 +57,7 @@ merged_assembly = rule(
executable = True,
cfg = "host",
default = Label("//third_party/dotnet/ilmerge:ilmerge.exe"),
allow_single_file = True
allow_single_file = True,
),
},
toolchains = ["//third_party/dotnet/ilmerge:toolchain_type"],
Expand Down
10 changes: 5 additions & 5 deletions dotnet/nuget.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def _nuget_package_impl(ctx):
# "<base>/net46", etc.). The base path for creating the NuGet
# package should be the "<base>" directory, which we need to
# hard-code with the parent operator, because Bazel doesn't
# provide proper path traversal for custom rules.
# provide proper path traversal for custom rules.
base_path = ctx.files.deps[0].dirname + "/.."

args.append(ctx.expand_location(ctx.attr.src.files.to_list()[0].path))
Expand All @@ -33,7 +33,7 @@ def _nuget_package_impl(ctx):
inputs = ctx.attr.src.files.to_list() + ctx.files.deps,
outputs = [
package_file,
]
],
)

return DefaultInfo(files = depset([
Expand All @@ -44,7 +44,7 @@ nuget_package = rule(
implementation = _nuget_package_impl,
attrs = {
"src": attr.label(
allow_single_file = True
allow_single_file = True,
),
"deps": attr.label_list(),
"package_id": attr.string(),
Expand All @@ -53,7 +53,7 @@ nuget_package = rule(
executable = True,
cfg = "host",
default = Label("//third_party/dotnet/nuget:nuget.exe"),
allow_single_file = True
allow_single_file = True,
),
}
},
)
4 changes: 2 additions & 2 deletions dotnet/nunit-test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def _nunit_test_impl(ctx):
additional_args = "%*"
result_location = "%XML_OUTPUT_FILE%"
script_prefix = "@echo off"

script_file_name = "{}.{}".format(name, script_file_extension)
script_file = ctx.actions.declare_file(script_file_name)
script_content = TEST_RUNNER_SCRIPT_CONTENT.format(
Expand Down Expand Up @@ -133,7 +133,7 @@ nunit_test = rule(
"dotnet_context_data": attr.label(default = Label("@io_bazel_rules_dotnet//:dotnet_context_data")),
"test_runner": attr.label(
default = Label("//third_party/dotnet/nunit.console-3.10.0/bin/net35:nunitconsole"),
allow_files = True
allow_files = True,
),
"_copy": attr.label(default = Label("@io_bazel_rules_dotnet//dotnet/tools/copy")),
"_xslt": attr.label(default = Label("@io_bazel_rules_dotnet//tools/converttests:n3.xslt"), allow_files = True),
Expand Down
6 changes: 4 additions & 2 deletions dotnet/workspace.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
load("@d2l_rules_csharp//csharp:defs.bzl",
load(
"@d2l_rules_csharp//csharp:defs.bzl",
"csharp_register_toolchains",
"csharp_repositories",
"import_nuget_package")
"import_nuget_package",
)

def selenium_register_dotnet():
csharp_register_toolchains()
Expand Down
2 changes: 1 addition & 1 deletion java/defs.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("//java/private:dist_zip.bzl", _java_dist_zip = "java_dist_zip")
load("//java/private:export.bzl", _java_export = "java_export")
load("//java/private:test.bzl", _java_test_suite = "java_test_suite", _java_selenium_test_suite = "java_selenium_test_suite")
load("//java/private:test.bzl", _java_selenium_test_suite = "java_selenium_test_suite", _java_test_suite = "java_test_suite")

java_dist_zip = _java_dist_zip
java_export = _java_export
Expand Down
30 changes: 15 additions & 15 deletions java/private/dist_zip.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,21 @@ def _java_dist_zip_impl(ctx):

for info in infos:
for dist_info in info.dist_infos.to_list():
if not dist_info.binary_jar:
continue

inputs.append(dist_info.binary_jar)
if is_third_party(ctx.attr.third_party_prefixes, dist_info.target):
third_party.append("lib/%s.jar=%s" % (dist_info.base_name, dist_info.binary_jar.path))
else:
first_party.append("%s.jar=%s" % (dist_info.base_name, dist_info.binary_jar.path))

if dist_info.source_jar:
inputs.append(dist_info.source_jar)
if is_third_party(ctx.attr.third_party_prefixes, dist_info.target):
third_party.append("lib/%s-sources.jar=%s" % (dist_info.base_name, dist_info.source_jar.path))
else:
first_party.append("%s-sources.jar=%s" % (dist_info.base_name, dist_info.source_jar.path))
if not dist_info.binary_jar:
continue

inputs.append(dist_info.binary_jar)
if is_third_party(ctx.attr.third_party_prefixes, dist_info.target):
third_party.append("lib/%s.jar=%s" % (dist_info.base_name, dist_info.binary_jar.path))
else:
first_party.append("%s.jar=%s" % (dist_info.base_name, dist_info.binary_jar.path))

if dist_info.source_jar:
inputs.append(dist_info.source_jar)
if is_third_party(ctx.attr.third_party_prefixes, dist_info.target):
third_party.append("lib/%s-sources.jar=%s" % (dist_info.base_name, dist_info.source_jar.path))
else:
first_party.append("%s-sources.jar=%s" % (dist_info.base_name, dist_info.source_jar.path))

args.add_all(sorted(files))
args.add_all(sorted(first_party))
Expand Down
5 changes: 3 additions & 2 deletions java/private/export.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def java_export(
pom_template,
module_uses_services = [],
module_exclude_patterns = [
".*\\.internal.*",
".*\\.internal.*",
],
visibility = None,
**kwargs):
Expand All @@ -18,7 +18,8 @@ def java_export(
# Construct the java library, or something that looks like one
native.java_library(
name = "%s-base-lib" % name,
**kwargs)
**kwargs
)

# Build the maven artifacts. The output of this has the same JavaInfo as
# the lib, but also has maven coordinates added.
Expand Down
52 changes: 26 additions & 26 deletions java/private/maven_artifacts.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ def _maven_artifacts_impl(ctx):
src_jar = ctx.outputs.srcjar
combine_jars(ctx, ctx.executable._singlejar, info.source_jars.to_list(), src_jar)

# # Now generate the module info
# module_jar = ctx.actions.declare_file("%s-module.jar" % ctx.attr.name)
#
# args = ctx.actions.args()
# args.add_all(["--coordinates", ctx.attr.maven_coordinates])
# args.add_all(["--in", temp_bin_jar.path])
# args.add_all(["--out", module_jar.path])
# if len(ctx.attr.module_uses_services) > 0:
# args.add_all(ctx.attr.module_uses_services, before_each = "--uses")
#
# paths = [file.path for file in target[GatheredJavaModuleInfo].module_jars.to_list()]
# if len(paths) > 0:
# args.add_all(["--module-path", ctx.host_configuration.host_path_separator.join(paths)])
# if len(ctx.attr.module_exclude_patterns) > 0:
# args.add_all(ctx.attr.module_exclude_patterns, before_each = "--exclude")
#
# ctx.actions.run(
# mnemonic = "BuildModuleJar",
# inputs = [temp_bin_jar] + target[GatheredJavaModuleInfo].module_jars.to_list(),
# outputs = [module_jar],
# executable = ctx.executable._generate_module,
# arguments = [args],
# )
#
# # Now merge the module info and the binary jars
# combine_jars(ctx, ctx.executable._singlejar, [temp_bin_jar, module_jar], ctx.outputs.binjar)
# # Now generate the module info
# module_jar = ctx.actions.declare_file("%s-module.jar" % ctx.attr.name)
#
# args = ctx.actions.args()
# args.add_all(["--coordinates", ctx.attr.maven_coordinates])
# args.add_all(["--in", temp_bin_jar.path])
# args.add_all(["--out", module_jar.path])
# if len(ctx.attr.module_uses_services) > 0:
# args.add_all(ctx.attr.module_uses_services, before_each = "--uses")
#
# paths = [file.path for file in target[GatheredJavaModuleInfo].module_jars.to_list()]
# if len(paths) > 0:
# args.add_all(["--module-path", ctx.host_configuration.host_path_separator.join(paths)])
# if len(ctx.attr.module_exclude_patterns) > 0:
# args.add_all(ctx.attr.module_exclude_patterns, before_each = "--exclude")
#
# ctx.actions.run(
# mnemonic = "BuildModuleJar",
# inputs = [temp_bin_jar] + target[GatheredJavaModuleInfo].module_jars.to_list(),
# outputs = [module_jar],
# executable = ctx.executable._generate_module,
# arguments = [args],
# )
#
# # Now merge the module info and the binary jars
# combine_jars(ctx, ctx.executable._singlejar, [temp_bin_jar, module_jar], ctx.outputs.binjar)

defaultInfo = target[DefaultInfo]

Expand Down
8 changes: 4 additions & 4 deletions java/private/module.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ def _has_java_module_deps(target, ctx):
# Gather all transitive deps
gathered = []
for dep in all_deps:
if GatheredJavaModuleInfo in dep:
items = dep[GatheredJavaModuleInfo].module_jars.to_list()
gathered.extend(items)
if GatheredJavaModuleInfo in dep:
items = dep[GatheredJavaModuleInfo].module_jars.to_list()
gathered.extend(items)
transitive = depset(gathered)

if JavaModuleInfo in target:
Expand All @@ -52,7 +52,7 @@ def _has_java_module_deps(target, ctx):
else:
return [GatheredJavaModuleInfo(
binary_jars = depset([]),
module_jars = depset([], transitive = [transitive])
module_jars = depset([], transitive = [transitive]),
)]

has_java_module_deps = aspect(
Expand Down
90 changes: 45 additions & 45 deletions java/private/test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load("@bazel_tools//tools/jdk:toolchain_utils.bzl", "find_java_runtime_toolchain
_BROWSERS = {
"chrome": {
"jvm_flags": ["-Dselenium.browser=chrome"],
"tags": []
"tags": [],
},
"edge": {
"jvm_flags": ["-Dselenium.browser=edge"],
Expand Down Expand Up @@ -205,48 +205,48 @@ def java_selenium_test_suite(
suites.append(test_name)
native.test_suite(name = name, tests = suites, tags = tags + ["manual"])


def java_test_suite(
name,
srcs,
size = None,
tags = [],
visibility = None,
**kwargs):

# By default bazel computes the name of test classes based on the
# standard Maven directory structure, which we don't use in
# Selenium, so try to compute the correct package name.
pkg = _package_name()

tests = []

actual_tags = []
actual_tags.extend(tags)
if "small" != size:
actual_tags.append("no-sandbox")

for src in srcs:
if src.endswith('Test.java'):
test_name = src[:-len('.java')]

test_class = _test_class_name(src)

if test_name in native.existing_rules():
test_name = "%s-%s" % (name, test_name)
tests += [test_name]

native.java_test(
name = test_name,
srcs = [src],
size = size,
test_class = test_class,
tags = actual_tags,
visibility = ["//visibility:private"],
**kwargs)

native.test_suite(
name = name,
tests = tests,
tags = ["manual"] + tags,
visibility = visibility)
name,
srcs,
size = None,
tags = [],
visibility = None,
**kwargs):
# By default bazel computes the name of test classes based on the
# standard Maven directory structure, which we don't use in
# Selenium, so try to compute the correct package name.
pkg = _package_name()

tests = []

actual_tags = []
actual_tags.extend(tags)
if "small" != size:
actual_tags.append("no-sandbox")

for src in srcs:
if src.endswith("Test.java"):
test_name = src[:-len(".java")]

test_class = _test_class_name(src)

if test_name in native.existing_rules():
test_name = "%s-%s" % (name, test_name)
tests += [test_name]

native.java_test(
name = test_name,
srcs = [src],
size = size,
test_class = test_class,
tags = actual_tags,
visibility = ["//visibility:private"],
**kwargs
)

native.test_suite(
name = name,
tests = tests,
tags = ["manual"] + tags,
visibility = visibility,
)
2 changes: 1 addition & 1 deletion javascript/private/header.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _closure_lang_file_impl(ctx):
)

return [
DefaultInfo(files = depset([ctx.outputs.out])),
DefaultInfo(files = depset([ctx.outputs.out])),
]

closure_lang_file = rule(
Expand Down
2 changes: 1 addition & 1 deletion py/private/import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _py_import_impl(ctx):

imports = depset(
items = [
"%s/%s/%s-pyroot" % (ctx.workspace_name, ctx.label.package, ctx.label.name),
"%s/%s/%s-pyroot" % (ctx.workspace_name, ctx.label.package, ctx.label.name),
],
transitive = [dep[PyInfo].imports for dep in ctx.attr.deps],
)
Expand Down
14 changes: 7 additions & 7 deletions py/private/pytest.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ if __name__ == "__main__":
args = sys.argv[1:] + ["-ra"] + %s + %s
sys.exit(pytest.main(args))""" % (_stringify(ctx.attr.args), _stringify([src.path for src in ctx.files.srcs])),
is_executable = True)
is_executable = True,
)

return [
DefaultInfo(
files = depset([runner]),
executable = runner,
),
DefaultInfo(
files = depset([runner]),
executable = runner,
),
]

_pytest_runner = rule(
Expand Down Expand Up @@ -68,6 +69,5 @@ def pytest_test(name, srcs, deps = None, args = None, python_version = None, **k
main = runner_target,
legacy_create_init = False,
imports = ["."],
**kwargs,
**kwargs
)

2 changes: 1 addition & 1 deletion py/private/suite.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def py_test_suite(name, srcs, size = None, deps = None, python_version = None, i
srcs = [src],
deps = [library_name],
python_version = python_version,
**kwargs,
**kwargs
)
native.test_suite(
name = name,
Expand Down
2 changes: 1 addition & 1 deletion third_party/dotnet/ilmerge/toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ merge_toolchain = rule(
allow_single_file = True,
mandatory = True,
cfg = "host",
)
),
},
)

Expand Down
Loading

0 comments on commit edfbeed

Please sign in to comment.