diff --git a/BUILD.gn b/BUILD.gn index 01b94a4928f1837e0de229518782628b372fe92e..804193b3f2f0d57b97ae7e2fa5ade2a0ea925076 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -36,10 +36,22 @@ if (defined(ohos_lite)) { kernel_build_script_dir = "//kernel/linux/build" kernel_source_dir = "//kernel/linux/$linux_kernel_version" + 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), + rebase_path("$root_build_dir/packages/phone/images/uImage"), + rebase_path("$root_build_dir/kernel.timestamp"), + ] + } + action("build_kernel") { script = "build_kernel.sh" sources = [ kernel_source_dir ] + deps = [ ":check_build" ] product_path = "vendor/$product_company/$product_name" build_type = "standard" outputs = [ "$root_build_dir/packages/phone/images/uImage" ] diff --git a/build_kernel.sh b/build_kernel.sh index 8c146fdf51d4cfe184ed47ac9a4b743120b41288..0ea4802e031a7dc7db9af76c594d4ca534f79ccc 100755 --- a/build_kernel.sh +++ b/build_kernel.sh @@ -19,10 +19,11 @@ set -e #$2 - kernel build script stage dir #$3 - GN target output dir - +echo build_kernel pushd ${1} ./kernel_module_build.sh ${2} ${4} ${5} ${6} ${7} ${8} mkdir -p ${3} +rm -rf ${3}/../../../kernel.timestamp cp ${2}/kernel/OBJ/${8}/arch/arm/boot/uImage ${3}/uImage cp ${2}/kernel/OBJ/${8}/arch/arm/boot/zImage-dtb ${3}/zImage-dtb popd diff --git a/check_build.sh b/check_build.sh new file mode 100755 index 0000000000000000000000000000000000000000..55a55b98003b0842849fc164b592aa6124dbf8b7 --- /dev/null +++ b/check_build.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# 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 . + +set -e + +function readfile () +{ + for file in $1/* + do + if [ -d $file ];then + readfile $file $2 $3 + elif [ $file -nt $2 ]; then + echo $file is update + touch $3; + return + fi + done +} + +echo $1 for check kernel dir +echo $2 for output image +echo $3 for timestamp +if [ -e $2 ]; then + readfile $1 $2 $3 + if [ $3 -nt $2 ]; then + echo "need update $2" + rm -rf $2; + fi +fi +