| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from recipe_engine.types import freeze | 5 from recipe_engine.types import freeze |
| 6 | 6 |
| 7 DEPS = [ | 7 DEPS = [ |
| 8 'depot_tools/bot_update', |
| 8 'chromium', | 9 'chromium', |
| 9 'commit_position', | 10 'commit_position', |
| 10 'depot_tools/bot_update', | 11 'file', |
| 11 'depot_tools/gclient', | 12 'depot_tools/gclient', |
| 12 'file', | |
| 13 'goma', | |
| 14 'gsutil', | 13 'gsutil', |
| 15 'recipe_engine/json', | 14 'recipe_engine/json', |
| 16 'recipe_engine/path', | 15 'recipe_engine/path', |
| 17 'recipe_engine/properties', | 16 'recipe_engine/properties', |
| 18 'recipe_engine/python', | 17 'recipe_engine/python', |
| 19 'recipe_engine/raw_io', | 18 'recipe_engine/raw_io', |
| 20 'recipe_engine/step', | 19 'recipe_engine/step', |
| 21 ] | 20 ] |
| 22 | 21 |
| 23 BUCKET_NAME = 'chrome-codesearch' | 22 BUCKET_NAME = 'chrome-codesearch' |
| (...skipping 15 matching lines...) Expand all Loading... |
| 39 'tools/deps2git': '%s/chromium/tools/deps2git' % CHROMIUM_GIT_URL, | 38 'tools/deps2git': '%s/chromium/tools/deps2git' % CHROMIUM_GIT_URL, |
| 40 'tools/gsd_generate_index':\ | 39 'tools/gsd_generate_index':\ |
| 41 '%s/chromium/tools/gsd_generate_index' % CHROMIUM_GIT_URL, | 40 '%s/chromium/tools/gsd_generate_index' % CHROMIUM_GIT_URL, |
| 42 'tools/perf': '%s/chromium/tools/perf' % CHROMIUM_GIT_URL, | 41 'tools/perf': '%s/chromium/tools/perf' % CHROMIUM_GIT_URL, |
| 43 }) | 42 }) |
| 44 | 43 |
| 45 LINUX_GN_ARGS = [ | 44 LINUX_GN_ARGS = [ |
| 46 'is_clang=true', | 45 'is_clang=true', |
| 47 'is_component_build=true', | 46 'is_component_build=true', |
| 48 'is_debug=true', | 47 'is_debug=true', |
| 48 'goma_dir="/b/build/goma"', |
| 49 'symbol_level=1', | 49 'symbol_level=1', |
| 50 'target_cpu="x64"', | 50 'target_cpu="x64"', |
| 51 'use_goma=true', |
| 51 ] | 52 ] |
| 52 | 53 |
| 53 CHROMEOS_GN_ARGS = LINUX_GN_ARGS + [ | 54 CHROMEOS_GN_ARGS = LINUX_GN_ARGS + [ |
| 54 'target_os="chromeos"', | 55 'target_os="chromeos"', |
| 55 'use_ozone=true', | 56 'use_ozone=true', |
| 56 ] | 57 ] |
| 57 | 58 |
| 58 SPEC = freeze({ | 59 SPEC = freeze({ |
| 59 # The builders have the following parameters: | 60 # The builders have the following parameters: |
| 60 # - compile_targets: the compile targets. | 61 # - compile_targets: the compile targets. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 'platform': 'chromeos', | 96 'platform': 'chromeos', |
| 96 }, | 97 }, |
| 97 }, | 98 }, |
| 98 }) | 99 }) |
| 99 | 100 |
| 100 def GenerateCompilationDatabase(api, debug_path, targets, platform): | 101 def GenerateCompilationDatabase(api, debug_path, targets, platform): |
| 101 # TODO(akuegel): If we ever build on Windows or Mac, this needs to be | 102 # TODO(akuegel): If we ever build on Windows or Mac, this needs to be |
| 102 # adjusted. | 103 # adjusted. |
| 103 gn_path = api.path['checkout'].join('buildtools', 'linux64', 'gn') | 104 gn_path = api.path['checkout'].join('buildtools', 'linux64', 'gn') |
| 104 args = LINUX_GN_ARGS if platform == 'linux' else CHROMEOS_GN_ARGS | 105 args = LINUX_GN_ARGS if platform == 'linux' else CHROMEOS_GN_ARGS |
| 105 args.extend(['use_goma=true', | |
| 106 'goma_dir=%s' % api.goma.goma_dir]) | |
| 107 command = [gn_path, 'gen', debug_path, '--args=%s' % ' '.join(args)] | 106 command = [gn_path, 'gen', debug_path, '--args=%s' % ' '.join(args)] |
| 108 api.step('generate build files for %s' % platform, command, | 107 api.step('generate build files for %s' % platform, command, |
| 109 cwd=api.path['checkout']) | 108 cwd=api.path['checkout']) |
| 110 command = ['ninja', '-C', debug_path] + list(targets) | 109 command = ['ninja', '-C', debug_path] + list(targets) |
| 111 # Add the parameters for creating the compilation database. | 110 # Add the parameters for creating the compilation database. |
| 112 command += ['-t', 'compdb', 'cc', 'cxx', 'objc', 'objcxx'] | 111 command += ['-t', 'compdb', 'cc', 'cxx', 'objc', 'objcxx'] |
| 113 | 112 return api.step('generate compilation database for %s' % platform, |
| 114 command += ['-j', api.goma.recommended_goma_jobs] | 113 command, |
| 115 | 114 stdout=api.raw_io.output()) |
| 116 with api.goma.build_with_goma( | |
| 117 ninja_log_outdir=debug_path, | |
| 118 ninja_log_command=command, | |
| 119 ninja_log_compiler='goma'): | |
| 120 return api.step('generate compilation database for %s' % platform, | |
| 121 command, | |
| 122 stdout=api.raw_io.output()) | |
| 123 | 115 |
| 124 | 116 |
| 125 def RunSteps(api): | 117 def RunSteps(api): |
| 126 buildername = api.properties.get('buildername') | 118 buildername = api.properties.get('buildername') |
| 127 | 119 |
| 128 bot_config = SPEC.get('builders', {}).get(buildername) | 120 bot_config = SPEC.get('builders', {}).get(buildername) |
| 129 platform = bot_config.get('platform', 'linux') | 121 platform = bot_config.get('platform', 'linux') |
| 130 | 122 |
| 131 # Checkout the repositories that are either directly needed or should be | 123 # Checkout the repositories that are either directly needed or should be |
| 132 # included in the source archive. | 124 # included in the source archive. |
| 133 gclient_config = api.gclient.make_config('chromium') | 125 gclient_config = api.gclient.make_config('chromium') |
| 134 for name, url in ADDITIONAL_REPOS.iteritems(): | 126 for name, url in ADDITIONAL_REPOS.iteritems(): |
| 135 solution = gclient_config.solutions.add() | 127 solution = gclient_config.solutions.add() |
| 136 solution.name = name | 128 solution.name = name |
| 137 solution.url = url | 129 solution.url = url |
| 138 api.gclient.c = gclient_config | 130 api.gclient.c = gclient_config |
| 139 update_step = api.bot_update.ensure_checkout() | 131 update_step = api.bot_update.ensure_checkout() |
| 140 api.chromium.set_build_properties(update_step.json.output['properties']) | 132 api.chromium.set_build_properties(update_step.json.output['properties']) |
| 141 | 133 |
| 142 # Remove the llvm-build directory, so that gclient runhooks will download | 134 # Remove the llvm-build directory, so that gclient runhooks will download |
| 143 # the pre-built clang binary and not use the locally compiled binary from | 135 # the pre-built clang binary and not use the locally compiled binary from |
| 144 # the 'compile translation_unit clang tool' step. | 136 # the 'compile translation_unit clang tool' step. |
| 145 api.file.rmtree('llvm-build', | 137 api.file.rmtree('llvm-build', |
| 146 api.path['checkout'].join('third_party', 'llvm-build')) | 138 api.path['checkout'].join('third_party', 'llvm-build')) |
| 147 | 139 |
| 148 debug_path = api.path['checkout'].join('out', 'Debug') | 140 debug_path = api.path['checkout'].join('out', 'Debug') |
| 149 targets = bot_config.get('compile_targets', []) | 141 targets = bot_config.get('compile_targets', []) |
| 150 api.chromium.set_config('codesearch', BUILD_CONFIG='Debug') | 142 api.chromium.set_config('codesearch', BUILD_CONFIG='Debug') |
| 151 api.chromium.ensure_goma() | |
| 152 api.chromium.runhooks() | 143 api.chromium.runhooks() |
| 153 | 144 |
| 154 result = GenerateCompilationDatabase(api, debug_path, targets, platform) | 145 result = GenerateCompilationDatabase(api, debug_path, targets, platform) |
| 155 | 146 |
| 156 try: | 147 try: |
| 157 api.chromium.compile(targets) | 148 api.chromium.compile(targets) |
| 158 except api.step.StepFailure as f: # pragma: no cover | 149 except api.step.StepFailure as f: # pragma: no cover |
| 159 # Even if compilation fails, the Grok indexer may still be able to extract | 150 # Even if compilation fails, the Grok indexer may still be able to extract |
| 160 # (almost) all cross references. And the downside of failing on compile | 151 # (almost) all cross references. And the downside of failing on compile |
| 161 # error is that Codesearch gets stale. | 152 # error is that Codesearch gets stale. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 api.test( | 256 api.test( |
| 266 'full_%s_fail' % _sanitize_nonalpha('ChromiumOS Codesearch')) + | 257 'full_%s_fail' % _sanitize_nonalpha('ChromiumOS Codesearch')) + |
| 267 api.step_data('generate compilation database for chromeos', | 258 api.step_data('generate compilation database for chromeos', |
| 268 stdout=api.raw_io.output('some compilation data')) + | 259 stdout=api.raw_io.output('some compilation data')) + |
| 269 api.step_data('generate compilation database for linux', | 260 api.step_data('generate compilation database for linux', |
| 270 stdout=api.raw_io.output('some compilation data')) + | 261 stdout=api.raw_io.output('some compilation data')) + |
| 271 api.step_data('run translation_unit clang tool', retcode=2) + | 262 api.step_data('run translation_unit clang tool', retcode=2) + |
| 272 api.properties.generic(buildername='ChromiumOS Codesearch', | 263 api.properties.generic(buildername='ChromiumOS Codesearch', |
| 273 mastername='chromium.infra.cron') | 264 mastername='chromium.infra.cron') |
| 274 ) | 265 ) |
| OLD | NEW |