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 Mar 20, 2023
1 parent 0bcef9f commit 499a491
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 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
23 changes: 21 additions & 2 deletions src/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function kernel_build()
local llvm
local env_name
local clean
local flag
local output_kbuild_flag=''

parse_build_options "$@"
Expand Down Expand Up @@ -84,6 +85,8 @@ function kernel_build()
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 @@ -145,6 +148,8 @@ function kernel_build()
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 499a491

Please sign in to comment.