Compare commits
4 Commits
89784e1dd8
...
dfdaab8f26
| Author | SHA1 | Date |
|---|---|---|
|
|
dfdaab8f26 | |
|
|
4b23ecd62a | |
|
|
349ddcb4c0 | |
|
|
020b714faa |
53
src/_cmake
53
src/_cmake
|
|
@ -144,6 +144,29 @@ _cmake_generator_options() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ----------------------
|
||||||
|
# _cmake_build_presets
|
||||||
|
# ----------------------
|
||||||
|
(( $+functions[_cmake_build_presets] )) ||
|
||||||
|
_cmake_build_presets() {
|
||||||
|
local list_presets=(${(f)"$(cmake --list-presets=build 2>/dev/null |
|
||||||
|
sed -n -e 's,^[[:space:]]*"\([^"]*\)"[[:space:]]*-[[:space:]]*\(.*\),\1:\2,p' \
|
||||||
|
-e 's,^[[:space:]]*"\([^"]*\)"[[:space:]]*$,\1,p')"})
|
||||||
|
|
||||||
|
_describe 'build presets' list_presets
|
||||||
|
}
|
||||||
|
|
||||||
|
# --------------------------
|
||||||
|
# _cmake_preset_build_dir
|
||||||
|
#
|
||||||
|
# Finds the build directory by locating the nearest CMakeCache.txt.
|
||||||
|
# --------------------------
|
||||||
|
(( $+functions[_cmake_preset_build_dir] )) ||
|
||||||
|
_cmake_preset_build_dir() {
|
||||||
|
find . -maxdepth 5 -name CMakeCache.txt -print -quit | xargs -I{} dirname {}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# --------------
|
# --------------
|
||||||
# _cmake_presets
|
# _cmake_presets
|
||||||
# --------------
|
# --------------
|
||||||
|
|
@ -194,6 +217,8 @@ _cmake_on_build() {
|
||||||
'--config[For multi-configuration tools]'
|
'--config[For multi-configuration tools]'
|
||||||
'--parallel[maximum number of build processes]'
|
'--parallel[maximum number of build processes]'
|
||||||
'--use-stderr'
|
'--use-stderr'
|
||||||
|
'--preset[Specify a build preset]:preset:_cmake_build_presets'
|
||||||
|
'--list-presets[List available build presets]'
|
||||||
)
|
)
|
||||||
local -a undescribed_build_extras
|
local -a undescribed_build_extras
|
||||||
local i=1
|
local i=1
|
||||||
|
|
@ -226,23 +251,41 @@ _cmake_on_build() {
|
||||||
if [[ $words[(($i - 1))] == --target ]]; then continue ; fi
|
if [[ $words[(($i - 1))] == --target ]]; then continue ; fi
|
||||||
if [[ $words[(($i - 1))] == --config ]]; then continue ; fi
|
if [[ $words[(($i - 1))] == --config ]]; then continue ; fi
|
||||||
if [[ $words[(($i - 1))] == --parallel ]] ; then continue ; fi
|
if [[ $words[(($i - 1))] == --parallel ]] ; then continue ; fi
|
||||||
|
if [[ $words[(($i - 1))] == --preset ]] ; then continue ; fi
|
||||||
out_of_build=true
|
out_of_build=true
|
||||||
done
|
done
|
||||||
|
|
||||||
if (( $dash_dash_position > 0 )) ; then
|
if (( $dash_dash_position > 0 )) ; then
|
||||||
_cmake_generator_options $words[(($build_at + 1))] $dash_dash_position && return 0
|
local _build_first=$words[(($build_at + 1))]
|
||||||
|
[[ $_build_first != --* ]] && _cmake_generator_options $_build_first $dash_dash_position && return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$in_build" == false || "$difference" -eq 1 ]] ; then
|
if [[ "$in_build" == false ]] ; then
|
||||||
# either there is no --build or completing the directory after --build
|
# no --build seen, complete normally
|
||||||
_arguments -s \
|
_arguments -s \
|
||||||
- build_opts \
|
- build_opts \
|
||||||
"$cmake_build_options[@]" \
|
"$cmake_build_options[@]" \
|
||||||
- build_cmds \
|
- build_cmds \
|
||||||
"$cmake_suggest_build[@]" && return 0
|
"$cmake_suggest_build[@]" && return 0
|
||||||
|
elif [[ "$difference" -eq 1 ]] ; then
|
||||||
|
# completing first arg after --build: dir, --preset, or --list-presets
|
||||||
|
_alternative \
|
||||||
|
':current directory:(.)' \
|
||||||
|
'directory::_directories' \
|
||||||
|
'preset-flags:flag:((--preset\:"Specify a build preset" --list-presets\:"List available build presets"))' && return 0
|
||||||
|
elif [[ $words[(($CURRENT - 1))] == --preset ]] ; then
|
||||||
|
# after --build --preset, complete build presets
|
||||||
|
_cmake_build_presets && return 0
|
||||||
elif [[ $words[(($CURRENT - 1))] == --target ]] ; then
|
elif [[ $words[(($CURRENT - 1))] == --target ]] ; then
|
||||||
# after --build <dir> --target, suggest targets
|
# after --build <dir|--preset name> --target, suggest targets
|
||||||
_cmake_targets $words[(($build_at + 1))] && return 0
|
local _tgt_first=$words[(($build_at + 1))]
|
||||||
|
if [[ $_tgt_first == --preset ]]; then
|
||||||
|
local _tgt_dir=$(_cmake_preset_build_dir "$words[(($build_at + 2))]")
|
||||||
|
[[ -n "$_tgt_dir" ]] && _cmake_targets "$_tgt_dir"
|
||||||
|
elif [[ $_tgt_first != --* ]]; then
|
||||||
|
_cmake_targets "$_tgt_first"
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
elif [[ $words[(($CURRENT - 1))] == --config ]] ; then
|
elif [[ $words[(($CURRENT - 1))] == --config ]] ; then
|
||||||
# after --build <dir> --config, no idea
|
# after --build <dir> --config, no idea
|
||||||
return 0
|
return 0
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#compdef cppcheck
|
#compdef cppcheck cppcheck-htmlreport
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2019 Github zsh-users - https://github.com/zsh-users
|
# Copyright (c) 2019 Github zsh-users - https://github.com/zsh-users
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
|
|
@ -48,7 +48,11 @@ _cppcheck_files() {
|
||||||
_path_files -/ -g "*.(c|cpp|cxx|h|hpp|C)"
|
_path_files -/ -g "*.(c|cpp|cxx|h|hpp|C)"
|
||||||
}
|
}
|
||||||
|
|
||||||
_cppcheck() {
|
_cppcheck_author_information() {
|
||||||
|
local -a info=(name email date)
|
||||||
|
_values -s ',' 'info' $info
|
||||||
|
}
|
||||||
|
|
||||||
local -a check_ids=(
|
local -a check_ids=(
|
||||||
all warning style performance portability information unusedFunction missingInclude
|
all warning style performance portability information unusedFunction missingInclude
|
||||||
)
|
)
|
||||||
|
|
@ -60,6 +64,20 @@ _cppcheck() {
|
||||||
misra-cpp-2008 misra-cpp-2023
|
misra-cpp-2008 misra-cpp-2023
|
||||||
)
|
)
|
||||||
|
|
||||||
|
case $service in
|
||||||
|
(cppcheck-htmlreport)
|
||||||
|
_arguments \
|
||||||
|
'(- *)'{-h,--help}'[show help message and exit]' \
|
||||||
|
'--title[Title of the project]:title' \
|
||||||
|
'*--file[cppcheck xml output file to read defects from(default stdin)]:file:_files' \
|
||||||
|
'--checkers-report-file[cppcheck checkers report file]:file:_files' \
|
||||||
|
'--report-dir[Directory where the HTML report content is written]:dir:_files -/' \
|
||||||
|
'--source-dir[Base directory where source code files can be found or a URL to a remote]:dir:_files -/' \
|
||||||
|
'--add-author-information[Blame information to include(default "name,email,date")]:info:_cppcheck_author_information' \
|
||||||
|
'--source-encoding[Encoding of source code]:encoding' \
|
||||||
|
'--blame-options[Blame options which you can use to get author and author mail]:options'
|
||||||
|
;;
|
||||||
|
(cppcheck)
|
||||||
_arguments \
|
_arguments \
|
||||||
"--addon=[Execute addon]" \
|
"--addon=[Execute addon]" \
|
||||||
"--addon-python=[Specify the python interpreter]: :_files" \
|
"--addon-python=[Specify the python interpreter]: :_files" \
|
||||||
|
|
@ -122,9 +140,8 @@ _cppcheck() {
|
||||||
"--version[Print out version number]" \
|
"--version[Print out version number]" \
|
||||||
"--xml[Write results in xml format to stderr]" \
|
"--xml[Write results in xml format to stderr]" \
|
||||||
"*: :_cppcheck_files"
|
"*: :_cppcheck_files"
|
||||||
}
|
;;
|
||||||
|
esac
|
||||||
_cppcheck "$@"
|
|
||||||
|
|
||||||
# Local Variables:
|
# Local Variables:
|
||||||
# mode: Shell-Script
|
# mode: Shell-Script
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue