aboutsummaryrefslogtreecommitdiff
path: root/scripts/buildsystems/make_wrapper/windres-rc
blob: 88cc8425f72b7a33267b68fcdef6a3ca5a84359a (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#! /bin/sh
# Wrapper for windres to rc which do not understand '-i -o --output-format'.
# cvtres is invoked by the linker
scriptversion=2020-08-17.03; # UTC


nl='
'

# We need space, tab and new line, in precisely that order.  Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" ""	$nl"

file_conv=

# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
  file=$1
  case $file in
    / | /[!/]*) # absolute file, and not a UNC file
      if test -z "$file_conv"; then
	# lazily determine how to convert abs files
	case `uname -s` in
	  MINGW*)
	    file_conv=mingw
	    ;;
	  CYGWIN* | MSYS*)
	    file_conv=cygwin
	    ;;
	  *)
	    file_conv=wine
	    ;;
	esac
      fi
      case $file_conv/,$2, in
	*,$file_conv,*)
	  ;;
	mingw/*)
	  file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
	  ;;
	cygwin/* | msys/*)
	  file=`cygpath -m "$file" || echo "$file"`
	  ;;
	wine/*)
	  file=`winepath -w "$file" || echo "$file"`
	  ;;
      esac
      ;;
  esac
}

# func_windres_wrapper rc args...
# Adjust compile command to suit rc instead of windres
func_windres_wrapper ()
{
  echo "FROM WINDRESWRAPPER FUNCTION:$@"
  echo "RCFLAGS:$(RCFLAGS)"
  # Assume a capable shell
  in=
  out=

  for arg
  do
    if test -n "$eat"; then
      eat=
    else
      case $1 in
	-o)
	  eat=1
	  func_file_conv "$2"
	  out="$file"
	  echo "OUTPUT:$file"
	  set x "$@"
	  shift
	  ;;
	*.obj)
	  func_file_conv "$1"
	  out="$file"
	  echo "OUTPUT:$file"
	  set x "$@"
	  shift
	  ;;
	--output-format=*)
	  set x "$@"
	  shift
	  ;;
	-i)
	  eat=1
	  func_file_conv "$2" mingw
	  in="$file"
	  echo "INPUT:$file"
	  set x "$@"
	  shift
	  ;;
	-*)
	  set x "$@" "${1//\\\"/\"}"
	  shift
	  ;;
	*)
	  set x "$@" "$1"
	  shift
	  ;;
      esac
    fi
    shift
  done
  echo "$@" -fo "$out" "$in"
  exec "$@" -fo "$out" "$in"
  exit 1
}

eat=

func_windres_wrapper "$@"


# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End: