aboutsummaryrefslogtreecommitdiff
path: root/msvc-common
blob: 479ec3f65f17b3b4cfd793dc811a6bea983f98a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /usr/bin/env bash

# Note: shouldn't be executed directly.

# Translate absolute POSIX path to a Windows path with winepath.
#
function translate () # <path>
{
  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 () # <length> <option-path>
{
  local o="${2:0:$1}" # First <length> 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 <diag> argument should be 1 or 2. It indicates whether the diagnostics
# is sent to stdout (1) or stderr (2).
#
function msvc_exec () # <diag> <exe> <arg>...
{
  local diag="$1"
  shift

  # Suppress Wine noise.
  #
  export WINEDEBUG=fixme-all

  # Filter diagnostics output replacing absolute Windows paths with their
  # POSIX mapping. If <diag> is 1 then both stdout and stderr output are read
  # and filtered.
  #
  "$(dirname $(realpath ${BASH_SOURCE[0]}))/msvc-filter" "$diag" wine "$@"
}