move Bazel version header generation to shared build structure (#75332)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/75332

ghstack-source-id: 154678044

Test Plan: Rely on OSS CI.

Reviewed By: malfet

Differential Revision: D35434229

fbshipit-source-id: 7cdd33fa32d0c485f44477e414c24c9bc4b74963
(cherry picked from commit 60285c613e8703c52f36f0bf1178e35c04574ffa)
This commit is contained in:
mikey dagitses
2022-04-25 10:45:10 -07:00
committed by PyTorch MergeBot
parent 111b2bf9da
commit f4200600e4
3 changed files with 15 additions and 8 deletions

View File

@ -1617,14 +1617,6 @@ cc_library(
)
# torch
genrule(
name = "version_h",
srcs = ["torch/csrc/api/include/torch/version.h.in", "version.txt"],
outs = ["torch/csrc/api/include/torch/version.h"],
cmd = "$(location //tools/setup_helpers:gen_version_header) --template-path $(location torch/csrc/api/include/torch/version.h.in) --version-path $(location version.txt) --output-path $@",
tools = ['//tools/setup_helpers:gen_version_header'],
)
py_binary(
name = "stringify_file",
srcs = ["torch/csrc/jit/codegen/cuda/tools/stringify_file.py"],

View File

@ -10,6 +10,7 @@ def define_targets(rules):
tags = [
"supermodule:android/default/pytorch",
"supermodule:ios/default/public.pytorch",
"xplat",
],
visibility = ["//visibility:public"],
deps = [
@ -19,3 +20,16 @@ def define_targets(rules):
"//third_party/miniz-2.0.8:miniz",
],
)
rules.genrule(
name = "version_h",
srcs = [
":torch/csrc/api/include/torch/version.h.in",
":version.txt",
],
outs = ["torch/csrc/api/include/torch/version.h"],
cmd = "$(location //tools/setup_helpers:gen_version_header) " +
"--template-path $(location :torch/csrc/api/include/torch/version.h.in) " +
"--version-path $(location :version.txt) --output-path $@ ",
tools = ["//tools/setup_helpers:gen_version_header"],
)

View File

@ -19,6 +19,7 @@ rules = struct(
cc_test = cc_test,
cmake_configure_file = cmake_configure_file,
filegroup = native.filegroup,
genrule = native.genrule,
glob = native.glob,
if_cuda = if_cuda,
py_binary = native.py_binary,