# shellcheck shell=bash # Whether a compiler line compiles and links nothing, which is when -v is a # query. # # Sourced by brintcc-glibc, brintcc-musl, brintc++-glibc and brintc++-musl. # # brintium_line_is_query "$@" # status 0: -v on this line is a query # # As with clang and gcc, `cc -v` prints and exits, while `cc -v x.o -o x` is a # link with verbose output; CMake's compiler ABI probe is such a link. Such a # line has no -c, -E or -S and no input: no argument without a leading dash # that is not an option's operand, no `-` for stdin, and none of what clang # hands the linker as an input (-l, -Wl, -Xlinker, -z). # --version, -dumpversion, -dumpmachine and -print-* answer and exit on any # line, and the callers keep them as queries. # # meta-brintos carries copies of this test in its wasmc++-glibc drivers and # toolchain environment files; change them together. brintium_line_is_query() { local _lk_a _lk_skip=0 for _lk_a in "$@"; do if [ "$_lk_skip" = 1 ]; then _lk_skip=0; continue; fi case "$_lk_a" in -c|-E|-S|-|-l*|-Wl,*|-Xlinker|-z) return 1 ;; -o|-x|-I|-D|-U|-L|-B|-F|-include|-imacros|-include-pch|-isystem|-isystem-after|-idirafter|-iquote|-isysroot|-imultilib|-iprefix|-iwithprefix|-iwithprefixbefore|-iwithsysroot|-iframework|-cxx-isystem|-ivfsoverlay|-resource-dir|-working-directory|-gcc-toolchain|--serialize-diagnostics|-MF|-MT|-MQ|-MJ|--param|-arch|-Xclang|-Xpreprocessor|-Xassembler|-target|-mllvm|-T|-u|-e|--sysroot) _lk_skip=1 ;; -*) ;; *) return 1 ;; esac done return 0 }