aboutsummaryrefslogtreecommitdiff
path: root/msvc-common/msvc-common
blob: 8d4e87e17d74d7589d2dcf8321d57b578493c764 (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
51
52
53
54
#! /usr/bin/env bash

# file      : msvc-common/msvc-common
# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

# Note: shouldn't be executed directly, src_dir must be set.

# 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.
  #
  "$src_dir/msvc-common/msvc-filter" "$diag" wine "$@"
}