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