OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 """ | 6 """ |
7 This tool creates a tarball with all the sources, but without .svn directories. | 7 This tool creates a tarball with all the sources, but without .svn directories. |
8 | 8 |
9 It can also remove files which are not strictly required for build, so that | 9 It can also remove files which are not strictly required for build, so that |
10 the resulting tarball can be reasonably small (last time it was ~110 MB). | 10 the resulting tarball can be reasonably small (last time it was ~110 MB). |
11 | 11 |
12 Example usage: | 12 Example usage: |
13 | 13 |
14 export_tarball.py /foo/bar | 14 export_tarball.py /foo/bar |
15 | 15 |
16 The above will create file /foo/bar.tar.bz2. | 16 The above will create file /foo/bar.tar.bz2. |
17 """ | 17 """ |
18 | 18 |
19 import optparse | 19 import optparse |
20 import os | 20 import os |
21 import subprocess | |
21 import sys | 22 import sys |
22 import tarfile | 23 import tarfile |
23 | 24 |
24 NONESSENTIAL_DIRS = ( | 25 NONESSENTIAL_DIRS = ( |
25 'chrome/common/extensions/docs', | 26 'chrome/common/extensions/docs', |
26 'chrome/test/data', | 27 'chrome/test/data', |
27 'chrome/tools/test/reference_build', | 28 'chrome/tools/test/reference_build', |
28 'courgette/testdata', | 29 'courgette/testdata', |
29 'data', | 30 'data', |
30 'native_client/src/trusted/service_runtime/testdata', | 31 'native_client/src/trusted/service_runtime/testdata', |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 | 91 |
91 if len(args) != 1: | 92 if len(args) != 1: |
92 print 'You must provide only one argument: output file name' | 93 print 'You must provide only one argument: output file name' |
93 print '(without .tar.bz2 extension).' | 94 print '(without .tar.bz2 extension).' |
94 return 1 | 95 return 1 |
95 | 96 |
96 if not os.path.exists(GetSourceDirectory()): | 97 if not os.path.exists(GetSourceDirectory()): |
97 print 'Cannot find the src directory.' | 98 print 'Cannot find the src directory.' |
98 return 1 | 99 return 1 |
99 | 100 |
101 nacl_download_path = \ | |
bradn
2011/05/24 19:55:36
Style guide discourages \
Do this instead:
nacl_do
Paweł Hajdan Jr.
2011/05/25 08:49:44
Done.
| |
102 os.path.join(GetSourceDirectory(), 'build', 'download_nacl_irt.py') | |
103 nacl_cwd = os.path.join(GetSourceDirectory(), '..') | |
104 if subprocess.call(['python', nacl_download_path], cwd=nacl_cwd) != 0: | |
105 # The error is not fatal - NaCl is still experimental. | |
106 print 'Failed to download NaCl integrated runtime files.' | |
107 print 'The NaCl-enabled build will fail. You can pass -Ddisable_nacl=1' | |
108 print 'to gyp as a workaround. For more info see' | |
109 print 'http://groups.google.com/a/chromium.org/group/chromium-dev/browse_thr ead/thread/1fe6e2c3f9e78c2b' | |
bradn
2011/05/24 19:55:36
Use () to split.
Paweł Hajdan Jr.
2011/05/25 08:49:44
Done.
| |
110 | |
100 output_fullname = args[0] + '.tar.bz2' | 111 output_fullname = args[0] + '.tar.bz2' |
101 output_basename = os.path.basename(args[0]) | 112 output_basename = os.path.basename(args[0]) |
102 | 113 |
103 archive = MyTarFile.open(output_fullname, 'w:bz2') | 114 archive = MyTarFile.open(output_fullname, 'w:bz2') |
104 archive.set_remove_nonessential_files(options.remove_nonessential_files) | 115 archive.set_remove_nonessential_files(options.remove_nonessential_files) |
105 try: | 116 try: |
106 archive.add(GetSourceDirectory(), arcname=output_basename) | 117 archive.add(GetSourceDirectory(), arcname=output_basename) |
107 finally: | 118 finally: |
108 archive.close() | 119 archive.close() |
109 | 120 |
110 return 0 | 121 return 0 |
111 | 122 |
112 if __name__ == "__main__": | 123 if __name__ == "__main__": |
113 sys.exit(main(sys.argv[1:])) | 124 sys.exit(main(sys.argv[1:])) |
OLD | NEW |