summaryrefslogtreecommitdiffstats
path: root/adb
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2015-05-05 17:46:50 -0700
committerDan Albert <danalbert@google.com>2015-05-06 09:11:16 -0700
commitc1cfbd304ad1f4f5f136a175ed687de41701235a (patch)
treea1bbaaae91c8409c1a5f3ac554decfdd6d52d1da /adb
parentb0481f48091d77f21492cc2f717308412091bc02 (diff)
downloadsystem_core-c1cfbd304ad1f4f5f136a175ed687de41701235a.tar.gz
system_core-c1cfbd304ad1f4f5f136a175ed687de41701235a.tar.bz2
system_core-c1cfbd304ad1f4f5f136a175ed687de41701235a.zip
Include the git sha in the adb version.
Also add --version to adbd to display the same thing. Change-Id: I47dfbad16c892c42ea938aedd085ba77492791ba (cherry picked from commit 1ba1d7c1ee644967ff4743b0d257290cbeca7a83)
Diffstat (limited to 'adb')
-rw-r--r--adb/Android.mk16
-rw-r--r--adb/adb_main.cpp35
-rw-r--r--adb/commandline.cpp4
3 files changed, 34 insertions, 21 deletions
diff --git a/adb/Android.mk b/adb/Android.mk
index dd1343b49..1613a88e4 100644
--- a/adb/Android.mk
+++ b/adb/Android.mk
@@ -11,6 +11,13 @@ else
adb_host_clang := true
endif
+adb_version := $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)-android
+
+ADB_COMMON_CFLAGS := \
+ -Wall -Werror \
+ -Wno-unused-parameter \
+ -DADB_REVISION='"$(adb_version)"' \
+
# libadb
# =========================================================
@@ -37,8 +44,7 @@ LIBADB_TEST_SRCS := \
transport_test.cpp \
LIBADB_CFLAGS := \
- -Wall -Werror \
- -Wno-unused-parameter \
+ $(ADB_COMMON_CFLAGS) \
-Wno-missing-field-initializers \
-fvisibility=hidden \
@@ -169,8 +175,7 @@ LOCAL_SRC_FILES := \
file_sync_client.cpp \
LOCAL_CFLAGS += \
- -Wall -Werror \
- -Wno-unused-parameter \
+ $(ADB_COMMON_CFLAGS) \
-D_GNU_SOURCE \
-DADB_HOST=1 \
@@ -222,10 +227,9 @@ LOCAL_SRC_FILES := \
set_verity_enable_state_service.cpp \
LOCAL_CFLAGS := \
+ $(ADB_COMMON_CFLAGS) \
-DADB_HOST=0 \
-D_GNU_SOURCE \
- -Wall -Werror \
- -Wno-unused-parameter \
-Wno-deprecated-declarations \
ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
diff --git a/adb/adb_main.cpp b/adb/adb_main.cpp
index bd22d74ba..3f88d1303 100644
--- a/adb/adb_main.cpp
+++ b/adb/adb_main.cpp
@@ -358,29 +358,25 @@ void close_stdin() {
}
#endif
+// TODO(danalbert): Split this file up into adb_main.cpp and adbd_main.cpp.
int main(int argc, char **argv) {
#if ADB_HOST
+ // adb client/server
adb_sysdeps_init();
-#else
- close_stdin();
-#endif
adb_trace_init();
-
-#if ADB_HOST
D("Handling commandline()\n");
return adb_commandline(argc - 1, const_cast<const char**>(argv + 1));
#else
- /* If adbd runs inside the emulator this will enable adb tracing via
- * adb-debug qemud service in the emulator. */
- adb_qemu_trace_init();
+ // adbd
while (true) {
- int c;
- int option_index = 0;
static struct option opts[] = {
- {"root_seclabel", required_argument, 0, 's' },
- {"device_banner", required_argument, 0, 'b' }
+ {"root_seclabel", required_argument, nullptr, 's'},
+ {"device_banner", required_argument, nullptr, 'b'},
+ {"version", no_argument, nullptr, 'v'},
};
- c = getopt_long(argc, argv, "", opts, &option_index);
+
+ int option_index = 0;
+ int c = getopt_long(argc, argv, "", opts, &option_index);
if (c == -1)
break;
switch (c) {
@@ -390,11 +386,24 @@ int main(int argc, char **argv) {
case 'b':
adb_device_banner = optarg;
break;
+ case 'v':
+ printf("Android Debug Bridge Daemon version %d.%d.%d %s\n",
+ ADB_VERSION_MAJOR, ADB_VERSION_MINOR, ADB_SERVER_VERSION,
+ ADB_REVISION);
+ return 0;
default:
break;
}
}
+ close_stdin();
+
+ adb_trace_init();
+
+ /* If adbd runs inside the emulator this will enable adb tracing via
+ * adb-debug qemud service in the emulator. */
+ adb_qemu_trace_init();
+
D("Handling main()\n");
return adb_main(0, DEFAULT_ADB_PORT);
#endif
diff --git a/adb/commandline.cpp b/adb/commandline.cpp
index aa31bfd83..1d7197515 100644
--- a/adb/commandline.cpp
+++ b/adb/commandline.cpp
@@ -66,8 +66,8 @@ static std::string product_file(const char *extra) {
}
static void version(FILE* out) {
- fprintf(out, "Android Debug Bridge version %d.%d.%d\n",
- ADB_VERSION_MAJOR, ADB_VERSION_MINOR, ADB_SERVER_VERSION);
+ fprintf(out, "Android Debug Bridge version %d.%d.%d %s\n", ADB_VERSION_MAJOR,
+ ADB_VERSION_MINOR, ADB_SERVER_VERSION, ADB_REVISION);
}
static void help() {