1# Copyright (c) 2012 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5# This file is meant to be included into a target to provide a rule
6# to "build" .isolate files into a .isolated file.
7#
8# To use this, create a gyp target with the following form:
9# 'conditions': [
10#   ['test_isolation_mode != "noop"', {
11#     'targets': [
12#       {
13#         'target_name': 'foo_test_run',
14#         'type': 'none',
15#         'dependencies': [
16#           'foo_test',
17#         ],
18#         'includes': [
19#           '../build/isolate.gypi',
20#           'foo_test.isolate',
21#         ],
22#         'sources': [
23#           'foo_test.isolate',
24#         ],
25#       },
26#     ],
27#   }],
28# ],
29#
30# Note: foo_test.isolate is included and a source file. It is an inherent
31# property of the .isolate format. This permits to define GYP variables but is
32# a stricter format than GYP so isolate.py can read it.
33#
34# The generated .isolated file will be:
35#   <(PRODUCT_DIR)/foo_test.isolated
36#
37# See http://dev.chromium.org/developers/testing/isolated-testing/for-swes
38# for more information.
39
40{
41  'includes': [
42    '../build/util/version.gypi',
43  ],
44  'rules': [
45    {
46      'rule_name': 'isolate',
47      'extension': 'isolate',
48      'inputs': [
49        # Files that are known to be involved in this step.
50        '<(DEPTH)/tools/isolate_driver.py',
51        '<(DEPTH)/tools/swarming_client/isolate.py',
52        '<(DEPTH)/tools/swarming_client/run_isolated.py',
53
54        # Disable file tracking by the build driver for now. This means the
55        # project must have the proper build-time dependency for their runtime
56        # dependency. This improves the runtime of the build driver since it
57        # doesn't have to stat() all these files.
58        #
59        # More importantly, it means that even if a isolate_dependency_tracked
60        # file is missing, for example if a file was deleted and the .isolate
61        # file was not updated, that won't break the build, especially in the
62        # case where foo_tests_run is not built! This should be reenabled once
63        # the switch-over to running tests on Swarm is completed.
64        #'<@(isolate_dependency_tracked)',
65      ],
66      'outputs': [],
67      'action': [
68        'python',
69        '<(DEPTH)/tools/isolate_driver.py',
70        '<(test_isolation_mode)',
71        '--isolated', '<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).isolated',
72        '--isolate', '<(RULE_INPUT_PATH)',
73
74        # Variables should use the -V FOO=<(FOO) form so frequent values,
75        # like '0' or '1', aren't stripped out by GYP. Run 'isolate.py help' for
76        # more details.
77        #
78        # This list needs to be kept in sync with the cmd line options
79        # in src/build/android/pylib/gtest/setup.py.
80
81        # Path variables are used to replace file paths when loading a .isolate
82        # file
83        '--path-variable', 'DEPTH', '<(DEPTH)',
84        '--path-variable', 'PRODUCT_DIR', '<(PRODUCT_DIR) ',
85
86        # Extra variables are replaced on the 'command' entry and on paths in
87        # the .isolate file but are not considered relative paths.
88        '--extra-variable', 'version_full=<(version_full)',
89
90        '--config-variable', 'OS=<(OS)',
91        '--config-variable', 'CONFIGURATION_NAME=<(CONFIGURATION_NAME)',
92        '--config-variable', 'asan=<(asan)',
93        '--config-variable', 'chromeos=<(chromeos)',
94        '--config-variable', 'component=<(component)',
95        '--config-variable', 'fastbuild=<(fastbuild)',
96        # TODO(kbr): move this to chrome_tests.gypi:gles2_conform_tests_run
97        # once support for user-defined config variables is added.
98        '--config-variable',
99          'internal_gles2_conform_tests=<(internal_gles2_conform_tests)',
100        '--config-variable', 'icu_use_data_file_flag=<(icu_use_data_file_flag)',
101        '--config-variable', 'libpeer_target_type=<(libpeer_target_type)',
102        '--config-variable', 'use_openssl=<(use_openssl)',
103        '--config-variable', 'target_arch=<(target_arch)',
104        '--config-variable', 'use_ozone=<(use_ozone)',
105      ],
106      'conditions': [
107        # Note: When gyp merges lists, it appends them to the old value.
108        ['OS=="mac"', {
109          # <(mac_product_name) can contain a space, so don't use FOO=<(FOO)
110          # form.
111          'action': [
112            '--extra-variable', 'mac_product_name', '<(mac_product_name)',
113          ],
114        }],
115        ["test_isolation_outdir!=''", {
116          'action': [ '--isolate-server', '<(test_isolation_outdir)' ],
117        }],
118        ['test_isolation_fail_on_missing == 0', {
119          'action': ['--ignore_broken_items'],
120        }],
121        ["test_isolation_mode == 'prepare'", {
122          'outputs': [
123            '<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).isolated.gen.json',
124          ],
125        }, {
126          'outputs': [
127            '<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).isolated',
128          ],
129        }],
130      ],
131    },
132  ],
133}
134