2021-08-26 06:50:46 +00:00
|
|
|
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2022-01-16 05:38:27 +00:00
|
|
|
if (os_level == "mini" || os_level == "small") {
|
2021-10-27 03:43:03 +00:00
|
|
|
import("//build/lite/config/component/lite_component.gni")
|
2021-08-26 06:50:46 +00:00
|
|
|
} else {
|
2021-10-27 03:43:03 +00:00
|
|
|
import("//build/config/clang/clang.gni")
|
|
|
|
import("//build/ohos.gni")
|
2021-08-26 06:50:46 +00:00
|
|
|
}
|
2021-09-07 03:22:07 +00:00
|
|
|
import("//build/ohos/kernel/kernel.gni")
|
2021-08-26 08:37:26 +00:00
|
|
|
|
2022-01-16 05:38:27 +00:00
|
|
|
# it needs adaptation for more device target
|
|
|
|
kernel_image = ""
|
|
|
|
if (target_cpu == "arm") {
|
|
|
|
kernel_image = "uImage"
|
|
|
|
} else if (target_cpu == "arm64") {
|
|
|
|
kernel_image = "Image"
|
2023-12-21 05:28:16 +00:00
|
|
|
} else if (target_cpu == "riscv64") {
|
|
|
|
kernel_image = "Image"
|
2022-10-06 09:15:43 +00:00
|
|
|
} else if (target_cpu == "x86_64") {
|
|
|
|
kernel_image = "bzImage"
|
2024-06-29 05:58:55 +00:00
|
|
|
} else if (target_cpu == "loongarch64") {
|
|
|
|
kernel_image = "vmlinuz.efi"
|
2022-01-16 05:38:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (os_level == "mini" || os_level == "small") {
|
2021-10-27 03:43:03 +00:00
|
|
|
build_ext_component("linux_kernel") {
|
|
|
|
no_default_deps = true
|
2021-08-26 06:50:46 +00:00
|
|
|
exec_path = rebase_path(".", root_build_dir)
|
|
|
|
outdir = rebase_path("$root_out_dir")
|
|
|
|
build_type = "small"
|
|
|
|
product_path_rebase = rebase_path(product_path, ohos_root_path)
|
2022-01-16 05:38:27 +00:00
|
|
|
command = "./kernel_module_build.sh ${outdir} ${build_type} ${target_cpu} ${product_path_rebase} ${board_name} ${linux_kernel_version}"
|
2021-08-26 06:50:46 +00:00
|
|
|
}
|
|
|
|
} else {
|
2021-10-27 03:43:03 +00:00
|
|
|
kernel_build_script_dir = "//kernel/linux/build"
|
|
|
|
kernel_source_dir = "//kernel/linux/$linux_kernel_version"
|
2021-11-01 11:57:55 +00:00
|
|
|
action("check_build") {
|
|
|
|
script = "check_build.sh"
|
|
|
|
sources = [ kernel_source_dir ]
|
|
|
|
outputs = [ "$root_build_dir/kernel.timestamp" ]
|
|
|
|
args = [
|
|
|
|
rebase_path(kernel_source_dir, root_build_dir),
|
2022-01-16 05:38:27 +00:00
|
|
|
rebase_path("$root_build_dir/packages/phone/images/$kernel_image"),
|
2021-11-01 11:57:55 +00:00
|
|
|
rebase_path("$root_build_dir/kernel.timestamp"),
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2021-10-27 03:43:03 +00:00
|
|
|
action("build_kernel") {
|
|
|
|
script = "build_kernel.sh"
|
|
|
|
sources = [ kernel_source_dir ]
|
2021-08-26 06:50:46 +00:00
|
|
|
|
2021-11-01 11:57:55 +00:00
|
|
|
deps = [ ":check_build" ]
|
2021-10-27 03:43:03 +00:00
|
|
|
product_path = "vendor/$product_company/$product_name"
|
|
|
|
build_type = "standard"
|
2022-01-16 05:38:27 +00:00
|
|
|
outputs = [ "$root_build_dir/packages/phone/images/$kernel_image" ]
|
2021-10-27 03:43:03 +00:00
|
|
|
args = [
|
|
|
|
rebase_path(kernel_build_script_dir, root_build_dir),
|
|
|
|
rebase_path("$root_out_dir/../KERNEL_OBJ"),
|
|
|
|
rebase_path("$root_build_dir/packages/phone/images"),
|
|
|
|
build_type,
|
2022-01-16 05:38:27 +00:00
|
|
|
target_cpu,
|
2021-10-27 03:43:03 +00:00
|
|
|
product_path,
|
|
|
|
device_name,
|
|
|
|
linux_kernel_version,
|
|
|
|
]
|
|
|
|
}
|
2021-08-26 06:50:46 +00:00
|
|
|
|
2021-10-27 03:43:03 +00:00
|
|
|
group("linux_kernel") {
|
|
|
|
deps = [ ":build_kernel" ]
|
|
|
|
}
|
2021-08-26 06:50:46 +00:00
|
|
|
}
|