OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Build script to generate a new sdk_tools bundle. | 6 """Build script to generate a new sdk_tools bundle. |
7 | 7 |
8 This script packages the files necessary to generate the SDK updater -- the | 8 This script packages the files necessary to generate the SDK updater -- the |
9 tool users run to download new bundles, update existing bundles, etc. | 9 tool users run to download new bundles, update existing bundles, etc. |
10 """ | 10 """ |
11 | 11 |
12 import buildbot_common | 12 import buildbot_common |
13 import build_utils | 13 import build_utils |
14 import cStringIO | |
15 import optparse | 14 import optparse |
16 import os | 15 import os |
17 import re | |
18 import sys | 16 import sys |
19 | 17 |
20 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 18 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
21 SDK_SRC_DIR = os.path.dirname(SCRIPT_DIR) | 19 SDK_SRC_DIR = os.path.dirname(SCRIPT_DIR) |
22 SDK_DIR = os.path.dirname(SDK_SRC_DIR) | 20 SDK_DIR = os.path.dirname(SDK_SRC_DIR) |
23 SRC_DIR = os.path.dirname(SDK_DIR) | 21 SRC_DIR = os.path.dirname(SDK_DIR) |
24 NACL_DIR = os.path.join(SRC_DIR, 'native_client') | 22 NACL_DIR = os.path.join(SRC_DIR, 'native_client') |
25 CYGTAR = os.path.join(NACL_DIR, 'build', 'cygtar.py') | 23 CYGTAR = os.path.join(NACL_DIR, 'build', 'cygtar.py') |
26 | 24 |
27 sys.path.append(os.path.join(SDK_SRC_DIR, 'tools')) | 25 sys.path.append(os.path.join(SDK_SRC_DIR, 'tools')) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 out_dir: The output directory containing the scripts to update. | 102 out_dir: The output directory containing the scripts to update. |
105 revision_number: The revision number as an integer, or None to use the | 103 revision_number: The revision number as an integer, or None to use the |
106 current Chrome revision (as retrieved through svn/git). | 104 current Chrome revision (as retrieved through svn/git). |
107 """ | 105 """ |
108 if revision_number is None: | 106 if revision_number is None: |
109 revision_number = build_utils.ChromeRevision() | 107 revision_number = build_utils.ChromeRevision() |
110 | 108 |
111 SDK_UPDATE_MAIN = os.path.join(out_dir, | 109 SDK_UPDATE_MAIN = os.path.join(out_dir, |
112 'nacl_sdk/sdk_tools/sdk_update_main.py') | 110 'nacl_sdk/sdk_tools/sdk_update_main.py') |
113 | 111 |
114 file = open(SDK_UPDATE_MAIN, 'r').read().replace( | 112 contents = open(SDK_UPDATE_MAIN, 'r').read().replace( |
115 '{REVISION}', str(revision_number)) | 113 '{REVISION}', str(revision_number)) |
116 open(SDK_UPDATE_MAIN, 'w').write(file) | 114 open(SDK_UPDATE_MAIN, 'w').write(contents) |
117 | 115 |
118 | 116 |
119 def BuildUpdater(out_dir, revision_number=None): | 117 def BuildUpdater(out_dir, revision_number=None): |
120 """Build naclsdk.zip and sdk_tools.tgz in |out_dir|. | 118 """Build naclsdk.zip and sdk_tools.tgz in |out_dir|. |
121 | 119 |
122 Args: | 120 Args: |
123 out_dir: The output directory. | 121 out_dir: The output directory. |
124 revision_number: The revision number of this updater, as an integer. Or | 122 revision_number: The revision number of this updater, as an integer. Or |
125 None, to use the current Chrome revision.""" | 123 None, to use the current Chrome revision.""" |
126 buildbot_common.BuildStep('Create Updater') | 124 buildbot_common.BuildStep('Create Updater') |
127 | 125 |
128 out_dir = os.path.abspath(out_dir) | 126 out_dir = os.path.abspath(out_dir) |
129 | 127 |
130 # Build SDK directory | 128 # Build SDK directory |
131 buildbot_common.RemoveDir(os.path.join(out_dir, 'nacl_sdk')) | 129 buildbot_common.RemoveDir(os.path.join(out_dir, 'nacl_sdk')) |
132 | 130 |
133 updater_files = MakeUpdaterFilesAbsolute(out_dir) | 131 updater_files = MakeUpdaterFilesAbsolute(out_dir) |
134 out_files = [out_file for in_file, out_file in updater_files] | 132 out_files = [out_file for _, out_file in updater_files] |
135 | 133 |
136 CopyFiles(updater_files) | 134 CopyFiles(updater_files) |
137 UpdateRevisionNumber(out_dir, revision_number) | 135 UpdateRevisionNumber(out_dir, revision_number) |
138 | 136 |
139 # Make zip | 137 # Make zip |
140 buildbot_common.RemoveFile(os.path.join(out_dir, 'nacl_sdk.zip')) | 138 buildbot_common.RemoveFile(os.path.join(out_dir, 'nacl_sdk.zip')) |
141 buildbot_common.Run([sys.executable, oshelpers.__file__, 'zip', | 139 buildbot_common.Run([sys.executable, oshelpers.__file__, 'zip', |
142 'nacl_sdk.zip'] + out_files, | 140 'nacl_sdk.zip'] + out_files, |
143 cwd=out_dir) | 141 cwd=out_dir) |
144 | 142 |
(...skipping 12 matching lines...) Expand all Loading... |
157 parser = optparse.OptionParser() | 155 parser = optparse.OptionParser() |
158 parser.add_option('-o', '--out', help='output directory', | 156 parser.add_option('-o', '--out', help='output directory', |
159 dest='out_dir', default='out') | 157 dest='out_dir', default='out') |
160 options, args = parser.parse_args(args[1:]) | 158 options, args = parser.parse_args(args[1:]) |
161 | 159 |
162 BuildUpdater(options.out_dir) | 160 BuildUpdater(options.out_dir) |
163 | 161 |
164 | 162 |
165 if __name__ == '__main__': | 163 if __name__ == '__main__': |
166 sys.exit(main(sys.argv)) | 164 sys.exit(main(sys.argv)) |
OLD | NEW |