Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: trunk/src/build/android/pylib/forwarder.py

Issue 23926012: Revert 221736 "[android] Adds constants.GetOutDirectory() and co..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « trunk/src/build/android/pylib/fake_dns.py ('k') | trunk/src/build/android/pylib/gtest/setup.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/build/android/pylib/forwarder.py
===================================================================
--- trunk/src/build/android/pylib/forwarder.py (revision 222006)
+++ trunk/src/build/android/pylib/forwarder.py (working copy)
@@ -17,6 +17,10 @@
from pylib import valgrind_tools
+def _MakeBinaryPath(build_type, binary_name):
+ return os.path.join(cmd_helper.OutDirectory.get(), build_type, binary_name)
+
+
def _GetProcessStartTime(pid):
return psutil.Process(pid).create_time
@@ -60,7 +64,7 @@
os.environ[Forwarder._MULTIPROCESSING_ENV_VAR] = '1'
@staticmethod
- def Map(port_pairs, adb, tool=None):
+ def Map(port_pairs, adb, build_type='Debug', tool=None):
"""Runs the forwarder.
Args:
@@ -79,7 +83,7 @@
if not tool:
tool = valgrind_tools.CreateTool(None, adb)
with _FileLock(Forwarder._LOCK_PATH):
- instance = Forwarder._GetInstanceLocked(tool)
+ instance = Forwarder._GetInstanceLocked(build_type, tool)
instance._InitDeviceLocked(adb, tool)
device_serial = adb.Adb().GetSerialNumber()
@@ -133,7 +137,7 @@
"""
with _FileLock(Forwarder._LOCK_PATH):
port_map = Forwarder._GetInstanceLocked(
- None)._device_to_host_port_map
+ None, None)._device_to_host_port_map
adb_serial = adb.Adb().GetSerialNumber()
for (device_serial, device_port) in port_map.keys():
if adb_serial == device_serial:
@@ -144,43 +148,51 @@
"""Returns the device port that corresponds to a given host port."""
with _FileLock(Forwarder._LOCK_PATH):
(device_serial, device_port) = Forwarder._GetInstanceLocked(
- None)._host_to_device_port_map.get(host_port)
+ None, None)._host_to_device_port_map.get(host_port)
return device_port
@staticmethod
- def _GetInstanceLocked(tool):
+ def _GetInstanceLocked(build_type, tool):
"""Returns the singleton instance.
Note that the global lock must be acquired before calling this method.
Args:
+ build_type: 'Release' or 'Debug'
tool: Tool class to use to get wrapper, if necessary, for executing the
forwarder (see valgrind_tools.py).
"""
if not Forwarder._instance:
- Forwarder._instance = Forwarder(tool)
+ Forwarder._instance = Forwarder(build_type, tool)
return Forwarder._instance
- def __init__(self, tool):
+ def __init__(self, build_type, tool):
"""Constructs a new instance of Forwarder.
Note that Forwarder is a singleton therefore this constructor should be
called only once.
Args:
+ build_type: 'Release' or 'Debug'
tool: Tool class to use to get wrapper, if necessary, for executing the
forwarder (see valgrind_tools.py).
"""
assert not Forwarder._instance
+ self._build_type = build_type
self._tool = tool
self._initialized_devices = set()
self._device_to_host_port_map = dict()
self._host_to_device_port_map = dict()
- self._host_forwarder_path = os.path.join(
- constants.GetOutDirectory(), 'host_forwarder')
- assert os.path.exists(self._host_forwarder_path), 'Please build forwarder2'
+ self._host_forwarder_path = _MakeBinaryPath(
+ self._build_type, 'host_forwarder')
+ if not os.path.exists(self._host_forwarder_path):
+ self._build_type = 'Release' if self._build_type == 'Debug' else 'Debug'
+ self._host_forwarder_path = _MakeBinaryPath(
+ self._build_type, 'host_forwarder')
+ assert os.path.exists(
+ self._host_forwarder_path), 'Please build forwarder2'
self._device_forwarder_path_on_host = os.path.join(
- constants.GetOutDirectory(), 'forwarder_dist')
+ cmd_helper.OutDirectory.get(), self._build_type, 'forwarder_dist')
self._InitHostLocked()
@staticmethod
@@ -189,7 +201,7 @@
Note that the global lock must be acquired before calling this method.
"""
- instance = Forwarder._GetInstanceLocked(None)
+ instance = Forwarder._GetInstanceLocked(None, None)
serial = adb.Adb().GetSerialNumber()
serial_with_port = (serial, device_port)
if not serial_with_port in instance._device_to_host_port_map:
« no previous file with comments | « trunk/src/build/android/pylib/fake_dns.py ('k') | trunk/src/build/android/pylib/gtest/setup.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698