Skip to content

Commit

Permalink
chore: buildifier format all files (#775)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle authored Nov 6, 2023
1 parent a2250d9 commit eb46104
Show file tree
Hide file tree
Showing 38 changed files with 175 additions and 173 deletions.
2 changes: 1 addition & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package(
license(
name = "license",
license_kinds = [
"@rules_license//licenses/spdx:Apache-2.0"
"@rules_license//licenses/spdx:Apache-2.0",
],
license_text = "LICENSE",
)
Expand Down
8 changes: 6 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module(
name = "rules_pkg",
version = "0.10.0", # Must sync with version.bzl.
repo_name = "rules_pkg",
compatibility_level = 1,
repo_name = "rules_pkg",
)

# Do not update to newer versions until you need a specific new feature.
Expand All @@ -18,4 +18,8 @@ bazel_dep(name = "rules_cc", version = "0.0.9", dev_dependency = True)
# Find the system rpmbuild if one is available.
find_rpm = use_extension("//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild_bzlmod", dev_dependency = True)
use_repo(find_rpm, "rules_pkg_rpmbuild")
register_toolchains("@rules_pkg_rpmbuild//:all", dev_dependency = True)

register_toolchains(
"@rules_pkg_rpmbuild//:all",
dev_dependency = True,
)
5 changes: 3 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "platforms",
sha256 = "3a561c99e7bdbe9173aa653fd579fe849f1d8d67395780ab4770b1f381431d51",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz",
"https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz",
],
sha256 = "3a561c99e7bdbe9173aa653fd579fe849f1d8d67395780ab4770b1f381431d51",
)

# Find rpmbuild if it exists.
Expand Down Expand Up @@ -74,10 +74,11 @@ stardoc_repositories()

http_archive(
name = "rules_cc",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"],
sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf",
strip_prefix = "rules_cc-0.0.9",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"],
)

load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies", "rules_cc_toolchains")

rules_cc_dependencies()
Expand Down
5 changes: 2 additions & 3 deletions distro/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_python//python:defs.bzl", "py_test")
load("//:version.bzl", "version")
load("//pkg:tar.bzl", "pkg_tar")
load("//pkg/releasing:defs.bzl", "print_rel_notes")
load("//pkg/releasing:git.bzl", "git_changelog")
load("@rules_python//python:defs.bzl", "py_test")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

package(
default_applicable_licenses = ["//:license"],
Expand Down Expand Up @@ -83,12 +82,12 @@ py_test(
"packaging_test.py",
":release_version.py",
],
imports = [".."],
data = [
"testdata/BUILD.tpl",
":distro",
"//:standard_package",
],
imports = [".."],
local = True,
python_version = "PY3",
tags = [
Expand Down
21 changes: 10 additions & 11 deletions doc_build/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ How to:

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
load("@rules_python//python:defs.bzl", "py_library")
load("//:version.bzl", "version")

package(default_applicable_licenses = ["//:license"])
Expand Down Expand Up @@ -50,16 +49,16 @@ exports_files(
# pairs of rule name and the source file to get it from
# buildifier: leave-alone, do not sort
ORDER = [
("toc", None),
("common", None),
("pkg_deb", "//pkg/private/deb:deb.bzl"),
("pkg_deb_impl", "//pkg/private/deb:deb.bzl"),
("pkg_rpm", "//pkg:rpm_pfg.bzl"),
("pkg_tar", "//pkg/private/tar:tar.bzl"),
("pkg_tar_impl", "//pkg/private/tar:tar.bzl"),
("pkg_zip", "//pkg/private/zip:zip.bzl"),
("pkg_zip_impl", "//pkg/private/zip:zip.bzl"),
("mappings", None),
("toc", None),
("common", None),
("pkg_deb", "//pkg/private/deb:deb.bzl"),
("pkg_deb_impl", "//pkg/private/deb:deb.bzl"),
("pkg_rpm", "//pkg:rpm_pfg.bzl"),
("pkg_tar", "//pkg/private/tar:tar.bzl"),
("pkg_tar_impl", "//pkg/private/tar:tar.bzl"),
("pkg_zip", "//pkg/private/zip:zip.bzl"),
("pkg_zip_impl", "//pkg/private/zip:zip.bzl"),
("mappings", None),
("legacy_pkg_rpm", None),
]

Expand Down
8 changes: 4 additions & 4 deletions examples/naming_package_files/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
# limitations under the License.
# -*- coding: utf-8 -*-

licenses(["notice"])

load("@rules_pkg//pkg:deb.bzl", "pkg_deb")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load(":package_upload.bzl", "debian_upload")
load(":my_package_name.bzl", "basic_naming", "name_part_from_command_line", "names_from_toolchains")
load(":package_upload.bzl", "debian_upload")

licenses(["notice"])

config_setting(
name = "special_build",
Expand Down Expand Up @@ -97,7 +97,7 @@ pkg_tar(
)

#
#
#
#
pkg_tar(
name = "using_variable_from_ctx_var",
Expand Down
2 changes: 1 addition & 1 deletion examples/naming_package_files/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ rules_pkg_dependencies()

http_archive(
name = "rules_cc",
url = "https://github.com/bazelbuild/rules_cc/archive/b1c40e1de81913a3c40e5948f78719c28152486d.zip",
sha256 = "d0c573b94a6ef20ef6ff20154a23d0efcb409fb0e1ff0979cec318dfe42f0cdd",
strip_prefix = "rules_cc-b1c40e1de81913a3c40e5948f78719c28152486d",
url = "https://github.com/bazelbuild/rules_cc/archive/b1c40e1de81913a3c40e5948f78719c28152486d.zip",
)
3 changes: 2 additions & 1 deletion examples/naming_package_files/my_package_name.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

"""Example rules to show package naming techniques."""

load("@rules_pkg//pkg:providers.bzl", "PackageVariablesInfo")
load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain")
load("@rules_pkg//pkg:providers.bzl", "PackageVariablesInfo")

def _basic_naming_impl(ctx):
values = {}
Expand Down Expand Up @@ -97,6 +97,7 @@ names_from_toolchains = rule(
#
def _name_part_from_command_line_naming_impl(ctx):
values = {"name_part": ctx.build_setting_value}

# Just pass the value from the command line through. An implementation
# could also perform validation, such as done in
# https://github.com/bazelbuild/bazel-skylib/blob/master/rules/common_settings.bzl
Expand Down
2 changes: 1 addition & 1 deletion examples/rich_structure/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "pkg_mkdirs", "strip_prefix")
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("@rules_pkg//pkg:zip.bzl", "pkg_zip")

Expand Down
3 changes: 2 additions & 1 deletion examples/rich_structure/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ rules_pkg_dependencies()

http_archive(
name = "rules_cc",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"],
sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf",
strip_prefix = "rules_cc-0.0.9",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"],
)

load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies", "rules_cc_toolchains")

rules_cc_dependencies()
Expand Down
5 changes: 4 additions & 1 deletion examples/rich_structure/docs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

filegroup(
name = "docs",
srcs = glob(["**/*"], exclude=["BUILD"]),
srcs = glob(
["**/*"],
exclude = ["BUILD"],
),
visibility = ["//visibility:public"],
)
1 change: 0 additions & 1 deletion examples/rich_structure/resources/l10n/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "strip_prefix")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("@rules_pkg//pkg:zip.bzl", "pkg_zip")
load("//:foo_defs.bzl", "shared_object_path_selector")

# There are localized message catalogs for all the components.
Expand Down
1 change: 0 additions & 1 deletion examples/rich_structure/src/server/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "pkg_mkdirs")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("//:foo_defs.bzl", "shared_object_path_selector")

cc_library(
name = "foolib",
Expand Down
4 changes: 2 additions & 2 deletions examples/time_stamping/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# limitations under the License.
# -*- coding: utf-8 -*-

licenses(["notice"])

load("@rules_pkg//pkg:tar.bzl", "pkg_tar")

licenses(["notice"])

pkg_tar(
name = "never_stamped",
srcs = [
Expand Down
2 changes: 0 additions & 2 deletions examples/where_is_my_output/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

workspace(name = "rich_structure")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

local_repository(
name = "rules_pkg",
path = "../..",
Expand Down
1 change: 1 addition & 0 deletions examples/where_is_my_output/show_all_outputs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
def format(target):
provider_map = providers(target)
output_group_info = provider_map["OutputGroupInfo"]

# Look at the attributes of the provider. Visit the depsets.
ret = []
for attr in dir(output_group_info):
Expand Down
3 changes: 2 additions & 1 deletion pkg/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_pkg//pkg/private:make_starlark_library.bzl", "starlark_library")

# -*- coding: utf-8 -*-
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
load("@rules_pkg//pkg/private:make_starlark_library.bzl", "starlark_library")

package(default_applicable_licenses = ["//:license"])

Expand Down
38 changes: 19 additions & 19 deletions pkg/legacy/rpm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ def _pkg_rpm_impl(ctx):
tools = []
args = ["--name=" + ctx.label.name]
if ctx.attr.debug:
args += ["--debug"]
args.append("--debug")

if ctx.attr.rpmbuild_path:
args += ["--rpmbuild=" + ctx.attr.rpmbuild_path]
args.append("--rpmbuild=" + ctx.attr.rpmbuild_path)

# buildifier: disable=print
print("rpmbuild_path is deprecated. See the README for instructions on how" +
Expand All @@ -50,7 +50,7 @@ def _pkg_rpm_impl(ctx):
fail("The rpmbuild_toolchain is not properly configured: " +
toolchain.name)
if toolchain.path:
args += ["--rpmbuild=" + toolchain.path]
args.append("--rpmbuild=" + toolchain.path)
else:
executable_files = toolchain.label[DefaultInfo].files_to_run
tools.append(executable_files)
Expand All @@ -60,31 +60,31 @@ def _pkg_rpm_impl(ctx):
if ctx.attr.version_file:
if ctx.attr.version:
fail("Both version and version_file attributes were specified")
args += ["--version=@" + ctx.file.version_file.path]
files += [ctx.file.version_file]
args.append("--version=@" + ctx.file.version_file.path)
files.append(ctx.file.version_file)
elif ctx.attr.version:
args += ["--version=" + ctx.attr.version]
args.append("--version=" + ctx.attr.version)

# Release can be specified by a file or inlined.
if ctx.attr.release_file:
if ctx.attr.release:
fail("Both release and release_file attributes were specified")
args += ["--release=@" + ctx.file.release_file.path]
files += [ctx.file.release_file]
args.append("--release=@" + ctx.file.release_file.path)
files.append(ctx.file.release_file)
elif ctx.attr.release:
args += ["--release=" + ctx.attr.release]
args.append("--release=" + ctx.attr.release)

# SOURCE_DATE_EPOCH can be specified by a file or inlined.
if ctx.attr.source_date_epoch_file:
if ctx.attr.source_date_epoch:
fail("Both source_date_epoch and source_date_epoch_file attributes were specified")
args += ["--source_date_epoch=@" + ctx.file.source_date_epoch_file.path]
files += [ctx.file.source_date_epoch_file]
args.append("--source_date_epoch=@" + ctx.file.source_date_epoch_file.path)
files.append(ctx.file.source_date_epoch_file)
elif ctx.attr.source_date_epoch != None:
args += ["--source_date_epoch=" + str(ctx.attr.source_date_epoch)]
args.append("--source_date_epoch=" + str(ctx.attr.source_date_epoch))

if ctx.attr.architecture:
args += ["--arch=" + ctx.attr.architecture]
args.append("--arch=" + ctx.attr.architecture)

if not ctx.attr.spec_file:
fail("spec_file was not specified")
Expand All @@ -102,19 +102,19 @@ def _pkg_rpm_impl(ctx):
output = spec_file,
substitutions = substitutions,
)
args += ["--spec_file=" + spec_file.path]
files += [spec_file]
args.append("--spec_file=" + spec_file.path)
files.append(spec_file)

args += ["--out_file=" + ctx.outputs.rpm.path]
args.append("--out_file=" + ctx.outputs.rpm.path)

# Add data files.
if ctx.file.changelog:
files += [ctx.file.changelog]
args += [ctx.file.changelog.path]
files.append(ctx.file.changelog)
args.append(ctx.file.changelog.path)
files += ctx.files.data

for f in ctx.files.data:
args += [f.path]
args.append(f.path)

# Call the generator script.
ctx.actions.run(
Expand Down
2 changes: 1 addition & 1 deletion pkg/mappings.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ Rules that actually make use of the outputs of the above rules are not specified
here.
"""

load("//pkg:providers.bzl", "PackageDirsInfo", "PackageFilegroupInfo", "PackageFilesInfo", "PackageSymlinkInfo")
load("@bazel_skylib//lib:paths.bzl", "paths")
load("//pkg:providers.bzl", "PackageDirsInfo", "PackageFilegroupInfo", "PackageFilesInfo", "PackageSymlinkInfo")

# TODO(#333): strip_prefix module functions should produce unique outputs. In
# particular, this one and `_sp_from_pkg` can overlap.
Expand Down
4 changes: 2 additions & 2 deletions pkg/package_variables.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

def add_ctx_variables(ctx, values):
"""Add selected variables from ctx."""
values['target_cpu'] = ctx.var.get("TARGET_CPU")
values['compilation_mode'] = ctx.var.get("COMPILATION_MODE")
values["target_cpu"] = ctx.var.get("TARGET_CPU")
values["compilation_mode"] = ctx.var.get("COMPILATION_MODE")
return values
Loading

0 comments on commit eb46104

Please sign in to comment.