Skip to content

Commit

Permalink
[bazel] Run buildifier
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Jan 19, 2021
1 parent 626f908 commit 92e0daf
Show file tree
Hide file tree
Showing 54 changed files with 311 additions and 294 deletions.
24 changes: 16 additions & 8 deletions common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package(default_visibility = ["//visibility:public"])

bool_flag(
name = "pin_browsers",
build_setting_default = False
build_setting_default = False,
)

config_setting(
Expand Down Expand Up @@ -78,14 +78,22 @@ config_setting(
[
config_setting(
name = "use_pinned_%s_%s" % (platform, browser),
flag_values = {
":pin_browsers": "true",
},
constraint_values = [
"@platforms//os:%s" % platform,
],
flag_values = {
":pin_browsers": "true",
},
)

for platform in ["linux", "macos", "windows"]]

for browser in ["chrome", "edge", "firefox"]]
for platform in [
"linux",
"macos",
"windows",
]
]
for browser in [
"chrome",
"edge",
"firefox",
]
]
2 changes: 1 addition & 1 deletion common/devtools/chromium/v84/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package(
default_visibility = [
"//dotnet/src/webdriver:__subpackages__",
"//java/client/src/org/openqa/selenium/devtools:__subpackages__",
"//javascript/node/selenium-webdriver:__pkg__",
"//py:__pkg__",
"//dotnet/src/webdriver:__subpackages__",
],
)

Expand Down
2 changes: 1 addition & 1 deletion common/devtools/chromium/v85/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package(
default_visibility = [
"//dotnet/src/webdriver:__subpackages__",
"//java/client/src/org/openqa/selenium/devtools:__subpackages__",
"//javascript/node/selenium-webdriver:__pkg__",
"//py:__pkg__",
"//dotnet/src/webdriver:__subpackages__",
],
)

Expand Down
2 changes: 1 addition & 1 deletion common/devtools/chromium/v86/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package(
default_visibility = [
"//dotnet/src/webdriver:__subpackages__",
"//java/client/src/org/openqa/selenium/devtools:__subpackages__",
"//javascript/node/selenium-webdriver:__pkg__",
"//py:__pkg__",
"//dotnet/src/webdriver:__subpackages__",
],
)

Expand Down
2 changes: 1 addition & 1 deletion common/devtools/chromium/v87/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package(
default_visibility = [
"//dotnet/src/webdriver:__subpackages__",
"//java/client/src/org/openqa/selenium/devtools:__subpackages__",
"//javascript/node/selenium-webdriver:__pkg__",
"//py:__pkg__",
"//dotnet/src/webdriver:__subpackages__",
],
)

Expand Down
3 changes: 1 addition & 2 deletions common/devtools/chromium/v88/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package(
default_visibility = [
"//dotnet/src/webdriver:__subpackages__",
"//java/client/src/org/openqa/selenium/devtools:__subpackages__",
"//javascript/node/selenium-webdriver:__pkg__",
"//javascript/node/selenium-webdriver:__pkg__",
"//py:__pkg__",
"//dotnet/src/webdriver:__subpackages__",
],
)

Expand Down
2 changes: 1 addition & 1 deletion common/devtools/chromium/v89/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package(
default_visibility = [
"//dotnet/src/webdriver:__subpackages__",
"//java/client/src/org/openqa/selenium/devtools:__subpackages__",
"//javascript/node/selenium-webdriver:__pkg__",
"//py:__pkg__",
"//dotnet/src/webdriver:__subpackages__",
],
)

Expand Down
52 changes: 27 additions & 25 deletions common/private/dmg_archive.bzl
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@

def _dmg_archive_impl(repository_ctx):
url = repository_ctx.attr.url
(ignored, ignored, dmg_name) = url.rpartition("/")
dmg_name = dmg_name.replace("%20", "_")
url = repository_ctx.attr.url
(ignored, ignored, dmg_name) = url.rpartition("/")
dmg_name = dmg_name.replace("%20", "_")

attrs = {
"output": dmg_name
}
if repository_ctx.attr.sha256:
attrs.update({"sha256": repository_ctx.attr.sha256})
attrs = {
"output": dmg_name,
}
if repository_ctx.attr.sha256:
attrs.update({"sha256": repository_ctx.attr.sha256})

repository_ctx.download(
url,
**attrs,
)
repository_ctx.download(
url,
**attrs
)

zip_name = dmg_name.replace(".dmg", ".zip")
repository_ctx.execute([
repository_ctx.path(Label("//common/private:convert_dmg.sh")), dmg_name, zip_name])
zip_name = dmg_name.replace(".dmg", ".zip")
repository_ctx.execute([
repository_ctx.path(Label("//common/private:convert_dmg.sh")),
dmg_name,
zip_name,
])

repository_ctx.extract(
archive = zip_name,
stripPrefix = repository_ctx.attr.strip_prefix,
)
repository_ctx.extract(
archive = zip_name,
stripPrefix = repository_ctx.attr.strip_prefix,
)

repository_ctx.file(
"BUILD.bazel",
repository_ctx.attr.build_file_content,
)
repository_ctx.file(
"BUILD.bazel",
repository_ctx.attr.build_file_content,
)

dmg_archive = repository_rule(
_dmg_archive_impl,
Expand All @@ -39,5 +41,5 @@ dmg_archive = repository_rule(
"strip_prefix": attr.string(),
"build_file_content": attr.string(),
"build_file": attr.label(),
}
},
)
16 changes: 7 additions & 9 deletions common/private/drivers.bzl
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@

def _symlink_if_available(repository_ctx, driver_name):
driver = repository_ctx.which(driver_name)

if driver:
repository_ctx.symlink(driver, driver_name)
else:
repository_ctx.file(driver_name, "")
repository_ctx.file(driver_name, "")

return "\n".join([
"bool_setting(name = \"use_%s\", build_setting_default = %s)" % (driver_name, driver != None),
"exports_files([\"%s\"])" % driver_name,
"",
])


def _local_drivers_impl(repository_ctx):
contents = [
"load(\"@bazel_skylib//rules:common_settings.bzl\", \"bool_setting\")",
"",
"package(default_visibility = [\"//visibility:public\"])",
_symlink_if_available(repository_ctx, "chromedriver"),
_symlink_if_available(repository_ctx, "msedgedriver"),
_symlink_if_available(repository_ctx, "geckodriver"),
"load(\"@bazel_skylib//rules:common_settings.bzl\", \"bool_setting\")",
"",
"package(default_visibility = [\"//visibility:public\"])",
_symlink_if_available(repository_ctx, "chromedriver"),
_symlink_if_available(repository_ctx, "msedgedriver"),
_symlink_if_available(repository_ctx, "geckodriver"),
]

repository_ctx.file("BUILD.bazel", "\n".join(contents))
Expand Down
13 changes: 8 additions & 5 deletions common/private/pkg_archive.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

def _pkg_archive_impl(repository_ctx):
url = repository_ctx.attr.url
(ignored, ignored, pkg_name) = url.rpartition("/")
Expand All @@ -8,18 +7,22 @@ def _pkg_archive_impl(repository_ctx):
pkg_name = pkg_name.replace("%20", "_")

attrs = {
"output": pkg_name + ".download"
"output": pkg_name + ".download",
}
if repository_ctx.attr.sha256:
attrs.update({"sha256": repository_ctx.attr.sha256})

repository_ctx.download(
url,
**attrs,
**attrs
)

repository_ctx.execute([
repository_ctx.which("pkgutil"), "--expand-full", pkg_name + ".download", pkg_name])
repository_ctx.which("pkgutil"),
"--expand-full",
pkg_name + ".download",
pkg_name,
])

for (key, value) in repository_ctx.attr.move.items():
repository_ctx.execute(["mv", pkg_name + "/" + key, value])
Expand All @@ -36,5 +39,5 @@ pkg_archive = repository_rule(
"move": attr.string_dict(),
"build_file_content": attr.string(),
"build_file": attr.label(),
}
},
)
15 changes: 8 additions & 7 deletions common/private/selenium_test.bzl
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
load(
"//java:browsers.bzl",
"chrome_data",
"chrome_jvm_flags",
"edge_data",
"edge_jvm_flags",
"firefox_data",
"firefox_jvm_flags")
"//java:browsers.bzl",
"chrome_data",
"chrome_jvm_flags",
"edge_data",
"edge_jvm_flags",
"firefox_data",
"firefox_jvm_flags",
)

DEFAULT_BROWSER = "firefox"

Expand Down
Loading

0 comments on commit 92e0daf

Please sign in to comment.