diff --git a/CHANGES b/CHANGES index 8c9ca644c266e990e5ec13529ca003ee40efddbe..5ad0b44191b4e201ae10ad0e471033d2597ec6c5 100644 --- a/CHANGES +++ b/CHANGES @@ -1,12 +1,12 @@ V2.1.6 -Add binary_c_help API function (for David). +Add binary_c_help and binary_c_help_all API functions (for David's python updates). Updates to meson build to fix dependency issues (e.g. for docker and Fedora) and add some documentation. Please keep reporting problems on different platforms. Updates to Docker build for meson compatibility. -Documentation updates (thanks to all, especially Nina and David). +Documentation updates (thanks to all, especially Nina and David), also added a section about meson autocompletion in bash. The binary_grid Perl module has been marked as deprecated. diff --git a/doc/binary_c2.lyx b/doc/binary_c2.lyx index 69cbd1d4a8a6039db8d27fbfdf5092966976421f..8a5e35d3c9561e0b8029a93adaa340b1086ea573 100644 --- a/doc/binary_c2.lyx +++ b/doc/binary_c2.lyx @@ -4778,7 +4778,7 @@ ninja \end_inset - (see section + (see sections \begin_inset space ~ \end_inset @@ -4790,12 +4790,32 @@ plural "false" caps "false" noprefix "false" +\end_inset + + and +\begin_inset CommandInset ref +LatexCommand ref +reference "subsec:Meson-autocompletion" +plural "false" +caps "false" +noprefix "false" + \end_inset for \begin_inset Flex Software status open +\begin_layout Plain Layout +meson +\end_layout + +\end_inset + +- and +\begin_inset Flex Software +status open + \begin_layout Plain Layout ninja \end_layout @@ -20453,6 +20473,160 @@ https://github.com/ninja-build/ninja/blob/master/misc/bash-completion , distributed under an Apache 2.0 licence. \end_layout +\begin_layout Subsection +Meson autocompletion +\end_layout + +\begin_layout Standard +\begin_inset CommandInset label +LatexCommand label +name "subsec:Meson-autocompletion" + +\end_inset + +You can find a script for +\begin_inset Flex Software +status open + +\begin_layout Plain Layout +meson +\end_layout + +\end_inset + + autocompletion at +\begin_inset Flex File +status open + +\begin_layout Plain Layout +meson/bash_meson_autocomplete.sh +\end_layout + +\end_inset + + (which was downloaded from +\begin_inset Flex URL +status collapsed + +\begin_layout Plain Layout + +https://raw.githubusercontent.com/mesonbuild/meson/master/data/shell-completions/b +ash/meson +\end_layout + +\end_inset + +). + Do similarly to the +\begin_inset Flex Software +status open + +\begin_layout Plain Layout +ninja +\end_layout + +\end_inset + + autocompletion script describe in section +\begin_inset space ~ +\end_inset + + +\begin_inset CommandInset ref +LatexCommand ref +reference "subsec:Ninja-autocompletion" +plural "false" +caps "false" +noprefix "false" + +\end_inset + +. +\end_layout + +\begin_layout Standard +If you get errors like +\begin_inset listings +inline true +status open + +\begin_layout Plain Layout + +_filedir: command not found +\end_layout + +\end_inset + + put the following into your +\begin_inset Flex File +status open + +\begin_layout Plain Layout +.bashrc +\end_layout + +\end_inset + + before sourcing the above file, +\end_layout + +\begin_layout Standard +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +if [ -n "$BASH_VERSION" ]; then +\end_layout + +\begin_layout Plain Layout + + [ -f /etc/bash_completion ] && . + /etc/bash_completion +\end_layout + +\begin_layout Plain Layout + +fi +\end_layout + +\end_inset + +which assumes your +\begin_inset Flex Software +status open + +\begin_layout Plain Layout +bash_completion +\end_layout + +\end_inset + + directory is +\begin_inset Flex File +status open + +\begin_layout Plain Layout +/etc/bash_completion +\end_layout + +\end_inset + + (this is where it is on Ubuntu 18.04) and that you have installed the relevant + +\begin_inset Flex Software +status open + +\begin_layout Plain Layout +bash_completion +\end_layout + +\end_inset + + package. +\end_layout + \begin_layout Section Changelog \end_layout diff --git a/doc/binary_c2.pdf b/doc/binary_c2.pdf index 9837e3feaea0a8ec2d7c9652af9354535417c7e9..d5079d05de4b8a63999c83e4f8fe2c03207d0190 100644 Binary files a/doc/binary_c2.pdf and b/doc/binary_c2.pdf differ diff --git a/meson/bash_meson_autocomplete.sh b/meson/bash_meson_autocomplete.sh new file mode 100755 index 0000000000000000000000000000000000000000..729c75352873441f8b3d27bd71d5afbfccdaf6a6 --- /dev/null +++ b/meson/bash_meson_autocomplete.sh @@ -0,0 +1,422 @@ +# autocomplete script for meson +# +# downloaded from +# https://raw.githubusercontent.com/mesonbuild/meson/master/data/shell-completions/bash/meson +# on 22/12/2019 + +_meson() { + command="${COMP_WORDS[1]}" + case "$command" in + setup |\ + configure |\ + install |\ + introspect |\ + init |\ + test |\ + wrap |\ + subprojects |\ + help) + _meson-$command "${COMP_WORDS[@]:1}" + ;; + *) + _meson-setup "${COMP_WORDS[@]}" + ;; + esac +} && +complete -F _meson meson + +_meson_complete_option() { + option_string=$1 + + if [[ $# -eq 2 ]] && ! [[ "$option_string" == *=* ]]; then + option_string="$option_string=$2" + fi + + if [[ "$option_string" == *=* ]]; then + _meson_complete_option_value "$option_string" + else + _meson_complete_option_name "$option_string" + fi +} + +_meson_complete_option_name() { + option=$1 + options=($(python3 -c 'import sys, json +for option in json.load(sys.stdin): + print(option["name"]) +' <<< "$(_meson_get_options)")) + compopt -o nospace + COMPREPLY=($(compgen -W '${options[@]}' -S= -- "$option")) +} + +_meson_complete_option_value() { + cur=$1 + option_name=${cur%%=*} + option_value=${cur#*=} + + if _meson_complete_filedir "$option_name" "$option_value"; then + return + fi + +# TODO: support all the option types + options=($(python3 -c 'import sys, json +for option in json.load(sys.stdin): + if option["name"] != "'$option_name'": + continue + choices = [] + if option["type"] == "boolean": + choices.append("true") + choices.append("false") + elif option["type"] == "combo": + for choice in option["choices"]: + choices.append(choice) + for choice in choices: + if choice.startswith("'$cur'"): + print(choice) +' <<< "$(_meson_get_options)")) + COMPREPLY=("${options[@]}") +} + +_meson_get_options() { + local options + for builddir in "${COMP_WORDS[@]}"; do + if [ -d "$builddir" ]; then + break + fi + builddir=. + done + options=$(meson introspect "$builddir" --buildoptions 2>/dev/null) && + echo "$options" || + echo '[]' +} + +_meson_complete_filedir() { + _filedir_in() { + pushd "$1" &>/dev/null + local COMPREPLY=() + _filedir + echo "${COMPREPLY[@]}" + popd &>/dev/null + } + + option=$1 + cur=$2 + case $option in + prefix |\ + libdir |\ + libexecdir |\ + bindir |\ + sbindir |\ + includedir |\ + datadir |\ + mandir |\ + infodir |\ + localedir |\ + sysconfdir |\ + localstatedir |\ + sharedstatedir) + _filedir -d + ;; + cross-file) + _filedir + COMPREPLY+=($(_filedir_in "$XDG_DATA_DIRS"/meson/cross)) + COMPREPLY+=($(_filedir_in /usr/local/share/meson/cross)) + COMPREPLY+=($(_filedir_in /usr/share/meson/cross)) + COMPREPLY+=($(_filedir_in "$XDG_DATA_HOME"/meson/cross)) + COMPREPLY+=($(_filedir_in ~/.local/share/meson/cross)) + ;; + *) + return 1;; + esac + return 0 +} + +_meson-setup() { + + shortopts=( + h + D + v + ) + + longopts=( + help + prefix + libdir + libexecdir + bindir + sbindir + includedir + datadir + mandir + infodir + localedir + sysconfdir + localstatedir + sharedstatedir + backend + buildtype + strip + unity + werror + layout + default-library + warnlevel + stdsplit + errorlogs + cross-file + version + wrap-mode + ) + + local cur prev + if _get_comp_words_by_ref cur prev &>/dev/null && + [ "${prev:0:2}" = '--' ] && _meson_complete_option "${prev:2}" "$cur"; then + return + elif _get_comp_words_by_ref cur prev &>/dev/null && + [ "${prev:0:1}" = '-' ] && [ "${prev:1:2}" != '-' ] && _meson_complete_option "${prev:1}"; then + return + elif _get_comp_words_by_ref -n '=' cur prev &>/dev/null; then + if [ $prev == -D ]; then + _meson_complete_option "$cur" + return + fi + else + cur="${COMP_WORDS[COMP_CWORD]}" + fi + + if [[ "$cur" == "--"* ]]; then + COMPREPLY+=($(compgen -P '--' -W '${longopts[*]}' -- "${cur:2}")) + elif [[ "$cur" == "-"* ]]; then + COMPREPLY+=($(compgen -P '--' -W '${longopts[*]}' -- "${cur:2}")) + COMPREPLY+=($(compgen -P '-' -W '${shortopts[*]}' -- "${cur:1}")) + else + _filedir -d + if [ -z "$cur" ]; then + COMPREPLY+=($(compgen -P '--' -W '${longopts[*]}')) + COMPREPLY+=($(compgen -P '-' -W '${shortopts[*]}')) + fi + + if [ $COMP_CWORD -eq 1 ]; then + COMPREPLY+=($(compgen -W 'setup configure test introspect' -- "$cur")) + fi + fi +} + +_meson-configure() { + + shortopts=( + h + D + ) + + longopts=( + help + clearcache + ) + + local cur prev + if _get_comp_words_by_ref -n '=' cur prev &>/dev/null; then + if [ $prev == -D ]; then + _meson_complete_option "$cur" + return + fi + else + cur="${COMP_WORDS[COMP_CWORD]}" + fi + + if [[ "$cur" == "--"* ]]; then + COMPREPLY+=($(compgen -P '--' -W '${longopts[*]}' -- "${cur:2}")) + elif [[ "$cur" == "-"* ]]; then + COMPREPLY+=($(compgen -P '--' -W '${longopts[*]}' -- "${cur:2}")) + COMPREPLY+=($(compgen -P '-' -W '${shortopts[*]}' -- "${cur:1}")) + else + for dir in "${COMP_WORDS[@]}"; do + if [ -d "$dir" ]; then + break + fi + dir=. + done + if [ ! -d "$dir/meson-private" ]; then + _filedir -d + fi + + if [ -z "$cur" ]; then + COMPREPLY+=($(compgen -P '--' -W '${longopts[*]}')) + COMPREPLY+=($(compgen -P '-' -W '${shortopts[*]}')) + fi + fi +} + +_meson-test() { + shortopts=( + q + v + t + C + ) + + longopts=( + quiet + verbose + timeout-multiplier + repeat + no-rebuild + gdb + list + wrapper --wrap + no-suite + suite + no-stdsplit + print-errorlogs + benchmark + logbase + num-processes + setup + test-args + ) + + local cur prev + if _get_comp_words_by_ref -n ':' cur prev &>/dev/null; then + case $prev in + --repeat) + # number, can't be completed + return + ;; + --wrapper) + _command_offset $COMP_CWORD + return + ;; + -C) + _filedir -d + return + ;; + --suite | --no-suite) + for i in "${!COMP_WORDS[@]}"; do + opt="${COMP_WORDS[i]}" + dir="${COMP_WORDS[i+1]}" + case "$opt" in + -C) + break + ;; + esac + dir=. + done + suites=($(python3 -c 'import sys, json; +for test in json.load(sys.stdin): + for suite in test["suite"]: + print(suite) + ' <<< "$(meson introspect "$dir" --tests)")) +# TODO + COMPREPLY+=($(compgen -W "${suites[*]}" -- "$cur")) + return + ;; + --logbase) + # free string, can't be completed + return + ;; + --num-processes) + # number, can't be completed + return + ;; + -t | --timeout-multiplier) + # number, can't be completed + return + ;; + --setup) + # TODO + return + ;; + --test-args) + return + ;; + esac + else + cur="${COMP_WORDS[COMP_CWORD]}" + fi + + if [[ "$cur" == "--"* ]]; then + COMPREPLY+=($(compgen -P '--' -W '${longopts[*]}' -- "${cur:2}")) + elif [[ "$cur" == "-"* && ${#cur} -gt 1 ]]; then + COMPREPLY+=($(compgen -P '-' -W '${shortopts[*]}' -- "${cur:1}")) + else + for dir in "${COMP_WORDS[@]}"; do + if [ -d "$dir" ]; then + break + fi + dir=. + done + if [ ! -d "$dir/meson-private" ]; then + _filedir -d + fi + + for i in "${!COMP_WORDS[@]}"; do + opt="${COMP_WORDS[i]}" + dir="${COMP_WORDS[i+1]}" + case "$opt" in + -C) + break + ;; + esac + dir=. + done + tests=($(python3 -c 'import sys, json; +for test in json.load(sys.stdin): + print(test["name"]) +' <<< "$(meson introspect "$dir" --tests)")) + COMPREPLY+=($(compgen -W "${tests[*]}" -- "$cur")) + + if [ -z "$cur" ]; then + COMPREPLY+=($(compgen -P '--' -W '${longopts[*]}' -- "${cur:2}")) + COMPREPLY+=($(compgen -P '-' -W '${shortopts[*]}' -- "${cur:1}")) + fi + fi +} + +_meson-introspect() { + shortopts=( + h + ) + + longopts=( + targets + installed + buildsystem-files + buildoptions + tests + benchmarks + dependencies + projectinfo + ) + + local cur prev + if ! _get_comp_words_by_ref cur prev &>/dev/null; then + cur="${COMP_WORDS[COMP_CWORD]}" + fi + + if [[ "$cur" == "--"* ]]; then + COMPREPLY+=($(compgen -P '--' -W '${longopts[*]}' -- "${cur:2}")) + elif [[ "$cur" == "-"* ]]; then + COMPREPLY+=($(compgen -P '--' -W '${longopts[*]}' -- "${cur:2}")) + COMPREPLY+=($(compgen -P '-' -W '${shortopts[*]}' -- "${cur:1}")) + else + for dir in "${COMP_WORDS[@]}"; do + if [ -d "$dir" ]; then + break + fi + dir=. + done + if [ ! -d "$dir/meson-private" ]; then + _filedir -d + fi + + if [ -z "$cur" ]; then + COMPREPLY+=($(compgen -P '--' -W '${longopts[*]}')) + COMPREPLY+=($(compgen -P '-' -W '${shortopts[*]}')) + fi + fi +} + +_meson-wrap() { + : TODO +}