| 1 | #! /bin/sh |
| 2 | |
| 3 | # MIT License |
| 4 | |
| 5 | # Copyright (c) Microsoft Corporation |
| 6 | |
| 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this |
| 8 | # software and associated documentation files (the "Software"), to deal in the Software |
| 9 | # without restriction, including without limitation the rights to use, copy, modify, |
| 10 | # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to |
| 11 | # permit persons to whom the Software is furnished to do so, subject to the following |
| 12 | # conditions: |
| 13 | |
| 14 | # The above copyright notice and this permission notice shall be included in all copies |
| 15 | # or substantial portions of the Software. |
| 16 | |
| 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, |
| 18 | # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A |
| 19 | # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
| 20 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
| 21 | # CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE |
| 22 | # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 23 | |
| 24 | # https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/buildsystems/make_wrapper/windres-rc |
| 25 | |
| 26 | |
| 27 | # Wrapper for windres to rc which do not understand '-i -o --output-format'. |
| 28 | # cvtres is invoked by the linker |
| 29 | scriptversion=2022-08-24.12; # UTC |
| 30 | |
| 31 | |
| 32 | nl=' |
| 33 | ' |
| 34 | |
| 35 | # We need space, tab and new line, in precisely that order. Quoting is |
| 36 | # there to prevent tools from complaining about whitespace usage. |
| 37 | IFS=" "" $nl" |
| 38 | |
| 39 | file_conv= |
| 40 | |
| 41 | # func_file_conv build_file lazy |
| 42 | # Convert a $build file to $host form and store it in $file |
| 43 | # Currently only supports Windows hosts. If the determined conversion |
| 44 | # type is listed in (the comma separated) LAZY, no conversion will |
| 45 | # take place. |
| 46 | func_file_conv () |
| 47 | { |
| 48 | file=$1 |
| 49 | case $file in |
| 50 | / | /[!/]*) # absolute file, and not a UNC file |
| 51 | if test -z "$file_conv"; then |
| 52 | # lazily determine how to convert abs files |
| 53 | case `uname -s` in |
| 54 | MINGW*) |
| 55 | file_conv=mingw |
| 56 | ;; |
| 57 | CYGWIN* | MSYS*) |
| 58 | file_conv=cygwin |
| 59 | ;; |
| 60 | *) |
| 61 | file_conv=wine |
| 62 | ;; |
| 63 | esac |
| 64 | fi |
| 65 | case $file_conv/,$2, in |
| 66 | *,$file_conv,*) |
| 67 | ;; |
| 68 | mingw/*) |
| 69 | file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` |
| 70 | ;; |
| 71 | cygwin/* | msys/*) |
| 72 | file=`cygpath -m "$file" || echo "$file"` |
| 73 | ;; |
| 74 | wine/*) |
| 75 | file=`winepath -w "$file" || echo "$file"` |
| 76 | ;; |
| 77 | esac |
| 78 | ;; |
| 79 | esac |
| 80 | } |
| 81 | |
| 82 | # func_windres_wrapper rc args... |
| 83 | # Adjust compile command to suit rc instead of windres |
| 84 | func_windres_wrapper () |
| 85 | { |
| 86 | # Assume a capable shell |
| 87 | bin= |
| 88 | in= |
| 89 | out= |
| 90 | |
| 91 | for arg |
| 92 | do |
| 93 | if test -z "$bin"; then |
| 94 | bin=$1 |
| 95 | elif test -n "$eat"; then |
| 96 | eat= |
| 97 | else |
| 98 | case $1 in |
| 99 | --output-format=*) |
| 100 | ;; |
| 101 | --define*) |
| 102 | eat=1 |
| 103 | set -- "$@" "-d $2" |
| 104 | ;; |
| 105 | --include-dir*) |
| 106 | eat=1 |
| 107 | func_file_conv "$2" |
| 108 | set -- "$@" "-I $file" |
| 109 | ;; |
| 110 | -o) |
| 111 | eat=1 |
| 112 | func_file_conv "$2" |
| 113 | out="$file" |
| 114 | echo "OUTPUT:$file" |
| 115 | ;; |
| 116 | *.obj) |
| 117 | func_file_conv "$1" |
| 118 | out="$file" |
| 119 | echo "OUTPUT:$file" |
| 120 | ;; |
| 121 | -i) |
| 122 | eat=1 |
| 123 | func_file_conv "$2" mingw |
| 124 | in="$file" |
| 125 | echo "INPUT:$file" |
| 126 | ;; |
| 127 | -*) |
| 128 | set -- "$@" "${1//\\\"/\"}" |
| 129 | ;; |
| 130 | *) |
| 131 | # libtool reorders arguments; save unqualified one as input |
| 132 | func_file_conv "$1" |
| 133 | in="$file" |
| 134 | echo "INPUT:$file" |
| 135 | ;; |
| 136 | esac |
| 137 | fi |
| 138 | shift |
| 139 | done |
| 140 | echo "$bin" "$@" -fo "$out" "$in" |
| 141 | exec "$bin" "$@" -fo "$out" "$in" |
| 142 | exit 1 |
| 143 | } |
| 144 | |
| 145 | eat= |
| 146 | |
| 147 | func_windres_wrapper "$@" |
| 148 | |
| 149 | |
| 150 | # Local Variables: |
| 151 | # mode: shell-script |
| 152 | # sh-indentation: 2 |
| 153 | # eval: (add-hook 'before-save-hook 'time-stamp) |
| 154 | # time-stamp-start: "scriptversion=" |
| 155 | # time-stamp-format: "%:y-%02m-%02d.%02H" |
| 156 | # time-stamp-time-zone: "UTC0" |
| 157 | # time-stamp-end: "; # UTC" |
| 158 | # End: |