common/bin/extractvcvars.sh

Tue, 03 Jul 2012 16:11:12 -0700

author
erikj
date
Tue, 03 Jul 2012 16:11:12 -0700
changeset 458
c8d320b48626
parent 425
e1830598f0b7
permissions
-rw-r--r--

7181504: Update of latest build-infra Makefiles
Reviewed-by: ohair

ohair@425 1 #!/bin/bash
ohair@425 2 #
ohair@425 3 # Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
ohair@425 4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ohair@425 5 #
ohair@425 6 # This code is free software; you can redistribute it and/or modify it
ohair@425 7 # under the terms of the GNU General Public License version 2 only, as
ohair@425 8 # published by the Free Software Foundation.
ohair@425 9 #
ohair@425 10 # This code is distributed in the hope that it will be useful, but WITHOUT
ohair@425 11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ohair@425 12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ohair@425 13 # version 2 for more details (a copy is included in the LICENSE file that
ohair@425 14 # accompanied this code).
ohair@425 15 #
ohair@425 16 # You should have received a copy of the GNU General Public License version
ohair@425 17 # 2 along with this work; if not, write to the Free Software Foundation,
ohair@425 18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ohair@425 19 #
ohair@425 20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@425 21 # or visit www.oracle.com if you need additional information or have any
ohair@425 22 # questions.
ohair@425 23 #
ohair@425 24
ohair@425 25 # Must be bash, but that is ok since we are running from cygwin.
ohair@425 26 # The first argument is the vcvarsall.bat file to run.
ohair@425 27 # The second argument is the arch arg to give to vcvars.
ohair@425 28 VCVARSALL="$1"
ohair@425 29 ARCH_ARG="$2"
ohair@425 30
ohair@425 31 # Cannot use the VS10 setup script directly (since it only updates the DOS subshell environment)
ohair@425 32 # but calculate the difference in Cygwin environment before/after running it and then
ohair@425 33 # apply the diff.
ohair@425 34 _vs10varsall=`cygpath -a -m -s "$VCVARSALL"`
ohair@425 35 _dosvs10varsall=`cygpath -a -w -s $_vs10varsall`
ohair@425 36 _dosbash=`cygpath -a -w -s \`which bash\`.*`
ohair@425 37
ohair@425 38 # generate the set of exported vars before/after the vs10 setup
ohair@425 39 echo "@echo off" > localdevenvtmp.bat
ohair@425 40 echo "$_dosbash -c \"export -p\" > localdevenvtmp.export0" >> localdevenvtmp.bat
ohair@425 41 echo "call $_dosvs10varsall $ARCH_ARG" >> localdevenvtmp.bat
ohair@425 42 echo "$_dosbash -c \"export -p\" > localdevenvtmp.export1" >> localdevenvtmp.bat
ohair@425 43 cmd /c localdevenvtmp.bat
ohair@425 44
ohair@425 45 # apply the diff (less some non-vs10 vars named by "!")
ohair@425 46 sort localdevenvtmp.export0 |grep -v "!" > localdevenvtmp.export0.sort
ohair@425 47 sort localdevenvtmp.export1 |grep -v "!" > localdevenvtmp.export1.sort
ohair@425 48 comm -1 -3 localdevenvtmp.export0.sort localdevenvtmp.export1.sort > localdevenv.sh
ohair@425 49 cat localdevenv.sh | sed 's/declare -x /export /g' | sed 's/="/:="/g' | sed 's/\\\\/\\/g' | sed 's/"//g' | \
ohair@425 50 sed 's/#/\$\(HASH\)/g' > localdevenv.gmk
ohair@425 51
ohair@425 52 # cleanup
ohair@425 53 rm -f localdevenvtmp*

mercurial