run buildifier on unified build files (#98141)

This is pretty tricky. buildifier by default doesn't do much to these
files. It does a little more if you tell it that they are
`BUILD.bazel` files with -type=build. But it can do even more if you
remove the target definitions from the `def define_rules()` wrapper
and dedent them.

I wrote a little wrapper that does that. I'll submit it at a later
date.

Differential Revision: [D44606558](https://our.internmc.facebook.com/intern/diff/D44606558/)

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D44606558/)!
Pull Request resolved: https://github.com/pytorch/pytorch/pull/98141
Approved by: https://github.com/ezyang, https://github.com/PaliC
This commit is contained in:
mikey dagitses
2023-04-02 03:36:26 -07:00
committed by PyTorch MergeBot
parent b1e60bfb6a
commit 2ac9086987
10 changed files with 63 additions and 59 deletions

View File

@ -16,17 +16,17 @@ def define_targets(rules):
],
copts = ["-fexceptions"],
tags = [
"-fbcode",
"supermodule:android/default/pytorch",
"supermodule:ios/default/public.pytorch",
"-fbcode",
"xplat",
],
visibility = ["//visibility:public"],
deps = [
":caffe2_headers",
"@com_github_glog//:glog",
"//c10",
"//third_party/miniz-2.1.0:miniz",
"@com_github_glog//:glog",
],
)
@ -69,19 +69,19 @@ def define_targets(rules):
rules.genrule(
name = "gen_aten",
srcs = gen_aten_srcs,
tools = ["//torchgen:gen"],
outs = gen_aten_outs,
cmd = gen_aten_cmd,
tools = ["//torchgen:gen"],
)
rules.genrule(
name = "gen_aten_hip",
srcs = gen_aten_srcs,
tools = ["//torchgen:gen"],
outs = gen_aten_outs_cuda,
cmd = gen_aten_cmd + " --rocm",
features = ["-create_bazel_outputs"],
tags = ["-bazel"],
tools = ["//torchgen:gen"],
)
rules.genrule(
@ -91,21 +91,21 @@ def define_targets(rules):
":DispatchKeyNativeFunctions.h",
":LazyIr.h",
":LazyNonNativeIr.h",
":RegisterDispatchKey.cpp",
":RegisterDispatchDefinitions.ini",
":RegisterDispatchKey.cpp",
":native_functions.yaml",
":shape_inference.h",
":tags.yaml",
":ts_native_functions.cpp",
":ts_native_functions.yaml",
],
tools = ["//tools/setup_helpers:generate_code"],
outs = GENERATED_AUTOGRAD_CPP + GENERATED_AUTOGRAD_PYTHON + GENERATED_TESTING_PY,
cmd = "$(execpath //tools/setup_helpers:generate_code) " +
"--gen-dir=$(RULEDIR) " +
"--native-functions-path $(location :native_functions.yaml) " +
"--tags-path=$(location :tags.yaml) " +
"--gen_lazy_ts_backend",
tools = ["//tools/setup_helpers:generate_code"],
)
rules.cc_library(