1#!/usr/bin/env python
2#
3# Copyright 2014 The Chromium Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7"""
8Invokes concatenate_application_code for applications specified on the command line.
9"""
10
11from os import path
12import concatenate_application_code
13import modular_build
14import sys
15
16try:
17    import simplejson as json
18except ImportError:
19    import json
20
21
22def main(argv):
23    try:
24        input_path_flag_index = argv.index('--input_path')
25        input_path = argv[input_path_flag_index + 1]
26        output_path_flag_index = argv.index('--output_path')
27        output_path = argv[output_path_flag_index + 1]
28        application_names = argv[1:input_path_flag_index]
29        debug_flag_index = argv.index('--debug')
30        minify = argv[debug_flag_index + 1] == '0'
31    except:
32        print('Usage: %s app_1 app_2 ... app_N --input_path <input_path> --output_path <output_path> --debug <0_or_1>' % argv[0])
33        raise
34
35    loader = modular_build.DescriptorLoader(input_path)
36    for app in application_names:
37        concatenate_application_code.build_application(app, loader, input_path, output_path, minify)
38
39if __name__ == '__main__':
40    sys.exit(main(sys.argv))
41