6909331: Add vsvars.sh to the jdk repository (handy cygwin way to get vcvars32.bat run)

Mon, 20 Dec 2010 08:44:58 -0800

author
ohair
date
Mon, 20 Dec 2010 08:44:58 -0800
changeset 263
6d8ed82e5070
parent 262
f4c95f4b7590
child 268
6f7376db67f8
child 275
4346ba98938b
child 276
dc9eb519c6ed

6909331: Add vsvars.sh to the jdk repository (handy cygwin way to get vcvars32.bat run)
Reviewed-by: robilad

make/scripts/vsvars.sh file | annotate | diff | comparison | revisions
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/make/scripts/vsvars.sh	Mon Dec 20 08:44:58 2010 -0800
     1.3 @@ -0,0 +1,546 @@
     1.4 +#!/bin/sh
     1.5 +
     1.6 +#
     1.7 +# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
     1.8 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.9 +#
    1.10 +# This code is free software; you can redistribute it and/or modify it
    1.11 +# under the terms of the GNU General Public License version 2 only, as
    1.12 +# published by the Free Software Foundation.
    1.13 +#
    1.14 +# This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 +# version 2 for more details (a copy is included in the LICENSE file that
    1.18 +# accompanied this code).
    1.19 +#
    1.20 +# You should have received a copy of the GNU General Public License version
    1.21 +# 2 along with this work; if not, write to the Free Software Foundation,
    1.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 +#
    1.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 +# or visit www.oracle.com if you need additional information or have any
    1.26 +# questions.
    1.27 +#
    1.28 +
    1.29 +# This file should be used to set the Visual Studio environment
    1.30 +#   variables normally set by the vcvars32.bat or vcvars64.bat file or
    1.31 +#   SetEnv.cmd for older SDKs.
    1.32 +
    1.33 +# Use cygpath?
    1.34 +isCygwin="`uname -s | grep CYGWIN`"
    1.35 +if [ "${isCygwin}" != "" ] ; then
    1.36 +  cygpath="/usr/bin/cygpath"
    1.37 +  cygpath_short="${cygpath} -m -s"
    1.38 +  cygpath_windows="${cygpath} -w -s"
    1.39 +  cygpath_path="${cygpath} -p"
    1.40 +  pathsep=':'
    1.41 +else
    1.42 +  cygpath="dosname"
    1.43 +  cygpath_short="${cygpath} -s"
    1.44 +  cygpath_windows="${cygpath} -s"
    1.45 +  cygpath_path="echo"
    1.46 +  pathsep=';'
    1.47 +fi
    1.48 +
    1.49 +########################################################################
    1.50 +# Error functions
    1.51 +msg() # message
    1.52 +{
    1.53 +  echo "$1" 1>&2
    1.54 +}
    1.55 +error() # message
    1.56 +{
    1.57 +  msg "ERROR: $1"
    1.58 +  exit 1
    1.59 +}
    1.60 +warning() # message
    1.61 +{
    1.62 +  msg "WARNING: $1"
    1.63 +}
    1.64 +envpath() # path
    1.65 +{
    1.66 +  if [ "${cygpath_short}" != "" -a -d "$1" ] ; then
    1.67 +    ${cygpath_short} "$1"
    1.68 +  else
    1.69 +    echo "$1"
    1.70 +  fi
    1.71 +}
    1.72 +########################################################################
    1.73 +
    1.74 +
    1.75 +# Defaults settings
    1.76 +debug="false"
    1.77 +verbose="false"
    1.78 +shellStyle="sh"
    1.79 +parentCsh="` ps -p ${PPID} 2> /dev/null | grep csh `"
    1.80 +if [ "${parentCsh}" != "" ] ; then
    1.81 +  shellStyle="csh"
    1.82 +fi
    1.83 +
    1.84 +set -e
    1.85 +
    1.86 +# Check environment first
    1.87 +if [ "${PROGRAMFILES}" != "" ] ; then
    1.88 +  progfiles=`envpath "${PROGRAMFILES}"`
    1.89 +elif [ "${ProgramFiles}" != "" ] ; then
    1.90 +  progfiles=`envpath "${ProgramFiles}"`
    1.91 +elif [ "${SYSTEMDRIVE}" != "" ] ; then
    1.92 +  progfiles=`envpath "${SYSTEMDRIVE}/Program Files"`
    1.93 +elif [ "${SystemDrive}" != "" ] ; then
    1.94 +  progfiles=`envpath "${SystemDrive}/Program Files"`
    1.95 +else
    1.96 +  error "No PROGRAMFILES or SYSTEMDRIVE defined in environment"
    1.97 +fi
    1.98 +
    1.99 +# Arch data model
   1.100 +if [ "${PROCESSOR_IDENTIFIER}" != "" ] ; then
   1.101 +  arch=`echo "${PROCESSOR_IDENTIFIER}" | cut -d' ' -f1`
   1.102 +elif [ "${MACHTYPE}" != "" ] ; then
   1.103 +  if [ "`echo ${MACHTYPE} | grep 64`" != "" ] ; then
   1.104 +    # Assume this is X64, not IA64
   1.105 +    arch="x64"
   1.106 +  else
   1.107 +    arch="x86"
   1.108 +  fi
   1.109 +else
   1.110 + arch="`uname -m`"
   1.111 +fi
   1.112 +if [ "${arch}" = "X86" -o \
   1.113 +     "${arch}" = "386" -o "${arch}" = "i386" -o \
   1.114 +     "${arch}" = "486" -o "${arch}" = "i486" -o \
   1.115 +     "${arch}" = "586" -o "${arch}" = "i586" -o \
   1.116 +     "${arch}" = "686" -o "${arch}" = "i686" -o \
   1.117 +     "${arch}" = "86" ] ; then
   1.118 +  arch="x86"
   1.119 +fi
   1.120 +if [ "${arch}" = "X64"     -o \
   1.121 +     "${arch}" = "8664"    -o "${arch}" = "i8664"   -o \
   1.122 +     "${arch}" = "amd64"   -o "${arch}" = "AMD64"   -o \
   1.123 +     "${arch}" = "EM64T"   -o "${arch}" = "emt64t"  -o \
   1.124 +     "${arch}" = "intel64" -o "${arch}" = "Intel64" -o \
   1.125 +     "${arch}" = "64" ] ; then
   1.126 +  arch="x64"
   1.127 +  binarch64="/amd64"
   1.128 +fi
   1.129 +if [ "${arch}" = "IA64" ] ; then
   1.130 +  arch="ia64"
   1.131 +  binarch64="/ia64"
   1.132 +fi
   1.133 +if [ "${arch}" != "x86" -a "${arch}" != "x64" -a "${arch}" != "ia64" ] ; then
   1.134 + error "No PROCESSOR_IDENTIFIER or MACHTYPE environment variables and uname -m is not helping"
   1.135 +fi
   1.136 +if [ "${arch}" = "x86" ] ; then
   1.137 +  arch_data_model=32
   1.138 +  progfiles32="${progfiles}"
   1.139 +  progfiles64="${progfiles}"
   1.140 +else
   1.141 +  arch_data_model=64
   1.142 +  progfiles32="${progfiles}"
   1.143 +  if [ "${PROGRAMW6432}" != "" ] ; then
   1.144 +    progfiles64=`envpath "${PROGRAMW6432}"`
   1.145 +  else
   1.146 +    progfiles64=`envpath "C:/Program Files"`
   1.147 +  fi
   1.148 +fi
   1.149 +
   1.150 +# VS2010 (VC10)
   1.151 +if [ "${VS100COMNTOOLS}" = "" ] ; then
   1.152 +  VS100COMNTOOLS="${progfiles32}/Microsoft Visual Studio 10.0/Common7/Tools/"
   1.153 +  export VS100COMNTOOLS
   1.154 +fi
   1.155 +vc10Bin32Dir=`envpath "${VS100COMNTOOLS}"`/../../VC/Bin
   1.156 +vc10Bin64Dir="${vc10Bin32Dir}${binarch64}"
   1.157 +vc10vars32Bat="vcvars32.bat"
   1.158 +vc10vars64Bat="vcvars64.bat"
   1.159 +
   1.160 +# VS2008 (VC9)
   1.161 +if [ "${VS90COMNTOOLS}" = "" ] ; then
   1.162 +  VS90COMNTOOLS="${progfiles32}/Microsoft Visual Studio 9.0/Common7/Tools/"
   1.163 +  export VS90COMNTOOLS
   1.164 +fi
   1.165 +vc9Bin32Dir=`envpath "${VS90COMNTOOLS}"`/../../VC/Bin
   1.166 +vc9Bin64Dir="${vc9Bin32Dir}"
   1.167 +vc9vars32Bat="vcvars32.bat"
   1.168 +vc9vars64Bat="vcvars64.bat"
   1.169 +
   1.170 +# VS2005 (VC8)
   1.171 +if [ "${VS80COMNTOOLS}" = "" ] ; then
   1.172 +  VS80COMNTOOLS="${progfiles32}/Microsoft Visual Studio 8.0/Common7/Tools/"
   1.173 +  export VS80COMNTOOLS
   1.174 +fi
   1.175 +vc8Bin32Dir=`envpath "${VS80COMNTOOLS}"`/../../VC/Bin
   1.176 +vc8Bin64Dir="${progfiles64}/Microsoft Platform SDK"
   1.177 +vc8vars32Bat="vcvars32.bat"
   1.178 +vc8vars64Bat="SetEnv.cmd /X64"
   1.179 +
   1.180 +# VS2003 (VC7)
   1.181 +if [ "${VS71COMNTOOLS}" = "" ] ; then
   1.182 +  VS71COMNTOOLS="${progfiles32}/Microsoft Visual Studio .NET 2003/Common7/Tools/"
   1.183 +  export VS71COMNTOOLS
   1.184 +fi
   1.185 +vc7Bin32Dir=`envpath "${VS71COMNTOOLS}"`/../../VC7/Bin
   1.186 +vc7Bin64Dir="${progfiles64}/Microsoft Platform SDK"
   1.187 +vc7vars32Bat="vcvars32.bat"
   1.188 +vc7vars64Bat="SetEnv.cmd /X64"
   1.189 +
   1.190 +# Force user to select
   1.191 +vcSelection=""
   1.192 +
   1.193 +# Parse options
   1.194 +usage="Usage: $0 [-help] [-debug] [-v] [-c] [-s] [-p] [-v10] [-v9] [-v8] [-v7] [-32] [-64]"
   1.195 +while [ $# -gt 0 ] ; do
   1.196 +  if [ "$1" = "-help" ] ; then
   1.197 +    msg "${usage}"
   1.198 +    msg "  -help    Print out this help message"
   1.199 +    msg "  -debug   Print out extra env variables to help debug this script"
   1.200 +    msg "  -v       Verbose output warns about missing directories"
   1.201 +    msg "  -c       Print out csh style output"
   1.202 +    msg "  -s       Print out sh style output"
   1.203 +    msg "  -p       Print out properties style output"
   1.204 +    msg "  -v10     Use Visual Studio 10 VS2010"
   1.205 +    msg "  -v9      Use Visual Studio 9 VS2008"
   1.206 +    msg "  -v8      Use Visual Studio 8 VS2005"
   1.207 +    msg "  -v7      Use Visual Studio 7 VS2003"
   1.208 +    msg "  -32      Force 32bit"
   1.209 +    msg "  -64      Force 64bit"
   1.210 +    exit 0
   1.211 +  elif [ "$1" = "-debug" ] ; then
   1.212 +    debug="true"
   1.213 +    shift
   1.214 +  elif [ "$1" = "-v" ] ; then
   1.215 +    verbose="true"
   1.216 +    shift
   1.217 +  elif [ "$1" = "-c" ] ; then
   1.218 +    shellStyle="csh"
   1.219 +    shift
   1.220 +  elif [ "$1" = "-s" ] ; then
   1.221 +    shellStyle="sh"
   1.222 +    shift
   1.223 +  elif [ "$1" = "-p" ] ; then
   1.224 +    shellStyle="props"
   1.225 +    shift
   1.226 +  elif [ "$1" = "-v10" ] ; then
   1.227 +    vcBin32Dir="${vc10Bin32Dir}"
   1.228 +    vcBin64Dir="${vc10Bin64Dir}"
   1.229 +    vcvars32Bat="${vc10vars32Bat}"
   1.230 +    vcvars64Bat="${vc10vars64Bat}"
   1.231 +    vcSelection="10"
   1.232 +    shift
   1.233 +  elif [ "$1" = "-v9" ] ; then
   1.234 +    vcBin32Dir="${vc9Bin32Dir}"
   1.235 +    vcBin64Dir="${vc9Bin64Dir}"
   1.236 +    vcvars32Bat="${vc9vars32Bat}"
   1.237 +    vcvars64Bat="${vc9vars64Bat}"
   1.238 +    vcSelection="9"
   1.239 +    shift
   1.240 +  elif [ "$1" = "-v8" ] ; then
   1.241 +    vcBin32Dir="${vc8Bin32Dir}"
   1.242 +    vcBin64Dir="${vc8Bin64Dir}"
   1.243 +    vcvars32Bat="${vc8vars32Bat}"
   1.244 +    vcvars64Bat="${vc8vars64Bat}"
   1.245 +    vcSelection="8"
   1.246 +    shift
   1.247 +  elif [ "$1" = "-v7" ] ; then
   1.248 +    vcBin32Dir="${vc7Bin32Dir}"
   1.249 +    vcBin64Dir="${vc7Bin64Dir}"
   1.250 +    vcvars32Bat="${vc7vars32Bat}"
   1.251 +    vcvars64Bat="${vc7vars64Bat}"
   1.252 +    vcSelection="7"
   1.253 +    shift
   1.254 +  elif [ "$1" = "-32" ] ; then
   1.255 +    arch_data_model=32
   1.256 +    shift
   1.257 +  elif [ "$1" = "-64" ] ; then
   1.258 +    arch_data_model=64
   1.259 +    shift
   1.260 +  else
   1.261 +    msg "${usage}"
   1.262 +    error "Unknown option: $1"
   1.263 +  fi
   1.264 +done
   1.265 +
   1.266 +# Need to pick
   1.267 +if [ "${vcSelection}" = "" ] ; then
   1.268 +  msg "${usage}"
   1.269 +  error "You must pick the version"
   1.270 +fi
   1.271 +
   1.272 +# Which vcvars bat file to run
   1.273 +if [ "${arch_data_model}" = "32" ] ; then
   1.274 +  vcBinDir="${vcBin32Dir}"
   1.275 +  vcvarsBat="${vcvars32Bat}"
   1.276 +fi
   1.277 +if [ "${arch_data_model}" = "64" ] ; then
   1.278 +  vcBinDir="${vcBin64Dir}"
   1.279 +  vcvarsBat="${vcvars64Bat}"
   1.280 +fi
   1.281 +
   1.282 +# Do not allow any error returns
   1.283 +set -e
   1.284 +
   1.285 +# Different systems have different awk's
   1.286 +if [ -f /usr/bin/nawk ] ; then
   1.287 +  awk="nawk"
   1.288 +elif [ -f /usr/bin/gawk ] ; then
   1.289 +  awk="gawk"
   1.290 +else
   1.291 +  awk="awk"
   1.292 +fi
   1.293 +
   1.294 +if [ "${verbose}" = "true" ] ; then
   1.295 +  echo "# Welcome to verbose mode"
   1.296 +  set -x
   1.297 +fi
   1.298 +
   1.299 +if [ "${debug}" = "true" ] ; then
   1.300 +  echo "# Welcome to debug mode"
   1.301 +  set -x
   1.302 +fi
   1.303 +
   1.304 +# Temp file area
   1.305 +tmp="/tmp/vsvars.$$"
   1.306 +rm -f -r ${tmp}
   1.307 +mkdir -p ${tmp}
   1.308 +
   1.309 +# Check paths
   1.310 +checkPaths() # var path sep
   1.311 +{
   1.312 +  set -e
   1.313 +  sep="$3"
   1.314 +  checklist="${tmp}/checklist"
   1.315 +  printf "%s\n" "$2" | \
   1.316 +    sed -e 's@\\@/@g' | \
   1.317 +    sed -e 's@//@/@g' | \
   1.318 +    ${awk} -F"${sep}" '{for(i=1;i<=NF;i++){printf "%s\n",$i;}}'  \
   1.319 +      > ${checklist}
   1.320 +  cat ${checklist} | while read orig; do
   1.321 +    if [ "${orig}" != "" ] ; then
   1.322 +      if [ ! -d "${orig}" ] ; then
   1.323 +        warning "Directory in $1 does not exist: ${orig}"
   1.324 +      fi
   1.325 +    fi
   1.326 +  done
   1.327 +}
   1.328 +
   1.329 +# Remove all duplicate entries
   1.330 +removeDeadDups() # string sep
   1.331 +{
   1.332 +  set -e
   1.333 +  sep="$2"
   1.334 +  pathlist="${tmp}/pathlist"
   1.335 +  printf "%s\n" "$1" | \
   1.336 +    sed -e 's@\\@/@g' | \
   1.337 +    sed -e 's@//@/@g' | \
   1.338 +    ${awk} -F"${sep}" '{for(i=1;i<=NF;i++){printf "%s\n",$i;}}'  \
   1.339 +      > ${pathlist}
   1.340 +  upaths="${tmp}/upaths"
   1.341 +  cat ${pathlist} | while read orig; do
   1.342 +    p="${orig}"
   1.343 +    if [ "${cygpath_short}" != "" ] ; then
   1.344 +      if [ "${p}" != "" ] ; then
   1.345 +        if [ -d "${p}" ] ; then
   1.346 +          short=`${cygpath_short} "${p}"`
   1.347 +          if [ "${short}" != "" -a -d "${short}" ] ; then
   1.348 +            p=`${cygpath} "${short}"`
   1.349 +          fi
   1.350 +          echo "${p}" >> ${upaths}
   1.351 +        fi
   1.352 +      fi
   1.353 +    fi
   1.354 +  done
   1.355 +  newpaths=""
   1.356 +  for i in  `cat ${upaths}` ; do
   1.357 +    # For some reason, \r characters can get into this
   1.358 +    i=`echo "${i}" | tr -d '\r' | sed -e 's@/$@@'`
   1.359 +    if [ "${newpaths}" = "" ] ; then
   1.360 +      newpaths="${i}"
   1.361 +    else
   1.362 +      newpaths="${newpaths}${sep}${i}"
   1.363 +    fi
   1.364 +  done
   1.365 +  printf "%s\n" "${newpaths}" | \
   1.366 +    ${awk} -F"${sep}" \
   1.367 +       '{a[$1];printf "%s",$1;for(i=2;i<=NF;i++){if(!($i in a)){a[$i];printf "%s%s",FS,$i;}};printf "\n";}'
   1.368 +}
   1.369 +
   1.370 +# Create bat file to process Visual Studio vcvars*.bat files
   1.371 +createBat() # batfile bindir command
   1.372 +{
   1.373 +  bat="$1"
   1.374 +  bindir="$2"
   1.375 +  command="$3"
   1.376 +  stdout="${bat}.stdout"
   1.377 +  rm -f ${bat} ${stdout}
   1.378 +  echo "Output from: ${command}" > ${stdout}
   1.379 +  bdir=`envpath "${bindir}"`
   1.380 +  cat > ${bat} << EOF  
   1.381 +REM Pick the right vcvars bat file
   1.382 +REM Empty these out so we only get the additions we want
   1.383 +set INCLUDE=
   1.384 +set LIB=
   1.385 +set LIBPATH=
   1.386 +set MSVCDIR=
   1.387 +set MSSdk=
   1.388 +set Mstools=
   1.389 +set DevEnvDir=
   1.390 +set VCINSTALLDIR=
   1.391 +set VSINSTALLDIR=
   1.392 +set WindowsSdkDir=
   1.393 +REM Run the vcvars bat file, send all output to stderr
   1.394 +call `${cygpath_windows} ${bdir}`\\${command} > `${cygpath_windows} "${stdout}"`
   1.395 +REM Echo out env var settings
   1.396 +echo VS_VS71COMNTOOLS="%VS71COMNTOOLS%"
   1.397 +echo export VS_VS71COMNTOOLS
   1.398 +echo VS_VS80COMNTOOLS="%VS80COMNTOOLS%"
   1.399 +echo export VS_VS80COMNTOOLS
   1.400 +echo VS_VS90COMNTOOLS="%VS90COMNTOOLS%"
   1.401 +echo export VS_VS90COMNTOOLS
   1.402 +echo VS_VS100COMNTOOLS="%VS100COMNTOOLS%"
   1.403 +echo export VS_VS100COMNTOOLS
   1.404 +echo VS_VCINSTALLDIR="%VCINSTALLDIR%"
   1.405 +echo export VS_VCINSTALLDIR
   1.406 +echo VS_VSINSTALLDIR="%VSINSTALLDIR%"
   1.407 +echo export VS_VSINSTALLDIR
   1.408 +echo VS_DEVENVDIR="%DevEnvDir%"
   1.409 +echo export VS_DEVENVDIR
   1.410 +echo VS_MSVCDIR="%MSVCDIR%"
   1.411 +echo export VS_MSVCDIR
   1.412 +echo VS_MSSDK="%MSSdk%"
   1.413 +echo export VS_MSSDK
   1.414 +echo VS_MSTOOLS="%Mstools%"
   1.415 +echo export VS_MSTOOLS
   1.416 +echo VS_WINDOWSSDKDIR="%WindowsSdkDir%"
   1.417 +echo export VS_WINDOWSSDKDIR
   1.418 +echo VS_INCLUDE="%INCLUDE%"
   1.419 +echo export VS_INCLUDE
   1.420 +echo VS_LIB="%LIB%"
   1.421 +echo export VS_LIB
   1.422 +echo VS_LIBPATH="%LIBPATH%"
   1.423 +echo export VS_LIBPATH
   1.424 +echo VS_WPATH="%PATH%"
   1.425 +echo export VS_WPATH
   1.426 +EOF
   1.427 +  chmod a+x ${bat}
   1.428 +}
   1.429 +
   1.430 +# Create env file
   1.431 +createEnv() # batfile envfile
   1.432 +{
   1.433 +  rm -f ${1}.stdout
   1.434 +  cmd.exe /Q /C `${cygpath_short} $1` | \
   1.435 +    sed -e 's@\\@/@g' | \
   1.436 +    sed -e 's@//@/@g' > $2
   1.437 +  if [ -f "${1}.stdout" ] ; then
   1.438 +    cat ${1}.stdout 1>&2
   1.439 +  fi
   1.440 +  chmod a+x $2
   1.441 +}
   1.442 +
   1.443 +printEnv() # name pname vsname val
   1.444 +{
   1.445 +  name="$1"
   1.446 +  pname="$2"
   1.447 +  vsname="$3"
   1.448 +  val="$4"
   1.449 +  if [ "${val}" != "" ] ; then
   1.450 +    if [ "${shellStyle}" = "csh" ] ; then
   1.451 +      if [ "${debug}" = "true" ] ; then
   1.452 +        echo "setenv ${vsname} \"${val}\";"
   1.453 +      fi
   1.454 +      echo "setenv ${name} \"${val}\";"
   1.455 +    elif [ "${shellStyle}" = "sh" ] ; then
   1.456 +      if [ "${debug}" = "true" ] ; then
   1.457 +        echo "${vsname}=\"${val}\";"
   1.458 +        echo "export ${vsname};"
   1.459 +      fi
   1.460 +      echo "${name}=\"${val}\";"
   1.461 +      echo "export ${name};"
   1.462 +    elif [ "${shellStyle}" = "props" ] ; then
   1.463 +      echo "vs.${pname}=${val}"
   1.464 +    fi
   1.465 +  fi
   1.466 +}
   1.467 +
   1.468 +#############################################################################
   1.469 +
   1.470 +# Get Visual Studio settings
   1.471 +if [ "${cygpath}" != "" ] ; then
   1.472 +
   1.473 +  # Create bat file to run
   1.474 +  batfile="${tmp}/vs-to-env.bat"
   1.475 +  if [ ! -d "${vcBinDir}" ] ; then
   1.476 +    error "Does not exist: ${vcBinDir}"
   1.477 +  elif [ "${vcvarsBat}" = "" ] ; then
   1.478 +    error "No vcvars script: ${vcvarsBat}"
   1.479 +  else
   1.480 +    createBat "${batfile}" "${vcBinDir}" "${vcvarsBat}"
   1.481 +  fi
   1.482 +
   1.483 +  # Run bat file to create environment variable settings
   1.484 +  envfile="${tmp}/env.sh"
   1.485 +  createEnv "${batfile}" "${envfile}"
   1.486 +
   1.487 +  # Read in the VS_* settings
   1.488 +  . ${envfile}
   1.489 +
   1.490 +  # Derive unix style path, save old, and define new (remove dups)
   1.491 +  VS_UPATH=`${cygpath_path} "${VS_WPATH}"`
   1.492 +  export VS_UPATH
   1.493 +  VS_OPATH=`printf "%s" "${PATH}" | sed -e 's@\\\\@/@g'`
   1.494 +  export VS_OPATH
   1.495 +  VS_PATH=`removeDeadDups "${VS_UPATH}${pathsep}${VS_OPATH}" "${pathsep}"`
   1.496 +  export VS_PATH
   1.497 +
   1.498 +fi
   1.499 +
   1.500 +# Adjustments due to differences in vcvars*bat files
   1.501 +if [ "${VS_MSVCDIR}" = "" ] ; then
   1.502 +  VS_MSVCDIR="${VS_VCINSTALLDIR}"
   1.503 +fi
   1.504 +if [ "${VS_DEVENVDIR}" = "" ] ; then
   1.505 +  VS_DEVENVDIR="${VS_VSINSTALLDIR}"
   1.506 +fi
   1.507 +
   1.508 +# Print env settings
   1.509 +#        env           vs.prop       vs env           value
   1.510 +#        -------       -------       ----------       -----
   1.511 +printEnv INCLUDE       include       VS_INCLUDE       "${VS_INCLUDE}"
   1.512 +printEnv LIB           lib           VS_LIB           "${VS_LIB}"
   1.513 +printEnv LIBPATH       libpath       VS_LIBPATH       "${VS_LIBPATH}"
   1.514 +if [ "${debug}" = "true" ] ; then
   1.515 +  printEnv UPATH         upath         VS_UPATH         "${VS_UPATH}"
   1.516 +  printEnv WPATH         wpath         VS_WPATH         "${VS_WPATH}"
   1.517 +  printEnv OPATH         opath         VS_OPATH         "${VS_OPATH}"
   1.518 +fi
   1.519 +printEnv PATH          path          VS_PATH          "${VS_PATH}"
   1.520 +printEnv VCINSTALLDIR  vcinstalldir  VS_VCINSTALLDIR  "${VS_VCINSTALLDIR}"
   1.521 +printEnv VSINSTALLDIR  vsinstalldir  VS_VSINSTALLDIR  "${VS_VSINSTALLDIR}"
   1.522 +printEnv MSVCDIR       msvcdir       VS_MSVCDIR       "${VS_MSVCDIR}"
   1.523 +printEnv MSSDK         mssdk         VS_MSSDK         "${VS_MSSDK}"
   1.524 +printEnv MSTOOLS       mstools       VS_MSTOOLS       "${VS_MSTOOLS}"
   1.525 +printEnv DEVENVDIR     devenvdir     VS_DEVENVDIR     "${VS_DEVENVDIR}"
   1.526 +printEnv WINDOWSSDKDIR windowssdkdir VS_WINDOWSSDKDIR "${VS_WINDOWSSDKDIR}"
   1.527 +if [ "${vcSelection}" = "10" ] ; then
   1.528 +  printEnv VS100COMNTOOLS vs100comntools VS_VS100COMNTOOLS "${VS_VS100COMNTOOLS}"
   1.529 +elif [ "${vcSelection}" = "9" ] ; then
   1.530 +  printEnv VS90COMNTOOLS vs90comntools VS_VS90COMNTOOLS "${VS_VS90COMNTOOLS}"
   1.531 +elif [ "${vcSelection}" = "7" ] ; then
   1.532 +  printEnv VS71COMNTOOLS vs71comntools VS_VS71COMNTOOLS "${VS_VS71COMNTOOLS}"
   1.533 +elif [ "${vcSelection}" = "8" ] ; then
   1.534 +  printEnv VS80COMNTOOLS vs80comntools VS_VS80COMNTOOLS "${VS_VS80COMNTOOLS}"
   1.535 +fi
   1.536 +
   1.537 +# Check final settings
   1.538 +if [ "${verbose}" = "true" ] ; then
   1.539 +  checkPaths "Windows PATH" "${VS_WPATH}" ";"
   1.540 +  checkPaths LIB "${VS_LIB}" ";"
   1.541 +  checkPaths INCLUDE "${VS_INCLUDE}" ";"
   1.542 +  checkPaths PATH "${VS_PATH}" "${pathsep}"
   1.543 +fi
   1.544 +
   1.545 +# Remove all temp files
   1.546 +rm -f -r ${tmp}
   1.547 +
   1.548 +exit 0
   1.549 +

mercurial