Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # | 2 # |
| 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a |
| 5 # BSD-style license that can be found in the LICENSE file. | 5 # BSD-style license that can be found in the LICENSE file. |
| 6 | 6 |
| 7 """ This file will run docgen.dart on the SDK libraries, and upload them to | 7 """ This file will run docgen.dart on the SDK libraries, and upload them to |
| 8 Google Cloud Storage for the documentation viewer. | 8 Google Cloud Storage for the documentation viewer. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import argparse | |
|
Emily Fortuna
2013/07/19 22:49:28
Our buildbots actually still have python 2.6, and
janicejl
2013/07/22 16:56:11
Done.
| |
| 11 import os | 12 import os |
| 12 from os.path import join, dirname, abspath, exists | 13 from os.path import join, dirname, abspath, exists |
| 13 import platform | 14 import platform |
| 14 import subprocess | 15 import subprocess |
| 15 import sys | 16 import sys |
| 16 sys.path.append(abspath(join(dirname(__file__), '../../../tools'))) | 17 sys.path.append(abspath(join(dirname(__file__), '../../../tools'))) |
| 17 import utils | 18 import utils |
| 18 from upload_sdk import ExecuteCommand | 19 from upload_sdk import ExecuteCommand |
| 19 | 20 |
| 20 | 21 |
| 21 DART = abspath(join(dirname(__file__), '../../../%s/%s/dart-sdk/bin/dart' | 22 DART = abspath(join(dirname(__file__), '../../../%s/%s/dart-sdk/bin/dart' |
| 22 % (utils.BUILD_ROOT[utils.GuessOS()], utils.GetBuildConf('release', | 23 % (utils.BUILD_ROOT[utils.GuessOS()], utils.GetBuildConf('release', |
| 23 utils.GuessArchitecture())))) | 24 utils.GuessArchitecture())))) |
| 25 PACKAGE_ROOT = abspath(join(dirname(__file__), '../../../%s/%s/packages/' | |
| 26 % (utils.BUILD_ROOT[utils.GuessOS()], utils.GetBuildConf('release', | |
| 27 utils.GuessArchitecture())))) | |
| 24 GSUTIL = utils.GetBuildbotGSUtilPath() | 28 GSUTIL = utils.GetBuildbotGSUtilPath() |
| 25 GS_SITE = 'gs://dartlang-docgen' | 29 GS_SITE = 'gs://dartlang-docgen' |
| 30 DESCRIPTION='Runs docgen.dart on the SDK libraries, and uploads them to Google \ | |
| 31 Cloud Storage for the dartdoc-viewer. ' | |
| 32 | |
| 33 | |
| 34 def GetOptions(): | |
| 35 parser = argparse.ArgumentParser(description=DESCRIPTION) | |
| 36 parser.add_argument('--package-root', action=SetPackageRoot, | |
|
Emily Fortuna
2013/07/19 22:49:28
Instead of having the separate SetPackageRoot clas
janicejl
2013/07/22 16:56:11
Done.
| |
| 37 help='Sets the package root for dart.') | |
| 38 parser.parse_args() | |
| 39 | |
| 40 | |
| 41 class SetPackageRoot(argparse.Action): | |
| 42 def __call__(self, parser, namespace, values, option_string=None): | |
| 43 global PACKAGE_ROOT | |
| 44 if exists(values): | |
| 45 PACKAGE_ROOT = abspath(values) | |
| 26 | 46 |
| 27 | 47 |
| 28 def SetGsutil(): | 48 def SetGsutil(): |
| 29 """ If not on buildbots, find gsutil relative to docgen. """ | 49 """ If not on buildbots, find gsutil relative to docgen. """ |
| 30 global GSUTIL | 50 global GSUTIL |
| 31 if not exists(GSUTIL): | 51 if not exists(GSUTIL): |
| 32 GSUTIL = abspath(join(dirname(__file__), | 52 GSUTIL = abspath(join(dirname(__file__), |
| 33 '../../../third_party/gsutil/gsutil')) | 53 '../../../third_party/gsutil/gsutil')) |
| 34 | 54 |
| 35 | 55 |
| 36 def Upload(source, target): | 56 def Upload(source, target): |
| 37 """ Upload files to Google Storage. """ | 57 """ Upload files to Google Storage. """ |
| 38 cmd = [GSUTIL, '-m', 'cp', '-q', '-a', 'public-read', '-r', source, target] | 58 cmd = [GSUTIL, '-m', 'cp', '-q', '-a', 'public-read', '-r', source, target] |
| 39 (status, output) = ExecuteCommand(cmd) | 59 (status, output) = ExecuteCommand(cmd) |
| 40 return status | 60 return status |
| 41 | 61 |
| 42 | 62 |
| 43 def main(): | 63 def main(): |
| 64 GetOptions() | |
| 65 | |
| 44 SetGsutil() | 66 SetGsutil() |
| 45 | 67 |
| 46 # Execute Docgen.dart on the SDK. | 68 # Execute Docgen.dart on the SDK. |
| 47 ExecuteCommand([DART, abspath(join(dirname(__file__), 'docgen.dart')), | 69 ExecuteCommand([DART, '--checked', '--package-root=' + PACKAGE_ROOT, |
| 70 abspath(join(dirname(__file__), 'docgen.dart')), | |
| 48 '--parse-sdk']) | 71 '--parse-sdk']) |
| 49 | 72 |
| 50 # Use SVN Revision to get the revision number. | 73 # Use SVN Revision to get the revision number. |
| 51 revision = utils.GetSVNRevision() | 74 revision = utils.GetSVNRevision() |
| 52 if revision is None: | 75 if revision is None: |
| 53 # Try to find the version from the dart-sdk folder. | 76 # Try to find the version from the dart-sdk folder. |
| 54 revision_file_location = abspath(join(dirname(__file__), | 77 revision_file_location = abspath(join(dirname(__file__), |
| 55 '../../../%s/%s/dart-sdk/revision' % (utils.BUILD_ROOT[utils.GuessOS()], | 78 '../../../%s/%s/dart-sdk/revision' % (utils.BUILD_ROOT[utils.GuessOS()], |
| 56 utils.GetBuildConf('release', utils.GuessArchitecture())))) | 79 utils.GetBuildConf('release', utils.GuessArchitecture())))) |
| 57 with open(revision_file_location, 'r') as revision_file: | 80 with open(revision_file_location, 'r') as revision_file: |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 71 version_file.close() | 94 version_file.close() |
| 72 Upload('./VERSION', GS_SITE + '/VERSION') | 95 Upload('./VERSION', GS_SITE + '/VERSION') |
| 73 | 96 |
| 74 # Clean up the files it creates. | 97 # Clean up the files it creates. |
| 75 ExecuteCommand(['rm', '-rf', './docs']) | 98 ExecuteCommand(['rm', '-rf', './docs']) |
| 76 ExecuteCommand(['rm', '-f', './VERSION']) | 99 ExecuteCommand(['rm', '-f', './VERSION']) |
| 77 | 100 |
| 78 | 101 |
| 79 if __name__ == '__main__': | 102 if __name__ == '__main__': |
| 80 main() | 103 main() |
| OLD | NEW |