1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# Copyright (c) 2024 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 argparse
17import json
18import os
19import shutil
20import stat
21import time
22import utils
23
24
25def _get_args():
26    parser = argparse.ArgumentParser(add_help=True)
27    parser.add_argument(
28        "-rp",
29        "--root_path",
30        default=r".",
31        type=str,
32        help="Path of root",
33    )
34    parser.add_argument(
35        "-v",
36        "--variants",
37        default=r".",
38        type=str,
39        help="variants of build target",
40    )
41    args = parser.parse_args()
42    return args
43
44
45def main():
46    args = _get_args()
47    root_path = args.root_path
48    variants = args.variants
49    variants_path = os.path.join(root_path, 'binarys', "variants", "variants_" + variants, "config")
50    variants_out_path = os.path.join(root_path, 'out', "preloader", variants)
51    etc_out_path = os.path.join(variants_out_path, "system", "etc")
52    syscap_para_out_path = os.path.join(etc_out_path, "param")
53
54    os.makedirs(syscap_para_out_path, exist_ok=True)
55
56    system_capability_file = os.path.join(variants_path, "SystemCapability.json")
57    features_file = os.path.join(variants_path, "features.json")
58    build_file = os.path.join(variants_path, "build_config.json")
59    paths_config_file = os.path.join(variants_path, "parts_config.json")
60    syscap_json_file = os.path.join(variants_path, "syscap.json")
61    syscap_para_file = os.path.join(variants_path, "syscap.para")
62
63    shutil.copy(system_capability_file, etc_out_path)
64    shutil.copy(syscap_json_file, etc_out_path)
65    shutil.copy(syscap_para_file, syscap_para_out_path)
66    shutil.copy(features_file, variants_out_path)
67    shutil.copy(build_file, variants_out_path)
68    shutil.copy(paths_config_file, variants_out_path)
69
70
71if __name__ == '__main__':
72    main()
73