Add isolate targets for libjingle

Add .isolate file for libjingle tests and and the necessary isolate.gypi file, similar to the change in
http://review.webrtc.org/2338004/

TEST=trybots passing.
I also ran build/gyp_chromium in a Chromium checkout
with third_party/libjingle/source/talk having this patch
applied to ensure GYP processing was still working.

BUG=1916
R=henrike@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/2353005

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4926 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/talk/build/isolate.gypi b/talk/build/isolate.gypi
new file mode 100644
index 0000000..83dd502
--- /dev/null
+++ b/talk/build/isolate.gypi
@@ -0,0 +1,136 @@
+#
+# libjingle
+# Copyright 2013, Google Inc.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+#  1. Redistributions of source code must retain the above copyright notice,
+#     this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright notice,
+#     this list of conditions and the following disclaimer in the documentation
+#     and/or other materials provided with the distribution.
+#  3. The name of the author may not be used to endorse or promote products
+#     derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+# Copied from Chromium's src/build/isolate.gypi
+#
+# It was necessary to copy this file to libjingle , because the path to
+# build/common.gypi is different for the standalone and Chromium builds. Gyp
+# doesn't permit conditional inclusion or variable expansion in include paths.
+# http://code.google.com/p/gyp/wiki/InputFormatReference#Including_Other_Files
+
+# This file is meant to be included into a target to provide a rule
+# to "build" .isolate files into a .isolated file.
+#
+# To use this, create a gyp target with the following form:
+# 'conditions': [
+#   ['test_isolation_mode != "noop"', {
+#     'targets': [
+#       {
+#         'target_name': 'foo_test_run',
+#         'type': 'none',
+#         'dependencies': [
+#           'foo_test',
+#         ],
+#         'includes': [
+#           '../build/isolate.gypi',
+#           'foo_test.isolate',
+#         ],
+#         'sources': [
+#           'foo_test.isolate',
+#         ],
+#       },
+#     ],
+#   }],
+# ],
+#
+# Note: foo_test.isolate is included and a source file. It is an inherent
+# property of the .isolate format. This permits to define GYP variables but is
+# a stricter format than GYP so isolate.py can read it.
+#
+# The generated .isolated file will be:
+#   <(PRODUCT_DIR)/foo_test.isolated
+
+{
+  'rules': [
+    {
+      'rule_name': 'isolate',
+      'extension': 'isolate',
+      'inputs': [
+        # Files that are known to be involved in this step.
+        '<(DEPTH)/tools/swarm_client/isolate.py',
+        '<(DEPTH)/tools/swarm_client/run_isolated.py',
+        '<(DEPTH)/tools/swarm_client/googletest/run_test_cases.py',
+
+        # Disable file tracking by the build driver for now. This means the
+        # project must have the proper build-time dependency for their runtime
+        # dependency. This improves the runtime of the build driver since it
+        # doesn't have to stat() all these files.
+        #
+        # More importantly, it means that even if a isolate_dependency_tracked
+        # file is missing, for example if a file was deleted and the .isolate
+        # file was not updated, that won't break the build, especially in the
+        # case where foo_tests_run is not built! This should be reenabled once
+        # the switch-over to running tests on Swarm is completed.
+        #'<@(isolate_dependency_tracked)',
+      ],
+      'outputs': [
+        '<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).isolated',
+      ],
+      'conditions': [
+        ["test_isolation_outdir==''", {
+          'action': [
+            'python',
+            '<(DEPTH)/tools/swarm_client/isolate.py',
+            '<(test_isolation_mode)',
+            # GYP will eliminate duplicate arguments so '<(PRODUCT_DIR)' cannot
+            # be provided twice. To work around this behavior, append '/'.
+            #
+            # Also have a space after <(PRODUCT_DIR) or visual studio will
+            # escape the argument wrappping " with the \ and merge it into
+            # the following arguments.
+            #
+            # Other variables should use the -V FOO=<(FOO) form so frequent
+            # values, like '0' or '1', aren't stripped out by GYP.
+            '--outdir', '<(PRODUCT_DIR)/ ',
+            '--variable', 'PRODUCT_DIR', '<(PRODUCT_DIR) ',
+            '--variable', 'OS=<(OS)',
+            '--result', '<@(_outputs)',
+            '--isolate', '<(RULE_INPUT_PATH)',
+          ],
+        }, {
+          'action': [
+            'python',
+            '<(DEPTH)/tools/swarm_client/isolate.py',
+            '<(test_isolation_mode)',
+            '--outdir', '<(test_isolation_outdir)',
+            # See comment above.
+            '--variable', 'PRODUCT_DIR', '<(PRODUCT_DIR) ',
+            '--variable', 'OS=<(OS)',
+            '--result', '<@(_outputs)',
+            '--isolate', '<(RULE_INPUT_PATH)',
+          ],
+        }],
+        ['test_isolation_fail_on_missing == 0', {
+            'action': ['--ignore_broken_items'],
+          },
+        ],
+      ],
+
+      'msvs_cygwin_shell': 0,
+    },
+  ],
+}
diff --git a/talk/libjingle_media_unittest.isolate b/talk/libjingle_media_unittest.isolate
new file mode 100644
index 0000000..4c4ee31
--- /dev/null
+++ b/talk/libjingle_media_unittest.isolate
@@ -0,0 +1,47 @@
+#
+# libjingle
+# Copyright 2013, Google Inc.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+#  1. Redistributions of source code must retain the above copyright notice,
+#     this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright notice,
+#     this list of conditions and the following disclaimer in the documentation
+#     and/or other materials provided with the distribution.
+#  3. The name of the author may not be used to endorse or promote products
+#     derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+{
+  'conditions': [
+    ['OS=="linux" or OS=="mac" or OS=="win"', {
+      'variables': {
+        'command': [
+          '../testing/test_env.py',
+          '../tools/swarm_client/googletest/run_test_cases.py',
+          '<(PRODUCT_DIR)/libjingle_media_unittest<(EXECUTABLE_SUFFIX)',
+        ],
+        'isolate_dependency_tracked': [
+          'media/testdata/captured-320x240-2s-48.frames',
+          '../testing/test_env.py',
+          '<(PRODUCT_DIR)/libjingle_media_unittest<(EXECUTABLE_SUFFIX)',
+        ],
+        'isolate_dependency_untracked': [
+          '../tools/swarm_client/',
+        ],
+      },
+    }],
+  ],
+}
diff --git a/talk/libjingle_p2p_unittest.isolate b/talk/libjingle_p2p_unittest.isolate
new file mode 100644
index 0000000..848f234
--- /dev/null
+++ b/talk/libjingle_p2p_unittest.isolate
@@ -0,0 +1,46 @@
+#
+# libjingle
+# Copyright 2013, Google Inc.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+#  1. Redistributions of source code must retain the above copyright notice,
+#     this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright notice,
+#     this list of conditions and the following disclaimer in the documentation
+#     and/or other materials provided with the distribution.
+#  3. The name of the author may not be used to endorse or promote products
+#     derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+{
+  'conditions': [
+    ['OS=="linux" or OS=="mac" or OS=="win"', {
+      'variables': {
+        'command': [
+          '../testing/test_env.py',
+          '../tools/swarm_client/googletest/run_test_cases.py',
+          '<(PRODUCT_DIR)/libjingle_p2p_unittest<(EXECUTABLE_SUFFIX)',
+        ],
+        'isolate_dependency_tracked': [
+          '../testing/test_env.py',
+          '<(PRODUCT_DIR)/libjingle_p2p_unittest<(EXECUTABLE_SUFFIX)',
+        ],
+        'isolate_dependency_untracked': [
+          '../tools/swarm_client/',
+        ],
+      },
+    }],
+  ],
+}
diff --git a/talk/libjingle_peerconnection_unittest.isolate b/talk/libjingle_peerconnection_unittest.isolate
new file mode 100644
index 0000000..660ffd5
--- /dev/null
+++ b/talk/libjingle_peerconnection_unittest.isolate
@@ -0,0 +1,46 @@
+#
+# libjingle
+# Copyright 2013, Google Inc.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+#  1. Redistributions of source code must retain the above copyright notice,
+#     this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright notice,
+#     this list of conditions and the following disclaimer in the documentation
+#     and/or other materials provided with the distribution.
+#  3. The name of the author may not be used to endorse or promote products
+#     derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+{
+  'conditions': [
+    ['OS=="linux" or OS=="mac" or OS=="win"', {
+      'variables': {
+        'command': [
+          '../testing/test_env.py',
+          '../tools/swarm_client/googletest/run_test_cases.py',
+          '<(PRODUCT_DIR)/libjingle_peerconnection_unittest<(EXECUTABLE_SUFFIX)',
+        ],
+        'isolate_dependency_tracked': [
+          '../testing/test_env.py',
+          '<(PRODUCT_DIR)/libjingle_peerconnection_unittest<(EXECUTABLE_SUFFIX)',
+        ],
+        'isolate_dependency_untracked': [
+          '../tools/swarm_client/',
+        ],
+      },
+    }],
+  ],
+}
diff --git a/talk/libjingle_sound_unittest.isolate b/talk/libjingle_sound_unittest.isolate
new file mode 100644
index 0000000..6da7d88
--- /dev/null
+++ b/talk/libjingle_sound_unittest.isolate
@@ -0,0 +1,46 @@
+#
+# libjingle
+# Copyright 2013, Google Inc.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+#  1. Redistributions of source code must retain the above copyright notice,
+#     this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright notice,
+#     this list of conditions and the following disclaimer in the documentation
+#     and/or other materials provided with the distribution.
+#  3. The name of the author may not be used to endorse or promote products
+#     derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+{
+  'conditions': [
+    ['OS=="linux" or OS=="mac" or OS=="win"', {
+      'variables': {
+        'command': [
+          '../testing/test_env.py',
+          '../tools/swarm_client/googletest/run_test_cases.py',
+          '<(PRODUCT_DIR)/libjingle_sound_unittest<(EXECUTABLE_SUFFIX)',
+        ],
+        'isolate_dependency_tracked': [
+          '../testing/test_env.py',
+          '<(PRODUCT_DIR)/libjingle_sound_unittest<(EXECUTABLE_SUFFIX)',
+        ],
+        'isolate_dependency_untracked': [
+          '../tools/swarm_client/',
+        ],
+      },
+    }],
+  ],
+}
diff --git a/talk/libjingle_tests.gyp b/talk/libjingle_tests.gyp
index 546767d..bce81a5 100755
--- a/talk/libjingle_tests.gyp
+++ b/talk/libjingle_tests.gyp
@@ -517,5 +517,79 @@
         },  # target libjingle_peerconnection_objc_test
       ],
     }],
+    ['test_isolation_mode != "noop"', {
+      'targets': [
+        {
+          'target_name': 'libjingle_media_unittest_run',
+          'type': 'none',
+          'dependencies': [
+            'libjingle_media_unittest',
+          ],
+          'includes': [
+            'build/isolate.gypi',
+            'libjingle_media_unittest.isolate',
+          ],
+          'sources': [
+            'libjingle_media_unittest.isolate',
+          ],
+        },
+        {
+          'target_name': 'libjingle_p2p_unittest_run',
+          'type': 'none',
+          'dependencies': [
+            'libjingle_p2p_unittest',
+          ],
+          'includes': [
+            'build/isolate.gypi',
+            'libjingle_p2p_unittest.isolate',
+          ],
+          'sources': [
+            'libjingle_p2p_unittest.isolate',
+          ],
+        },
+        {
+          'target_name': 'libjingle_peerconnection_unittest_run',
+          'type': 'none',
+          'dependencies': [
+            'libjingle_peerconnection_unittest',
+          ],
+          'includes': [
+            'build/isolate.gypi',
+            'libjingle_peerconnection_unittest.isolate',
+          ],
+          'sources': [
+            'libjingle_peerconnection_unittest.isolate',
+          ],
+        },
+        {
+          'target_name': 'libjingle_sound_unittest_run',
+          'type': 'none',
+          'dependencies': [
+            'libjingle_sound_unittest',
+          ],
+          'includes': [
+            'build/isolate.gypi',
+            'libjingle_sound_unittest.isolate',
+          ],
+          'sources': [
+            'libjingle_sound_unittest.isolate',
+          ],
+        },
+        {
+          'target_name': 'libjingle_unittest_run',
+          'type': 'none',
+          'dependencies': [
+            'libjingle_unittest',
+          ],
+          'includes': [
+            'build/isolate.gypi',
+            'libjingle_unittest.isolate',
+          ],
+          'sources': [
+            'libjingle_unittest.isolate',
+          ],
+        },
+      ],
+    }],
   ],
 }
diff --git a/talk/libjingle_unittest.isolate b/talk/libjingle_unittest.isolate
new file mode 100644
index 0000000..efb8625
--- /dev/null
+++ b/talk/libjingle_unittest.isolate
@@ -0,0 +1,46 @@
+#
+# libjingle
+# Copyright 2013, Google Inc.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+#  1. Redistributions of source code must retain the above copyright notice,
+#     this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright notice,
+#     this list of conditions and the following disclaimer in the documentation
+#     and/or other materials provided with the distribution.
+#  3. The name of the author may not be used to endorse or promote products
+#     derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+{
+  'conditions': [
+    ['OS=="linux" or OS=="mac" or OS=="win"', {
+      'variables': {
+        'command': [
+          '../testing/test_env.py',
+          '../tools/swarm_client/googletest/run_test_cases.py',
+          '<(PRODUCT_DIR)/libjingle_unittest<(EXECUTABLE_SUFFIX)',
+        ],
+        'isolate_dependency_tracked': [
+          '../testing/test_env.py',
+          '<(PRODUCT_DIR)/libjingle_unittest<(EXECUTABLE_SUFFIX)',
+        ],
+        'isolate_dependency_untracked': [
+          '../tools/swarm_client/',
+        ],
+      },
+    }],
+  ],
+}