mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
Differential Revision: [D83685392](https://our.internmc.facebook.com/intern/diff/D83685392) Pull Request resolved: https://github.com/pytorch/pytorch/pull/164381 Approved by: https://github.com/janeyx99
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
def define_targets(rules):
|
|
# workaround issue where open source bazel requires $(location ...)
|
|
# for filepaths but the buck conversion requires no $(location ...)
|
|
# for filepaths.
|
|
is_buck = hasattr(native, "read_config")
|
|
template_arg = "version.h.in" if is_buck else "$(location version.h.in)"
|
|
|
|
genrule_args = {
|
|
"name": "version_h",
|
|
"srcs": [
|
|
"version.h.in",
|
|
"//:version.txt",
|
|
],
|
|
"outs": ["version.h"],
|
|
"cmd": "$(execpath //tools/setup_helpers:gen_version_header) " +
|
|
"--template-path " + template_arg + " " +
|
|
"--version-path $(location //:version.txt) --output-path $@ ",
|
|
"tools": ["//tools/setup_helpers:gen_version_header"],
|
|
}
|
|
|
|
# Add visibility only for Bazel, buck genrule in fbcode.bzl does not
|
|
# support this argument
|
|
if not is_buck:
|
|
genrule_args["visibility"] = ["//visibility:public"]
|
|
|
|
rules.genrule(**genrule_args)
|
|
|
|
rules.cc_library(
|
|
name = "torch_headeronly",
|
|
hdrs = rules.glob([
|
|
"**/*.h"
|
|
]) + ["version.h.in"],
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
"//torch/headeronly/macros",
|
|
],
|
|
)
|