15f9996aaSopenharmony_ci#!/usr/bin/env python 25f9996aaSopenharmony_ci# -*- coding: utf-8 -*- 35f9996aaSopenharmony_ci# Copyright (c) 2024 Huawei Device Co., Ltd. 45f9996aaSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 55f9996aaSopenharmony_ci# you may not use this file except in compliance with the License. 65f9996aaSopenharmony_ci# You may obtain a copy of the License at 75f9996aaSopenharmony_ci# 85f9996aaSopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 95f9996aaSopenharmony_ci# 105f9996aaSopenharmony_ci# Unless required by applicable law or agreed to in writing, software 115f9996aaSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 125f9996aaSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135f9996aaSopenharmony_ci# See the License for the specific language governing permissions and 145f9996aaSopenharmony_ci# limitations under the License. 155f9996aaSopenharmony_ci 165f9996aaSopenharmony_ciimport argparse 175f9996aaSopenharmony_ciimport json 185f9996aaSopenharmony_ciimport os 195f9996aaSopenharmony_ciimport shutil 205f9996aaSopenharmony_ciimport stat 215f9996aaSopenharmony_ciimport time 225f9996aaSopenharmony_ciimport utils 235f9996aaSopenharmony_ci 245f9996aaSopenharmony_ci 255f9996aaSopenharmony_cidef _get_args(): 265f9996aaSopenharmony_ci parser = argparse.ArgumentParser(add_help=True) 275f9996aaSopenharmony_ci parser.add_argument( 285f9996aaSopenharmony_ci "-rp", 295f9996aaSopenharmony_ci "--root_path", 305f9996aaSopenharmony_ci default=r".", 315f9996aaSopenharmony_ci type=str, 325f9996aaSopenharmony_ci help="Path of root", 335f9996aaSopenharmony_ci ) 345f9996aaSopenharmony_ci parser.add_argument( 355f9996aaSopenharmony_ci "-v", 365f9996aaSopenharmony_ci "--variants", 375f9996aaSopenharmony_ci default=r".", 385f9996aaSopenharmony_ci type=str, 395f9996aaSopenharmony_ci help="variants of build target", 405f9996aaSopenharmony_ci ) 415f9996aaSopenharmony_ci args = parser.parse_args() 425f9996aaSopenharmony_ci return args 435f9996aaSopenharmony_ci 445f9996aaSopenharmony_ci 455f9996aaSopenharmony_cidef main(): 465f9996aaSopenharmony_ci args = _get_args() 475f9996aaSopenharmony_ci root_path = args.root_path 485f9996aaSopenharmony_ci variants = args.variants 495f9996aaSopenharmony_ci variants_path = os.path.join(root_path, 'binarys', "variants", "variants_" + variants, "config") 505f9996aaSopenharmony_ci variants_out_path = os.path.join(root_path, 'out', "preloader", variants) 515f9996aaSopenharmony_ci etc_out_path = os.path.join(variants_out_path, "system", "etc") 525f9996aaSopenharmony_ci syscap_para_out_path = os.path.join(etc_out_path, "param") 535f9996aaSopenharmony_ci 545f9996aaSopenharmony_ci os.makedirs(syscap_para_out_path, exist_ok=True) 555f9996aaSopenharmony_ci 565f9996aaSopenharmony_ci system_capability_file = os.path.join(variants_path, "SystemCapability.json") 575f9996aaSopenharmony_ci features_file = os.path.join(variants_path, "features.json") 585f9996aaSopenharmony_ci build_file = os.path.join(variants_path, "build_config.json") 595f9996aaSopenharmony_ci paths_config_file = os.path.join(variants_path, "parts_config.json") 605f9996aaSopenharmony_ci syscap_json_file = os.path.join(variants_path, "syscap.json") 615f9996aaSopenharmony_ci syscap_para_file = os.path.join(variants_path, "syscap.para") 625f9996aaSopenharmony_ci 635f9996aaSopenharmony_ci shutil.copy(system_capability_file, etc_out_path) 645f9996aaSopenharmony_ci shutil.copy(syscap_json_file, etc_out_path) 655f9996aaSopenharmony_ci shutil.copy(syscap_para_file, syscap_para_out_path) 665f9996aaSopenharmony_ci shutil.copy(features_file, variants_out_path) 675f9996aaSopenharmony_ci shutil.copy(build_file, variants_out_path) 685f9996aaSopenharmony_ci shutil.copy(paths_config_file, variants_out_path) 695f9996aaSopenharmony_ci 705f9996aaSopenharmony_ci 715f9996aaSopenharmony_ciif __name__ == '__main__': 725f9996aaSopenharmony_ci main() 73