coapp/devtools — Issue #4: pTK does not correctly set compiler variables
Author: Raggles
Created: 2012-01-17 09:54:39+00:00
State: open

When setting compiler environment variables using vcvarsall.bat in pTK, for VC10 (and possibly others) it is not called with the correct syntax.

Correct syntax is:
vcvarsall.bat x86 | amd64 | x86_amd64

If compiling x64 on a x86 system x86_amd64 should be used.

Possible solution:

In pTKMain.cs:
```
private void SetVCCompiler(string compilerName, string compilerBatchFile, string arch)
```
replace

```
_cmdexe.Exec(@"/c ""{0}"" /{1} & set ", compilerBatchFile, arch == "x86" ? "x86" : "x64");
```
with
```
var archToSet = string.Empty;
if (arch == "x86")
archToSet = "x86";
else if (Environment.Is64BitOperatingSystem && arch == "x64")
archToSet = "amd64";
else if (!Environment.Is64BitOperatingSystem && arch == "x64")
archToSet = "x86_amd64";
_cmdexe.Exec(@"/c ""{0}"" {1} & set ", compilerBatchFile, archToSet);
```