summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-12-14 14:45:36 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-04-24 02:32:13 +0300
commite7385853e45b8352a073de40252df21e43d2aec3 (patch)
tree666aac811cca6bd1eea42610dd75ccd7b129c5d3
parente4645c618591e1039fb07fc701075d2c801f2ea2 (diff)
kbuild: Add options to selectively compile kernel components
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rwxr-xr-xkbuild.sh54
1 files changed, 42 insertions, 12 deletions
diff --git a/kbuild.sh b/kbuild.sh
index 3776e72..7d857df 100755
--- a/kbuild.sh
+++ b/kbuild.sh
@@ -35,12 +35,16 @@ usage() {
echo ""
echo "Supported options:"
echo "--bootloader file Boot loader file (CrOS images only)"
+ echo "--build components List of components to build: image, modules, dt (default: all)"
echo "--cmdline Command line arguments file (CrOS images only)"
echo "--config Run menuconfig"
echo "--deb Create Debian packages"
echo "--defconfig file Generate a new .config with defaults from file"
echo "--doc[=dir] Compile the documentation (for the specified dir only)"
echo "-h, --help Print this help text"
+ echo "--no-dt Don't compile the device trees"
+ echo "--no-image Don't compile the kernel image"
+ echo "--no-modules Don't compile the kernel modules"
echo "-- End options parsing, next argument is the platform"
echo ""
echo "Supported platforms:"
@@ -49,10 +53,11 @@ usage() {
done
}
-do_compile_doc=0
+declare -A do_build
do_menu_config=0
do_package_deb=0
opt_bootloader=
+opt_build="image,modules,dt"
opt_cmdline_file=
opt_defconfig=
opt_doc_dirs='.'
@@ -71,6 +76,10 @@ while [[ $# != 0 ]] ; do
fi
shift
;;
+ --build)
+ opt_build="$1"
+ shift
+ ;;
--cmdline)
opt_cmdline_file=$1
if [[ ! -r $opt_cmdline_file ]] ; then
@@ -94,10 +103,10 @@ while [[ $# != 0 ]] ; do
shift
;;
--doc)
- do_compile_doc=1
+ do_build[doc]=1
;;
--doc=*)
- do_compile_doc=1
+ do_build[doc]=1
opt_doc_dirs="${option/--doc=/}"
;;
-h|--help)
@@ -121,6 +130,19 @@ while [[ $# != 0 ]] ; do
esac
done
+IFS=',' read -r -a opt_build <<< "$opt_build"
+for component in ${opt_build[@]} ; do
+ case $component in
+ dt|image|modules)
+ do_build[$component]=1
+ ;;
+ *)
+ echo "Invalid build component ${component}"
+ exit 1
+ ;;
+ esac
+done
+
#
# Platform
#
@@ -205,7 +227,7 @@ fi
# Compile documentation if requested
#
-if [[ $do_compile_doc == 1 ]] ; then
+if [[ ${do_build[doc]} == 1 ]] ; then
(
if [[ ! -f $PWD/output/doc/bin/activate ]] ; then
virtualenv $PWD/output/doc
@@ -224,15 +246,19 @@ fi
#
kernel_dtbs=
-for dtb in $dtbs ; do
- dtb=${dtb/:*/}
- kernel_dtbs="$kernel_dtbs $dtb"
-done
+if [[ ${do_build[dtbs]} == 1 ]] ; then
+ for dtb in $dtbs ; do
+ dtb=${dtb/:*/}
+ kernel_dtbs="$kernel_dtbs $dtb"
+ done
+fi
-$pmake $kbuild_options KCFLAGS="$kcflags" $image_kernel $kernel_dtbs
+if [[ ${do_build[image]} == 1 ]] ; then
+ $pmake $kbuild_options KCFLAGS="$kcflags" $image_kernel $kernel_dtbs
+fi
grep 'CONFIG_MODULES=y' $output_dir/.config > /dev/null && modules=modules
-if [[ x$modules == xmodules ]] ; then
+if [[ x$modules == xmodules ]] && [[ ${do_build[modules]} == 1 ]]; then
$pmake $kbuild_options KCFLAGS="$kcflags" $modules
fi
@@ -277,6 +303,10 @@ copy_dtbs() {
local dest_dir=$1
local dtb
+ if [[ ${do_build[dtbs]} != 1 ]] ; then
+ return
+ fi
+
if [[ $_image_type == FIT || $_image_type == CrOS ]] ; then
return
fi
@@ -301,7 +331,7 @@ if [[ $_image_type != CrOS && -d "$tftp_dir" ]] ; then
copy_dtbs $tftp_dir/
fi
-if [[ x$modules == xmodules ]] ; then
+if [[ x$modules == xmodules ]] && [[ ${do_build[modules]} == 1 ]]; then
mod_path=${target_dir:-$output_dir/modules}
mkdir -p $mod_path
$pmake INSTALL_MOD_PATH=$mod_path modules_install
@@ -320,7 +350,7 @@ fi
#
echo "Kernel image available in ${_image_file}"
-if [[ x$modules == xmodules ]] ; then
+if [[ x$modules == xmodules ]] && [[ ${do_build[modules]} == 1 ]]; then
echo "Kernel modules installed to $mod_path/lib/modules/$version"
fi
echo "Build $version completed at $(date)"