Skip to content

Commit cf9afc9

Browse files
authored
Merge pull request tensorflow#18679 from yifeif/cherrypicks_Z6PNR
Cherrypicks 1.8rc1 fix tf.GIT_VERSION always 'unknown' on windows cmake build (tensorflow#16730)
2 parents 966e389 + 558b3d3 commit cf9afc9

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

tensorflow/contrib/cmake/tf_core_framework.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ add_custom_command(OUTPUT __force_rebuild COMMAND ${CMAKE_COMMAND} -E echo)
276276
add_custom_command(OUTPUT
277277
${VERSION_INFO_CC}
278278
COMMAND ${PYTHON_EXECUTABLE} ${tensorflow_source_dir}/tensorflow/tools/git/gen_git_source.py
279-
ARGS --raw_generate ${VERSION_INFO_CC} --git_tag_override=${GIT_TAG_OVERRIDE}
279+
ARGS --raw_generate ${VERSION_INFO_CC} --source_dir ${tensorflow_source_dir} --git_tag_override=${GIT_TAG_OVERRIDE}
280280
DEPENDS __force_rebuild)
281281
set(tf_version_srcs ${tensorflow_source_dir}/tensorflow/core/util/version_info.cc)
282282

tensorflow/tools/git/gen_git_source.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,9 @@ def get_git_version(git_base_path, git_tag_override):
172172
"but got '%s'") % val)
173173
# There might be "-" in the tag name. But we can be sure that the final
174174
# two "-" are those inserted by the git describe command.
175-
commits_ahead_of_tag = split_val[-2]
176175
abbrev_commit = split_val[-1]
177176
val = bytes(
178-
"-".join([git_tag_override, commits_ahead_of_tag, abbrev_commit]))
177+
"-".join([git_tag_override, "0", abbrev_commit]))
179178
return val if val else unknown_label
180179
except subprocess.CalledProcessError:
181180
return unknown_label
@@ -257,20 +256,21 @@ def generate(arglist, git_tag_override=None):
257256
write_version_info(dest_file, git_version)
258257

259258

260-
def raw_generate(output_file, git_tag_override=None):
259+
def raw_generate(output_file, source_dir, git_tag_override=None):
261260
"""Simple generator used for cmake/make build systems.
262261
263262
This does not create any symlinks. It requires the build system
264263
to build unconditionally.
265264
266265
Args:
267266
output_file: Output filename for the version info cc
267+
source_dir: Base path of the source code
268268
git_tag_override: Override the value for the git tag. This is useful for
269269
releases where we want to build the release before the git tag is
270270
created.
271271
"""
272272

273-
git_version = get_git_version(".", git_tag_override)
273+
git_version = get_git_version(source_dir, git_tag_override)
274274
write_version_info(output_file, git_version)
275275

276276

@@ -308,6 +308,11 @@ def raw_generate(output_file, git_tag_override=None):
308308
type=str,
309309
help="Generate version_info.cc (simpler version used for cmake/make)")
310310

311+
parser.add_argument(
312+
"--source_dir",
313+
type=str,
314+
help="Base path of the source code (used for cmake/make)")
315+
311316
args = parser.parse_args()
312317

313318
if args.configure is not None:
@@ -317,7 +322,10 @@ def raw_generate(output_file, git_tag_override=None):
317322
elif args.generate is not None:
318323
generate(args.generate, args.git_tag_override)
319324
elif args.raw_generate is not None:
320-
raw_generate(args.raw_generate, args.git_tag_override)
325+
source_path = "."
326+
if args.source_dir is not None:
327+
source_path = args.source_dir
328+
raw_generate(args.raw_generate, source_path, args.git_tag_override)
321329
else:
322330
raise RuntimeError("--configure or --generate or --raw_generate "
323-
"must be used")
331+
"must be used")

0 commit comments

Comments
 (0)