mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
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:
parent
b1e60bfb6a
commit
2ac9086987
12
build.bzl
12
build.bzl
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
def define_targets(rules):
|
||||
rules.cc_library(
|
||||
name = "c10",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//c10/core:CPUAllocator",
|
||||
"//c10/core:ScalarType",
|
||||
"//c10/core:alignment",
|
||||
"//c10/core:alloc_cpu",
|
||||
"//c10/core:base",
|
||||
"//c10/macros:macros",
|
||||
"//c10/macros",
|
||||
"//c10/mobile:CPUCachingAllocator",
|
||||
"//c10/mobile:CPUProfilingAllocator",
|
||||
"//c10/util:TypeCast",
|
||||
|
|
@ -20,5 +21,4 @@ def define_targets(rules):
|
|||
],
|
||||
[],
|
||||
),
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -3,9 +3,6 @@ def define_targets(rules):
|
|||
name = "CPUAllocator",
|
||||
srcs = ["CPUAllocator.cpp"],
|
||||
hdrs = ["CPUAllocator.h"],
|
||||
# This library defines a flag, The use of alwayslink keeps it
|
||||
# from being stripped.
|
||||
alwayslink = True,
|
||||
linkstatic = True,
|
||||
local_defines = ["C10_BUILD_MAIN_LIB"],
|
||||
visibility = ["//visibility:public"],
|
||||
|
|
@ -16,6 +13,9 @@ def define_targets(rules):
|
|||
"//c10/mobile:CPUProfilingAllocator",
|
||||
"//c10/util:base",
|
||||
],
|
||||
# This library defines a flag, The use of alwayslink keeps it
|
||||
# from being stripped.
|
||||
alwayslink = True,
|
||||
)
|
||||
|
||||
rules.cc_library(
|
||||
|
|
@ -39,17 +39,17 @@ def define_targets(rules):
|
|||
name = "alloc_cpu",
|
||||
srcs = ["impl/alloc_cpu.cpp"],
|
||||
hdrs = ["impl/alloc_cpu.h"],
|
||||
# This library defines flags, The use of alwayslink keeps them
|
||||
# from being stripped.
|
||||
alwayslink = True,
|
||||
linkstatic = True,
|
||||
local_defines = ["C10_BUILD_MAIN_LIB"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":alignment",
|
||||
"//c10/macros:macros",
|
||||
"//c10/macros",
|
||||
"//c10/util:base",
|
||||
],
|
||||
# This library defines flags, The use of alwayslink keeps them
|
||||
# from being stripped.
|
||||
alwayslink = True,
|
||||
)
|
||||
|
||||
rules.cc_library(
|
||||
|
|
@ -74,19 +74,19 @@ def define_targets(rules):
|
|||
"impl/alloc_cpu.h",
|
||||
],
|
||||
),
|
||||
# This library uses flags and registration. Do not let the
|
||||
# linker remove them.
|
||||
alwayslink = True,
|
||||
linkstatic = True,
|
||||
local_defines = ["C10_BUILD_MAIN_LIB"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":ScalarType",
|
||||
"//c10/macros:macros",
|
||||
"//c10/macros",
|
||||
"//c10/util:TypeCast",
|
||||
"//c10/util:base",
|
||||
"//c10/util:typeid",
|
||||
],
|
||||
# This library uses flags and registration. Do not let the
|
||||
# linker remove them.
|
||||
alwayslink = True,
|
||||
)
|
||||
|
||||
rules.filegroup(
|
||||
|
|
|
|||
|
|
@ -19,21 +19,21 @@ def define_targets(rules):
|
|||
"CUDAMacros.h",
|
||||
],
|
||||
),
|
||||
defines = ["USE_CUDA"],
|
||||
linkstatic = True,
|
||||
local_defines = ["C10_BUILD_MAIN_LIB"],
|
||||
target_compatible_with = rules.requires_cuda_enabled(),
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":Macros",
|
||||
"//c10/core:base",
|
||||
"//c10/macros",
|
||||
"//c10/util:base",
|
||||
"@cuda",
|
||||
],
|
||||
# This library uses registration. Don't let registered
|
||||
# entities be removed.
|
||||
alwayslink = True,
|
||||
linkstatic = True,
|
||||
local_defines = ["C10_BUILD_MAIN_LIB"],
|
||||
visibility = ["//visibility:public"],
|
||||
defines = ["USE_CUDA"],
|
||||
deps = [
|
||||
":Macros",
|
||||
"@cuda",
|
||||
"//c10/core:base",
|
||||
"//c10/macros:macros",
|
||||
"//c10/util:base",
|
||||
],
|
||||
target_compatible_with = rules.requires_cuda_enabled(),
|
||||
)
|
||||
|
||||
rules.cc_library(
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ def define_targets(rules):
|
|||
srcs = [
|
||||
"impl/CUDATest.cpp",
|
||||
],
|
||||
deps = [
|
||||
"@com_google_googletest//:gtest_main",
|
||||
"//c10/cuda:cuda",
|
||||
],
|
||||
target_compatible_with = rules.requires_cuda_enabled(),
|
||||
deps = [
|
||||
"//c10/cuda",
|
||||
"@com_google_googletest//:gtest_main",
|
||||
],
|
||||
)
|
||||
|
||||
for src in dsa_tests:
|
||||
|
|
@ -28,11 +28,11 @@ def define_targets(rules):
|
|||
srcs = [
|
||||
src,
|
||||
],
|
||||
deps = [
|
||||
"@com_google_googletest//:gtest_main",
|
||||
"//c10/cuda:cuda",
|
||||
],
|
||||
target_compatible_with = rules.requires_cuda_enabled(),
|
||||
deps = [
|
||||
"//c10/cuda",
|
||||
"@com_google_googletest//:gtest_main",
|
||||
],
|
||||
)
|
||||
rules.cc_test(
|
||||
name = "test_" + name,
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ def define_targets(rules):
|
|||
"//conditions:default": [],
|
||||
}),
|
||||
)
|
||||
|
||||
rules.filegroup(
|
||||
name = "headers",
|
||||
srcs = rules.glob(
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ def define_targets(rules):
|
|||
]),
|
||||
copts = ["-Wno-deprecated-declarations"],
|
||||
deps = [
|
||||
"@com_google_googletest//:gtest_main",
|
||||
"//c10/core:base",
|
||||
"//c10/util:base",
|
||||
"@com_google_googletest//:gtest_main",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
@ -30,8 +30,8 @@ def define_targets(rules):
|
|||
srcs = ["util/typeid_test.cpp"],
|
||||
copts = ["-Wno-deprecated-declarations"],
|
||||
deps = [
|
||||
"@com_google_googletest//:gtest_main",
|
||||
"//c10/util:typeid",
|
||||
"@com_google_googletest//:gtest_main",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
@ -49,9 +49,9 @@ def define_targets(rules):
|
|||
":Macros",
|
||||
":complex_math_test_common",
|
||||
":complex_test_common",
|
||||
"@com_google_googletest//:gtest_main",
|
||||
"//c10/macros:macros",
|
||||
"//c10/macros",
|
||||
"//c10/util:base",
|
||||
"@com_google_googletest//:gtest_main",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
@ -59,35 +59,35 @@ def define_targets(rules):
|
|||
name = "util/ssize_test",
|
||||
srcs = ["util/ssize_test.cpp"],
|
||||
deps = [
|
||||
"@com_google_googletest//:gtest_main",
|
||||
"//c10/util:ssize",
|
||||
"@com_google_googletest//:gtest_main",
|
||||
],
|
||||
)
|
||||
|
||||
rules.cc_library(
|
||||
name = "Macros",
|
||||
hdrs = ["util/Macros.h"],
|
||||
testonly = True,
|
||||
hdrs = ["util/Macros.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
)
|
||||
|
||||
rules.cc_library(
|
||||
name = "complex_math_test_common",
|
||||
testonly = True,
|
||||
hdrs = ["util/complex_math_test_common.h"],
|
||||
deps = [
|
||||
"@com_google_googletest//:gtest",
|
||||
"//c10/util:base",
|
||||
"@com_google_googletest//:gtest",
|
||||
],
|
||||
testonly = True,
|
||||
)
|
||||
|
||||
rules.cc_library(
|
||||
name = "complex_test_common",
|
||||
testonly = True,
|
||||
hdrs = ["util/complex_test_common.h"],
|
||||
deps = [
|
||||
"@com_google_googletest//:gtest",
|
||||
"//c10/macros:macros",
|
||||
"//c10/macros",
|
||||
"//c10/util:base",
|
||||
"@com_google_googletest//:gtest",
|
||||
],
|
||||
testonly = True,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ def define_targets(rules):
|
|||
deps = [
|
||||
":base",
|
||||
"//c10/core:ScalarType",
|
||||
"//c10/macros:macros",
|
||||
"//c10/macros",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
@ -29,15 +29,12 @@ def define_targets(rules):
|
|||
"typeid.h",
|
||||
],
|
||||
),
|
||||
# This library uses flags and registration. Do not let the
|
||||
# linker remove them.
|
||||
alwayslink = True,
|
||||
linkstatic = True,
|
||||
local_defines = ["C10_BUILD_MAIN_LIB"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//c10/macros",
|
||||
"@fmt",
|
||||
"//c10/macros:macros",
|
||||
] + rules.select({
|
||||
"//c10:using_gflags": ["@com_github_gflags_gflags//:gflags"],
|
||||
"//conditions:default": [],
|
||||
|
|
@ -45,6 +42,9 @@ def define_targets(rules):
|
|||
"//c10:using_glog": ["@com_github_glog//:glog"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
# This library uses flags and registration. Do not let the
|
||||
# linker remove them.
|
||||
alwayslink = True,
|
||||
)
|
||||
|
||||
rules.cc_library(
|
||||
|
|
@ -65,7 +65,7 @@ def define_targets(rules):
|
|||
deps = [
|
||||
":base",
|
||||
"//c10/core:ScalarType",
|
||||
"//c10/macros:macros",
|
||||
"//c10/macros",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
@ -77,5 +77,8 @@ def define_targets(rules):
|
|||
"ssize.h",
|
||||
],
|
||||
),
|
||||
visibility = ["//c10:__pkg__", "//:__pkg__"],
|
||||
visibility = [
|
||||
"//:__pkg__",
|
||||
"//c10:__pkg__",
|
||||
],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,6 @@ def define_targets(rules):
|
|||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
rules.requirement("PyYAML"),
|
||||
"//torchgen:torchgen",
|
||||
"//torchgen",
|
||||
],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ def define_targets(rules):
|
|||
rules.py_library(
|
||||
name = "torchgen",
|
||||
srcs = rules.glob(["**/*.py"]),
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
rules.requirement("PyYAML"),
|
||||
rules.requirement("typing-extensions"),
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
rules.py_binary(
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user