1# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. 2# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without modification, 5# are permitted provided that the following conditions are met: 6# 7# 1. Redistributions of source code must retain the above copyright notice, this list of 8# conditions and the following disclaimer. 9# 10# 2. Redistributions in binary form must reproduce the above copyright notice, this list 11# of conditions and the following disclaimer in the documentation and/or other materials 12# provided with the distribution. 13# 14# 3. Neither the name of the copyright holder nor the names of its contributors may be used 15# to endorse or promote products derived from this software without specific prior written 16# permission. 17# 18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 30import("$root_out_dir/config.gni") 31 32LITEOSTOPDIR = "//kernel/liteos_a" 33LITEOSTHIRDPARTY = "//third_party" 34HDFTOPDIR = "//drivers/adapter/khdf/liteos" 35 36ARCH = "" 37if (defined(LOSCFG_ARCH_ARM_AARCH32)) { 38 ARCH = "arm" 39} else if (defined(LOSCFG_ARCH_ARM_AARCH64)) { 40 ARCH = "aarch64" 41} 42 43template("kernel_module") { 44 current_dir_name = get_path_info(rebase_path("."), "file") 45 if (target_name != current_dir_name) { 46 build_gn = rebase_path("BUILD.gn") 47 cmd = "if grep -q '^\s*group\s*(\s*\"$current_dir_name\"\s*)\s*{\s*\$' $build_gn; then echo true; else echo false; fi" 48 has_current_dir_group = exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value") 49 if (!has_current_dir_group) { 50 module_name = target_name 51 group(current_dir_name) { 52 public_deps = [ ":$module_name" ] 53 } 54 } 55 } 56 if (defined(invoker.module_switch) && !invoker.module_switch) { 57 group(target_name) { 58 not_needed(invoker, "*") 59 } 60 } else { 61 source_set(target_name) { 62 forward_variables_from(invoker, "*") 63 } 64 } 65} 66 67template("config") { 68 config(target_name) { 69 if (defined(invoker.module_switch) && !invoker.module_switch && target_name == "public") { 70 not_needed(invoker, "*") 71 forward_variables_from(invoker, [ "configs" ]) 72 } else { 73 forward_variables_from(invoker, "*") 74 } 75 } 76} 77 78set_defaults("kernel_module") { 79 configs = [ 80 "$LITEOSTOPDIR:public", 81 "$LITEOSTOPDIR:los_config", 82 ] 83} 84