| OLD | NEW |
| 1 # Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
| 3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
| 4 # | 4 # |
| 5 # This python script creates a tar archive and a C++ source file which contains | 5 # This python script creates a tar archive and a C++ source file which contains |
| 6 # the tar archive as an array of bytes. | 6 # the tar archive as an array of bytes. |
| 7 | 7 |
| 8 import os | 8 import os |
| 9 import sys | 9 import sys |
| 10 from os.path import join, splitext | 10 from os.path import join, splitext |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 for dirname, dirnames, filenames in os.walk(options.client_root): | 125 for dirname, dirnames, filenames in os.walk(options.client_root): |
| 126 # strip out all dot files. | 126 # strip out all dot files. |
| 127 filenames = [f for f in filenames if not f[0] == '.'] | 127 filenames = [f for f in filenames if not f[0] == '.'] |
| 128 dirnames[:] = [d for d in dirnames if not d[0] == '.'] | 128 dirnames[:] = [d for d in dirnames if not d[0] == '.'] |
| 129 for f in filenames: | 129 for f in filenames: |
| 130 src_path = os.path.join(dirname, f) | 130 src_path = os.path.join(dirname, f) |
| 131 if (os.path.isdir(src_path)): | 131 if (os.path.isdir(src_path)): |
| 132 continue | 132 continue |
| 133 files.append(src_path) | 133 files.append(src_path) |
| 134 | 134 |
| 135 # Ensure consistent file ordering for reproducible builds. |
| 136 files.sort() |
| 137 |
| 135 # Write out archive. | 138 # Write out archive. |
| 136 makeArchive(options.tar_output, | 139 makeArchive(options.tar_output, |
| 137 options.client_root, | 140 options.client_root, |
| 138 options.compress, | 141 options.compress, |
| 139 files) | 142 files) |
| 140 | 143 |
| 141 # Read it back in. | 144 # Read it back in. |
| 142 with open(options.tar_output, 'rb') as tar_file: | 145 with open(options.tar_output, 'rb') as tar_file: |
| 143 tar_archive = tar_file.read() | 146 tar_archive = tar_file.read() |
| 144 | 147 |
| 145 # Write CC file. | 148 # Write CC file. |
| 146 writeCCFile(options.output, | 149 writeCCFile(options.output, |
| 147 options.outer_namespace, | 150 options.outer_namespace, |
| 148 options.inner_namespace, | 151 options.inner_namespace, |
| 149 options.name, | 152 options.name, |
| 150 tar_archive) | 153 tar_archive) |
| 151 return 0 | 154 return 0 |
| 152 | 155 |
| 153 except Exception, inst: | 156 except Exception, inst: |
| 154 sys.stderr.write('create_resources.py exception\n') | 157 sys.stderr.write('create_resources.py exception\n') |
| 155 sys.stderr.write(str(inst)) | 158 sys.stderr.write(str(inst)) |
| 156 sys.stderr.write('\n') | 159 sys.stderr.write('\n') |
| 157 return -1 | 160 return -1 |
| 158 | 161 |
| 159 if __name__ == '__main__': | 162 if __name__ == '__main__': |
| 160 sys.exit(main(sys.argv)) | 163 sys.exit(main(sys.argv)) |
| OLD | NEW |