Run gen_git_source.py inside of a repo_rule instead of configure.
PiperOrigin-RevId: 179971055
This commit is contained in:
parent
f10a598e34
commit
a64485dbb3
14
configure.py
14
configure.py
@ -265,19 +265,6 @@ def reset_tf_configure_bazelrc():
|
|||||||
f.write('import %workspace%/.tf_configure.bazelrc\n')
|
f.write('import %workspace%/.tf_configure.bazelrc\n')
|
||||||
|
|
||||||
|
|
||||||
def run_gen_git_source(environ_cp):
|
|
||||||
"""Run the gen_git_source to create links.
|
|
||||||
|
|
||||||
The links are for bazel to track dependencies for git hash propagation.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
environ_cp: copy of the os.environ.
|
|
||||||
"""
|
|
||||||
cmd = '"%s" tensorflow/tools/git/gen_git_source.py --configure %s' % (
|
|
||||||
environ_cp.get('PYTHON_BIN_PATH'), os.getcwd())
|
|
||||||
os.system(cmd)
|
|
||||||
|
|
||||||
|
|
||||||
def cleanup_makefile():
|
def cleanup_makefile():
|
||||||
"""Delete any leftover BUILD files from the Makefile build.
|
"""Delete any leftover BUILD files from the Makefile build.
|
||||||
|
|
||||||
@ -1251,7 +1238,6 @@ def main():
|
|||||||
reset_tf_configure_bazelrc()
|
reset_tf_configure_bazelrc()
|
||||||
cleanup_makefile()
|
cleanup_makefile()
|
||||||
setup_python(environ_cp)
|
setup_python(environ_cp)
|
||||||
run_gen_git_source(environ_cp)
|
|
||||||
|
|
||||||
if is_windows():
|
if is_windows():
|
||||||
environ_cp['TF_NEED_S3'] = '0'
|
environ_cp['TF_NEED_S3'] = '0'
|
||||||
|
@ -1561,9 +1561,9 @@ def tf_version_info_genrule():
|
|||||||
native.genrule(
|
native.genrule(
|
||||||
name="version_info_gen",
|
name="version_info_gen",
|
||||||
srcs=[
|
srcs=[
|
||||||
clean_dep("//tensorflow/tools/git:gen/spec.json"),
|
clean_dep("@local_config_git//:gen/spec.json"),
|
||||||
clean_dep("//tensorflow/tools/git:gen/head"),
|
clean_dep("@local_config_git//:gen/head"),
|
||||||
clean_dep("//tensorflow/tools/git:gen/branch_ref"),
|
clean_dep("@local_config_git//:gen/branch_ref"),
|
||||||
],
|
],
|
||||||
outs=["util/version_info.cc"],
|
outs=["util/version_info.cc"],
|
||||||
cmd=
|
cmd=
|
||||||
|
@ -7,9 +7,7 @@ package(default_visibility = ["//tensorflow:internal"])
|
|||||||
licenses(["notice"]) # Apache 2.0
|
licenses(["notice"]) # Apache 2.0
|
||||||
|
|
||||||
exports_files(
|
exports_files(
|
||||||
glob(["gen/*"]) + [
|
["gen_git_source.py"],
|
||||||
"gen_git_source.py",
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
@ -1 +0,0 @@
|
|||||||
|
|
@ -1 +0,0 @@
|
|||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"git": false
|
|
||||||
}
|
|
@ -62,7 +62,7 @@ def parse_branch_ref(filename):
|
|||||||
raise RuntimeError("Git directory has unparseable HEAD")
|
raise RuntimeError("Git directory has unparseable HEAD")
|
||||||
|
|
||||||
|
|
||||||
def configure(src_base_path, debug=False):
|
def configure(src_base_path, gen_path, debug=False):
|
||||||
"""Configure `src_base_path` to embed git hashes if available."""
|
"""Configure `src_base_path` to embed git hashes if available."""
|
||||||
|
|
||||||
# TODO(aselle): No files generated or symlinked here are deleted by
|
# TODO(aselle): No files generated or symlinked here are deleted by
|
||||||
@ -71,7 +71,6 @@ def configure(src_base_path, debug=False):
|
|||||||
# without running ./configure again.
|
# without running ./configure again.
|
||||||
|
|
||||||
git_path = os.path.join(src_base_path, ".git")
|
git_path = os.path.join(src_base_path, ".git")
|
||||||
gen_path = os.path.join(src_base_path, "tensorflow", "tools", "git", "gen")
|
|
||||||
|
|
||||||
# Remove and recreate the path
|
# Remove and recreate the path
|
||||||
if os.path.exists(gen_path):
|
if os.path.exists(gen_path):
|
||||||
@ -260,6 +259,10 @@ parser.add_argument(
|
|||||||
"--configure", type=str,
|
"--configure", type=str,
|
||||||
help="Path to configure as a git repo dependency tracking sentinel")
|
help="Path to configure as a git repo dependency tracking sentinel")
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"--gen_root_path", type=str,
|
||||||
|
help="Root path to place generated git files (created by --configure).")
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--generate",
|
"--generate",
|
||||||
type=str,
|
type=str,
|
||||||
@ -274,7 +277,9 @@ parser.add_argument(
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.configure is not None:
|
if args.configure is not None:
|
||||||
configure(args.configure, debug=args.debug)
|
if args.gen_root_path is None:
|
||||||
|
raise RuntimeError("Must pass --gen_root_path arg when running --configure")
|
||||||
|
configure(args.configure, args.gen_root_path, debug=args.debug)
|
||||||
elif args.generate is not None:
|
elif args.generate is not None:
|
||||||
generate(args.generate)
|
generate(args.generate)
|
||||||
elif args.raw_generate is not None:
|
elif args.raw_generate is not None:
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
load("//third_party/gpus:cuda_configure.bzl", "cuda_configure")
|
load("//third_party/gpus:cuda_configure.bzl", "cuda_configure")
|
||||||
load("//third_party/mkl:build_defs.bzl", "mkl_repository")
|
load("//third_party/mkl:build_defs.bzl", "mkl_repository")
|
||||||
|
load("//third_party/git:git_configure.bzl", "git_configure")
|
||||||
load("//third_party/py:python_configure.bzl", "python_configure")
|
load("//third_party/py:python_configure.bzl", "python_configure")
|
||||||
load("//third_party/sycl:sycl_configure.bzl", "sycl_configure")
|
load("//third_party/sycl:sycl_configure.bzl", "sycl_configure")
|
||||||
load("//third_party/toolchains/cpus/arm:arm_compiler_configure.bzl", "arm_compiler_configure")
|
load("//third_party/toolchains/cpus/arm:arm_compiler_configure.bzl", "arm_compiler_configure")
|
||||||
@ -47,6 +48,7 @@ def tf_workspace(path_prefix="", tf_repo_name=""):
|
|||||||
# version we require here.
|
# version we require here.
|
||||||
check_version("0.5.4")
|
check_version("0.5.4")
|
||||||
cuda_configure(name="local_config_cuda")
|
cuda_configure(name="local_config_cuda")
|
||||||
|
git_configure(name="local_config_git")
|
||||||
sycl_configure(name="local_config_sycl")
|
sycl_configure(name="local_config_sycl")
|
||||||
python_configure(name="local_config_python")
|
python_configure(name="local_config_python")
|
||||||
|
|
||||||
|
0
third_party/git/BUILD
vendored
Normal file
0
third_party/git/BUILD
vendored
Normal file
10
third_party/git/BUILD.tpl
vendored
Normal file
10
third_party/git/BUILD.tpl
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# Description:
|
||||||
|
# Exports generated files used to generate tensorflow/core/util/version_info.cc
|
||||||
|
|
||||||
|
package(default_visibility = ["//visibility:public"])
|
||||||
|
|
||||||
|
licenses(["notice"])
|
||||||
|
|
||||||
|
exports_files(
|
||||||
|
glob(["gen/*"]),
|
||||||
|
)
|
20
third_party/git/git_configure.bzl
vendored
Normal file
20
third_party/git/git_configure.bzl
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
"""Repository rule for Git autoconfiguration."""
|
||||||
|
|
||||||
|
def _git_conf_impl(repository_ctx):
|
||||||
|
repository_ctx.template(
|
||||||
|
"BUILD",
|
||||||
|
Label("//third_party/git:BUILD.tpl"))
|
||||||
|
|
||||||
|
tensorflow_root_path = str(repository_ctx.path(
|
||||||
|
Label("@org_tensorflow//:BUILD")))[:-len("BUILD")]
|
||||||
|
python_script_path = repository_ctx.path(
|
||||||
|
Label("@org_tensorflow//tensorflow/tools/git:gen_git_source.py"))
|
||||||
|
generated_files_path = repository_ctx.path("gen")
|
||||||
|
|
||||||
|
repository_ctx.execute([
|
||||||
|
python_script_path, "--configure", tensorflow_root_path,
|
||||||
|
"--gen_root_path", generated_files_path], quiet=False)
|
||||||
|
|
||||||
|
git_configure = repository_rule(
|
||||||
|
implementation = _git_conf_impl,
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user