13f085823Sopenharmony_ci#!/usr/bin/env python3 23f085823Sopenharmony_ci# coding=utf-8 33f085823Sopenharmony_ci 43f085823Sopenharmony_ci# 53f085823Sopenharmony_ci# Copyright (c) 2022 Huawei Device Co., Ltd. 63f085823Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 73f085823Sopenharmony_ci# you may not use this file except in compliance with the License. 83f085823Sopenharmony_ci# You may obtain a copy of the License at 93f085823Sopenharmony_ci# 103f085823Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 113f085823Sopenharmony_ci# 123f085823Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 133f085823Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 143f085823Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 153f085823Sopenharmony_ci# See the License for the specific language governing permissions and 163f085823Sopenharmony_ci# limitations under the License. 173f085823Sopenharmony_ci# 183f085823Sopenharmony_ci 193f085823Sopenharmony_ciimport os 203f085823Sopenharmony_ci 213f085823Sopenharmony_ci__all__ = ["get_source_code_root_path"] 223f085823Sopenharmony_ci 233f085823Sopenharmony_ci 243f085823Sopenharmony_cidef is_source_code_root_path(path): 253f085823Sopenharmony_ci check_name_list = ["./build.sh", 263f085823Sopenharmony_ci "build", 273f085823Sopenharmony_ci "prebuilts"] 283f085823Sopenharmony_ci for item in check_name_list: 293f085823Sopenharmony_ci check_path = os.path.join(path, item) 303f085823Sopenharmony_ci if os.path.exists(check_path): 313f085823Sopenharmony_ci return True 323f085823Sopenharmony_ci return False 333f085823Sopenharmony_ci 343f085823Sopenharmony_ci 353f085823Sopenharmony_cidef get_source_code_root_path(path): 363f085823Sopenharmony_ci code_root_path = path 373f085823Sopenharmony_ci while True: 383f085823Sopenharmony_ci if code_root_path == "": 393f085823Sopenharmony_ci break 403f085823Sopenharmony_ci if code_root_path == "/" or code_root_path.endswith(":\\"): 413f085823Sopenharmony_ci code_root_path = "" 423f085823Sopenharmony_ci break 433f085823Sopenharmony_ci if is_source_code_root_path(code_root_path): 443f085823Sopenharmony_ci break 453f085823Sopenharmony_ci code_root_path = os.path.dirname(code_root_path) 463f085823Sopenharmony_ci return code_root_path 473f085823Sopenharmony_ci 483f085823Sopenharmony_ci 493f085823Sopenharmony_cidef is_open_source_product(product_name): 503f085823Sopenharmony_ci open_source_products = ["Hi3516DV300"] 513f085823Sopenharmony_ci return True 52