| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """A tool to build chrome, executed by buildbot. | 6 """A tool to build chrome, executed by buildbot. |
| 7 | 7 |
| 8 When this is run, the current directory (cwd) should be the outer build | 8 When this is run, the current directory (cwd) should be the outer build |
| 9 directory (e.g., chrome-release/build/). | 9 directory (e.g., chrome-release/build/). |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 # If the project isn't in args, add all.xcodeproj so simplify configuration. | 47 # If the project isn't in args, add all.xcodeproj so simplify configuration. |
| 48 command = ['xcodebuild', '-configuration', options.target] | 48 command = ['xcodebuild', '-configuration', options.target] |
| 49 if not '-project' in args: | 49 if not '-project' in args: |
| 50 command.extend(['-project', 'all.xcodeproj']) | 50 command.extend(['-project', 'all.xcodeproj']) |
| 51 command.extend(args) | 51 command.extend(args) |
| 52 | 52 |
| 53 result = chromium_utils.RunCommand(command) | 53 result = chromium_utils.RunCommand(command) |
| 54 return result | 54 return result |
| 55 | 55 |
| 56 | 56 |
| 57 def common_linux_settings(command, distcc_pump=False): | 57 def common_linux_settings(command, distcc_pump=False, crosstool=None): |
| 58 """ | 58 """ |
| 59 Sets desirable Linux environment variables and command-line options | 59 Sets desirable Linux environment variables and command-line options |
| 60 that are common to the Make and SCons builds. | 60 that are common to the Make and SCons builds. |
| 61 """ | 61 """ |
| 62 if options.mode == 'google_chrome' or options.mode == 'official': | 62 if options.mode == 'google_chrome' or options.mode == 'official': |
| 63 os.environ['CHROMIUM_BUILD'] = '_google_chrome' | 63 os.environ['CHROMIUM_BUILD'] = '_google_chrome' |
| 64 | 64 |
| 65 if options.mode == 'official': | 65 if options.mode == 'official': |
| 66 os.environ['OFFICIAL_BUILD'] = '1' | 66 os.environ['OFFICIAL_BUILD'] = '1' |
| 67 os.environ['CHROME_BUILD_TYPE'] = '_official' | 67 os.environ['CHROME_BUILD_TYPE'] = '_official' |
| 68 # Official builds are always Google Chrome. | 68 # Official builds are always Google Chrome. |
| 69 | 69 |
| 70 # Don't stop at the first error. | 70 # Don't stop at the first error. |
| 71 command.append('-k') | 71 command.append('-k') |
| 72 | 72 |
| 73 # distcc pump is ccache incompatible, the pump script sets CC/CXX/-j. | 73 # distcc pump is ccache incompatible, the pump script sets CC/CXX/-j. |
| 74 if distcc_pump: | 74 if distcc_pump: |
| 75 return | 75 return |
| 76 | 76 |
| 77 # Setup crosstool environment variables. |
| 78 if crosstool: |
| 79 os.environ['AR'] = crosstool + '-ar' |
| 80 os.environ['AS'] = crosstool + '-as' |
| 81 os.environ['CC'] = crosstool + '-gcc' |
| 82 os.environ['CXX'] = crosstool + '-g++' |
| 83 os.environ['LD'] = crosstool + '-ld' |
| 84 os.environ['RANLIB'] = crosstool + '-ranlib' |
| 85 command.append('-j4') |
| 86 return |
| 87 |
| 77 jobs = 4 | 88 jobs = 4 |
| 78 cc = 'gcc' | 89 cc = 'gcc' |
| 79 cpp = 'g++' | 90 cpp = 'g++' |
| 80 distcc_hosts_file = os.path.join(os.path.expanduser('~'), '.distcc/hosts') | 91 distcc_hosts_file = os.path.join(os.path.expanduser('~'), '.distcc/hosts') |
| 81 if os.path.exists('/usr/bin/distcc') and os.path.exists(distcc_hosts_file): | 92 if os.path.exists('/usr/bin/distcc') and os.path.exists(distcc_hosts_file): |
| 82 cc = 'distcc ' + cc | 93 cc = 'distcc ' + cc |
| 83 cpp = 'distcc ' + cpp | 94 cpp = 'distcc ' + cpp |
| 84 jobs = 12 | 95 jobs = 12 |
| 85 if os.path.exists('/usr/bin/ccache'): | 96 if os.path.exists('/usr/bin/ccache'): |
| 86 cc = 'ccache ' + cc | 97 cc = 'ccache ' + cc |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 132 |
| 122 if options.distcc_pump: | 133 if options.distcc_pump: |
| 123 # pump_chrome is a custom script for running distcc pump. We just call | 134 # pump_chrome is a custom script for running distcc pump. We just call |
| 124 # pump_chrome so the local user can easily customize distcc parameters. | 135 # pump_chrome so the local user can easily customize distcc parameters. |
| 125 # The simplist pump_chrome script would be: | 136 # The simplist pump_chrome script would be: |
| 126 # #!/bin/sh | 137 # #!/bin/sh |
| 127 # CC="distcc gcc" CXX="distcc g++" pump make -jN $@ | 138 # CC="distcc gcc" CXX="distcc g++" pump make -jN $@ |
| 128 command = ['pump_chrome'] | 139 command = ['pump_chrome'] |
| 129 else: | 140 else: |
| 130 command = ['make'] | 141 command = ['make'] |
| 131 common_linux_settings(command, options.distcc_pump) | 142 common_linux_settings(command, options.distcc_pump, options.crosstool) |
| 132 | 143 |
| 133 command.append('BUILDTYPE=' + options.target) | 144 command.append('BUILDTYPE=' + options.target) |
| 134 | 145 |
| 135 # Here's what you can uncomment if you need to see more info | 146 # Here's what you can uncomment if you need to see more info |
| 136 # about what the build is doing on a slave: | 147 # about what the build is doing on a slave: |
| 137 # | 148 # |
| 138 # V=1 prints the actual executed command | 149 # V=1 prints the actual executed command |
| 139 # | 150 # |
| 140 #command.extend(['V=1']) | 151 #command.extend(['V=1']) |
| 141 command.extend(options.build_args + args) | 152 command.extend(options.build_args + args) |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 option_parser.add_option('', '--msvs_version', default='8', | 314 option_parser.add_option('', '--msvs_version', default='8', |
| 304 help='VisualStudio version to use ' | 315 help='VisualStudio version to use ' |
| 305 '[default:%default]') | 316 '[default:%default]') |
| 306 option_parser.add_option('', '--fastbuild', action="store_true", | 317 option_parser.add_option('', '--fastbuild', action="store_true", |
| 307 help='faster build (with debug info stripped)') | 318 help='faster build (with debug info stripped)') |
| 308 if chromium_utils.IsLinux(): | 319 if chromium_utils.IsLinux(): |
| 309 # This is for Linux local testing where we have a distcc pump cluster. | 320 # This is for Linux local testing where we have a distcc pump cluster. |
| 310 # Only works for make builds. Ask thestig if you're curious. | 321 # Only works for make builds. Ask thestig if you're curious. |
| 311 option_parser.add_option('', '--distcc-pump', action="store_true", | 322 option_parser.add_option('', '--distcc-pump', action="store_true", |
| 312 help='run distcc pump mode for local testing') | 323 help='run distcc pump mode for local testing') |
| 324 # For linux to arm cross compile. |
| 325 option_parser.add_option('', '--crosstool', default=None, |
| 326 help='optional path to crosstool toolset') |
| 313 | 327 |
| 314 options, args = option_parser.parse_args() | 328 options, args = option_parser.parse_args() |
| 315 | 329 |
| 316 if options.build_tool is None: | 330 if options.build_tool is None: |
| 317 if chromium_utils.IsWindows(): | 331 if chromium_utils.IsWindows(): |
| 318 main = main_win | 332 main = main_win |
| 319 elif chromium_utils.IsMac(): | 333 elif chromium_utils.IsMac(): |
| 320 main = main_xcode | 334 main = main_xcode |
| 321 elif chromium_utils.IsLinux(): | 335 elif chromium_utils.IsLinux(): |
| 322 main = main_scons | 336 main = main_scons |
| 323 else: | 337 else: |
| 324 print('Please specify --build-tool.') | 338 print('Please specify --build-tool.') |
| 325 sys.exit(1) | 339 sys.exit(1) |
| 326 else: | 340 else: |
| 327 build_tool_map = { | 341 build_tool_map = { |
| 328 'ib' : main_win, | 342 'ib' : main_win, |
| 329 'vs' : main_win, | 343 'vs' : main_win, |
| 330 'make' : main_make, | 344 'make' : main_make, |
| 331 'scons' : main_scons, | 345 'scons' : main_scons, |
| 332 'xcode' : main_xcode, | 346 'xcode' : main_xcode, |
| 333 } | 347 } |
| 334 main = build_tool_map.get(options.build_tool) | 348 main = build_tool_map.get(options.build_tool) |
| 335 if not main: | 349 if not main: |
| 336 sys.stderr.write('Unknown build tool %s.\n' % repr(options.build_tool)) | 350 sys.stderr.write('Unknown build tool %s.\n' % repr(options.build_tool)) |
| 337 sys.exit(2) | 351 sys.exit(2) |
| 338 | 352 |
| 339 sys.exit(main(options, args)) | 353 sys.exit(main(options, args)) |
| OLD | NEW |