frerich/clcache — Issue #10: Visual Studio does not invoke cl.bat
Author: Popovich
Created: 2011-12-19 20:21:06+00:00
State: open

Hello!
I have visual studio 2008 SP1 installed. I did all that discribed in your readme file about installation.
But visual studio does not invoke cl.bat. I used process monitor and saw that the studio runs the compiler as "cl.exe", not just "cl". So I wrote a small program in c + +, which does the same thing as your cl.bat. And it worked !

#include
#include
#include

std::string GetExeDir()
{
char filename[MAX_PATH];
GetModuleFileNameA(GetModuleHandleA(NULL), filename, MAX_PATH);

char* pszFile = strrchr(filename, '\\');
pszFile++; // Moves on from \

// Get path
char szPath[MAX_PATH] = "";
strncat(szPath, filename, pszFile - filename);

return szPath;
}

int main(int argc, char* argv[])
{
std::string cmd = "python ";
cmd += GetExeDir() + "\\clcache.py";
for (int i = 1; i < argc; ++i)
{
cmd += " ";
cmd += argv[i];
}

// Execute command
return system(cmd.c_str());
}