int main()

in graveyard/src/wcg/Deploy.cpp [79:258]


int main(int argc, char* argv[])
{
    char currentdir[DIRPATHLENGTH];
    string arg;
    char opt;
    string optval = "";
    if (argc == 1) usage();
    bDontDeleteSourceFiles = false;
    for (int n=1; n<argc; n++)
    {
        arg = argv[n];
        if (arg[0] == OPTIONTAG)
        {
            if (!arg[1]) usage();
            opt = arg[1];
            optval = arg.substr(2);
            if ((opt != 'D') && (optval == "")) usage();
            switch (opt)
            {
            case 'I':
                g_sAxisIncludePaths.push_back(optval);
                break;
            case 'L':
                g_sLibraryPaths.push_back(optval);
                break;
            case 'l':
                g_sCompiledLibs.push_back(optval);
                break;
            case 'o':
                g_sServiceFile = optval;
                break;
            case 'D':
                bDontDeleteSourceFiles = true;
                break;
            case 'S':
                g_sWebServiceClass = optval;
                break;
            default:
                usage();
            }
        }
        else if ((n+1) == argc)
        {
            if (g_sWsFileName != "") usage();
            g_sWsFileName = arg;    
        }
        else
        {
            cout << "too many parameters " << arg << endl << endl;     
            usage();
        }
    }

    if (!got_all_options()) usage();
    cout << "Checking for validity of the parameters ..." ;
    if (!is_parameters_valid()) 
    {
        cout << "Invalid" << endl;
        exit(0); /* at least one parameter is invalid */
    }
    cout << "Valid" << endl;
    cout << "Checking web service header file ..." ;
    if (!is_webservice_header_compilable())
    {
        cout << "Failed" << endl;
        exit(0);
    }
    cout << "Success" << endl;

    cout << "Parsing web service header file ..." ; 
    init_keyword_map();
    /* add predefined classes to the list so that parser recognizes them */
    /* Change directory to the directory where the initial web service header 
     * file is
     */
    getcwd(currentdir, DIRPATHLENGTH);
    chdir(g_sWsFileName.substr(0, g_sWsFileName.find_last_of('/')).c_str());
    /* parse wsdd files */
    /* parse web service header files */
    if (parse_header_file(g_sWsFileName.substr
        (g_sWsFileName.find_last_of('/')+1, string::npos).c_str()))
    {
        cout << "Failed" << endl;
        exit(0);
    }
    chdir(currentdir);
    /* here we have to continue parsing wsdd file */
    cout << "Done" << endl;
    g_pTranslationUnit->SetWsFileName(g_sWsFileName.c_str());
    cout << "Generating Wrapper class declaration file ...";
    if (g_pTranslationUnit->GenerateWrapperClassDef()) 
    {
        cout << "Failed" << endl;
        exit(0);
    }
    cout << "Done" << endl;
    cout << "Generating Wrapper class implimentation file ...";
    if (g_pTranslationUnit->GenerateWrapperClassImpl())
    {
        cout << "Failed" << endl;
        exit(0);
    }
    cout << "Done" << endl;
    cout << "Generating Export functions file ...";
    if (g_pTranslationUnit->GenerateServiceFile(g_sServiceFile))
    {
        cout << "Failed" << endl;
        exit(0);
    }
    cout << "Done" << endl;

    cout << "Generating WSDL file for the service ...";
    string sURI = "www.opensource.lk";
    /* this should be taken from the WSDD file */
    if (g_pTranslationUnit->GenerateWSDL(g_sServiceFile,sURI))
    {
        cout << "Failed" << endl;
        exit(0);
    }
    cout << "Done" << endl;

    string command;
    list<string>::iterator sit;

    command = COMPILECOMMAND;
    for (sit = g_sAxisIncludePaths.begin(); sit != g_sAxisIncludePaths.end();
    sit++)
    {
        command += "-I" + (*sit) + " ";
    }    

    cout << "Compiling ...";
    if (system(command.c_str()) == -1)
    {
        cout << "Failed" << endl;
        exit(0);
    }
    cout << "Done" << endl;
    
    command = LINKERCOMMAND;
#ifdef WIN32
    command += "/out:\"" + g_sServiceFile + ".dll\" ";
#else
    command += g_sServiceFile + ".so -o " + g_sServiceFile + ".so *.o ";
#endif
    for (sit = g_sLibraryPaths.begin(); sit != g_sLibraryPaths.end(); sit++)
    {
#ifdef WIN32
        command += "/libpath:\"" + (*sit) + "\" ";
#else
        command += "-L " + (*sit) + " ";
#endif
    }
    for (sit = g_sCompiledLibs.begin(); sit != g_sCompiledLibs.end(); sit++)
    {
        command += (*sit) + " ";
    }
    cout << "Linking ...";
    if (system(command.c_str()) == -1)
    {
        cout << "Failed" << endl;
        exit(0);
    }
    cout << "Done" << endl;

    cout << "Deleting temporary files ...";
    command = DELETECOMMAND;
#ifdef WIN32
    command += "*.obj *.exp *.lib ";
#else
    command += "*.o *.a ";
#endif
    if (!bDontDeleteSourceFiles)
    {
        command += "*.cpp *.hpp";
    }
    system(command.c_str());
    cout << "Done" << endl;
    return 0;
}