Reland "Add version consistently in all build configs and UI"

This is a partial reland of r.android.com/1499116 and
r.android.com/1497878, % the changes that depend on .git
on Android. Turns out that was a bad idea because some bots
can build without it.

Change:
The script that generates the build version can already gracefully
deal with the absence of git. However I forgot the dependency on
.git/HEAD, which makes the build system fail.
For now, in order to avoid problems, this avoids any git
invocation on Android in-tree builds. A follow up CL will
try extending with libbuildversion as suggedted in the bug.

This reverts commit 9d15a2309a4f03d000bcf6d4d4dcba36a3df2916.
This reverts commit bb4bfb0665d16525868e94f941d87ae89c858eb3.
The first patchset is a plain re-revert (i.e. a plain reland).
The patchset on top show the delta from the original cl (for ease
of re-review)

Bug: 173245796
Change-Id: Icd2f7f2727313b9cdc11c6bfa93b67478ae77974
diff --git a/BUILD.extras b/BUILD.extras
index 83a17f0..65611ef 100644
--- a/BUILD.extras
+++ b/BUILD.extras
@@ -78,6 +78,21 @@
     ],
 )
 
+# This is overridden in google internal builds via
+# PERFETTO_CONFIG.deps.version_header (see perfetto_cfg.bzl).
+perfetto_cc_library(
+    name = "cc_perfetto_version_header",
+    hdrs = ["perfetto_version.gen.h"],
+)
+
+perfetto_py_binary(
+    name = "gen_version_header_py",
+    srcs = ["tools/write_version_header.py"],
+    data = ["CHANGELOG"],
+    main = "tools/write_version_header.py",
+    python_version = "PY3",
+)
+
 # Noop targets used to represent targets of the protobuf library.
 # These will be rewritten in Google3 to be dependencies on the real targets.