Home | History | Annotate | Download | only in CLWrapper
      1 // CLWrapper.cpp : Calls the perl script parallelcl to perform parallel compilation
      2 
      3 #define WIN32_LEAN_AND_MEAN    // Exclude rarely-used stuff from Windows headers
      4 #include <process.h>
      5 #include <stdio.h>
      6 #include <string>
      7 #include <windows.h>
      8 
      9 using namespace std;
     10 
     11 int wmain(int argc, wchar_t* argv[])
     12 {
     13     const int numArgs = 3;
     14 
     15 #ifndef NDEBUG
     16     fwprintf(stderr, L"######### im in ur IDE, compiling ur c0des ########\n");
     17 #endif
     18 
     19     wstring** args = new wstring*[numArgs];
     20 
     21     args[0] = new wstring(L"sh");
     22     args[1] = new wstring(L"-c");
     23 
     24     args[2] = new wstring(L"\"parallelcl");
     25     for (int i = 1; i < argc; ++i) {
     26         args[2]->append(L" '");
     27         args[2]->append(argv[i]);
     28         if (i < argc - 1)
     29             args[2]->append(L"' ");
     30         else
     31             args[2]->append(L"'");
     32     }
     33     args[2]->append(L"\"");
     34 
     35     for (unsigned i = 0; i < args[2]->length(); i++) {
     36        if (args[2]->at(i) == '\\')
     37             args[2]->at(i) = '/';
     38     }
     39 
     40     wchar_t** newArgv = new wchar_t*[numArgs + 1];
     41     for (int i = 0; i < numArgs; i++)
     42         newArgv[i] = (wchar_t*)args[i]->c_str();
     43 
     44     newArgv[numArgs] = 0;
     45 
     46 #ifndef NDEBUG
     47     fwprintf(stderr, L"exec(\"%s\", \"%s\", \"%s\", \"%s\")\n", L"sh", newArgv[0], newArgv[1], newArgv[2]);
     48 #endif
     49 
     50     return _wspawnvp(_P_WAIT, L"sh", newArgv);
     51 }
     52 
     53