Tim van der Lippe | 790b929 | 2019-09-19 15:14:16 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # -*- coding: UTF-8 -*- |
| 3 | # |
| 4 | # Copyright 2019 The Chromium Authors. All rights reserved. |
| 5 | # Use of this source code is governed by a BSD-style license that can be |
| 6 | # found in the LICENSE file. |
| 7 | """ |
| 8 | Copies the modules into the resources folder |
| 9 | """ |
| 10 | |
| 11 | from os.path import join, relpath |
| 12 | import shutil |
| 13 | import sys |
| 14 | |
Tim van der Lippe | bc38bd6 | 2019-10-03 18:36:31 +0000 | [diff] [blame] | 15 | import rjsmin |
| 16 | |
| 17 | from modular_build import read_file, write_file |
| 18 | |
Tim van der Lippe | 790b929 | 2019-09-19 15:14:16 +0000 | [diff] [blame] | 19 | |
| 20 | def main(argv): |
| 21 | try: |
| 22 | input_path_flag_index = argv.index('--input_path') |
| 23 | input_path = argv[input_path_flag_index + 1] |
| 24 | output_path_flag_index = argv.index('--output_path') |
| 25 | output_path = argv[output_path_flag_index + 1] |
| 26 | devtools_modules = argv[1:input_path_flag_index] |
| 27 | except: |
Tim van der Lippe | bc38bd6 | 2019-10-03 18:36:31 +0000 | [diff] [blame] | 28 | print('Usage: %s module_1 module_2 ... module_N --input_path <input_path> --output_path <output_path>' % argv[0]) |
Tim van der Lippe | 790b929 | 2019-09-19 15:14:16 +0000 | [diff] [blame] | 29 | raise |
| 30 | |
| 31 | for file_name in devtools_modules: |
Tim van der Lippe | bc38bd6 | 2019-10-03 18:36:31 +0000 | [diff] [blame] | 32 | file_content = read_file(join(input_path, file_name)) |
| 33 | minified = rjsmin.jsmin(file_content) |
| 34 | write_file(join(output_path, relpath(file_name, 'front_end')), minified) |
Tim van der Lippe | 790b929 | 2019-09-19 15:14:16 +0000 | [diff] [blame] | 35 | |
| 36 | |
| 37 | if __name__ == '__main__': |
| 38 | sys.exit(main(sys.argv)) |