| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 """Prepares a local hermetic Go installation. | 6 """Prepares a local hermetic Go installation. |
| 7 | 7 |
| 8 - Downloads and unpacks the Go toolset in ../../golang. | 8 - Downloads and unpacks the Go toolset in ../../golang. |
| 9 - Downloads and installs goop and golint. | 9 - Downloads and installs goop and golint. |
| 10 - Fetches code dependencies via goop. | 10 - Fetches code dependencies via goop. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 # Where Go GAE SDK is supposedly installed. | 39 # Where Go GAE SDK is supposedly installed. |
| 40 GO_APPENGINE = os.path.join(os.path.dirname(ROOT), 'go_appengine') | 40 GO_APPENGINE = os.path.join(os.path.dirname(ROOT), 'go_appengine') |
| 41 | 41 |
| 42 # Default workspace with infra go code. | 42 # Default workspace with infra go code. |
| 43 WORKSPACE = os.path.join(ROOT, 'go') | 43 WORKSPACE = os.path.join(ROOT, 'go') |
| 44 | 44 |
| 45 # Platform depended suffix for executable files. | 45 # Platform depended suffix for executable files. |
| 46 EXE_SFX = '.exe' if sys.platform == 'win32' else '' | 46 EXE_SFX = '.exe' if sys.platform == 'win32' else '' |
| 47 | 47 |
| 48 # On Windows we use git from depot_tools. |
| 49 GIT_EXE = 'git.bat' if sys.platform == 'win32' else 'git' |
| 50 |
| 48 # Pinned version of Go toolset to download. | 51 # Pinned version of Go toolset to download. |
| 49 TOOLSET_VERSION = 'go1.4' | 52 TOOLSET_VERSION = 'go1.4' |
| 50 | 53 |
| 51 # Platform dependent portion of a download URL. See http://golang.org/dl/. | 54 # Platform dependent portion of a download URL. See http://golang.org/dl/. |
| 52 TOOLSET_VARIANTS = { | 55 TOOLSET_VARIANTS = { |
| 53 ('darwin', 'x86-32'): 'darwin-386-osx10.8.tar.gz', | 56 ('darwin', 'x86-32'): 'darwin-386-osx10.8.tar.gz', |
| 54 ('darwin', 'x86-64'): 'darwin-amd64-osx10.8.tar.gz', | 57 ('darwin', 'x86-64'): 'darwin-amd64-osx10.8.tar.gz', |
| 55 ('linux2', 'x86-32'): 'linux-386.tar.gz', | 58 ('linux2', 'x86-32'): 'linux-386.tar.gz', |
| 56 ('linux2', 'x86-64'): 'linux-amd64.tar.gz', | 59 ('linux2', 'x86-64'): 'linux-amd64.tar.gz', |
| 57 ('win32', 'x86-32'): 'windows-386.zip', | 60 ('win32', 'x86-32'): 'windows-386.zip', |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 LOGGER.info('Copying %s -> %s', sdk_dir, tool_dir) | 269 LOGGER.info('Copying %s -> %s', sdk_dir, tool_dir) |
| 267 shutil.copytree(sdk_dir, tool_dir) | 270 shutil.copytree(sdk_dir, tool_dir) |
| 268 | 271 |
| 269 for pkg in GAE_HACK_PKGS: | 272 for pkg in GAE_HACK_PKGS: |
| 270 shutil.rmtree(os.path.join(base_tool_dir, pkg)) | 273 shutil.rmtree(os.path.join(base_tool_dir, pkg)) |
| 271 | 274 |
| 272 patches = [os.path.join(WORKSPACE, 'patches', p) | 275 patches = [os.path.join(WORKSPACE, 'patches', p) |
| 273 for p in os.listdir(os.path.join(WORKSPACE, 'patches')) | 276 for p in os.listdir(os.path.join(WORKSPACE, 'patches')) |
| 274 if p.endswith('.patch')] | 277 if p.endswith('.patch')] |
| 275 for patch in patches: | 278 for patch in patches: |
| 276 subprocess.check_call(['git', 'apply'], cwd=toolset_root, | 279 subprocess.check_call([GIT_EXE, 'apply'], cwd=toolset_root, |
| 277 stdin=open(patch), stdout=sys.stderr) | 280 stdin=open(patch), stdout=sys.stderr) |
| 278 | 281 |
| 279 to_build = [] | 282 to_build = [] |
| 280 for d in GAE_PKGS: | 283 for d in GAE_PKGS: |
| 281 to_build.extend(discover_targets(base_tool_dir, d)) | 284 to_build.extend(discover_targets(base_tool_dir, d)) |
| 282 | 285 |
| 283 LOGGER.info('Building %d Appengine libs', len(to_build)) | 286 LOGGER.info('Building %d Appengine libs', len(to_build)) |
| 284 subprocess.check_call( | 287 subprocess.check_call( |
| 285 [get_go_exe(toolset_root), 'build'] + to_build, | 288 [get_go_exe(toolset_root), 'build'] + to_build, |
| 286 env=get_go_environ(toolset_root)) | 289 env=get_go_environ(toolset_root)) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 fetch_tools_code(tmp, TOOLS_SOURCE) | 350 fetch_tools_code(tmp, TOOLS_SOURCE) |
| 348 install(tmp, 'github.com/nitrous-io/goop') | 351 install(tmp, 'github.com/nitrous-io/goop') |
| 349 install(tmp, 'github.com/golang/lint/golint') | 352 install(tmp, 'github.com/golang/lint/golint') |
| 350 | 353 |
| 351 LOGGER.info('tools are installed') | 354 LOGGER.info('tools are installed') |
| 352 write_file([toolset_root, 'INSTALLED_TOOLS'], available_tools) | 355 write_file([toolset_root, 'INSTALLED_TOOLS'], available_tools) |
| 353 | 356 |
| 354 | 357 |
| 355 def fetch_tools_code(workspace, spec): | 358 def fetch_tools_code(workspace, spec): |
| 356 """Fetches goop and golint source code with dependencies.""" | 359 """Fetches goop and golint source code with dependencies.""" |
| 357 git_exe = 'git.bat' if sys.platform == 'win32' else 'git' | |
| 358 def git(cmd, cwd): | 360 def git(cmd, cwd): |
| 359 subprocess.check_call([git_exe] + cmd, cwd=cwd, stdout=sys.stderr) | 361 subprocess.check_call([GIT_EXE] + cmd, cwd=cwd, stdout=sys.stderr) |
| 360 for path, repo in sorted(spec.iteritems()): | 362 for path, repo in sorted(spec.iteritems()): |
| 361 path = os.path.join(workspace, path.replace('/', os.sep)) | 363 path = os.path.join(workspace, path.replace('/', os.sep)) |
| 362 os.makedirs(path) | 364 os.makedirs(path) |
| 363 git(['init', '.'], cwd=path) | 365 git(['init', '.'], cwd=path) |
| 364 git(['fetch', repo['url'], repo['ref']], cwd=path) | 366 git(['fetch', repo['url'], repo['ref']], cwd=path) |
| 365 git(['checkout', repo['rev']], cwd=path) | 367 git(['checkout', repo['rev']], cwd=path) |
| 366 | 368 |
| 367 | 369 |
| 368 def update_vendor_packages(toolset_root, workspace, force=False): | 370 def update_vendor_packages(toolset_root, workspace, force=False): |
| 369 """Runs goop to update external pinned packages.""" | 371 """Runs goop to update external pinned packages.""" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 def main(args): | 527 def main(args): |
| 526 if args: | 528 if args: |
| 527 print >> sys.stderr, sys.modules[__name__].__doc__, | 529 print >> sys.stderr, sys.modules[__name__].__doc__, |
| 528 return 2 | 530 return 2 |
| 529 bootstrap([WORKSPACE], logging.DEBUG) | 531 bootstrap([WORKSPACE], logging.DEBUG) |
| 530 return 0 | 532 return 0 |
| 531 | 533 |
| 532 | 534 |
| 533 if __name__ == '__main__': | 535 if __name__ == '__main__': |
| 534 sys.exit(main(sys.argv[1:])) | 536 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |