aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Michael Case <mikecase@google.com>2017-12-22 15:44:29 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-12-22 15:48:23 -0800
commita64485dbb378d7ac6afc9082fd7176a957815a8c (patch)
tree8569696c2116f674fcc1ba7e324602d0de0cc5e5
parentf10a598e34da5ea4060ccfb8a027dd5c37c108c0 (diff)
Run gen_git_source.py inside of a repo_rule instead of configure.
PiperOrigin-RevId: 179971055
-rw-r--r--configure.py14
-rw-r--r--tensorflow/tensorflow.bzl6
-rw-r--r--tensorflow/tools/git/BUILD4
-rw-r--r--tensorflow/tools/git/gen/branch_ref1
-rw-r--r--tensorflow/tools/git/gen/head1
-rw-r--r--tensorflow/tools/git/gen/spec.json3
-rwxr-xr-xtensorflow/tools/git/gen_git_source.py11
-rw-r--r--tensorflow/workspace.bzl2
-rw-r--r--third_party/git/BUILD0
-rw-r--r--third_party/git/BUILD.tpl10
-rw-r--r--third_party/git/git_configure.bzl20
11 files changed, 44 insertions, 28 deletions
diff --git a/configure.py b/configure.py
index 1917af4b65..e4218b5651 100644
--- a/configure.py
+++ b/configure.py
@@ -265,19 +265,6 @@ def reset_tf_configure_bazelrc():
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():
"""Delete any leftover BUILD files from the Makefile build.
@@ -1251,7 +1238,6 @@ def main():
reset_tf_configure_bazelrc()
cleanup_makefile()
setup_python(environ_cp)
- run_gen_git_source(environ_cp)
if is_windows():
environ_cp['TF_NEED_S3'] = '0'
diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl
index b71328f847..82675a91c5 100644
--- a/tensorflow/tensorflow.bzl
+++ b/tensorflow/tensorflow.bzl
@@ -1561,9 +1561,9 @@ def tf_version_info_genrule():
native.genrule(
name="version_info_gen",
srcs=[
- clean_dep("//tensorflow/tools/git:gen/spec.json"),
- clean_dep("//tensorflow/tools/git:gen/head"),
- clean_dep("//tensorflow/tools/git:gen/branch_ref"),
+ clean_dep("@local_config_git//:gen/spec.json"),
+ clean_dep("@local_config_git//:gen/head"),
+ clean_dep("@local_config_git//:gen/branch_ref"),
],
outs=["util/version_info.cc"],
cmd=
diff --git a/tensorflow/tools/git/BUILD b/tensorflow/tools/git/BUILD
index f502c8dde0..942ceab85f 100644
--- a/tensorflow/tools/git/BUILD
+++ b/tensorflow/tools/git/BUILD
@@ -7,9 +7,7 @@ package(default_visibility = ["//tensorflow:internal"])
licenses(["notice"]) # Apache 2.0
exports_files(
- glob(["gen/*"]) + [
- "gen_git_source.py",
- ],
+ ["gen_git_source.py"],
)
# -----------------------------------------------------------------------------
diff --git a/tensorflow/tools/git/gen/branch_ref b/tensorflow/tools/git/gen/branch_ref
deleted file mode 100644
index 8b13789179..0000000000
--- a/tensorflow/tools/git/gen/branch_ref
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/tensorflow/tools/git/gen/head b/tensorflow/tools/git/gen/head
deleted file mode 100644
index 8b13789179..0000000000
--- a/tensorflow/tools/git/gen/head
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/tensorflow/tools/git/gen/spec.json b/tensorflow/tools/git/gen/spec.json
deleted file mode 100644
index 176bbc21cc..0000000000
--- a/tensorflow/tools/git/gen/spec.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "git": false
-}
diff --git a/tensorflow/tools/git/gen_git_source.py b/tensorflow/tools/git/gen_git_source.py
index 2e27487d2f..3630dbd740 100755
--- a/tensorflow/tools/git/gen_git_source.py
+++ b/tensorflow/tools/git/gen_git_source.py
@@ -62,7 +62,7 @@ def parse_branch_ref(filename):
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."""
# 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.
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
if os.path.exists(gen_path):
@@ -261,6 +260,10 @@ parser.add_argument(
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(
"--generate",
type=str,
help="Generate given spec-file, HEAD-symlink-file, ref-symlink-file",
@@ -274,7 +277,9 @@ parser.add_argument(
args = parser.parse_args()
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:
generate(args.generate)
elif args.raw_generate is not None:
diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl
index 6a496f53f0..6571d9c463 100644
--- a/tensorflow/workspace.bzl
+++ b/tensorflow/workspace.bzl
@@ -2,6 +2,7 @@
load("//third_party/gpus:cuda_configure.bzl", "cuda_configure")
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/sycl:sycl_configure.bzl", "sycl_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.
check_version("0.5.4")
cuda_configure(name="local_config_cuda")
+ git_configure(name="local_config_git")
sycl_configure(name="local_config_sycl")
python_configure(name="local_config_python")
diff --git a/third_party/git/BUILD b/third_party/git/BUILD
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/third_party/git/BUILD
diff --git a/third_party/git/BUILD.tpl b/third_party/git/BUILD.tpl
new file mode 100644
index 0000000000..7b031e74d5
--- /dev/null
+++ b/third_party/git/BUILD.tpl
@@ -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/*"]),
+)
diff --git a/third_party/git/git_configure.bzl b/third_party/git/git_configure.bzl
new file mode 100644
index 0000000000..bd197bfd24
--- /dev/null
+++ b/third_party/git/git_configure.bzl
@@ -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,
+)