summaryrefslogtreecommitdiffstats
path: root/tools/isolate_driver.py
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-07 18:04:09 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-07 18:04:09 +0000
commita233e301b6a7b5e9daac3dce805191f41f19d42a (patch)
tree56e1826c36a80c2b689c7209eab1134f0ceb5959 /tools/isolate_driver.py
parent7c98a2f0ad81c5e8245cf66cf426c487e3a0eb4b (diff)
downloadchromium_src-a233e301b6a7b5e9daac3dce805191f41f19d42a.zip
chromium_src-a233e301b6a7b5e9daac3dce805191f41f19d42a.tar.gz
chromium_src-a233e301b6a7b5e9daac3dce805191f41f19d42a.tar.bz2
Implement work around to detect libraries being linked.
This is very temporary to unblock using isolated testing with component builds. It basically scans the dlls twice and removes the ones that changed size. The proper solution is to use primitive ninja parsing. R=csharp@chromium.org BUG=360223,333473 Review URL: https://codereview.chromium.org/227093002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262155 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/isolate_driver.py')
-rwxr-xr-xtools/isolate_driver.py55
1 files changed, 45 insertions, 10 deletions
diff --git a/tools/isolate_driver.py b/tools/isolate_driver.py
index 07bf6c0..f806302 100755
--- a/tools/isolate_driver.py
+++ b/tools/isolate_driver.py
@@ -22,6 +22,7 @@ import os
import posixpath
import subprocess
import sys
+import time
TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
SWARMING_CLIENT_DIR = os.path.join(TOOLS_DIR, 'swarming_client')
@@ -41,6 +42,47 @@ DYNAMIC_LIBRARIES = {
}
+def get_dynamic_libs(build_dir):
+ """Finds all the dynamic libs to map.
+
+ Returns:
+ list of relative path, e.g. [../out/Debug/lib/libuser_prefs.so].
+ """
+ items = set()
+ root = os.path.join(build_dir, DYNAMIC_LIBRARIES[sys.platform])
+ for i in glob.iglob(root):
+ try:
+ # Will throw on Windows if another process is writing to this file.
+ open(i).close()
+ items.add((i, os.stat(i).st_size))
+ except IOError:
+ continue
+
+ # The following sleep value was carefully selected via random guessing. The
+ # goal is to detect files that are being linked by checking their file size
+ # after a small delay.
+ #
+ # This happens as other build targets can be built simultaneously. For
+ # example, base_unittests.isolated is being processed but dynamic libraries
+ # for chrome are currently being linked.
+ #
+ # TODO(maruel): Obviously, this must go away and be replaced with a proper
+ # ninja parser but we need something now. http://crbug.com/333473
+ time.sleep(10)
+
+ for item in sorted(items):
+ file_name, file_size = item
+ try:
+ open(file_name).close()
+ if os.stat(file_name).st_size != file_size:
+ items.remove(item)
+ except IOError:
+ items.remove(item)
+ continue
+
+ return [i[0].replace(os.path.sep, '/') for i in items]
+
+
def create_wrapper(args, isolate_index, isolated_index):
"""Creates a wrapper .isolate that add dynamic libs.
@@ -69,16 +111,10 @@ def create_wrapper(args, isolate_index, isolated_index):
isolate_relpath = os.path.relpath(
'.', temp_isolate_dir).replace(os.path.sep, '/')
- # This will look like [../out/Debug/lib/libuser_prefs.so].
- dynamic_libs = [
- i.replace(os.path.sep, '/')
- for i in glob.iglob(
- os.path.join(build_dir, DYNAMIC_LIBRARIES[sys.platform]))
- ]
- # And now like ['<(PRODUCT_DIR)/lib/flibuser_prefs.so'].
+ # Will look like ['<(PRODUCT_DIR)/lib/flibuser_prefs.so'].
rebased_libs = [
'<(PRODUCT_DIR)/%s' % i[len(build_dir)+1:]
- for i in dynamic_libs
+ for i in get_dynamic_libs(build_dir)
]
# Now do actual wrapping .isolate.
@@ -118,8 +154,7 @@ def main():
print >> sys.stderr, 'Internal failure'
return 1
- # http://crbug.com/360223
- if is_component and False:
+ if is_component:
create_wrapper(args, isolate, isolated)
swarming_client = os.path.join(SRC_DIR, 'tools', 'swarming_client')