From 3209a9fa6e87ad4d2f9d1087a1206347df4c6214 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 24 Nov 2016 11:38:44 +0200 Subject: Reorganize the script structure --- msvc-common/msvc-common | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 msvc-common/msvc-common (limited to 'msvc-common/msvc-common') diff --git a/msvc-common/msvc-common b/msvc-common/msvc-common new file mode 100755 index 0000000..d571f87 --- /dev/null +++ b/msvc-common/msvc-common @@ -0,0 +1,56 @@ +#! /usr/bin/env bash + +# Note: shouldn't be executed directly, src_dir must be set. + +# Translate absolute POSIX path to a Windows path with winepath. +# +function translate () # +{ + if [[ "$1" == /* ]]; then + winepath -w "$1" + else + echo "$1" + fi +} + +# Split the combined option and path value, translate the path component +# to a Windows path if absolute, then recombine the option and path. +# +function split_translate () # +{ + local o="${2:0:$1}" # First characters from $1. + local v="${2:$1}" # The rest. + + # If the path is absolute, map it with winepath. + # + if [[ "$v" == /* ]]; then + v="$(winepath -w "$v")" + fi + + echo "$o$v" +} + +# The argument should be 1 or 2. It indicates whether the diagnostics +# is sent to stdout (1) or stderr (2). +# +function msvc_exec () # ... +{ + local diag="$1" + shift + + # Suppress Wine noise. + # + export WINEDEBUG=fixme-all + + # Set an alternative .wine directory if requested. + # + if [ -n "$MSVC_WINEPREFIX" ]; then + export WINEPREFIX="$MSVC_WINEPREFIX" + fi + + # Filter diagnostics output replacing absolute Windows paths with their + # POSIX mapping. If is 1 then both stdout and stderr output are read + # and filtered. + # + "$src_dir/msvc-filter" "$diag" wine "$@" +} -- cgit v1.1