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