[Lldb-commits] [PATCH] D22052: Respect `ANDROID_SERIAL` environment variable used by ADB
Luke Drummond via lldb-commits
lldb-commits at lists.llvm.org
Thu Jul 7 05:24:43 PDT 2016
ldrumm removed rL LLVM as the repository for this revision.
ldrumm updated this revision to Diff 63055.
ldrumm added a comment.
- Ensure if ANDROID_SERIAL is set, it exists in the list of connected devices (Address feedback from @ovyalov)
- Also add a hint in the error message in case multiple devices are attached and no serial number is available.
http://reviews.llvm.org/D22052
Files:
source/Plugins/Platform/Android/AdbClient.cpp
Index: source/Plugins/Platform/Android/AdbClient.cpp
===================================================================
--- source/Plugins/Platform/Android/AdbClient.cpp
+++ source/Plugins/Platform/Android/AdbClient.cpp
@@ -25,6 +25,7 @@
#include <limits.h>
+#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <sstream>
@@ -99,19 +100,24 @@
if (error.Fail())
return error;
- if (device_id.empty())
+ std::string android_serial;
+ if (!device_id.empty())
+ android_serial = device_id;
+ else if (const char *env_serial = std::getenv("ANDROID_SERIAL"))
+ android_serial = env_serial;
+
+ if (android_serial.empty())
{
if (connect_devices.size() != 1)
- return Error("Expected a single connected device, got instead %" PRIu64,
- static_cast<uint64_t>(connect_devices.size()));
-
+ return Error("Expected a single connected device, got instead %zu - try setting 'ANDROID_SERIAL'",
+ connect_devices.size());
adb.SetDeviceID(connect_devices.front());
}
else
{
- auto find_it = std::find(connect_devices.begin(), connect_devices.end(), device_id);
+ auto find_it = std::find(connect_devices.begin(), connect_devices.end(), android_serial);
if (find_it == connect_devices.end())
- return Error("Device \"%s\" not found", device_id.c_str());
+ return Error("Device \"%s\" not found", android_serial.c_str());
adb.SetDeviceID(*find_it);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22052.63055.patch
Type: text/x-patch
Size: 1565 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160707/42baac5b/attachment.bin>
More information about the lldb-commits
mailing list