1# Copyright (c) 2021 Huawei Device Co., Ltd. 2# This program is free software; you can redistribute it and/or modify 3# it under the terms of the GNU General Public License as published by 4# the Free Software Foundation; either version 2 of the License, or 5# (at your option) any later version. 6# 7# This program is distributed in the hope that it will be useful, 8# but WITHOUT ANY WARRANTY; without even the implied warranty of 9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10# GNU General Public License for more details. 11# 12# You should have received a copy of the GNU General Public License 13# along with this program. If not, see <http://www.gnu.org/licenses/>. 14if (os_level == "mini" || os_level == "small") { 15 import("//build/lite/config/component/lite_component.gni") 16} else { 17 import("//build/config/clang/clang.gni") 18 import("//build/ohos.gni") 19} 20import("//build/ohos/kernel/kernel.gni") 21 22# it needs adaptation for more device target 23kernel_image = "" 24if (target_cpu == "arm") { 25 kernel_image = "uImage" 26} else if (target_cpu == "arm64") { 27 kernel_image = "Image" 28} 29 30if (os_level == "mini" || os_level == "small") { 31 build_ext_component("linux_kernel") { 32 no_default_deps = true 33 exec_path = rebase_path(".", root_build_dir) 34 outdir = rebase_path("$root_out_dir") 35 build_type = "small" 36 product_path_rebase = rebase_path(product_path, ohos_root_path) 37 command = "./kernel_module_build.sh ${outdir} ${build_type} ${target_cpu} ${product_path_rebase} ${board_name} ${linux_kernel_version}" 38 } 39} else { 40 kernel_build_script_dir = "//kernel/linux/build" 41 kernel_source_dir = "//kernel/linux/$linux_kernel_version" 42 action("check_build") { 43 script = "check_build.sh" 44 sources = [ kernel_source_dir ] 45 outputs = [ "$root_build_dir/kernel.timestamp" ] 46 args = [ 47 rebase_path(kernel_source_dir, root_build_dir), 48 rebase_path("$root_build_dir/packages/phone/images/$kernel_image"), 49 rebase_path("$root_build_dir/kernel.timestamp"), 50 ] 51 } 52 53 action("build_kernel") { 54 script = "build_kernel.sh" 55 sources = [ kernel_source_dir ] 56 57 deps = [ ":check_build" ] 58 product_path = "vendor/$product_company/$product_name" 59 build_type = "standard" 60 outputs = [ "$root_build_dir/packages/phone/images/$kernel_image" ] 61 args = [ 62 rebase_path(kernel_build_script_dir, root_build_dir), 63 rebase_path("$root_out_dir/../KERNEL_OBJ"), 64 rebase_path("$root_build_dir/packages/phone/images"), 65 build_type, 66 target_cpu, 67 product_path, 68 device_name, 69 linux_kernel_version, 70 ] 71 } 72 73 group("linux_kernel") { 74 deps = [ ":build_kernel" ] 75 } 76} 77