Windows Visual Studio Stupid Pet Trick of the Day
By kto on Aug 14, 2009
Sept 1, 2009: Updated script, now works with MKS shell environments.
Re-posting this blog about a shell script interface to the Visual Studio environment setting files vsvars32.bat or vcvars32.bat. Mine is called vsvars.sh. This was my Windows Visual Studio Stupid Pet Trick of the Day, but it's turned into the stupid pet trick of the year. It's mostly for you CYGWIN Visual Studio Users.
The vsvars.sh script will exec a Windows command shell, have it spit out the environment variables it sets, and then it echos out shell environment variable setting commands. And here it is:
Running "vsvars -v7" will get you the settings for Visual Studio 2003:
Nasty looking stuff, but matches what the official Visual Studio vcvars32.bat (or vsvars32.bat) files do to the Windows command shell environment. Note that not all these must be defined in the environment before running Visual Studio, depending on what you are running the critical ones are: INCLUDE, LIB, PATH, LIBPATH, VCINSTALLDIR, VSINSTALLDIR, MSVCDIR, and DEVENVDIR. The first ones INCLUDE, LIB, PATH, and LIBPATH are needed by the compiler, LIBPATH for the newer compilers. The others may be needed by other Visual Studio tools.
The nice thing is that you can use it in a shell environment like so:
eval `vcvars.sh -v7`
By default it should figure out what kind of shell you are using and do the right thing. Use the -help option to see all the options:
It works pretty slick... although I can't possibly test it in all situations.
This will probably be hooked into the JDK builds at some point, or provided with those sources.