Fix merge.

This commit is contained in:
Yifei Feng 2018-04-18 17:42:42 -07:00
parent 8cfbbafc17
commit 558b3d35f0

View File

@ -164,14 +164,17 @@ def get_git_version(git_base_path, git_tag_override):
"git", str("--git-dir=%s/.git" % git_base_path),
str("--work-tree=" + git_base_path), "describe", "--long", "--tags"
]).strip())
if git_tag_override:
if git_tag_override and val:
split_val = val.split("-")
if len(split_val) != 3:
if len(split_val) < 3:
raise Exception(
("Expected git version in format 'TAG-COMMITS AFTER TAG-HASH' "
"but got '%s'") % val)
split_val[0] = git_tag_override
val = bytes("-".join(split_val))
# There might be "-" in the tag name. But we can be sure that the final
# two "-" are those inserted by the git describe command.
abbrev_commit = split_val[-1]
val = bytes(
"-".join([git_tag_override, "0", abbrev_commit]))
return val if val else unknown_label
except subprocess.CalledProcessError:
return unknown_label
@ -189,15 +192,7 @@ def write_version_info(filename, git_version):
contents = """/* Generated by gen_git_source.py */
#include <string>
const char* tf_git_version() {return "%s";}
const char* tf_compiler_version() {
#ifdef _MSC_VER
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
return "MSVC " TOSTRING(_MSC_FULL_VER);
#else
return __VERSION__;
#endif
}
const char* tf_compiler_version() {return __VERSION__;}
const int tf_cxx11_abi_flag() {
#ifdef _GLIBCXX_USE_CXX11_ABI
return _GLIBCXX_USE_CXX11_ABI;
@ -333,4 +328,4 @@ elif args.raw_generate is not None:
raw_generate(args.raw_generate, source_path, args.git_tag_override)
else:
raise RuntimeError("--configure or --generate or --raw_generate "
"must be used")
"must be used")