2006-08-25 15:45:16 +00:00
|
|
|
# Completions for make
|
2019-03-15 18:50:28 +00:00
|
|
|
function __fish_print_make_targets --argument-names directory file
|
|
|
|
# Since we filter based on localized text, we need to ensure the
|
|
|
|
# text will be using the correct locale.
|
|
|
|
set -lx LC_ALL C
|
|
|
|
|
2020-03-28 21:13:09 +00:00
|
|
|
set -l makeflags -C $directory
|
|
|
|
if test -n "$file"
|
|
|
|
set -a makeflags -f $file
|
2019-03-15 18:50:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if make --version 2>/dev/null | string match -q 'GNU*'
|
|
|
|
# https://stackoverflow.com/a/26339924
|
2020-03-28 21:13:09 +00:00
|
|
|
make $makeflags -pRrq : 2>/dev/null |
|
2023-08-23 21:42:54 +00:00
|
|
|
awk -F: -v 'bs_regex=\\\\\\\\' '/^# Files/,/^# Finished Make data base/ {
|
2020-03-28 21:13:09 +00:00
|
|
|
if ($1 == "# Not a target") skip = 1;
|
2023-08-23 21:42:54 +00:00
|
|
|
if ($1 !~ "^[#.\t]" && !is_continuation ) {
|
|
|
|
if (!skip) print $1;
|
|
|
|
skip = 0
|
|
|
|
}
|
|
|
|
is_continuation = $0 ~ "^([^#]*[^#" bs_regex "])?(" bs_regex bs_regex ")*" bs_regex "$";
|
2020-03-28 21:13:09 +00:00
|
|
|
}' 2>/dev/null
|
2019-03-15 18:50:28 +00:00
|
|
|
else
|
2020-03-28 21:13:09 +00:00
|
|
|
# BSD make
|
|
|
|
make $makeflags -d g1 -rn >/dev/null 2>| awk -F, '/^#\*\*\* Input graph:/,/^$/ {if ($1 !~ "^#... ") {gsub(/# /,"",$1); print $1}}' 2>/dev/null
|
2019-03-15 18:50:28 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-12-07 10:05:14 +00:00
|
|
|
function __fish_complete_make_targets
|
2020-03-28 21:13:09 +00:00
|
|
|
set -l directory (string replace -rf '^make .*(-C ?|--directory(=| +))([^ ]*) .*$' '$3' -- $argv)
|
|
|
|
or set directory .
|
|
|
|
set -l file (string replace -rf '^make .*(-f ?|--file(=| +))([^ ]*) .*$' '$3' -- $argv)
|
|
|
|
__fish_print_make_targets $directory $file
|
2016-12-07 10:05:14 +00:00
|
|
|
end
|
2005-10-27 15:23:32 +00:00
|
|
|
|
2015-09-29 19:09:52 +00:00
|
|
|
# This completion reenables file completion on
|
|
|
|
# assignments, so e.g. 'make foo FILES=<tab>' will receive standard
|
|
|
|
# filename completion.
|
2020-03-28 21:13:09 +00:00
|
|
|
complete -c make -n 'commandline -ct | string match -q "*=*"' -a "(__fish_complete_make_targets (commandline -p))" -d Target
|
|
|
|
complete -f -c make -n 'commandline -ct | not string match -q "*=*"' -a "(__fish_complete_make_targets (commandline -p))" -d Target
|
2018-05-12 16:52:04 +00:00
|
|
|
complete -c make -s f -d "Use file as makefile" -r
|
2017-10-11 17:17:35 +00:00
|
|
|
complete -x -c make -s C -l directory -x -a "(__fish_complete_directories (commandline -ct))" -d "Change directory"
|
|
|
|
complete -c make -s d -d "Debug mode"
|
|
|
|
complete -c make -s e -d "Environment before makefile"
|
|
|
|
complete -c make -s i -d "Ignore errors"
|
|
|
|
complete -x -c make -s I -d "Search directory for makefile" -a "(__fish_complete_directories (commandline -ct))"
|
2020-09-16 21:19:19 +00:00
|
|
|
complete -f -c make -s j -d "Number of concurrent jobs (no argument means no limit)"
|
2017-10-11 17:17:35 +00:00
|
|
|
complete -c make -s k -d "Continue after an error"
|
|
|
|
complete -c make -s l -d "Start when load drops"
|
|
|
|
complete -c make -s n -d "Do not execute commands"
|
|
|
|
complete -c make -s o -r -d "Ignore specified file"
|
|
|
|
complete -c make -s p -d "Print database"
|
|
|
|
complete -c make -s q -d "Question mode"
|
|
|
|
complete -c make -s r -d "Eliminate implicit rules"
|
|
|
|
complete -c make -s s -d "Quiet mode"
|
|
|
|
complete -c make -s S -d "Don't continue after an error"
|
|
|
|
complete -c make -s t -d "Touch files, don't run commands"
|
|
|
|
complete -c make -s v -d "Display version and exit"
|
|
|
|
complete -c make -s w -d "Print working directory"
|
|
|
|
complete -c make -s W -r -d "Pretend file is modified"
|