[Yhc] VC(++) environment variables (vcvars32.bat, Issue 49)

Peter Tanski p.tanski at gmail.com
Mon Jan 8 12:31:10 EST 2007


Hi Andrew,

Thanks!

Andrew Wilkinson wrote:
> On 1/7/07, Peter Tanski wrote:
>> I looked at Issue 49, on setting the correct environment variables  
>> for a Visual Studio (Visual C++) toolset using vcvars32.bat or  
>> whatever the correct batch file is (see below)...
>
> ... Getting the right environment variables is probably complicated
> enough to warrant a new file with a function called from build/ 
> platform.py,
> but it could be included in the same function.

It would also be easier to modify later on.  Am I correct that "vc"  
is the MS CL compiler?

>> The basic strategy I want to try is this:
>>
>> 1. find the correct Visual Studio build by querying the system ...
>
> The dictionary os.environ is probably what you're looking for.
>
>> 2. find the correct vcvars32.bat or vsvars32.bat ... The easiest  
>> solution is to query the settings in the Registry... I haven't  
>> explored this thoroughly and expect there is some cool Python or  
>> scons function for that purpose.)
>
> http://sourceforge.net/projects/pywin32/ will let you query the  
> registry.
> I'm not sure if it is included in the main Python windows  
> installer, but it
> is definitely include in ActiveState's ActivePython.

The Python 2.5 Windows installer includes _winreg, as well.

> 3. run the batch file and query the environment variables
>
> Is the batch file simple enough to use regular expressions to  
> extract the
> values? That might be easier?

It could be parsed but in many cases and for different versions of  
VS, the main batch file calls other batch files.  I discovered a MS  
tool, Program Files\Microsoft Platform SDK [version, type]\Setup 
\VCDetect.Exe that will find the correct vsvars32.bat.

> 4. propagate the variables into scons ENV
>
>> ... after this, if Yhc ever needs the Visual Studio tools again, it
>> might be able to perform the same process after (or during)
>> installation.
>
> This is as simple as
>         env["CC"] = "path to compiler"

Very nice :)

Cheers,
Pete


More information about the Yhc mailing list