diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-06-06 18:17:33 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-06-06 18:17:33 +0200 |
commit | 18d2d38ba4c03d48a772174f3de856d81ff39a4f (patch) | |
tree | ea6a461953cae17b5006bac96171949f6e707489 /msvc-lib-common | |
parent | 34985ea6f26f6f0a383532ad804e44527715c3fe (diff) |
Major redesign of wrappers
Diffstat (limited to 'msvc-lib-common')
-rwxr-xr-x | msvc-lib-common | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/msvc-lib-common b/msvc-lib-common new file mode 100755 index 0000000..5d11ba1 --- /dev/null +++ b/msvc-lib-common @@ -0,0 +1,95 @@ +#! /usr/bin/env bash + +# @@ Do we really need LIB? What's /LIBPATH for? +# +# Common lib.exe driver that expects the VC and LIB variables to be set for +# the specific MSVC version/configuration set. + +trap "{ exit 1; }" ERR +set -o errtrace # Trap in functions. + +function info () { echo "$*" 1>&2; } +function error () { info "$*"; exit 1; } + +source $(dirname $(realpath ${BASH_SOURCE[0]}))/msvc-common + +# Translate absolute paths from POSIX to Windows. Use bash array to store +# arguments in case they contain spaces. +# +# This needs to be done for both certain option values and arguments. +# Arguments are tricky in that unless we recognize every option, and option +# may look a lot like an absolute POSIX path (e.g., /nologo). The heuristics +# that we are going to use here is that if the argument starts with / and +# contains at least one more /, then we consider it an argument. Otherwise -- +# an options. We will also explicitly recognize certain options which may +# not fit this scheme well. +# +args=() + +while [ $# -gt 0 ]; do + case $1 in + + # /DEF[:filename] + # /OUT:filename + # + [/-]DEF:* | \ + [/-]OUT:*) + args=("${args[@]}" "$(split_translate 5 $1)") + shift + ;; + + # /LIST[:filename] + # /NAME:filename + # + [/-]LIST:* | \ + [/-]NAME:*) + args=("${args[@]}" "$(split_translate 6 $1)") + shift + ;; + + # /LIBPATH:dir + # + [/-]LIBPATH:*) + args=("${args[@]}" "$(split_translate 9 $1)") + shift + ;; + + # Handle other options with separate values. This makes sure we don't try + # to path-translate them. + # + + # Aren't any. + + # Handle other options with combined values that could possibly be + # interpreted as paths, for example /EXTRACT:foo/bar.obj. + # + [/-]EXPORT:* | \ + [/-]EXTRACT:* | \ + [/-]INCLUDE:* | \ + [/-]REMOVE:*) + args=("${args[@]}" "$1") + shift + ;; + + # Option or argument. + # + *) + # If contains at least two slashes, treat it as a path. + # + if [[ "$1" == /*/* ]]; then + args=("${args[@]}" "$(translate $1)") + else + args=("${args[@]}" "$1") + fi + shift + ;; + esac +done + +# @@ Do we need this? +# +export LIB + +# Lib.exe always sends diagnostics to stdout. +# +msvc_exec 1 "$VC\\bin\\lib.exe" "${args[@]}" |