diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-04 03:44:03 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-04 03:44:03 +0000 |
commit | dc64721761637761afcbc166ea175ec338c463f8 (patch) | |
tree | aa07719cffb3854f3a9add8f0557d563ba97f155 | |
parent | 99d2535a119df388de31ae4796d38a5857b059f9 (diff) | |
download | chromium_src-dc64721761637761afcbc166ea175ec338c463f8.zip chromium_src-dc64721761637761afcbc166ea175ec338c463f8.tar.gz chromium_src-dc64721761637761afcbc166ea175ec338c463f8.tar.bz2 |
Add a wrapper script which modifies the .isolate on the fly.
This tool will ultimately process the .ninja files, in the meantime it archives
all the DLLs. It's cheezy but this will unblock the component build short term.
This is very crude but this will get folks going. This means once it's done, we
can remove all the .isolate representing the dynamic libraries.
Remove swarming_client/ as a dependency in the .isolate files, it's not needed
anymore.
R=vadimsh@chromium.org
BUG=333473
Review URL: https://codereview.chromium.org/196283016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261652 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/base_unittests.isolate | 3 | ||||
-rw-r--r-- | build/isolate.gypi | 5 | ||||
-rw-r--r-- | chrome/browser_tests.isolate | 1 | ||||
-rw-r--r-- | chrome/interactive_ui_tests.isolate | 1 | ||||
-rw-r--r-- | chrome/sync_integration_tests.isolate | 1 | ||||
-rw-r--r-- | chrome/unit_tests.isolate | 1 | ||||
-rw-r--r-- | content/content_browsertests.isolate | 1 | ||||
-rw-r--r-- | content/content_unittests.isolate | 3 | ||||
-rw-r--r-- | net/net_unittests.isolate | 1 | ||||
-rwxr-xr-x | tools/isolate_driver.py | 132 |
10 files changed, 135 insertions, 14 deletions
diff --git a/base/base_unittests.isolate b/base/base_unittests.isolate index 3da5a20..097c55a 100644 --- a/base/base_unittests.isolate +++ b/base/base_unittests.isolate @@ -32,9 +32,6 @@ '../testing/test_env.py', '<(PRODUCT_DIR)/base_unittests<(EXECUTABLE_SUFFIX)', ], - 'isolate_dependency_untracked': [ - '../tools/swarming_client/', - ], 'read_only': 1, }, }], diff --git a/build/isolate.gypi b/build/isolate.gypi index 6a84a56..6267441 100644 --- a/build/isolate.gypi +++ b/build/isolate.gypi @@ -47,6 +47,7 @@ 'extension': 'isolate', 'inputs': [ # Files that are known to be involved in this step. + '<(DEPTH)/tools/isolate_driver.py', '<(DEPTH)/tools/swarming_client/isolate.py', '<(DEPTH)/tools/swarming_client/run_isolated.py', @@ -67,9 +68,9 @@ ], 'action': [ 'python', - '<(DEPTH)/tools/swarming_client/isolate.py', + '<(DEPTH)/tools/isolate_driver.py', '<(test_isolation_mode)', - '--result', '<@(_outputs)', + '--isolated', '<@(_outputs)', '--isolate', '<(RULE_INPUT_PATH)', # Variables should use the -V FOO=<(FOO) form so frequent values, diff --git a/chrome/browser_tests.isolate b/chrome/browser_tests.isolate index 146c9f6..b851845 100644 --- a/chrome/browser_tests.isolate +++ b/chrome/browser_tests.isolate @@ -75,7 +75,6 @@ '../third_party/safe_browsing/', '../third_party/simplejson/', '../third_party/tlslite/', - '../tools/swarming_client/', '<(PRODUCT_DIR)/nacl_test_data/', '<(PRODUCT_DIR)/pnacl/', '<(PRODUCT_DIR)/pseudo_locales/', diff --git a/chrome/interactive_ui_tests.isolate b/chrome/interactive_ui_tests.isolate index 3d2a109..492bcc2 100644 --- a/chrome/interactive_ui_tests.isolate +++ b/chrome/interactive_ui_tests.isolate @@ -38,7 +38,6 @@ '../third_party/pyftpdlib/', '../third_party/pywebsocket/src/mod_pywebsocket/', '../third_party/tlslite/tlslite/', - '../tools/swarming_client/', 'test/data/', ], 'read_only': 1, diff --git a/chrome/sync_integration_tests.isolate b/chrome/sync_integration_tests.isolate index 7324cf5..4736fe8 100644 --- a/chrome/sync_integration_tests.isolate +++ b/chrome/sync_integration_tests.isolate @@ -44,7 +44,6 @@ ['OS=="linux" or OS=="mac" or OS=="win"', { 'variables': { 'isolate_dependency_untracked': [ - '../tools/swarming_client/', '<(PRODUCT_DIR)/pyproto/', ], }, diff --git a/chrome/unit_tests.isolate b/chrome/unit_tests.isolate index f35ecc8..03c0be9 100644 --- a/chrome/unit_tests.isolate +++ b/chrome/unit_tests.isolate @@ -69,7 +69,6 @@ '../third_party/pyftpdlib/', '../third_party/pywebsocket/', '../third_party/tlslite/', - '../tools/swarming_client/', '<(PRODUCT_DIR)/pyproto/', ], }, diff --git a/content/content_browsertests.isolate b/content/content_browsertests.isolate index 41ebc19..de3675f 100644 --- a/content/content_browsertests.isolate +++ b/content/content_browsertests.isolate @@ -51,7 +51,6 @@ '../third_party/pyftpdlib/', '../third_party/pywebsocket/', '../third_party/tlslite/', - '../tools/swarming_client/', ], }, }], diff --git a/content/content_unittests.isolate b/content/content_unittests.isolate index 76ad361..e3867e6 100644 --- a/content/content_unittests.isolate +++ b/content/content_unittests.isolate @@ -25,9 +25,6 @@ '../testing/test_env.py', '<(PRODUCT_DIR)/content_unittests<(EXECUTABLE_SUFFIX)', ], - 'isolate_dependency_untracked': [ - '../tools/swarming_client/', - ], }, }], ['OS=="linux"', { diff --git a/net/net_unittests.isolate b/net/net_unittests.isolate index 50ea631..c88685d 100644 --- a/net/net_unittests.isolate +++ b/net/net_unittests.isolate @@ -32,7 +32,6 @@ '../third_party/pyftpdlib/', '../third_party/pywebsocket/', '../third_party/tlslite/', - '../tools/swarming_client/', '<(PRODUCT_DIR)/pyproto/', 'tools/testserver/', ], diff --git a/tools/isolate_driver.py b/tools/isolate_driver.py new file mode 100755 index 0000000..4a20f22 --- /dev/null +++ b/tools/isolate_driver.py @@ -0,0 +1,132 @@ +#!/usr/bin/env python +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Adaptor script called through build/isolate.gypi. + +Creates a wrapping .isolate which 'includes' the original one, that can be +consumed by tools/swarming_client/isolate.py. Path variables are determined +based on the current working directory. The relative_cwd in the .isolated file +is determined based on *the .isolate file that declare the 'command' variable to +be used* so the wrapping .isolate doesn't affect this value. + +It packages all the dynamic libraries found in this wrapping .isolate. This is +inefficient and non-deterministic. In the very near future, it will parse +build.ninja, find back the root target and find all the dynamic libraries that +are marked as a dependency to this target. +""" + +import glob +import os +import posixpath +import subprocess +import sys + +TOOLS_DIR = os.path.dirname(os.path.abspath(__file__)) +SWARMING_CLIENT_DIR = os.path.join(TOOLS_DIR, 'swarming_client') +SRC_DIR = os.path.dirname(TOOLS_DIR) + +sys.path.insert(0, SWARMING_CLIENT_DIR) + +import isolate_format + + + +# Location to grab binaries based on the OS. +DYNAMIC_LIBRARIES = { + 'darwin': '*.dylib', + 'linux2': 'lib/*.so', + 'win32': '*.dll', +} + + +def create_wrapper(args, isolate_index, isolated_index): + """Creates a wrapper .isolate that add dynamic libs. + + The original .isolate is not modified. + """ + cwd = os.getcwd() + isolate = args[isolate_index] + # The code assumes the .isolate file is always specified path-less in cwd. Fix + # if this assumption doesn't hold true. + assert os.path.basename(isolate) == isolate, isolate + + # This will look like ../out/Debug. This is based against cwd. Note that this + # must equal the value provided as PRODUCT_DIR. + build_dir = os.path.dirname(args[isolated_index]) + + # This will look like chrome/unit_tests.isolate. It is based against SRC_DIR. + # It's used to calculate temp_isolate. + src_isolate = os.path.relpath(os.path.join(cwd, isolate), SRC_DIR) + + # The wrapping .isolate. This will look like + # ../out/Debug/gen/chrome/unit_tests.isolate. + temp_isolate = os.path.join(build_dir, 'gen', src_isolate) + temp_isolate_dir = os.path.dirname(temp_isolate) + + # Relative path between the new and old .isolate file. + 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']. + rebased_libs = [ + '<(PRODUCT_DIR)/%s' % i[len(build_dir)+1:] + for i in dynamic_libs + ] + + # Now do actual wrapping .isolate. + out = { + 'includes': [ + posixpath.join(isolate_relpath, isolate), + ], + 'variables': { + isolate_format.KEY_TRACKED: rebased_libs, + }, + } + if not os.path.isdir(temp_isolate_dir): + os.makedirs(temp_isolate_dir) + comment = ( + '# Warning: this file was AUTOGENERATED.\n' + '# DO NO EDIT.\n') + with open(temp_isolate, 'wb') as f: + isolate_format.print_all(comment, out, f) + if '--verbose' in args: + print('Added %d dynamic libs' % len(dynamic_libs)) + args[isolate_index] = temp_isolate + + +def main(): + args = sys.argv[1:] + isolate = None + isolated = None + is_component = False + for i, arg in enumerate(args): + if arg == '--isolate': + isolate = i + 1 + if arg == '--isolated': + isolated = i + 1 + if arg == 'component=shared_library': + is_component = True + if isolate is None or isolated is None: + print >> sys.stderr, 'Internal failure' + return 1 + + if is_component: + create_wrapper(args, isolate, isolated) + + swarming_client = os.path.join(SRC_DIR, 'tools', 'swarming_client') + sys.stdout.flush() + result = subprocess.call( + [sys.executable, os.path.join(swarming_client, 'isolate.py')] + args) + return result + + +if __name__ == '__main__': + sys.exit(main()) |