Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions contrib/shell-completion/_fbc
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#compdef fbc

# fbc - Zsh completion for the FreeBASIC compiler
# Place this file in a directory listed in $fpath (e.g. /usr/share/zsh/site-functions/)

_fbc() {
local -a arch_types gen_backends lang_dialects warn_opts print_opts z_opts

arch_types=(
native 32 64 x86 x86_64 amd64
i386 i486 i586 i686 prescott
armv5 armeabi armeabi-v7a armv7 armv7a armv8-a aarch64
)
gen_backends=(gas gas64 gcc llvm)
lang_dialects=(fb deprecated fblite qb)
warn_opts=(all pedantic none param escape next signedness constness suffix error upcast)
print_opts=(host target fblibdir x sha-1)
z_opts=(gosub-setjmp valist-as-ptr no-thiscall no-fastcall fbrt nocmdline)

_arguments -s \
'-a[treat file as .o/.a input]:file:_files' \
"-arch[set target architecture]:arch:(${arch_types[*]})" \
'-asm[set asm format (gas/gcc/llvm, x86/x86_64 only)]:format:(att intel)' \
'-b[treat file as .bas input]:file:_files -g "*.bas"' \
'-buildprefix[specify prefix on tool names (as, ar, ld)]:prefix' \
'-c[compile only, do not link]' \
'-C[preserve temporary .o files]' \
'-d[add a global #define]:name\=value' \
'-dll[same as -dylib]' \
'-dylib[create a DLL or shared library]' \
'-e[enable runtime error checking]' \
'-earray[enable array bounds checking]' \
'-eassert[enable assert() and assertwarn() checking]' \
'-edebug[enable __FB_DEBUG__]' \
'-edebuginfo[add debug info]' \
'-elocation[enable error location reporting]' \
'-enullptr[enable null-pointer checking]' \
'-eunwind[enable call stack unwind information]' \
'-entry[change the entry point of the program]:name' \
'-ex[-e plus RESUME support]' \
'-exx[-ex plus array bounds/null-pointer checking]' \
'-export[export symbols for dynamic linkage]' \
'-fbgfx[link to the appropriate libfbgfx variant]' \
"-forcelang[override #lang statements in source code]:dialect:(${lang_dialects[*]})" \
'-fpmode[select floating-point math accuracy/speed]:mode:(fast precise)' \
'-fpu[set target FPU]:fpu:(x87 sse)' \
'-g[add debug info, enable __FB_DEBUG__, and enable assert()]' \
"-gen[select code generation backend]:backend:(${gen_backends[*]})" \
'(--help -help)'{--help,-help}'[show help output]' \
'-i[add an include file search path]:path:_files -/' \
'-include[pre-#include a file for each input .bas]:file:_files' \
'-l[link in a library]:library' \
"-lang[select FB dialect]:dialect:(${lang_dialects[*]})" \
'-lib[create a static library]' \
'-m[specify main module]:name' \
'-map[save linking map to file]:file:_files' \
'-maxerr[only show n errors]:n' \
'-mt[use thread-safe FB runtime]' \
'-nodeflibs[do not include the default libraries when linking]' \
'-noerrline[do not show source context in error messages]' \
'-nolib[do not include the specified libraries]:libraries (comma-separated)' \
'-noobjinfo[do not read/write compile-time info from/to .o and .a files]' \
'-nostrip[do not strip symbol information from the output file]' \
'-o[set .o (or -pp .bas) file name for prev/next input file]:file:_files' \
'-O[optimization level (default\: 0)]:level:(0 1 2 3)' \
'-p[add a library search path]:path:_files -/' \
'-pic[generate position-independent code]' \
'-pp[write out preprocessed input file (.pp.bas) only]' \
'-prefix[set the compiler prefix path]:path:_files -/' \
"-print[display information]:info:(${print_opts[*]})" \
'-profile[enable function profiling]' \
'-r[write out .asm/.c/.ll only]' \
'-R[preserve temporary .asm/.c/.ll/.def files]' \
'-rr[write out the final .asm only]' \
'-RR[preserve the final .asm file]' \
'-s[select win32 subsystem]:subsystem:(console gui)' \
'-showincludes[display a tree of file names of #included files]' \
'-static[prefer static libraries over dynamic ones when linking]' \
'-strip[omit all symbol information from the output file]' \
'-t[set .exe stack size in kbytes (default\: 1024)]:size (kbytes)' \
'-target[set cross-compilation target]:target' \
'-title[set XBE display title (xbox)]:title' \
'-v[be verbose]' \
'-vec[automatic vectorization level (default\: 0)]:level:(0 1 2)' \
'(--version -version)'{--version,-version}'[show compiler version]' \
"-w[set min warning level]:warning:(${warn_opts[*]})" \
"-Wa[pass options to 'as']:options" \
"-Wc[pass options to 'gcc' (-gen gcc) or 'llc' (-gen llvm)]:options" \
"-Wl[pass options to 'ld']:options" \
'-x[set output executable/library file name]:file:_files' \
"-z[set miscellaneous option]:option:(${z_opts[*]})" \
'*:source file:_files -g "*.bas"'
}

_fbc
98 changes: 98 additions & 0 deletions contrib/shell-completion/fbc.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# fbc - Bash completion for the FreeBASIC compiler
# Source this file or place it in /etc/bash_completion.d/fbc

_fbc() {
local cur prev words cword
_init_completion || return

local arch_types="native 32 64 x86 x86_64 amd64 i386 i486 i586 i686 prescott
armv5 armeabi armeabi-v7a armv7 armv7a armv8-a aarch64"
local gen_backends="gas gas64 gcc llvm"
local lang_dialects="fb deprecated fblite qb"
local warn_opts="all pedantic none param escape next signedness constness suffix error upcast"
local print_opts="host target fblibdir x sha-1"
local z_opts="gosub-setjmp valist-as-ptr no-thiscall no-fastcall fbrt nocmdline"

case "$prev" in
-arch)
COMPREPLY=($(compgen -W "$arch_types" -- "$cur"))
return
;;
-asm)
COMPREPLY=($(compgen -W "att intel" -- "$cur"))
return
;;
-gen)
COMPREPLY=($(compgen -W "$gen_backends" -- "$cur"))
return
;;
-lang|-forcelang)
COMPREPLY=($(compgen -W "$lang_dialects" -- "$cur"))
return
;;
-s)
COMPREPLY=($(compgen -W "console gui" -- "$cur"))
return
;;
-w)
COMPREPLY=($(compgen -W "$warn_opts" -- "$cur"))
return
;;
-print)
COMPREPLY=($(compgen -W "$print_opts" -- "$cur"))
return
;;
-fpmode)
COMPREPLY=($(compgen -W "fast precise" -- "$cur"))
return
;;
-fpu)
COMPREPLY=($(compgen -W "x87 sse" -- "$cur"))
return
;;
-z)
COMPREPLY=($(compgen -W "$z_opts" -- "$cur"))
return
;;
-O)
COMPREPLY=($(compgen -W "0 1 2 3" -- "$cur"))
return
;;
-vec)
COMPREPLY=($(compgen -W "0 1 2" -- "$cur"))
return
;;
-a|-o|-x|-map|-include)
_filedir
return
;;
-b|-m)
_filedir 'bas'
return
;;
-i|-p|-prefix)
_filedir -d
return
;;
-d|-l|-nolib|-maxerr|-t|-title|-target|-buildprefix|-Wa|-Wc|-Wl|-entry)
return
;;
esac

if [[ "$cur" == -* ]]; then
local opts="-a -arch -asm -b -buildprefix -c -C -d -dll -dylib
-e -earray -eassert -edebug -edebuginfo -elocation -enullptr -eunwind
-entry -ex -exx -export -fbgfx -forcelang -fpmode -fpu -g -gen
--help -help -i -include -l -lang -lib -m -map -maxerr -mt
-nodeflibs -noerrline -nolib -noobjinfo -nostrip -o -O -p -pic
-pp -prefix -print -profile -r -rr -R -RR -s -showincludes
-static -strip -t -target -title -v -vec --version -version
-w -Wa -Wc -Wl -x -z"
COMPREPLY=($(compgen -W "$opts" -- "$cur"))
return
fi

_filedir '@(bas|a|o|rc|res|xpm)'
}

complete -F _fbc fbc
85 changes: 85 additions & 0 deletions contrib/shell-completion/fbc.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# fbc - Fish completion for the FreeBASIC compiler
# Place this file in ~/.config/fish/completions/ or /usr/share/fish/completions/

set -l arch_types \
native 32 64 x86 x86_64 amd64 \
i386 i486 i586 i686 prescott \
armv5 armeabi armeabi-v7a armv7 armv7a armv8-a aarch64

set -l lang_dialects fb deprecated fblite qb
set -l warn_opts all pedantic none param escape next signedness constness suffix error upcast
set -l z_opts gosub-setjmp valist-as-ptr no-thiscall no-fastcall fbrt nocmdline

complete -c fbc -f

complete -c fbc -s a -r -F -d 'Treat file as .o/.a input file'
complete -c fbc -l arch -r -d 'Set target architecture' -a "$arch_types"
complete -c fbc -l asm -r -d 'Set asm format (gas/gcc/llvm, x86/x86_64 only)' -a "att intel"
complete -c fbc -s b -r -F -d 'Treat file as .bas input file'
complete -c fbc -l buildprefix -r -d 'Specify prefix on tool names (as, ar, ld)'
complete -c fbc -s c -d 'Compile only, do not link'
complete -c fbc -s C -d 'Preserve temporary .o files'
complete -c fbc -s d -r -d 'Add a global #define'
complete -c fbc -l dll -d 'Same as -dylib'
complete -c fbc -l dylib -d 'Create a DLL (win32) or shared library (*nix/*BSD)'
complete -c fbc -s e -d 'Enable runtime error checking'
complete -c fbc -l earray -d 'Enable array bounds checking'
complete -c fbc -l eassert -d 'Enable assert() and assertwarn() checking'
complete -c fbc -l edebug -d 'Enable __FB_DEBUG__'
complete -c fbc -l edebuginfo -d 'Add debug info'
complete -c fbc -l elocation -d 'Enable error location reporting'
complete -c fbc -l enullptr -d 'Enable null-pointer checking'
complete -c fbc -l eunwind -d 'Enable call stack unwind information'
complete -c fbc -l entry -r -d 'Change the entry point of the program'
complete -c fbc -l ex -d '-e plus RESUME support'
complete -c fbc -l exx -d '-ex plus array bounds/null-pointer checking'
complete -c fbc -l export -d 'Export symbols for dynamic linkage'
complete -c fbc -l fbgfx -d 'Link to the appropriate libfbgfx variant'
complete -c fbc -l forcelang -r -d 'Override #lang statements in source code' -a "$lang_dialects"
complete -c fbc -l fpmode -r -d 'Select floating-point math accuracy/speed' -a "fast precise"
complete -c fbc -l fpu -r -d 'Set target FPU' -a "x87 sse"
complete -c fbc -s g -d 'Add debug info, enable __FB_DEBUG__, and enable assert()'
complete -c fbc -l gen -r -d 'Select code generation backend' -a "gas gas64 gcc llvm"
complete -c fbc -l help -d 'Show help output'
complete -c fbc -s i -r -F -d 'Add an include file search path'
complete -c fbc -l include -r -F -d 'Pre-#include a file for each input .bas'
complete -c fbc -s l -r -d 'Link in a library'
complete -c fbc -l lang -r -d 'Select FB dialect' -a "$lang_dialects"
complete -c fbc -l lib -d 'Create a static library'
complete -c fbc -s m -r -d 'Specify main module'
complete -c fbc -l map -r -F -d 'Save linking map to file'
complete -c fbc -l maxerr -r -d 'Only show n errors'
complete -c fbc -l mt -d 'Use thread-safe FB runtime'
complete -c fbc -l nodeflibs -d 'Do not include the default libraries when linking'
complete -c fbc -l noerrline -d 'Do not show source context in error messages'
complete -c fbc -l nolib -r -d 'Do not include the specified libraries (comma-separated)'
complete -c fbc -l noobjinfo -d 'Do not read/write compile-time info from/to .o and .a files'
complete -c fbc -l nostrip -d 'Do not strip symbol information from the output file'
complete -c fbc -s o -r -F -d 'Set .o (or -pp .bas) file name for prev/next input file'
complete -c fbc -s O -r -d 'Optimization level (default: 0)' -a "0 1 2 3"
complete -c fbc -s p -r -F -d 'Add a library search path'
complete -c fbc -l pic -d 'Generate position-independent code (non-x86 Unix shared libs)'
complete -c fbc -l pp -d 'Write out preprocessed input file (.pp.bas) only'
complete -c fbc -l prefix -r -F -d 'Set the compiler prefix path'
complete -c fbc -l print -r -d 'Display information' -a "host target fblibdir x sha-1"
complete -c fbc -l profile -d 'Enable function profiling'
complete -c fbc -s r -d 'Write out .asm/.c/.ll (-gen gas/gcc/llvm) only'
complete -c fbc -s R -d 'Preserve temporary .asm/.c/.ll/.def files'
complete -c fbc -l rr -d 'Write out the final .asm only'
complete -c fbc -l RR -d 'Preserve the final .asm file'
complete -c fbc -s s -r -d 'Select win32 subsystem' -a "console gui"
complete -c fbc -l showincludes -d 'Display a tree of file names of #included files'
complete -c fbc -l static -d 'Prefer static libraries over dynamic ones when linking'
complete -c fbc -l strip -d 'Omit all symbol information from the output file'
complete -c fbc -s t -r -d 'Set .exe stack size in kbytes (default: 1024, win32/dos)'
complete -c fbc -l target -r -d 'Set cross-compilation target'
complete -c fbc -l title -r -d 'Set XBE display title (xbox)'
complete -c fbc -s v -d 'Be verbose'
complete -c fbc -l vec -r -d 'Automatic vectorization level (default: 0)' -a "0 1 2"
complete -c fbc -l version -d 'Show compiler version'
complete -c fbc -s w -r -d 'Set min warning level' -a "$warn_opts"
complete -c fbc -l Wa -r -d "Pass options to 'as'"
complete -c fbc -l Wc -r -d "Pass options to 'gcc' (-gen gcc) or 'llc' (-gen llvm)"
complete -c fbc -l Wl -r -d "Pass options to 'ld'"
complete -c fbc -s x -r -F -d 'Set output executable/library file name'
complete -c fbc -s z -r -d 'Set miscellaneous option' -a "$z_opts"
48 changes: 48 additions & 0 deletions contrib/shell-completion/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Shell completion for the FreeBASIC compiler (fbc)

Files
-----
fbc.bash Bash completion
_fbc Zsh completion
fbc.fish Fish completion

Installation
------------

Bash:
System-wide:
sudo cp fbc.bash /etc/bash_completion.d/fbc

Per-user:
mkdir -p ~/.local/share/bash-completion/completions
cp fbc.bash ~/.local/share/bash-completion/completions/fbc

Or source it directly in ~/.bashrc:
source /path/to/fbc.bash

Zsh:
Add a directory to $fpath in ~/.zshrc, then copy the file there:
mkdir -p ~/.zsh/completions
cp _fbc ~/.zsh/completions/
# In ~/.zshrc, before compinit:
fpath=(~/.zsh/completions $fpath)
autoload -Uz compinit && compinit

System-wide:
sudo cp _fbc /usr/share/zsh/site-functions/

Fish:
Per-user:
cp fbc.fish ~/.config/fish/completions/

System-wide:
sudo cp fbc.fish /usr/share/fish/completions/

Completions provided
--------------------
Options with fixed value sets: -arch, -asm, -gen, -lang, -forcelang,
-fpmode, -fpu, -O, -vec, -s, -w, -print, -z
Options with file/directory completion: -a, -b, -i, -include, -m,
-map, -o, -p, -prefix, -x
Source file completion for positional arguments: *.bas, *.a, *.o,
*.rc, *.res, *.xpm