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 os | 11 import os |
| 12 from os.path import join, dirname, abspath, exists | 12 from os.path import join, dirname, abspath, exists |
| 13 import platform | 13 import platform |
| 14 import subprocess | 14 import subprocess |
| 15 import sys | 15 import sys |
| 16 sys.path.append(abspath(join(dirname(__file__), '../../../tools'))) | 16 sys.path.append(abspath(join(dirname(__file__), '../../../tools'))) |
| 17 import utils | 17 import utils |
| 18 from upload_sdk import ExecuteCommand | 18 from upload_sdk import ExecuteCommand |
| 19 | 19 |
| 20 | 20 |
| 21 DART = abspath(join(dirname(__file__), '../../../%s/%s/dart-sdk/bin/dart' | 21 DART = abspath(join(dirname(__file__), '../../../%s/%s/dart-sdk/bin/dart' |
| 22 % (utils.BUILD_ROOT[utils.GuessOS()], utils.GetBuildConf('release', | 22 % (utils.BUILD_ROOT[utils.GuessOS()], utils.GetBuildConf('release', |
| 23 utils.GuessArchitecture())))) | 23 utils.GuessArchitecture())))) |
| 24 PACKAGE_ROOT = abspath(join(dirname(__file__), '../../../%s/%s/packages/' | |
|
Emily Fortuna
2013/07/19 15:56:44
in addition to this constant, can you also allow a
janicejl
2013/07/19 22:31:31
Done.
| |
| 25 % (utils.BUILD_ROOT[utils.GuessOS()], utils.GetBuildConf('release', | |
| 26 utils.GuessArchitecture())))) | |
| 24 GSUTIL = utils.GetBuildbotGSUtilPath() | 27 GSUTIL = utils.GetBuildbotGSUtilPath() |
| 25 GS_SITE = 'gs://dartlang-docgen' | 28 GS_SITE = 'gs://dartlang-docgen' |
| 26 | 29 |
| 27 | 30 |
| 28 def SetGsutil(): | 31 def SetGsutil(): |
| 29 """ If not on buildbots, find gsutil relative to docgen. """ | 32 """ If not on buildbots, find gsutil relative to docgen. """ |
| 30 global GSUTIL | 33 global GSUTIL |
| 31 if not exists(GSUTIL): | 34 if not exists(GSUTIL): |
| 32 GSUTIL = abspath(join(dirname(__file__), | 35 GSUTIL = abspath(join(dirname(__file__), |
| 33 '../../../third_party/gsutil/gsutil')) | 36 '../../../third_party/gsutil/gsutil')) |
| 34 | 37 |
| 35 | 38 |
| 36 def Upload(source, target): | 39 def Upload(source, target): |
| 37 """ Upload files to Google Storage. """ | 40 """ Upload files to Google Storage. """ |
| 38 cmd = [GSUTIL, '-m', 'cp', '-q', '-a', 'public-read', '-r', source, target] | 41 cmd = [GSUTIL, '-m', 'cp', '-q', '-a', 'public-read', '-r', source, target] |
| 39 (status, output) = ExecuteCommand(cmd) | 42 (status, output) = ExecuteCommand(cmd) |
| 40 return status | 43 return status |
| 41 | 44 |
| 42 | 45 |
| 43 def main(): | 46 def main(): |
| 44 SetGsutil() | 47 SetGsutil() |
| 45 | 48 |
| 46 # Execute Docgen.dart on the SDK. | 49 # Execute Docgen.dart on the SDK. |
| 47 ExecuteCommand([DART, abspath(join(dirname(__file__), 'docgen.dart')), | 50 ExecuteCommand([DART, '--package-root=' + PACKAGE_ROOT, |
| 51 abspath(join(dirname(__file__), 'docgen.dart')), | |
| 48 '--parse-sdk']) | 52 '--parse-sdk']) |
| 49 | 53 |
| 50 # Use SVN Revision to get the revision number. | 54 # Use SVN Revision to get the revision number. |
| 51 revision = utils.GetSVNRevision() | 55 revision = utils.GetSVNRevision() |
| 52 if revision is None: | 56 if revision is None: |
| 53 # Try to find the version from the dart-sdk folder. | 57 # Try to find the version from the dart-sdk folder. |
| 54 revision_file_location = abspath(join(dirname(__file__), | 58 revision_file_location = abspath(join(dirname(__file__), |
| 55 '../../../%s/%s/dart-sdk/revision' % (utils.BUILD_ROOT[utils.GuessOS()], | 59 '../../../%s/%s/dart-sdk/revision' % (utils.BUILD_ROOT[utils.GuessOS()], |
| 56 utils.GetBuildConf('release', utils.GuessArchitecture())))) | 60 utils.GetBuildConf('release', utils.GuessArchitecture())))) |
| 57 with open(revision_file_location, 'r') as revision_file: | 61 with open(revision_file_location, 'r') as revision_file: |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 71 version_file.close() | 75 version_file.close() |
| 72 Upload('./VERSION', GS_SITE + '/VERSION') | 76 Upload('./VERSION', GS_SITE + '/VERSION') |
| 73 | 77 |
| 74 # Clean up the files it creates. | 78 # Clean up the files it creates. |
| 75 ExecuteCommand(['rm', '-rf', './docs']) | 79 ExecuteCommand(['rm', '-rf', './docs']) |
| 76 ExecuteCommand(['rm', '-f', './VERSION']) | 80 ExecuteCommand(['rm', '-f', './VERSION']) |
| 77 | 81 |
| 78 | 82 |
| 79 if __name__ == '__main__': | 83 if __name__ == '__main__': |
| 80 main() | 84 main() |
| OLD | NEW |