[build] Declare dependency of the version strings on the current Git commit.

Add fake Git reflog to Debian source tarball.

Bug: https://github.com/flutter/flutter/issues/15348
Bug: https://github.com/dart-lang/sdk/issues/32614
Change-Id: Ib4104a98cf245ee11285a37d5eee3165ca656645
Reviewed-on: https://dart-review.googlesource.com/48091
Reviewed-by: William Hesse <whesse@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn
index 2d4aa56..29f6545 100644
--- a/runtime/BUILD.gn
+++ b/runtime/BUILD.gn
@@ -229,19 +229,15 @@
 }
 
 action("generate_version_cc_file") {
-  deps = [
-    "third_party/double-conversion/src:libdouble_conversion",
-    "vm:libdart_lib_jit",
-    "vm:libdart_lib_nosnapshot_with_precompiler",
-    "vm:libdart_vm_jit",
-    "vm:libdart_vm_nosnapshot_with_precompiler",
-  ]
   inputs = [
     "../tools/utils.py",
     "../tools/print_version.py",
     "../tools/VERSION",
     "vm/version_in.cc",
   ]
+  if (dart_version_git_info) {
+    inputs += [ "../.git/logs/HEAD" ]
+  }
   output = "$target_gen_dir/version.cc"
   outputs = [
     output,
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn
index 6f84167..a15213c 100644
--- a/sdk/BUILD.gn
+++ b/sdk/BUILD.gn
@@ -845,6 +845,7 @@
   visibility = [ ":create_common_sdk" ]
   inputs = [
     "../tools/VERSION",
+    "../.git/logs/HEAD",
   ]
   output = "$root_out_dir/dart-sdk/version"
   outputs = [
@@ -860,6 +861,9 @@
 # This rule writes the revision file.
 action("write_revision_file") {
   visibility = [ ":create_common_sdk" ]
+  inputs = [
+    "../.git/logs/HEAD",
+  ]
   output = "$root_out_dir/dart-sdk/revision"
   outputs = [
     output,
diff --git a/tools/create_tarball.py b/tools/create_tarball.py
index 46ea0b9..661e7cb 100755
--- a/tools/create_tarball.py
+++ b/tools/create_tarball.py
@@ -137,6 +137,9 @@
       GenerateChangeLog(change_log, version)
       tar.add(change_log, arcname='%s/debian/changelog' % versiondir)
 
+      # For generated version file build dependency, add fake git reflog.
+      tar.add('/dev/null', arcname='%s/dart/.git/logs/HEAD' % versiondir)
+
       # For bleeding_edge add the GIT_REVISION file.
       if utils.GetChannel() == 'be':
         git_revision = join(temp_dir, 'GIT_REVISION')