webengine/osswebengine/WebKitTools/CLWrapper/CLWrapper.cpp
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // CLWrapper.cpp : Calls the perl script parallelcl to perform parallel compilation
       
    20 
       
    21 #define WIN32_LEAN_AND_MEAN    // Exclude rarely-used stuff from Windows headers
       
    22 #include <process.h>
       
    23 #include <stdio.h>
       
    24 #include <string>
       
    25 #include <windows.h>
       
    26 
       
    27 using namespace std;
       
    28 
       
    29 int wmain(int argc, wchar_t* argv[])
       
    30 {
       
    31     const int numArgs = 3;
       
    32 
       
    33 #ifndef NDEBUG
       
    34     fwprintf(stderr, L"######### im in ur IDE, compiling ur c0des ########\n");
       
    35 #endif
       
    36 
       
    37     wstring** args = new wstring*[numArgs];
       
    38 
       
    39     args[0] = new wstring(L"sh");
       
    40     args[1] = new wstring(L"-c");
       
    41 
       
    42     args[2] = new wstring(L"\"parallelcl");
       
    43     for (int i = 1; i < argc; ++i) {
       
    44         args[2]->append(L" '");
       
    45         args[2]->append(argv[i]);
       
    46         if (i < argc - 1)
       
    47             args[2]->append(L"' ");
       
    48         else
       
    49             args[2]->append(L"'");
       
    50     }
       
    51     args[2]->append(L"\"");
       
    52 
       
    53     for (unsigned i = 0; i < args[2]->length(); i++) {
       
    54        if (args[2]->at(i) == '\\')
       
    55             args[2]->at(i) = '/';
       
    56     }
       
    57 
       
    58     wchar_t** newArgv = new wchar_t*[numArgs + 1];
       
    59     for (int i = 0; i < numArgs; i++)
       
    60         newArgv[i] = (wchar_t*)args[i]->c_str();
       
    61 
       
    62     newArgv[numArgs] = 0;
       
    63 
       
    64 #ifndef NDEBUG
       
    65     fwprintf(stderr, L"exec(\"%s\", \"%s\", \"%s\", \"%s\")\n", L"sh", newArgv[0], newArgv[1], newArgv[2]);
       
    66 #endif
       
    67 
       
    68     return _wspawnvp(_P_WAIT, L"sh", newArgv);
       
    69 }
       
    70