Thu, 03 Oct 2013 09:52:21 -0400
Merge
ohair@263 | 1 | #!/bin/sh |
ohair@263 | 2 | |
ohair@263 | 3 | # |
tbell@487 | 4 | # Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. |
ohair@263 | 5 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ohair@263 | 6 | # |
ohair@263 | 7 | # This code is free software; you can redistribute it and/or modify it |
ohair@263 | 8 | # under the terms of the GNU General Public License version 2 only, as |
ohair@263 | 9 | # published by the Free Software Foundation. |
ohair@263 | 10 | # |
ohair@263 | 11 | # This code is distributed in the hope that it will be useful, but WITHOUT |
ohair@263 | 12 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ohair@263 | 13 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ohair@263 | 14 | # version 2 for more details (a copy is included in the LICENSE file that |
ohair@263 | 15 | # accompanied this code). |
ohair@263 | 16 | # |
ohair@263 | 17 | # You should have received a copy of the GNU General Public License version |
ohair@263 | 18 | # 2 along with this work; if not, write to the Free Software Foundation, |
ohair@263 | 19 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ohair@263 | 20 | # |
ohair@263 | 21 | # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@263 | 22 | # or visit www.oracle.com if you need additional information or have any |
ohair@263 | 23 | # questions. |
ohair@263 | 24 | # |
ohair@263 | 25 | |
ohair@263 | 26 | # This file should be used to set the Visual Studio environment |
ohair@263 | 27 | # variables normally set by the vcvars32.bat or vcvars64.bat file or |
ohair@263 | 28 | # SetEnv.cmd for older SDKs. |
ohair@263 | 29 | |
ohair@263 | 30 | ######################################################################## |
ohair@263 | 31 | # Error functions |
ohair@263 | 32 | msg() # message |
ohair@263 | 33 | { |
ohair@263 | 34 | echo "$1" 1>&2 |
ohair@263 | 35 | } |
ohair@263 | 36 | error() # message |
ohair@263 | 37 | { |
ohair@263 | 38 | msg "ERROR: $1" |
ohair@263 | 39 | exit 1 |
ohair@263 | 40 | } |
ohair@263 | 41 | warning() # message |
ohair@263 | 42 | { |
ohair@263 | 43 | msg "WARNING: $1" |
ohair@263 | 44 | } |
ohair@263 | 45 | envpath() # path |
ohair@263 | 46 | { |
tbell@487 | 47 | if [ "${fixpath}" != "" -a -d "$1" ] ; then |
tbell@487 | 48 | ${fixpath} "$1" |
ohair@263 | 49 | else |
ohair@263 | 50 | echo "$1" |
ohair@263 | 51 | fi |
ohair@263 | 52 | } |
ohair@263 | 53 | ######################################################################## |
ohair@263 | 54 | |
ohair@263 | 55 | |
ohair@263 | 56 | # Defaults settings |
ohair@263 | 57 | debug="false" |
ohair@263 | 58 | verbose="false" |
ohair@263 | 59 | |
ohair@263 | 60 | set -e |
ohair@263 | 61 | |
tbell@487 | 62 | CYGWIN="nodosfilewarning ntsec" |
tbell@487 | 63 | export CYGWIN |
tbell@487 | 64 | |
tbell@487 | 65 | # pathsepIn is always ; because the input strings are coming from |
tbell@487 | 66 | # vcvarsxx.bat. This is true under all of MKS, Cygwin, MINGW/msys |
tbell@487 | 67 | pathsepIn=';' |
tbell@487 | 68 | |
tbell@487 | 69 | OS="`uname -s`" |
tbell@487 | 70 | case "${OS}" in |
tbell@487 | 71 | CYGWIN*) |
tbell@487 | 72 | pathflag='-c' |
tbell@487 | 73 | devnull=/dev/null |
tbell@487 | 74 | pathsepOut=':' |
tbell@487 | 75 | ;; |
tbell@487 | 76 | |
tbell@487 | 77 | MINGW*) |
tbell@487 | 78 | pathflag='-m' |
tbell@487 | 79 | devnull=/dev/null |
tbell@487 | 80 | pathsepOut=':' |
tbell@487 | 81 | ;; |
tbell@487 | 82 | |
tbell@487 | 83 | *) |
tbell@487 | 84 | # MKS? |
tbell@487 | 85 | # Continue using dosname -s |
tbell@487 | 86 | pathflag='-s' |
tbell@487 | 87 | fixpath="dosname ${pathflag}" |
tbell@487 | 88 | fixpath_windows="${fixpath}" |
tbell@487 | 89 | fixpath_path="echo" |
tbell@487 | 90 | devnull=NUL |
tbell@487 | 91 | pathsepOut=';' |
tbell@487 | 92 | ;; |
tbell@487 | 93 | esac |
tbell@487 | 94 | |
tbell@487 | 95 | case "${OS}" in |
tbell@487 | 96 | CYGWIN*|MINGW*) |
tbell@487 | 97 | t=`dirname ${0}` |
tbell@487 | 98 | wd=`cd ${t} 2> ${devnull} && pwd` |
tbell@487 | 99 | fixpath_script="${wd}/fixpath.pl" |
tbell@487 | 100 | if [ ! -f "${fixpath_script}" ] ; then |
tbell@487 | 101 | error "Does not exist: ${fixpath_script}" |
tbell@487 | 102 | fi |
tbell@487 | 103 | fixpath="perl ${fixpath_script} ${pathflag}" |
tbell@487 | 104 | fixpath_windows="perl ${fixpath_script} -d" |
tbell@487 | 105 | fixpath_path="${fixpath_windows}" |
tbell@487 | 106 | ;; |
tbell@487 | 107 | esac |
tbell@487 | 108 | |
tbell@487 | 109 | shellStyle="sh" |
tbell@487 | 110 | ## As far as I can tell from hg history, this has not worked |
tbell@487 | 111 | ## for a long time because PPID is unset. When run under Cygwin |
tbell@487 | 112 | ## the script quits due to the 1 return from grep. |
tbell@487 | 113 | ##parentCsh="` ps -p ${PPID} 2> ${devnull} | grep csh `" |
tbell@487 | 114 | ##if [ "${parentCsh}" != "" ] ; then |
tbell@487 | 115 | ## shellStyle="csh" |
tbell@487 | 116 | ##fi |
tbell@487 | 117 | |
ohair@263 | 118 | # Check environment first |
ohair@263 | 119 | if [ "${PROGRAMFILES}" != "" ] ; then |
ohair@263 | 120 | progfiles=`envpath "${PROGRAMFILES}"` |
ohair@263 | 121 | elif [ "${ProgramFiles}" != "" ] ; then |
ohair@263 | 122 | progfiles=`envpath "${ProgramFiles}"` |
ohair@263 | 123 | elif [ "${SYSTEMDRIVE}" != "" ] ; then |
ohair@263 | 124 | progfiles=`envpath "${SYSTEMDRIVE}/Program Files"` |
ohair@263 | 125 | elif [ "${SystemDrive}" != "" ] ; then |
ohair@263 | 126 | progfiles=`envpath "${SystemDrive}/Program Files"` |
ohair@263 | 127 | else |
ohair@263 | 128 | error "No PROGRAMFILES or SYSTEMDRIVE defined in environment" |
ohair@263 | 129 | fi |
ohair@263 | 130 | |
ohair@263 | 131 | # Arch data model |
ohair@263 | 132 | if [ "${PROCESSOR_IDENTIFIER}" != "" ] ; then |
ohair@263 | 133 | arch=`echo "${PROCESSOR_IDENTIFIER}" | cut -d' ' -f1` |
tbell@487 | 134 | else |
tbell@487 | 135 | if [ "${MACHTYPE}" != "" ] ; then |
tbell@487 | 136 | if [ "`echo ${MACHTYPE} | grep 64`" != "" ] ; then |
tbell@487 | 137 | # Assume this is X64, not IA64 |
tbell@487 | 138 | arch="x64" |
tbell@487 | 139 | else |
tbell@487 | 140 | arch="x86" |
tbell@487 | 141 | fi |
ohair@263 | 142 | else |
tbell@487 | 143 | arch="`uname -m`" |
ohair@263 | 144 | fi |
tbell@487 | 145 | PROCESSOR_IDENTIFIER="${arch}" |
tbell@487 | 146 | export PROCESSOR_IDENTIFIER |
ohair@263 | 147 | fi |
ohair@263 | 148 | if [ "${arch}" = "X86" -o \ |
ohair@263 | 149 | "${arch}" = "386" -o "${arch}" = "i386" -o \ |
ohair@263 | 150 | "${arch}" = "486" -o "${arch}" = "i486" -o \ |
ohair@263 | 151 | "${arch}" = "586" -o "${arch}" = "i586" -o \ |
ohair@263 | 152 | "${arch}" = "686" -o "${arch}" = "i686" -o \ |
ohair@263 | 153 | "${arch}" = "86" ] ; then |
ohair@263 | 154 | arch="x86" |
ohair@263 | 155 | fi |
ohair@263 | 156 | if [ "${arch}" = "X64" -o \ |
ohair@263 | 157 | "${arch}" = "8664" -o "${arch}" = "i8664" -o \ |
ohair@263 | 158 | "${arch}" = "amd64" -o "${arch}" = "AMD64" -o \ |
ohair@263 | 159 | "${arch}" = "EM64T" -o "${arch}" = "emt64t" -o \ |
ohair@263 | 160 | "${arch}" = "intel64" -o "${arch}" = "Intel64" -o \ |
ohair@263 | 161 | "${arch}" = "64" ] ; then |
ohair@263 | 162 | arch="x64" |
tbell@487 | 163 | binarch64="\\amd64" |
ohair@263 | 164 | fi |
ohair@263 | 165 | if [ "${arch}" = "IA64" ] ; then |
ohair@263 | 166 | arch="ia64" |
tbell@487 | 167 | binarch64="\\ia64" |
ohair@263 | 168 | fi |
ohair@263 | 169 | if [ "${arch}" != "x86" -a "${arch}" != "x64" -a "${arch}" != "ia64" ] ; then |
ohair@263 | 170 | error "No PROCESSOR_IDENTIFIER or MACHTYPE environment variables and uname -m is not helping" |
ohair@263 | 171 | fi |
ohair@263 | 172 | if [ "${arch}" = "x86" ] ; then |
ohair@263 | 173 | arch_data_model=32 |
ohair@263 | 174 | progfiles32="${progfiles}" |
ohair@263 | 175 | progfiles64="${progfiles}" |
ohair@263 | 176 | else |
ohair@263 | 177 | arch_data_model=64 |
ohair@263 | 178 | progfiles32="${progfiles}" |
ohair@263 | 179 | if [ "${PROGRAMW6432}" != "" ] ; then |
ohair@263 | 180 | progfiles64=`envpath "${PROGRAMW6432}"` |
ohair@263 | 181 | else |
ohair@263 | 182 | progfiles64=`envpath "C:/Program Files"` |
ohair@263 | 183 | fi |
ohair@263 | 184 | fi |
ohair@263 | 185 | |
anthony@498 | 186 | # VS2012 (VC11) |
anthony@498 | 187 | if [ "${VS110COMNTOOLS}" = "" ] ; then |
anthony@498 | 188 | VS110COMNTOOLS="${progfiles32}/Microsoft Visual Studio 11.0/Common7/Tools/" |
anthony@498 | 189 | export VS110COMNTOOLS |
anthony@498 | 190 | fi |
anthony@498 | 191 | vc11Bin32Dir=`envpath "${VS110COMNTOOLS}"`/../../VC/Bin |
anthony@498 | 192 | vc11Bin64Dir="${vc11Bin32Dir}" |
anthony@498 | 193 | vc11vars32Bat="vcvars32.bat" |
anthony@498 | 194 | vc11vars64Bat="vcvars64.bat" |
anthony@498 | 195 | |
ohair@263 | 196 | # VS2010 (VC10) |
ohair@263 | 197 | if [ "${VS100COMNTOOLS}" = "" ] ; then |
ohair@263 | 198 | VS100COMNTOOLS="${progfiles32}/Microsoft Visual Studio 10.0/Common7/Tools/" |
ohair@263 | 199 | export VS100COMNTOOLS |
ohair@263 | 200 | fi |
ohair@263 | 201 | vc10Bin32Dir=`envpath "${VS100COMNTOOLS}"`/../../VC/Bin |
ohair@263 | 202 | vc10Bin64Dir="${vc10Bin32Dir}${binarch64}" |
ohair@263 | 203 | vc10vars32Bat="vcvars32.bat" |
ohair@263 | 204 | vc10vars64Bat="vcvars64.bat" |
ohair@263 | 205 | |
ohair@263 | 206 | # VS2008 (VC9) |
ohair@263 | 207 | if [ "${VS90COMNTOOLS}" = "" ] ; then |
ohair@263 | 208 | VS90COMNTOOLS="${progfiles32}/Microsoft Visual Studio 9.0/Common7/Tools/" |
ohair@263 | 209 | export VS90COMNTOOLS |
ohair@263 | 210 | fi |
ohair@263 | 211 | vc9Bin32Dir=`envpath "${VS90COMNTOOLS}"`/../../VC/Bin |
ohair@263 | 212 | vc9Bin64Dir="${vc9Bin32Dir}" |
ohair@263 | 213 | vc9vars32Bat="vcvars32.bat" |
ohair@263 | 214 | vc9vars64Bat="vcvars64.bat" |
ohair@263 | 215 | |
ohair@263 | 216 | # VS2005 (VC8) |
ohair@263 | 217 | if [ "${VS80COMNTOOLS}" = "" ] ; then |
ohair@263 | 218 | VS80COMNTOOLS="${progfiles32}/Microsoft Visual Studio 8.0/Common7/Tools/" |
ohair@263 | 219 | export VS80COMNTOOLS |
ohair@263 | 220 | fi |
ohair@263 | 221 | vc8Bin32Dir=`envpath "${VS80COMNTOOLS}"`/../../VC/Bin |
ohair@263 | 222 | vc8Bin64Dir="${progfiles64}/Microsoft Platform SDK" |
ohair@263 | 223 | vc8vars32Bat="vcvars32.bat" |
ohair@263 | 224 | vc8vars64Bat="SetEnv.cmd /X64" |
ohair@263 | 225 | |
ohair@263 | 226 | # VS2003 (VC7) |
ohair@263 | 227 | if [ "${VS71COMNTOOLS}" = "" ] ; then |
ohair@263 | 228 | VS71COMNTOOLS="${progfiles32}/Microsoft Visual Studio .NET 2003/Common7/Tools/" |
ohair@263 | 229 | export VS71COMNTOOLS |
ohair@263 | 230 | fi |
ohair@263 | 231 | vc7Bin32Dir=`envpath "${VS71COMNTOOLS}"`/../../VC7/Bin |
ohair@263 | 232 | vc7Bin64Dir="${progfiles64}/Microsoft Platform SDK" |
ohair@263 | 233 | vc7vars32Bat="vcvars32.bat" |
ohair@263 | 234 | vc7vars64Bat="SetEnv.cmd /X64" |
ohair@263 | 235 | |
ohair@263 | 236 | # Force user to select |
ohair@263 | 237 | vcSelection="" |
ohair@263 | 238 | |
ohair@263 | 239 | # Parse options |
anthony@498 | 240 | usage="Usage: $0 [-help] [-debug] [-v] [-c] [-s] [-p] [-v11] [-v10] [-v9] [-v8] [-v7] [-32] [-64]" |
ohair@263 | 241 | while [ $# -gt 0 ] ; do |
ohair@263 | 242 | if [ "$1" = "-help" ] ; then |
ohair@263 | 243 | msg "${usage}" |
ohair@263 | 244 | msg " -help Print out this help message" |
ohair@263 | 245 | msg " -debug Print out extra env variables to help debug this script" |
ohair@263 | 246 | msg " -v Verbose output warns about missing directories" |
ohair@263 | 247 | msg " -c Print out csh style output" |
ohair@263 | 248 | msg " -s Print out sh style output" |
ohair@263 | 249 | msg " -p Print out properties style output" |
anthony@498 | 250 | msg " -v11 Use Visual Studio 11 VS2012" |
ohair@263 | 251 | msg " -v10 Use Visual Studio 10 VS2010" |
ohair@263 | 252 | msg " -v9 Use Visual Studio 9 VS2008" |
ohair@263 | 253 | msg " -v8 Use Visual Studio 8 VS2005" |
ohair@263 | 254 | msg " -v7 Use Visual Studio 7 VS2003" |
ohair@263 | 255 | msg " -32 Force 32bit" |
ohair@263 | 256 | msg " -64 Force 64bit" |
ohair@263 | 257 | exit 0 |
ohair@263 | 258 | elif [ "$1" = "-debug" ] ; then |
ohair@263 | 259 | debug="true" |
ohair@263 | 260 | shift |
ohair@263 | 261 | elif [ "$1" = "-v" ] ; then |
ohair@263 | 262 | verbose="true" |
ohair@263 | 263 | shift |
ohair@263 | 264 | elif [ "$1" = "-c" ] ; then |
ohair@263 | 265 | shellStyle="csh" |
ohair@263 | 266 | shift |
ohair@263 | 267 | elif [ "$1" = "-s" ] ; then |
ohair@263 | 268 | shellStyle="sh" |
ohair@263 | 269 | shift |
ohair@263 | 270 | elif [ "$1" = "-p" ] ; then |
ohair@263 | 271 | shellStyle="props" |
ohair@263 | 272 | shift |
anthony@498 | 273 | elif [ "$1" = "-v11" ] ; then |
anthony@498 | 274 | vcBin32Dir="${vc11Bin32Dir}" |
anthony@498 | 275 | vcBin64Dir="${vc11Bin64Dir}" |
anthony@498 | 276 | vcvars32Bat="${vc11vars32Bat}" |
anthony@498 | 277 | vcvars64Bat="${vc11vars64Bat}" |
anthony@498 | 278 | vcSelection="11" |
anthony@498 | 279 | shift |
ohair@263 | 280 | elif [ "$1" = "-v10" ] ; then |
ohair@263 | 281 | vcBin32Dir="${vc10Bin32Dir}" |
ohair@263 | 282 | vcBin64Dir="${vc10Bin64Dir}" |
ohair@263 | 283 | vcvars32Bat="${vc10vars32Bat}" |
ohair@263 | 284 | vcvars64Bat="${vc10vars64Bat}" |
ohair@263 | 285 | vcSelection="10" |
ohair@263 | 286 | shift |
ohair@263 | 287 | elif [ "$1" = "-v9" ] ; then |
ohair@263 | 288 | vcBin32Dir="${vc9Bin32Dir}" |
ohair@263 | 289 | vcBin64Dir="${vc9Bin64Dir}" |
ohair@263 | 290 | vcvars32Bat="${vc9vars32Bat}" |
ohair@263 | 291 | vcvars64Bat="${vc9vars64Bat}" |
ohair@263 | 292 | vcSelection="9" |
ohair@263 | 293 | shift |
ohair@263 | 294 | elif [ "$1" = "-v8" ] ; then |
ohair@263 | 295 | vcBin32Dir="${vc8Bin32Dir}" |
ohair@263 | 296 | vcBin64Dir="${vc8Bin64Dir}" |
ohair@263 | 297 | vcvars32Bat="${vc8vars32Bat}" |
ohair@263 | 298 | vcvars64Bat="${vc8vars64Bat}" |
ohair@263 | 299 | vcSelection="8" |
ohair@263 | 300 | shift |
ohair@263 | 301 | elif [ "$1" = "-v7" ] ; then |
ohair@263 | 302 | vcBin32Dir="${vc7Bin32Dir}" |
ohair@263 | 303 | vcBin64Dir="${vc7Bin64Dir}" |
ohair@263 | 304 | vcvars32Bat="${vc7vars32Bat}" |
ohair@263 | 305 | vcvars64Bat="${vc7vars64Bat}" |
ohair@263 | 306 | vcSelection="7" |
ohair@263 | 307 | shift |
ohair@263 | 308 | elif [ "$1" = "-32" ] ; then |
ohair@263 | 309 | arch_data_model=32 |
ohair@263 | 310 | shift |
ohair@263 | 311 | elif [ "$1" = "-64" ] ; then |
ohair@263 | 312 | arch_data_model=64 |
ohair@263 | 313 | shift |
ohair@263 | 314 | else |
ohair@263 | 315 | msg "${usage}" |
ohair@263 | 316 | error "Unknown option: $1" |
ohair@263 | 317 | fi |
ohair@263 | 318 | done |
ohair@263 | 319 | |
ohair@263 | 320 | # Need to pick |
ohair@263 | 321 | if [ "${vcSelection}" = "" ] ; then |
ohair@263 | 322 | msg "${usage}" |
ohair@263 | 323 | error "You must pick the version" |
ohair@263 | 324 | fi |
ohair@263 | 325 | |
ohair@263 | 326 | # Which vcvars bat file to run |
ohair@263 | 327 | if [ "${arch_data_model}" = "32" ] ; then |
ohair@263 | 328 | vcBinDir="${vcBin32Dir}" |
ohair@263 | 329 | vcvarsBat="${vcvars32Bat}" |
ohair@263 | 330 | fi |
ohair@263 | 331 | if [ "${arch_data_model}" = "64" ] ; then |
ohair@263 | 332 | vcBinDir="${vcBin64Dir}" |
ohair@263 | 333 | vcvarsBat="${vcvars64Bat}" |
ohair@263 | 334 | fi |
ohair@263 | 335 | |
ohair@263 | 336 | # Do not allow any error returns |
ohair@263 | 337 | set -e |
ohair@263 | 338 | |
ohair@263 | 339 | # Different systems have different awk's |
ohair@263 | 340 | if [ -f /usr/bin/nawk ] ; then |
ohair@263 | 341 | awk="nawk" |
ohair@263 | 342 | elif [ -f /usr/bin/gawk ] ; then |
ohair@263 | 343 | awk="gawk" |
ohair@263 | 344 | else |
ohair@263 | 345 | awk="awk" |
ohair@263 | 346 | fi |
ohair@263 | 347 | |
ohair@263 | 348 | if [ "${verbose}" = "true" ] ; then |
ohair@263 | 349 | echo "# Welcome to verbose mode" |
ohair@263 | 350 | set -x |
ohair@263 | 351 | fi |
ohair@263 | 352 | |
ohair@263 | 353 | if [ "${debug}" = "true" ] ; then |
ohair@263 | 354 | echo "# Welcome to debug mode" |
ohair@263 | 355 | set -x |
ohair@263 | 356 | fi |
ohair@263 | 357 | |
ohair@263 | 358 | # Temp file area |
ohair@263 | 359 | tmp="/tmp/vsvars.$$" |
ohair@263 | 360 | rm -f -r ${tmp} |
ohair@263 | 361 | mkdir -p ${tmp} |
ohair@263 | 362 | |
ohair@263 | 363 | # Check paths |
ohair@263 | 364 | checkPaths() # var path sep |
ohair@263 | 365 | { |
ohair@263 | 366 | set -e |
ohair@263 | 367 | sep="$3" |
ohair@263 | 368 | checklist="${tmp}/checklist" |
ohair@263 | 369 | printf "%s\n" "$2" | \ |
ohair@263 | 370 | sed -e 's@\\@/@g' | \ |
ohair@263 | 371 | sed -e 's@//@/@g' | \ |
ohair@263 | 372 | ${awk} -F"${sep}" '{for(i=1;i<=NF;i++){printf "%s\n",$i;}}' \ |
ohair@263 | 373 | > ${checklist} |
ohair@263 | 374 | cat ${checklist} | while read orig; do |
ohair@263 | 375 | if [ "${orig}" != "" ] ; then |
ohair@263 | 376 | if [ ! -d "${orig}" ] ; then |
ohair@263 | 377 | warning "Directory in $1 does not exist: ${orig}" |
ohair@263 | 378 | fi |
ohair@263 | 379 | fi |
ohair@263 | 380 | done |
ohair@263 | 381 | } |
ohair@263 | 382 | |
ohair@263 | 383 | # Remove all duplicate entries |
tbell@487 | 384 | removeDeadDups() # string sepIn sepOut |
ohair@263 | 385 | { |
ohair@263 | 386 | set -e |
tbell@487 | 387 | sepIn="$2" |
tbell@487 | 388 | sepOut="$3" |
ohair@263 | 389 | pathlist="${tmp}/pathlist" |
ohair@263 | 390 | printf "%s\n" "$1" | \ |
ohair@263 | 391 | sed -e 's@\\@/@g' | \ |
ohair@263 | 392 | sed -e 's@//@/@g' | \ |
tbell@487 | 393 | ${awk} -F"${sepIn}" '{for(i=1;i<=NF;i++){printf "%s\n",$i;}}' \ |
ohair@263 | 394 | > ${pathlist} |
ohair@263 | 395 | upaths="${tmp}/upaths" |
ohair@263 | 396 | cat ${pathlist} | while read orig; do |
ohair@263 | 397 | p="${orig}" |
tbell@487 | 398 | if [ "${fixpath}" != "" ] ; then |
ohair@263 | 399 | if [ "${p}" != "" ] ; then |
ohair@263 | 400 | if [ -d "${p}" ] ; then |
tbell@487 | 401 | short=`${fixpath} "${p}"` |
ohair@263 | 402 | if [ "${short}" != "" -a -d "${short}" ] ; then |
tbell@487 | 403 | p="${short}" |
ohair@263 | 404 | fi |
ohair@263 | 405 | echo "${p}" >> ${upaths} |
ohair@263 | 406 | fi |
ohair@263 | 407 | fi |
ohair@263 | 408 | fi |
ohair@263 | 409 | done |
ohair@263 | 410 | newpaths="" |
ohair@263 | 411 | for i in `cat ${upaths}` ; do |
ohair@263 | 412 | # For some reason, \r characters can get into this |
ohair@263 | 413 | i=`echo "${i}" | tr -d '\r' | sed -e 's@/$@@'` |
ohair@263 | 414 | if [ "${newpaths}" = "" ] ; then |
ohair@263 | 415 | newpaths="${i}" |
ohair@263 | 416 | else |
tbell@487 | 417 | newpaths="${newpaths}${sepOut}${i}" |
ohair@263 | 418 | fi |
ohair@263 | 419 | done |
ohair@263 | 420 | printf "%s\n" "${newpaths}" | \ |
tbell@487 | 421 | ${awk} -F"${sepOut}" \ |
ohair@263 | 422 | '{a[$1];printf "%s",$1;for(i=2;i<=NF;i++){if(!($i in a)){a[$i];printf "%s%s",FS,$i;}};printf "\n";}' |
ohair@263 | 423 | } |
ohair@263 | 424 | |
ohair@263 | 425 | # Create bat file to process Visual Studio vcvars*.bat files |
ohair@263 | 426 | createBat() # batfile bindir command |
ohair@263 | 427 | { |
ohair@263 | 428 | bat="$1" |
ohair@263 | 429 | bindir="$2" |
ohair@263 | 430 | command="$3" |
ohair@263 | 431 | stdout="${bat}.stdout" |
ohair@263 | 432 | rm -f ${bat} ${stdout} |
ohair@263 | 433 | echo "Output from: ${command}" > ${stdout} |
ohair@263 | 434 | bdir=`envpath "${bindir}"` |
ohair@263 | 435 | cat > ${bat} << EOF |
ohair@263 | 436 | REM Pick the right vcvars bat file |
ohair@263 | 437 | REM Empty these out so we only get the additions we want |
ohair@263 | 438 | set INCLUDE= |
ohair@263 | 439 | set LIB= |
ohair@263 | 440 | set LIBPATH= |
ohair@263 | 441 | set MSVCDIR= |
ohair@263 | 442 | set MSSdk= |
ohair@263 | 443 | set Mstools= |
ohair@263 | 444 | set DevEnvDir= |
ohair@263 | 445 | set VCINSTALLDIR= |
ohair@263 | 446 | set VSINSTALLDIR= |
ohair@263 | 447 | set WindowsSdkDir= |
ohair@263 | 448 | REM Run the vcvars bat file, send all output to stderr |
tbell@487 | 449 | call `${fixpath_windows} ${bdir}`\\${command} > `${fixpath_windows} "${stdout}"` |
ohair@263 | 450 | REM Echo out env var settings |
ohair@263 | 451 | echo VS_VS71COMNTOOLS="%VS71COMNTOOLS%" |
ohair@263 | 452 | echo export VS_VS71COMNTOOLS |
ohair@263 | 453 | echo VS_VS80COMNTOOLS="%VS80COMNTOOLS%" |
ohair@263 | 454 | echo export VS_VS80COMNTOOLS |
ohair@263 | 455 | echo VS_VS90COMNTOOLS="%VS90COMNTOOLS%" |
ohair@263 | 456 | echo export VS_VS90COMNTOOLS |
ohair@263 | 457 | echo VS_VS100COMNTOOLS="%VS100COMNTOOLS%" |
ohair@263 | 458 | echo export VS_VS100COMNTOOLS |
anthony@498 | 459 | echo VS_VS110COMNTOOLS="%VS110COMNTOOLS%" |
anthony@498 | 460 | echo export VS_VS110COMNTOOLS |
ohair@263 | 461 | echo VS_VCINSTALLDIR="%VCINSTALLDIR%" |
ohair@263 | 462 | echo export VS_VCINSTALLDIR |
ohair@263 | 463 | echo VS_VSINSTALLDIR="%VSINSTALLDIR%" |
ohair@263 | 464 | echo export VS_VSINSTALLDIR |
ohair@263 | 465 | echo VS_DEVENVDIR="%DevEnvDir%" |
ohair@263 | 466 | echo export VS_DEVENVDIR |
ohair@263 | 467 | echo VS_MSVCDIR="%MSVCDIR%" |
ohair@263 | 468 | echo export VS_MSVCDIR |
ohair@263 | 469 | echo VS_MSSDK="%MSSdk%" |
ohair@263 | 470 | echo export VS_MSSDK |
ohair@263 | 471 | echo VS_MSTOOLS="%Mstools%" |
ohair@263 | 472 | echo export VS_MSTOOLS |
ohair@263 | 473 | echo VS_WINDOWSSDKDIR="%WindowsSdkDir%" |
ohair@263 | 474 | echo export VS_WINDOWSSDKDIR |
ohair@263 | 475 | echo VS_INCLUDE="%INCLUDE%" |
ohair@263 | 476 | echo export VS_INCLUDE |
ohair@263 | 477 | echo VS_LIB="%LIB%" |
ohair@263 | 478 | echo export VS_LIB |
ohair@263 | 479 | echo VS_LIBPATH="%LIBPATH%" |
ohair@263 | 480 | echo export VS_LIBPATH |
ohair@263 | 481 | echo VS_WPATH="%PATH%" |
ohair@263 | 482 | echo export VS_WPATH |
ohair@263 | 483 | EOF |
ohair@263 | 484 | chmod a+x ${bat} |
ohair@263 | 485 | } |
ohair@263 | 486 | |
ohair@263 | 487 | # Create env file |
ohair@263 | 488 | createEnv() # batfile envfile |
ohair@263 | 489 | { |
tbell@487 | 490 | rm -f ${1}.stdout ${1}.temp1 ${1}.temp2 |
tbell@487 | 491 | batfile=`${fixpath} ${1}` |
tbell@487 | 492 | cmd.exe -Q -C < "$batfile" 1> ${1}.temp1 2> ${1}.temp2 |
tbell@487 | 493 | cat ${1}.temp1 | \ |
tbell@487 | 494 | sed -e 's@^Microsoft.*@@' \ |
tbell@487 | 495 | -e 's@^.*Copyright.*@@' \ |
tbell@487 | 496 | -e 's@^.*>REM.*@@' \ |
tbell@487 | 497 | -e 's@^.*>set.*@@' \ |
tbell@487 | 498 | -e 's@^.*>echo.*@@' \ |
tbell@487 | 499 | -e 's@^.*>call.*@@' \ |
tbell@487 | 500 | -e 's@^.*>$@@' \ |
tbell@487 | 501 | -e 's@\\@/@g' | \ |
ohair@263 | 502 | sed -e 's@//@/@g' > $2 |
ohair@263 | 503 | if [ -f "${1}.stdout" ] ; then |
ohair@263 | 504 | cat ${1}.stdout 1>&2 |
ohair@263 | 505 | fi |
ohair@263 | 506 | chmod a+x $2 |
ohair@263 | 507 | } |
ohair@263 | 508 | |
ohair@263 | 509 | printEnv() # name pname vsname val |
ohair@263 | 510 | { |
ohair@263 | 511 | name="$1" |
ohair@263 | 512 | pname="$2" |
ohair@263 | 513 | vsname="$3" |
ohair@263 | 514 | val="$4" |
ohair@263 | 515 | if [ "${val}" != "" ] ; then |
ohair@263 | 516 | if [ "${shellStyle}" = "csh" ] ; then |
ohair@263 | 517 | if [ "${debug}" = "true" ] ; then |
ohair@263 | 518 | echo "setenv ${vsname} \"${val}\";" |
ohair@263 | 519 | fi |
ohair@263 | 520 | echo "setenv ${name} \"${val}\";" |
ohair@263 | 521 | elif [ "${shellStyle}" = "sh" ] ; then |
ohair@263 | 522 | if [ "${debug}" = "true" ] ; then |
ohair@263 | 523 | echo "${vsname}=\"${val}\";" |
ohair@263 | 524 | echo "export ${vsname};" |
ohair@263 | 525 | fi |
ohair@263 | 526 | echo "${name}=\"${val}\";" |
ohair@263 | 527 | echo "export ${name};" |
ohair@263 | 528 | elif [ "${shellStyle}" = "props" ] ; then |
ohair@263 | 529 | echo "vs.${pname}=${val}" |
ohair@263 | 530 | fi |
ohair@263 | 531 | fi |
ohair@263 | 532 | } |
ohair@263 | 533 | |
ohair@263 | 534 | ############################################################################# |
ohair@263 | 535 | |
ohair@263 | 536 | # Get Visual Studio settings |
tbell@487 | 537 | if [ "${fixpath}" != "" ] ; then |
ohair@263 | 538 | |
ohair@263 | 539 | # Create bat file to run |
ohair@263 | 540 | batfile="${tmp}/vs-to-env.bat" |
ohair@263 | 541 | if [ ! -d "${vcBinDir}" ] ; then |
ohair@263 | 542 | error "Does not exist: ${vcBinDir}" |
ohair@263 | 543 | elif [ "${vcvarsBat}" = "" ] ; then |
ohair@263 | 544 | error "No vcvars script: ${vcvarsBat}" |
ohair@263 | 545 | else |
ohair@263 | 546 | createBat "${batfile}" "${vcBinDir}" "${vcvarsBat}" |
ohair@263 | 547 | fi |
ohair@263 | 548 | |
ohair@263 | 549 | # Run bat file to create environment variable settings |
ohair@263 | 550 | envfile="${tmp}/env.sh" |
ohair@263 | 551 | createEnv "${batfile}" "${envfile}" |
ohair@263 | 552 | |
ohair@263 | 553 | # Read in the VS_* settings |
ohair@263 | 554 | . ${envfile} |
ohair@263 | 555 | |
ohair@263 | 556 | # Derive unix style path, save old, and define new (remove dups) |
tbell@487 | 557 | VS_UPATH=`${fixpath_path} "${VS_WPATH}"` |
ohair@263 | 558 | export VS_UPATH |
ohair@263 | 559 | VS_OPATH=`printf "%s" "${PATH}" | sed -e 's@\\\\@/@g'` |
ohair@263 | 560 | export VS_OPATH |
tbell@487 | 561 | VS_PATH=`removeDeadDups "${VS_UPATH}${pathsepIn}${VS_OPATH}" "${pathsepIn}" "${pathsepOut}"` |
ohair@263 | 562 | export VS_PATH |
ohair@263 | 563 | |
ohair@263 | 564 | fi |
ohair@263 | 565 | |
ohair@263 | 566 | # Adjustments due to differences in vcvars*bat files |
ohair@263 | 567 | if [ "${VS_MSVCDIR}" = "" ] ; then |
ohair@263 | 568 | VS_MSVCDIR="${VS_VCINSTALLDIR}" |
ohair@263 | 569 | fi |
ohair@263 | 570 | if [ "${VS_DEVENVDIR}" = "" ] ; then |
ohair@263 | 571 | VS_DEVENVDIR="${VS_VSINSTALLDIR}" |
ohair@263 | 572 | fi |
ohair@263 | 573 | |
ohair@263 | 574 | # Print env settings |
ohair@263 | 575 | # env vs.prop vs env value |
ohair@263 | 576 | # ------- ------- ---------- ----- |
ohair@263 | 577 | printEnv INCLUDE include VS_INCLUDE "${VS_INCLUDE}" |
ohair@263 | 578 | printEnv LIB lib VS_LIB "${VS_LIB}" |
ohair@263 | 579 | printEnv LIBPATH libpath VS_LIBPATH "${VS_LIBPATH}" |
ohair@263 | 580 | if [ "${debug}" = "true" ] ; then |
ohair@263 | 581 | printEnv UPATH upath VS_UPATH "${VS_UPATH}" |
ohair@263 | 582 | printEnv WPATH wpath VS_WPATH "${VS_WPATH}" |
ohair@263 | 583 | printEnv OPATH opath VS_OPATH "${VS_OPATH}" |
ohair@263 | 584 | fi |
ohair@263 | 585 | printEnv PATH path VS_PATH "${VS_PATH}" |
ohair@263 | 586 | printEnv VCINSTALLDIR vcinstalldir VS_VCINSTALLDIR "${VS_VCINSTALLDIR}" |
ohair@263 | 587 | printEnv VSINSTALLDIR vsinstalldir VS_VSINSTALLDIR "${VS_VSINSTALLDIR}" |
ohair@263 | 588 | printEnv MSVCDIR msvcdir VS_MSVCDIR "${VS_MSVCDIR}" |
ohair@263 | 589 | printEnv MSSDK mssdk VS_MSSDK "${VS_MSSDK}" |
ohair@263 | 590 | printEnv MSTOOLS mstools VS_MSTOOLS "${VS_MSTOOLS}" |
ohair@263 | 591 | printEnv DEVENVDIR devenvdir VS_DEVENVDIR "${VS_DEVENVDIR}" |
ohair@263 | 592 | printEnv WINDOWSSDKDIR windowssdkdir VS_WINDOWSSDKDIR "${VS_WINDOWSSDKDIR}" |
anthony@498 | 593 | if [ "${vcSelection}" = "11" ] ; then |
anthony@498 | 594 | printEnv VS110COMNTOOLS vs110comntools VS_VS110COMNTOOLS "${VS_VS110COMNTOOLS}" |
anthony@498 | 595 | elif [ "${vcSelection}" = "10" ] ; then |
ohair@263 | 596 | printEnv VS100COMNTOOLS vs100comntools VS_VS100COMNTOOLS "${VS_VS100COMNTOOLS}" |
ohair@263 | 597 | elif [ "${vcSelection}" = "9" ] ; then |
ohair@263 | 598 | printEnv VS90COMNTOOLS vs90comntools VS_VS90COMNTOOLS "${VS_VS90COMNTOOLS}" |
ohair@263 | 599 | elif [ "${vcSelection}" = "7" ] ; then |
ohair@263 | 600 | printEnv VS71COMNTOOLS vs71comntools VS_VS71COMNTOOLS "${VS_VS71COMNTOOLS}" |
ohair@263 | 601 | elif [ "${vcSelection}" = "8" ] ; then |
ohair@263 | 602 | printEnv VS80COMNTOOLS vs80comntools VS_VS80COMNTOOLS "${VS_VS80COMNTOOLS}" |
ohair@263 | 603 | fi |
ohair@263 | 604 | |
ohair@263 | 605 | # Check final settings |
ohair@263 | 606 | if [ "${verbose}" = "true" ] ; then |
ohair@263 | 607 | checkPaths "Windows PATH" "${VS_WPATH}" ";" |
ohair@263 | 608 | checkPaths LIB "${VS_LIB}" ";" |
ohair@263 | 609 | checkPaths INCLUDE "${VS_INCLUDE}" ";" |
tbell@487 | 610 | checkPaths PATH "${VS_PATH}" "${pathsepIn}" |
ohair@263 | 611 | fi |
ohair@263 | 612 | |
ohair@263 | 613 | # Remove all temp files |
tbell@487 | 614 | if [ "${debug}" != "true" ] ; then |
tbell@487 | 615 | rm -f -r ${tmp} |
tbell@487 | 616 | fi |
ohair@263 | 617 | |
ohair@263 | 618 | exit 0 |
ohair@263 | 619 |