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