• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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} else if (target_cpu == "riscv64") {
29  kernel_image = "Image"
30} else if (target_cpu == "x86_64") {
31  kernel_image = "bzImage"
32} else if (target_cpu == "loongarch64") {
33  kernel_image = "vmlinuz.efi"
34}
35
36if (os_level == "mini" || os_level == "small") {
37  build_ext_component("linux_kernel") {
38    no_default_deps = true
39    exec_path = rebase_path(".", root_build_dir)
40    outdir = rebase_path("$root_out_dir")
41    build_type = "small"
42    product_path_rebase = rebase_path(product_path, ohos_root_path)
43    command = "./kernel_module_build.sh ${outdir} ${build_type} ${target_cpu} ${product_path_rebase} ${board_name} ${linux_kernel_version}"
44  }
45} else {
46  kernel_build_script_dir = "//kernel/linux/build"
47  kernel_source_dir = "//kernel/linux/$linux_kernel_version"
48  action("check_build") {
49    script = "check_build.sh"
50    sources = [ kernel_source_dir ]
51    outputs = [ "$root_build_dir/kernel.timestamp" ]
52    args = [
53      rebase_path(kernel_source_dir, root_build_dir),
54      rebase_path("$root_build_dir/packages/phone/images/$kernel_image"),
55      rebase_path("$root_build_dir/kernel.timestamp"),
56    ]
57  }
58
59  action("build_kernel") {
60    script = "build_kernel.sh"
61    sources = [ kernel_source_dir ]
62
63    deps = [ ":check_build" ]
64    product_path = "vendor/$product_company/$product_name"
65    build_type = "standard"
66    outputs = [ "$root_build_dir/packages/phone/images/$kernel_image" ]
67    args = [
68      rebase_path(kernel_build_script_dir, root_build_dir),
69      rebase_path("$root_out_dir/../KERNEL_OBJ"),
70      rebase_path("$root_build_dir/packages/phone/images"),
71      build_type,
72      target_cpu,
73      product_path,
74      device_name,
75      linux_kernel_version,
76    ]
77  }
78
79  group("linux_kernel") {
80    deps = [ ":build_kernel" ]
81  }
82}
83