Skip to content

Commit

Permalink
src: build: Adding verbose mode.
Browse files Browse the repository at this point in the history
This commit adds support for the verbose parameter within `kw build`.
The verbose parameter gives details of the commands that are executed behind the scenes.

Note: This is part of the issue: kworkflow#179

Signed-off-by: Aquila Macedo <aquilamacedo@riseup.net>
  • Loading branch information
aquilamacedo committed Apr 11, 2023
1 parent cca88c2 commit 902df86
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
5 changes: 5 additions & 0 deletions documentation/man/features/build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ SYNOPSIS
| *kw* (*b* | *build*) [\--llvm] [\--alert=(s | v | (sv | vs) | n)]
| *kw* (*b* | *build*) [(-c | \--clean)] [\--alert=(s | v | (sv | vs) | n)]
| *kw* (*b* | *build*) [(-f | \--full-cleanup)] [\--alert=(s | v | (sv | vs) | n)]
| *kw* (*b* | *build*) [(-v | \--verbose)] [\--alert=(s | v | (sv | vs) | n)]

DESCRIPTION
===========
Expand Down Expand Up @@ -83,6 +85,9 @@ OPTIONS
build process, including configuration files and script output. This option also
considers whether or not the user is using kw env.

-v, \--verbose:
Verbose mode allows the user to see the commands executed under the hood.

\--alert=(s | v | (sv | vs) | n):
Defines the alert behaviour upon the command completion.
| **s** enables sound notification.
Expand Down
1 change: 1 addition & 0 deletions src/_kw
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ _kw_b() { _kw_build }
_kw_build()
{
_arguments : \
'(-v --verbose)'{-v,--verbose}'[enable verbose mode]' \
'(-i --info -c --clean -n --menu -d --doc --ccache -w --warnings -S --cpu-scaling -s --save-log-to --llvm)'{-i,--info}'[display kernel release name, version and number of modules to compile]' \
'(-c --clean -i --info -n --menu -d --doc --ccache -w --warnings -S --cpu-scaling -s --save-log-to --llvm)'{-c,--clean}'[remove files generated by the kernel build system]' \
'(-n --menu -i --info -c --clean -d --doc)'{-n,--menu}'[invoke kernel menuconfig]' \
Expand Down
2 changes: 1 addition & 1 deletion src/bash_autocomplete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function _kw_autocomplete()
kw_options['backup']='--restore --force --help'

kw_options['build']='--menu --info --doc --cpu-scaling --ccache --warnings
--save-log-to --llvm --help --full-cleanup'
--save-log-to --llvm --help --full-cleanup --verbose'
kw_options['b']="${kw_options['build']}"

kw_options['kernel-config-manager']='--fetch --get --list --remove --save --force
Expand Down
23 changes: 21 additions & 2 deletions src/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function build_kernel_main()
local llvm
local env_name
local clean
local flag
local output_kbuild_flag=''

parse_build_options "$@"
Expand Down Expand Up @@ -58,6 +59,8 @@ function build_kernel_main()
clean=${options_values['CLEAN']}
full_cleanup=${options_values['FULL_CLEANUP']}

[[ -n "${options_values['VERBOSE']}" ]] && flag='VERBOSE'

if [[ -n "${options_values['INFO']}" ]]; then
build_info ''
exit
Expand Down Expand Up @@ -119,6 +122,8 @@ function build_kernel_main()
return "$?"
fi

flag=${flag:-'SILENT'}

command="make ${optimizations} ${llvm}ARCH=${platform_ops}${warnings}${output_path}${output_kbuild_flag}"

# Let's avoid menu question by default
Expand Down Expand Up @@ -178,6 +183,8 @@ function build_menu_config()
local llvm="$5"
local cmd

flag=${flag:-'SILENT'}

cmd="make -j ${llvm}ARCH=${platform_ops} ${menu_config}${env_path}"
cmd_manager "$flag" "$cmd"
}
Expand All @@ -192,6 +199,8 @@ function build_doc()
local output_path="$5"
local cmd

flag=${flag:-'SILENT'}

cmd="make ${optimizations} ${doc_type}${output_path}${env_path}"
cmd_manager "$flag" "$cmd"
}
Expand All @@ -212,6 +221,8 @@ function build_clean()
local env_path="$2"
local cmd

flag=${flag:-'SILENT'}

cmd="make clean${env_path}"
cmd_manager "$flag" "$cmd"
}
Expand All @@ -225,6 +236,8 @@ function full_cleanup()
local env_path="$2"
local cmd

flag=${flag:-'SILENT'}

cmd="make distclean${env_path}"
cmd_manager "$flag" "$cmd"
}
Expand Down Expand Up @@ -275,8 +288,8 @@ function load_build_config()

function parse_build_options()
{
local long_options='help,info,menu,doc,ccache,cpu-scaling:,warnings::,save-log-to:,llvm,clean,full-cleanup'
local short_options='h,i,n,d,S:,w::,s:,c,f'
local long_options='help,info,menu,doc,ccache,cpu-scaling:,warnings::,save-log-to:,llvm,clean,full-cleanup,verbose'
local short_options='h,i,n,d,S:,w::,s:,c,f,v'
local doc_type
local file_name_size

Expand All @@ -303,6 +316,7 @@ function parse_build_options()
options_values['USE_LLVM_TOOLCHAIN']="${build_config[use_llvm]:-${configurations[use_llvm]}}"
options_values['CLEAN']=''
options_values['FULL_CLEANUP']=''
options_values['VERBOSE']=''

# Check llvm option
if [[ ${options_values['USE_LLVM_TOOLCHAIN']} =~ 'yes' ]]; then
Expand Down Expand Up @@ -353,6 +367,10 @@ function parse_build_options()
options_values['FULL_CLEANUP']=1
shift
;;
--verbose | -v)
options_values['VERBOSE']=1
shift
;;
--doc | -d)
doc_type_fallback="${configurations[doc_type]:-htmldocs}"
options_values['DOC_TYPE']="${build_config[doc_type]:-$doc_type_fallback}"
Expand Down Expand Up @@ -405,6 +423,7 @@ function build_help()
' build (-S | --cpu-scaling) <percentage> - Scale CPU usage by factor' \
' build (--ccache) - Enable use of ccache' \
' build (-w | --warnings) [warning_levels] - Enable warnings' \
' build (-v | --verbose) - Show a detailed output' \
' build (-s | --save-log-to) <path> - Save compilation log to path' \
' build (--llvm) - Enable use of the LLVM toolchain' \
' build (-c | --clean) - Clean option integrated into env' \
Expand Down

0 comments on commit 902df86

Please sign in to comment.