• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# Copyright (c) 2021 Huawei Device Co., Ltd.
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16import optparse
17import os
18import sys
19import json
20sys.path.append(
21    os.path.dirname(os.path.dirname(os.path.dirname(
22        os.path.abspath(__file__)))))
23from scripts.util import build_utils  # noqa: E402
24
25
26def _parse_args(args):
27    parser = optparse.OptionParser()
28    build_utils.add_depfile_option(parser)
29    parser.add_option('--output_dir', help='output directory')
30    parser.add_option('--source_dir', help='source directory')
31    parser.add_option('--target', help='name of target')
32    parser.add_option('--target_label')
33    parser.add_option('--test_type')
34    parser.add_option('--module_list_file', help='file name of module list')
35    options, _ = parser.parse_args(args)
36    build_utils.check_options(options,
37                             parser,
38                             required=('output_dir', 'target', 'source_dir',
39                                       'target_label', 'module_list_file'))
40    return options, parser
41
42
43def main(args):
44    options, _ = _parse_args(args)
45    if not os.path.exists(os.path.dirname(options.module_list_file)):
46        os.makedirs(os.path.dirname(options.module_list_file), exist_ok=True)
47    with open(options.module_list_file, 'w') as f:
48        contents = json.dumps([{
49            'target': options.target,
50            'label': options.target_label,
51            'source_directory': options.source_dir,
52            'output_directory': options.output_dir,
53            'test_type': options.test_type
54        }])
55        f.write(contents)
56
57
58if __name__ == '__main__':
59    sys.exit(main(sys.argv[1:]))
60