Include the upstream toybox version in "toybox --version".
SHAs have their uses, but upstream version numbers are better for getting
a quick ballpark figure for the version.
Before:
afc66714a4e3-android
After:
0.7.0-afc66714a4e3-android
(cherry picked from commit 35c9c63120a40f4cfe119f5670d914ac5e69c0f6)
Change-Id: I631b220135560023aa114d2fd6c324633afb8dcc
diff --git a/Android.mk b/Android.mk
index f2167ef..8c112ce 100644
--- a/Android.mk
+++ b/Android.mk
@@ -212,7 +212,10 @@
-ffunction-sections -fdata-sections \
-fno-asynchronous-unwind-tables \
-toybox_version := $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)-android
+toybox_upstream_version := $(shell awk 'match($$0, /TOYBOX_VERSION.*"(.*)"/, ary) {print ary[1]}' $(LOCAL_PATH)/main.c)
+toybox_sha := $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)
+
+toybox_version := $(toybox_upstream_version)-$(toybox_sha)-android
LOCAL_CFLAGS += -DTOYBOX_VERSION='"$(toybox_version)"'
LOCAL_CLANG := true