Tue, 13 Sep 2011 08:37:34 -0700
Merge
ohair@263 | 1 | #!/bin/sh |
ohair@263 | 2 | |
ohair@263 | 3 | # |
ohair@263 | 4 | # Copyright (c) 2009, 2010, 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 | # Use cygpath? |
ohair@263 | 31 | isCygwin="`uname -s | grep CYGWIN`" |
ohair@263 | 32 | if [ "${isCygwin}" != "" ] ; then |
ohair@263 | 33 | cygpath="/usr/bin/cygpath" |
ohair@263 | 34 | cygpath_short="${cygpath} -m -s" |
ohair@263 | 35 | cygpath_windows="${cygpath} -w -s" |
ohair@263 | 36 | cygpath_path="${cygpath} -p" |
ohair@263 | 37 | pathsep=':' |
ohair@263 | 38 | else |
ohair@263 | 39 | cygpath="dosname" |
ohair@263 | 40 | cygpath_short="${cygpath} -s" |
ohair@263 | 41 | cygpath_windows="${cygpath} -s" |
ohair@263 | 42 | cygpath_path="echo" |
ohair@263 | 43 | pathsep=';' |
ohair@263 | 44 | fi |
ohair@263 | 45 | |
ohair@263 | 46 | ######################################################################## |
ohair@263 | 47 | # Error functions |
ohair@263 | 48 | msg() # message |
ohair@263 | 49 | { |
ohair@263 | 50 | echo "$1" 1>&2 |
ohair@263 | 51 | } |
ohair@263 | 52 | error() # message |
ohair@263 | 53 | { |
ohair@263 | 54 | msg "ERROR: $1" |
ohair@263 | 55 | exit 1 |
ohair@263 | 56 | } |
ohair@263 | 57 | warning() # message |
ohair@263 | 58 | { |
ohair@263 | 59 | msg "WARNING: $1" |
ohair@263 | 60 | } |
ohair@263 | 61 | envpath() # path |
ohair@263 | 62 | { |
ohair@263 | 63 | if [ "${cygpath_short}" != "" -a -d "$1" ] ; then |
ohair@263 | 64 | ${cygpath_short} "$1" |
ohair@263 | 65 | else |
ohair@263 | 66 | echo "$1" |
ohair@263 | 67 | fi |
ohair@263 | 68 | } |
ohair@263 | 69 | ######################################################################## |
ohair@263 | 70 | |
ohair@263 | 71 | |
ohair@263 | 72 | # Defaults settings |
ohair@263 | 73 | debug="false" |
ohair@263 | 74 | verbose="false" |
ohair@263 | 75 | shellStyle="sh" |
ohair@263 | 76 | parentCsh="` ps -p ${PPID} 2> /dev/null | grep csh `" |
ohair@263 | 77 | if [ "${parentCsh}" != "" ] ; then |
ohair@263 | 78 | shellStyle="csh" |
ohair@263 | 79 | fi |
ohair@263 | 80 | |
ohair@263 | 81 | set -e |
ohair@263 | 82 | |
ohair@263 | 83 | # Check environment first |
ohair@263 | 84 | if [ "${PROGRAMFILES}" != "" ] ; then |
ohair@263 | 85 | progfiles=`envpath "${PROGRAMFILES}"` |
ohair@263 | 86 | elif [ "${ProgramFiles}" != "" ] ; then |
ohair@263 | 87 | progfiles=`envpath "${ProgramFiles}"` |
ohair@263 | 88 | elif [ "${SYSTEMDRIVE}" != "" ] ; then |
ohair@263 | 89 | progfiles=`envpath "${SYSTEMDRIVE}/Program Files"` |
ohair@263 | 90 | elif [ "${SystemDrive}" != "" ] ; then |
ohair@263 | 91 | progfiles=`envpath "${SystemDrive}/Program Files"` |
ohair@263 | 92 | else |
ohair@263 | 93 | error "No PROGRAMFILES or SYSTEMDRIVE defined in environment" |
ohair@263 | 94 | fi |
ohair@263 | 95 | |
ohair@263 | 96 | # Arch data model |
ohair@263 | 97 | if [ "${PROCESSOR_IDENTIFIER}" != "" ] ; then |
ohair@263 | 98 | arch=`echo "${PROCESSOR_IDENTIFIER}" | cut -d' ' -f1` |
ohair@263 | 99 | elif [ "${MACHTYPE}" != "" ] ; then |
ohair@263 | 100 | if [ "`echo ${MACHTYPE} | grep 64`" != "" ] ; then |
ohair@263 | 101 | # Assume this is X64, not IA64 |
ohair@263 | 102 | arch="x64" |
ohair@263 | 103 | else |
ohair@263 | 104 | arch="x86" |
ohair@263 | 105 | fi |
ohair@263 | 106 | else |
ohair@263 | 107 | arch="`uname -m`" |
ohair@263 | 108 | fi |
ohair@263 | 109 | if [ "${arch}" = "X86" -o \ |
ohair@263 | 110 | "${arch}" = "386" -o "${arch}" = "i386" -o \ |
ohair@263 | 111 | "${arch}" = "486" -o "${arch}" = "i486" -o \ |
ohair@263 | 112 | "${arch}" = "586" -o "${arch}" = "i586" -o \ |
ohair@263 | 113 | "${arch}" = "686" -o "${arch}" = "i686" -o \ |
ohair@263 | 114 | "${arch}" = "86" ] ; then |
ohair@263 | 115 | arch="x86" |
ohair@263 | 116 | fi |
ohair@263 | 117 | if [ "${arch}" = "X64" -o \ |
ohair@263 | 118 | "${arch}" = "8664" -o "${arch}" = "i8664" -o \ |
ohair@263 | 119 | "${arch}" = "amd64" -o "${arch}" = "AMD64" -o \ |
ohair@263 | 120 | "${arch}" = "EM64T" -o "${arch}" = "emt64t" -o \ |
ohair@263 | 121 | "${arch}" = "intel64" -o "${arch}" = "Intel64" -o \ |
ohair@263 | 122 | "${arch}" = "64" ] ; then |
ohair@263 | 123 | arch="x64" |
ohair@263 | 124 | binarch64="/amd64" |
ohair@263 | 125 | fi |
ohair@263 | 126 | if [ "${arch}" = "IA64" ] ; then |
ohair@263 | 127 | arch="ia64" |
ohair@263 | 128 | binarch64="/ia64" |
ohair@263 | 129 | fi |
ohair@263 | 130 | if [ "${arch}" != "x86" -a "${arch}" != "x64" -a "${arch}" != "ia64" ] ; then |
ohair@263 | 131 | error "No PROCESSOR_IDENTIFIER or MACHTYPE environment variables and uname -m is not helping" |
ohair@263 | 132 | fi |
ohair@263 | 133 | if [ "${arch}" = "x86" ] ; then |
ohair@263 | 134 | arch_data_model=32 |
ohair@263 | 135 | progfiles32="${progfiles}" |
ohair@263 | 136 | progfiles64="${progfiles}" |
ohair@263 | 137 | else |
ohair@263 | 138 | arch_data_model=64 |
ohair@263 | 139 | progfiles32="${progfiles}" |
ohair@263 | 140 | if [ "${PROGRAMW6432}" != "" ] ; then |
ohair@263 | 141 | progfiles64=`envpath "${PROGRAMW6432}"` |
ohair@263 | 142 | else |
ohair@263 | 143 | progfiles64=`envpath "C:/Program Files"` |
ohair@263 | 144 | fi |
ohair@263 | 145 | fi |
ohair@263 | 146 | |
ohair@263 | 147 | # VS2010 (VC10) |
ohair@263 | 148 | if [ "${VS100COMNTOOLS}" = "" ] ; then |
ohair@263 | 149 | VS100COMNTOOLS="${progfiles32}/Microsoft Visual Studio 10.0/Common7/Tools/" |
ohair@263 | 150 | export VS100COMNTOOLS |
ohair@263 | 151 | fi |
ohair@263 | 152 | vc10Bin32Dir=`envpath "${VS100COMNTOOLS}"`/../../VC/Bin |
ohair@263 | 153 | vc10Bin64Dir="${vc10Bin32Dir}${binarch64}" |
ohair@263 | 154 | vc10vars32Bat="vcvars32.bat" |
ohair@263 | 155 | vc10vars64Bat="vcvars64.bat" |
ohair@263 | 156 | |
ohair@263 | 157 | # VS2008 (VC9) |
ohair@263 | 158 | if [ "${VS90COMNTOOLS}" = "" ] ; then |
ohair@263 | 159 | VS90COMNTOOLS="${progfiles32}/Microsoft Visual Studio 9.0/Common7/Tools/" |
ohair@263 | 160 | export VS90COMNTOOLS |
ohair@263 | 161 | fi |
ohair@263 | 162 | vc9Bin32Dir=`envpath "${VS90COMNTOOLS}"`/../../VC/Bin |
ohair@263 | 163 | vc9Bin64Dir="${vc9Bin32Dir}" |
ohair@263 | 164 | vc9vars32Bat="vcvars32.bat" |
ohair@263 | 165 | vc9vars64Bat="vcvars64.bat" |
ohair@263 | 166 | |
ohair@263 | 167 | # VS2005 (VC8) |
ohair@263 | 168 | if [ "${VS80COMNTOOLS}" = "" ] ; then |
ohair@263 | 169 | VS80COMNTOOLS="${progfiles32}/Microsoft Visual Studio 8.0/Common7/Tools/" |
ohair@263 | 170 | export VS80COMNTOOLS |
ohair@263 | 171 | fi |
ohair@263 | 172 | vc8Bin32Dir=`envpath "${VS80COMNTOOLS}"`/../../VC/Bin |
ohair@263 | 173 | vc8Bin64Dir="${progfiles64}/Microsoft Platform SDK" |
ohair@263 | 174 | vc8vars32Bat="vcvars32.bat" |
ohair@263 | 175 | vc8vars64Bat="SetEnv.cmd /X64" |
ohair@263 | 176 | |
ohair@263 | 177 | # VS2003 (VC7) |
ohair@263 | 178 | if [ "${VS71COMNTOOLS}" = "" ] ; then |
ohair@263 | 179 | VS71COMNTOOLS="${progfiles32}/Microsoft Visual Studio .NET 2003/Common7/Tools/" |
ohair@263 | 180 | export VS71COMNTOOLS |
ohair@263 | 181 | fi |
ohair@263 | 182 | vc7Bin32Dir=`envpath "${VS71COMNTOOLS}"`/../../VC7/Bin |
ohair@263 | 183 | vc7Bin64Dir="${progfiles64}/Microsoft Platform SDK" |
ohair@263 | 184 | vc7vars32Bat="vcvars32.bat" |
ohair@263 | 185 | vc7vars64Bat="SetEnv.cmd /X64" |
ohair@263 | 186 | |
ohair@263 | 187 | # Force user to select |
ohair@263 | 188 | vcSelection="" |
ohair@263 | 189 | |
ohair@263 | 190 | # Parse options |
ohair@263 | 191 | usage="Usage: $0 [-help] [-debug] [-v] [-c] [-s] [-p] [-v10] [-v9] [-v8] [-v7] [-32] [-64]" |
ohair@263 | 192 | while [ $# -gt 0 ] ; do |
ohair@263 | 193 | if [ "$1" = "-help" ] ; then |
ohair@263 | 194 | msg "${usage}" |
ohair@263 | 195 | msg " -help Print out this help message" |
ohair@263 | 196 | msg " -debug Print out extra env variables to help debug this script" |
ohair@263 | 197 | msg " -v Verbose output warns about missing directories" |
ohair@263 | 198 | msg " -c Print out csh style output" |
ohair@263 | 199 | msg " -s Print out sh style output" |
ohair@263 | 200 | msg " -p Print out properties style output" |
ohair@263 | 201 | msg " -v10 Use Visual Studio 10 VS2010" |
ohair@263 | 202 | msg " -v9 Use Visual Studio 9 VS2008" |
ohair@263 | 203 | msg " -v8 Use Visual Studio 8 VS2005" |
ohair@263 | 204 | msg " -v7 Use Visual Studio 7 VS2003" |
ohair@263 | 205 | msg " -32 Force 32bit" |
ohair@263 | 206 | msg " -64 Force 64bit" |
ohair@263 | 207 | exit 0 |
ohair@263 | 208 | elif [ "$1" = "-debug" ] ; then |
ohair@263 | 209 | debug="true" |
ohair@263 | 210 | shift |
ohair@263 | 211 | elif [ "$1" = "-v" ] ; then |
ohair@263 | 212 | verbose="true" |
ohair@263 | 213 | shift |
ohair@263 | 214 | elif [ "$1" = "-c" ] ; then |
ohair@263 | 215 | shellStyle="csh" |
ohair@263 | 216 | shift |
ohair@263 | 217 | elif [ "$1" = "-s" ] ; then |
ohair@263 | 218 | shellStyle="sh" |
ohair@263 | 219 | shift |
ohair@263 | 220 | elif [ "$1" = "-p" ] ; then |
ohair@263 | 221 | shellStyle="props" |
ohair@263 | 222 | shift |
ohair@263 | 223 | elif [ "$1" = "-v10" ] ; then |
ohair@263 | 224 | vcBin32Dir="${vc10Bin32Dir}" |
ohair@263 | 225 | vcBin64Dir="${vc10Bin64Dir}" |
ohair@263 | 226 | vcvars32Bat="${vc10vars32Bat}" |
ohair@263 | 227 | vcvars64Bat="${vc10vars64Bat}" |
ohair@263 | 228 | vcSelection="10" |
ohair@263 | 229 | shift |
ohair@263 | 230 | elif [ "$1" = "-v9" ] ; then |
ohair@263 | 231 | vcBin32Dir="${vc9Bin32Dir}" |
ohair@263 | 232 | vcBin64Dir="${vc9Bin64Dir}" |
ohair@263 | 233 | vcvars32Bat="${vc9vars32Bat}" |
ohair@263 | 234 | vcvars64Bat="${vc9vars64Bat}" |
ohair@263 | 235 | vcSelection="9" |
ohair@263 | 236 | shift |
ohair@263 | 237 | elif [ "$1" = "-v8" ] ; then |
ohair@263 | 238 | vcBin32Dir="${vc8Bin32Dir}" |
ohair@263 | 239 | vcBin64Dir="${vc8Bin64Dir}" |
ohair@263 | 240 | vcvars32Bat="${vc8vars32Bat}" |
ohair@263 | 241 | vcvars64Bat="${vc8vars64Bat}" |
ohair@263 | 242 | vcSelection="8" |
ohair@263 | 243 | shift |
ohair@263 | 244 | elif [ "$1" = "-v7" ] ; then |
ohair@263 | 245 | vcBin32Dir="${vc7Bin32Dir}" |
ohair@263 | 246 | vcBin64Dir="${vc7Bin64Dir}" |
ohair@263 | 247 | vcvars32Bat="${vc7vars32Bat}" |
ohair@263 | 248 | vcvars64Bat="${vc7vars64Bat}" |
ohair@263 | 249 | vcSelection="7" |
ohair@263 | 250 | shift |
ohair@263 | 251 | elif [ "$1" = "-32" ] ; then |
ohair@263 | 252 | arch_data_model=32 |
ohair@263 | 253 | shift |
ohair@263 | 254 | elif [ "$1" = "-64" ] ; then |
ohair@263 | 255 | arch_data_model=64 |
ohair@263 | 256 | shift |
ohair@263 | 257 | else |
ohair@263 | 258 | msg "${usage}" |
ohair@263 | 259 | error "Unknown option: $1" |
ohair@263 | 260 | fi |
ohair@263 | 261 | done |
ohair@263 | 262 | |
ohair@263 | 263 | # Need to pick |
ohair@263 | 264 | if [ "${vcSelection}" = "" ] ; then |
ohair@263 | 265 | msg "${usage}" |
ohair@263 | 266 | error "You must pick the version" |
ohair@263 | 267 | fi |
ohair@263 | 268 | |
ohair@263 | 269 | # Which vcvars bat file to run |
ohair@263 | 270 | if [ "${arch_data_model}" = "32" ] ; then |
ohair@263 | 271 | vcBinDir="${vcBin32Dir}" |
ohair@263 | 272 | vcvarsBat="${vcvars32Bat}" |
ohair@263 | 273 | fi |
ohair@263 | 274 | if [ "${arch_data_model}" = "64" ] ; then |
ohair@263 | 275 | vcBinDir="${vcBin64Dir}" |
ohair@263 | 276 | vcvarsBat="${vcvars64Bat}" |
ohair@263 | 277 | fi |
ohair@263 | 278 | |
ohair@263 | 279 | # Do not allow any error returns |
ohair@263 | 280 | set -e |
ohair@263 | 281 | |
ohair@263 | 282 | # Different systems have different awk's |
ohair@263 | 283 | if [ -f /usr/bin/nawk ] ; then |
ohair@263 | 284 | awk="nawk" |
ohair@263 | 285 | elif [ -f /usr/bin/gawk ] ; then |
ohair@263 | 286 | awk="gawk" |
ohair@263 | 287 | else |
ohair@263 | 288 | awk="awk" |
ohair@263 | 289 | fi |
ohair@263 | 290 | |
ohair@263 | 291 | if [ "${verbose}" = "true" ] ; then |
ohair@263 | 292 | echo "# Welcome to verbose mode" |
ohair@263 | 293 | set -x |
ohair@263 | 294 | fi |
ohair@263 | 295 | |
ohair@263 | 296 | if [ "${debug}" = "true" ] ; then |
ohair@263 | 297 | echo "# Welcome to debug mode" |
ohair@263 | 298 | set -x |
ohair@263 | 299 | fi |
ohair@263 | 300 | |
ohair@263 | 301 | # Temp file area |
ohair@263 | 302 | tmp="/tmp/vsvars.$$" |
ohair@263 | 303 | rm -f -r ${tmp} |
ohair@263 | 304 | mkdir -p ${tmp} |
ohair@263 | 305 | |
ohair@263 | 306 | # Check paths |
ohair@263 | 307 | checkPaths() # var path sep |
ohair@263 | 308 | { |
ohair@263 | 309 | set -e |
ohair@263 | 310 | sep="$3" |
ohair@263 | 311 | checklist="${tmp}/checklist" |
ohair@263 | 312 | printf "%s\n" "$2" | \ |
ohair@263 | 313 | sed -e 's@\\@/@g' | \ |
ohair@263 | 314 | sed -e 's@//@/@g' | \ |
ohair@263 | 315 | ${awk} -F"${sep}" '{for(i=1;i<=NF;i++){printf "%s\n",$i;}}' \ |
ohair@263 | 316 | > ${checklist} |
ohair@263 | 317 | cat ${checklist} | while read orig; do |
ohair@263 | 318 | if [ "${orig}" != "" ] ; then |
ohair@263 | 319 | if [ ! -d "${orig}" ] ; then |
ohair@263 | 320 | warning "Directory in $1 does not exist: ${orig}" |
ohair@263 | 321 | fi |
ohair@263 | 322 | fi |
ohair@263 | 323 | done |
ohair@263 | 324 | } |
ohair@263 | 325 | |
ohair@263 | 326 | # Remove all duplicate entries |
ohair@263 | 327 | removeDeadDups() # string sep |
ohair@263 | 328 | { |
ohair@263 | 329 | set -e |
ohair@263 | 330 | sep="$2" |
ohair@263 | 331 | pathlist="${tmp}/pathlist" |
ohair@263 | 332 | printf "%s\n" "$1" | \ |
ohair@263 | 333 | sed -e 's@\\@/@g' | \ |
ohair@263 | 334 | sed -e 's@//@/@g' | \ |
ohair@263 | 335 | ${awk} -F"${sep}" '{for(i=1;i<=NF;i++){printf "%s\n",$i;}}' \ |
ohair@263 | 336 | > ${pathlist} |
ohair@263 | 337 | upaths="${tmp}/upaths" |
ohair@263 | 338 | cat ${pathlist} | while read orig; do |
ohair@263 | 339 | p="${orig}" |
ohair@263 | 340 | if [ "${cygpath_short}" != "" ] ; then |
ohair@263 | 341 | if [ "${p}" != "" ] ; then |
ohair@263 | 342 | if [ -d "${p}" ] ; then |
ohair@263 | 343 | short=`${cygpath_short} "${p}"` |
ohair@263 | 344 | if [ "${short}" != "" -a -d "${short}" ] ; then |
ohair@263 | 345 | p=`${cygpath} "${short}"` |
ohair@263 | 346 | fi |
ohair@263 | 347 | echo "${p}" >> ${upaths} |
ohair@263 | 348 | fi |
ohair@263 | 349 | fi |
ohair@263 | 350 | fi |
ohair@263 | 351 | done |
ohair@263 | 352 | newpaths="" |
ohair@263 | 353 | for i in `cat ${upaths}` ; do |
ohair@263 | 354 | # For some reason, \r characters can get into this |
ohair@263 | 355 | i=`echo "${i}" | tr -d '\r' | sed -e 's@/$@@'` |
ohair@263 | 356 | if [ "${newpaths}" = "" ] ; then |
ohair@263 | 357 | newpaths="${i}" |
ohair@263 | 358 | else |
ohair@263 | 359 | newpaths="${newpaths}${sep}${i}" |
ohair@263 | 360 | fi |
ohair@263 | 361 | done |
ohair@263 | 362 | printf "%s\n" "${newpaths}" | \ |
ohair@263 | 363 | ${awk} -F"${sep}" \ |
ohair@263 | 364 | '{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 | 365 | } |
ohair@263 | 366 | |
ohair@263 | 367 | # Create bat file to process Visual Studio vcvars*.bat files |
ohair@263 | 368 | createBat() # batfile bindir command |
ohair@263 | 369 | { |
ohair@263 | 370 | bat="$1" |
ohair@263 | 371 | bindir="$2" |
ohair@263 | 372 | command="$3" |
ohair@263 | 373 | stdout="${bat}.stdout" |
ohair@263 | 374 | rm -f ${bat} ${stdout} |
ohair@263 | 375 | echo "Output from: ${command}" > ${stdout} |
ohair@263 | 376 | bdir=`envpath "${bindir}"` |
ohair@263 | 377 | cat > ${bat} << EOF |
ohair@263 | 378 | REM Pick the right vcvars bat file |
ohair@263 | 379 | REM Empty these out so we only get the additions we want |
ohair@263 | 380 | set INCLUDE= |
ohair@263 | 381 | set LIB= |
ohair@263 | 382 | set LIBPATH= |
ohair@263 | 383 | set MSVCDIR= |
ohair@263 | 384 | set MSSdk= |
ohair@263 | 385 | set Mstools= |
ohair@263 | 386 | set DevEnvDir= |
ohair@263 | 387 | set VCINSTALLDIR= |
ohair@263 | 388 | set VSINSTALLDIR= |
ohair@263 | 389 | set WindowsSdkDir= |
ohair@263 | 390 | REM Run the vcvars bat file, send all output to stderr |
ohair@263 | 391 | call `${cygpath_windows} ${bdir}`\\${command} > `${cygpath_windows} "${stdout}"` |
ohair@263 | 392 | REM Echo out env var settings |
ohair@263 | 393 | echo VS_VS71COMNTOOLS="%VS71COMNTOOLS%" |
ohair@263 | 394 | echo export VS_VS71COMNTOOLS |
ohair@263 | 395 | echo VS_VS80COMNTOOLS="%VS80COMNTOOLS%" |
ohair@263 | 396 | echo export VS_VS80COMNTOOLS |
ohair@263 | 397 | echo VS_VS90COMNTOOLS="%VS90COMNTOOLS%" |
ohair@263 | 398 | echo export VS_VS90COMNTOOLS |
ohair@263 | 399 | echo VS_VS100COMNTOOLS="%VS100COMNTOOLS%" |
ohair@263 | 400 | echo export VS_VS100COMNTOOLS |
ohair@263 | 401 | echo VS_VCINSTALLDIR="%VCINSTALLDIR%" |
ohair@263 | 402 | echo export VS_VCINSTALLDIR |
ohair@263 | 403 | echo VS_VSINSTALLDIR="%VSINSTALLDIR%" |
ohair@263 | 404 | echo export VS_VSINSTALLDIR |
ohair@263 | 405 | echo VS_DEVENVDIR="%DevEnvDir%" |
ohair@263 | 406 | echo export VS_DEVENVDIR |
ohair@263 | 407 | echo VS_MSVCDIR="%MSVCDIR%" |
ohair@263 | 408 | echo export VS_MSVCDIR |
ohair@263 | 409 | echo VS_MSSDK="%MSSdk%" |
ohair@263 | 410 | echo export VS_MSSDK |
ohair@263 | 411 | echo VS_MSTOOLS="%Mstools%" |
ohair@263 | 412 | echo export VS_MSTOOLS |
ohair@263 | 413 | echo VS_WINDOWSSDKDIR="%WindowsSdkDir%" |
ohair@263 | 414 | echo export VS_WINDOWSSDKDIR |
ohair@263 | 415 | echo VS_INCLUDE="%INCLUDE%" |
ohair@263 | 416 | echo export VS_INCLUDE |
ohair@263 | 417 | echo VS_LIB="%LIB%" |
ohair@263 | 418 | echo export VS_LIB |
ohair@263 | 419 | echo VS_LIBPATH="%LIBPATH%" |
ohair@263 | 420 | echo export VS_LIBPATH |
ohair@263 | 421 | echo VS_WPATH="%PATH%" |
ohair@263 | 422 | echo export VS_WPATH |
ohair@263 | 423 | EOF |
ohair@263 | 424 | chmod a+x ${bat} |
ohair@263 | 425 | } |
ohair@263 | 426 | |
ohair@263 | 427 | # Create env file |
ohair@263 | 428 | createEnv() # batfile envfile |
ohair@263 | 429 | { |
ohair@263 | 430 | rm -f ${1}.stdout |
ohair@263 | 431 | cmd.exe /Q /C `${cygpath_short} $1` | \ |
ohair@263 | 432 | sed -e 's@\\@/@g' | \ |
ohair@263 | 433 | sed -e 's@//@/@g' > $2 |
ohair@263 | 434 | if [ -f "${1}.stdout" ] ; then |
ohair@263 | 435 | cat ${1}.stdout 1>&2 |
ohair@263 | 436 | fi |
ohair@263 | 437 | chmod a+x $2 |
ohair@263 | 438 | } |
ohair@263 | 439 | |
ohair@263 | 440 | printEnv() # name pname vsname val |
ohair@263 | 441 | { |
ohair@263 | 442 | name="$1" |
ohair@263 | 443 | pname="$2" |
ohair@263 | 444 | vsname="$3" |
ohair@263 | 445 | val="$4" |
ohair@263 | 446 | if [ "${val}" != "" ] ; then |
ohair@263 | 447 | if [ "${shellStyle}" = "csh" ] ; then |
ohair@263 | 448 | if [ "${debug}" = "true" ] ; then |
ohair@263 | 449 | echo "setenv ${vsname} \"${val}\";" |
ohair@263 | 450 | fi |
ohair@263 | 451 | echo "setenv ${name} \"${val}\";" |
ohair@263 | 452 | elif [ "${shellStyle}" = "sh" ] ; then |
ohair@263 | 453 | if [ "${debug}" = "true" ] ; then |
ohair@263 | 454 | echo "${vsname}=\"${val}\";" |
ohair@263 | 455 | echo "export ${vsname};" |
ohair@263 | 456 | fi |
ohair@263 | 457 | echo "${name}=\"${val}\";" |
ohair@263 | 458 | echo "export ${name};" |
ohair@263 | 459 | elif [ "${shellStyle}" = "props" ] ; then |
ohair@263 | 460 | echo "vs.${pname}=${val}" |
ohair@263 | 461 | fi |
ohair@263 | 462 | fi |
ohair@263 | 463 | } |
ohair@263 | 464 | |
ohair@263 | 465 | ############################################################################# |
ohair@263 | 466 | |
ohair@263 | 467 | # Get Visual Studio settings |
ohair@263 | 468 | if [ "${cygpath}" != "" ] ; then |
ohair@263 | 469 | |
ohair@263 | 470 | # Create bat file to run |
ohair@263 | 471 | batfile="${tmp}/vs-to-env.bat" |
ohair@263 | 472 | if [ ! -d "${vcBinDir}" ] ; then |
ohair@263 | 473 | error "Does not exist: ${vcBinDir}" |
ohair@263 | 474 | elif [ "${vcvarsBat}" = "" ] ; then |
ohair@263 | 475 | error "No vcvars script: ${vcvarsBat}" |
ohair@263 | 476 | else |
ohair@263 | 477 | createBat "${batfile}" "${vcBinDir}" "${vcvarsBat}" |
ohair@263 | 478 | fi |
ohair@263 | 479 | |
ohair@263 | 480 | # Run bat file to create environment variable settings |
ohair@263 | 481 | envfile="${tmp}/env.sh" |
ohair@263 | 482 | createEnv "${batfile}" "${envfile}" |
ohair@263 | 483 | |
ohair@263 | 484 | # Read in the VS_* settings |
ohair@263 | 485 | . ${envfile} |
ohair@263 | 486 | |
ohair@263 | 487 | # Derive unix style path, save old, and define new (remove dups) |
ohair@263 | 488 | VS_UPATH=`${cygpath_path} "${VS_WPATH}"` |
ohair@263 | 489 | export VS_UPATH |
ohair@263 | 490 | VS_OPATH=`printf "%s" "${PATH}" | sed -e 's@\\\\@/@g'` |
ohair@263 | 491 | export VS_OPATH |
ohair@263 | 492 | VS_PATH=`removeDeadDups "${VS_UPATH}${pathsep}${VS_OPATH}" "${pathsep}"` |
ohair@263 | 493 | export VS_PATH |
ohair@263 | 494 | |
ohair@263 | 495 | fi |
ohair@263 | 496 | |
ohair@263 | 497 | # Adjustments due to differences in vcvars*bat files |
ohair@263 | 498 | if [ "${VS_MSVCDIR}" = "" ] ; then |
ohair@263 | 499 | VS_MSVCDIR="${VS_VCINSTALLDIR}" |
ohair@263 | 500 | fi |
ohair@263 | 501 | if [ "${VS_DEVENVDIR}" = "" ] ; then |
ohair@263 | 502 | VS_DEVENVDIR="${VS_VSINSTALLDIR}" |
ohair@263 | 503 | fi |
ohair@263 | 504 | |
ohair@263 | 505 | # Print env settings |
ohair@263 | 506 | # env vs.prop vs env value |
ohair@263 | 507 | # ------- ------- ---------- ----- |
ohair@263 | 508 | printEnv INCLUDE include VS_INCLUDE "${VS_INCLUDE}" |
ohair@263 | 509 | printEnv LIB lib VS_LIB "${VS_LIB}" |
ohair@263 | 510 | printEnv LIBPATH libpath VS_LIBPATH "${VS_LIBPATH}" |
ohair@263 | 511 | if [ "${debug}" = "true" ] ; then |
ohair@263 | 512 | printEnv UPATH upath VS_UPATH "${VS_UPATH}" |
ohair@263 | 513 | printEnv WPATH wpath VS_WPATH "${VS_WPATH}" |
ohair@263 | 514 | printEnv OPATH opath VS_OPATH "${VS_OPATH}" |
ohair@263 | 515 | fi |
ohair@263 | 516 | printEnv PATH path VS_PATH "${VS_PATH}" |
ohair@263 | 517 | printEnv VCINSTALLDIR vcinstalldir VS_VCINSTALLDIR "${VS_VCINSTALLDIR}" |
ohair@263 | 518 | printEnv VSINSTALLDIR vsinstalldir VS_VSINSTALLDIR "${VS_VSINSTALLDIR}" |
ohair@263 | 519 | printEnv MSVCDIR msvcdir VS_MSVCDIR "${VS_MSVCDIR}" |
ohair@263 | 520 | printEnv MSSDK mssdk VS_MSSDK "${VS_MSSDK}" |
ohair@263 | 521 | printEnv MSTOOLS mstools VS_MSTOOLS "${VS_MSTOOLS}" |
ohair@263 | 522 | printEnv DEVENVDIR devenvdir VS_DEVENVDIR "${VS_DEVENVDIR}" |
ohair@263 | 523 | printEnv WINDOWSSDKDIR windowssdkdir VS_WINDOWSSDKDIR "${VS_WINDOWSSDKDIR}" |
ohair@263 | 524 | if [ "${vcSelection}" = "10" ] ; then |
ohair@263 | 525 | printEnv VS100COMNTOOLS vs100comntools VS_VS100COMNTOOLS "${VS_VS100COMNTOOLS}" |
ohair@263 | 526 | elif [ "${vcSelection}" = "9" ] ; then |
ohair@263 | 527 | printEnv VS90COMNTOOLS vs90comntools VS_VS90COMNTOOLS "${VS_VS90COMNTOOLS}" |
ohair@263 | 528 | elif [ "${vcSelection}" = "7" ] ; then |
ohair@263 | 529 | printEnv VS71COMNTOOLS vs71comntools VS_VS71COMNTOOLS "${VS_VS71COMNTOOLS}" |
ohair@263 | 530 | elif [ "${vcSelection}" = "8" ] ; then |
ohair@263 | 531 | printEnv VS80COMNTOOLS vs80comntools VS_VS80COMNTOOLS "${VS_VS80COMNTOOLS}" |
ohair@263 | 532 | fi |
ohair@263 | 533 | |
ohair@263 | 534 | # Check final settings |
ohair@263 | 535 | if [ "${verbose}" = "true" ] ; then |
ohair@263 | 536 | checkPaths "Windows PATH" "${VS_WPATH}" ";" |
ohair@263 | 537 | checkPaths LIB "${VS_LIB}" ";" |
ohair@263 | 538 | checkPaths INCLUDE "${VS_INCLUDE}" ";" |
ohair@263 | 539 | checkPaths PATH "${VS_PATH}" "${pathsep}" |
ohair@263 | 540 | fi |
ohair@263 | 541 | |
ohair@263 | 542 | # Remove all temp files |
ohair@263 | 543 | rm -f -r ${tmp} |
ohair@263 | 544 | |
ohair@263 | 545 | exit 0 |
ohair@263 | 546 |