Thread: [Compbench-devel] CompBenchmarks++/compbenchmarks-plan cloptions.cpp, 1.2, 1.3
Brought to you by:
xfred
From: Frederic T. <xf...@us...> - 2007-05-30 17:09:03
|
Update of /cvsroot/compbench/CompBenchmarks++/compbenchmarks-plan In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv16815 Modified Files: cloptions.cpp Log Message: CBM::OptionSet and CBM::Options handling. Index: cloptions.cpp =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/compbenchmarks-plan/cloptions.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cloptions.cpp 29 May 2007 18:26:11 -0000 1.2 --- cloptions.cpp 30 May 2007 17:08:49 -0000 1.3 *************** *** 31,35 **** ActionRegisterBatch, ActionUnregisterBatch, ActionListBatch, ActionRegisterCompiler, ActionUnregisterCompiler, ActionListCompiler, ! ActionRegisterOptionset, ActionUnregisterOptionset, ActionListOptionset } OptAction; --- 31,36 ---- ActionRegisterBatch, ActionUnregisterBatch, ActionListBatch, ActionRegisterCompiler, ActionUnregisterCompiler, ActionListCompiler, ! ActionRegisterOptionset, ActionUnregisterOptionset, ActionListOptionset, ! ActionRegisterOptions, ActionUnregisterOptions, ActionListOptions } OptAction; *************** *** 123,126 **** --- 124,138 ---- } + CBM::CompilerOptionSet *getOptionSet(CBM::PlanBatch *B, + std::string optionsetName) + { + CBM::CompilerOptionSet *OS; + OS = B->getCompilerOptions(optionsetName); + if (!OS) + std::cerr << "No option set defined. Look at --optionset-use." << std::endl; + + return(OS); + } + int cbmPlanOptionsParse(int argc, char *argv[]) { *************** *** 135,138 **** --- 147,152 ---- std::string compilerName; std::string optionsetName; + std::string optionsName; + std::string options; CBM::Plan *P = 0; *************** *** 141,144 **** --- 155,159 ---- CBM::Compiler *C = 0; CBM::CompilerOptionSet *OS = 0; + CBM::CompilerOptions *O = 0; int i, n; *************** *** 165,168 **** --- 180,188 ---- {"optionset-unregister", required_argument, 0, 4002}, {"optionset-list", no_argument, 0, 4003}, + {"optionset-use", required_argument, 0, 4004}, + + {"options-register", required_argument, 0, 5001}, + {"options-unregister", required_argument, 0, 5002}, + {"options-list", no_argument, 0, 5003}, { 0, 0, 0, 0 } *************** *** 243,246 **** --- 263,284 ---- action=ActionListOptionset; break; + case 4004: + optionsetName=optarg; + break; + case 5001: + action=ActionRegisterOptions; + optionsName=optarg; + optind++; + if (optind<=argc) { + options=argv[optind-1]; + } + break; + case 5002: + action=ActionUnregisterOptions; + optionsName=optarg; + break; + case 5003: + action=ActionListOptions; + break; default: case '?': *************** *** 482,486 **** std::cerr << optionsetName << " has not been added." << std::endl; } - delete(OS); delete(P); break; --- 520,523 ---- *************** *** 502,506 **** } ! OS = new CompilerOptionSet(optionsetName); if (B->remove(OS)) { storePlan(P, planFileName); --- 539,543 ---- } ! OS = B->getCompilerOptions(optionsetName); if (B->remove(OS)) { storePlan(P, planFileName); *************** *** 512,516 **** } - delete(OS); delete(P); --- 549,552 ---- *************** *** 543,546 **** --- 579,688 ---- } } + delete(P); + break; + + case ActionRegisterOptions: + if (!getPlanFileName(planFileName)) + break; + + B=restoreBatch(&P, + planFileName, + batchName); + + if (!P) + break; + + if (!B) { + delete(P); + break; + } + + OS = getOptionSet(B, optionsetName); + if (!OS) + break; + + O=new CBM::CompilerOptions(optionsName, options); + if (OS->add(O)) { + storePlan(P, planFileName); + if (!parseExitValue) { + std::cout << O->Id() << " added in set " << optionsetName << std::endl; + } + } else { + std::cerr << O->Id() << " has not been added." << std::endl; + } + delete(P); + break; + + case ActionUnregisterOptions: + if (!getPlanFileName(planFileName)) + break; + + B=restoreBatch(&P, + planFileName, + batchName); + + if (!P) + break; + + if (!B) { + delete(P); + break; + } + + OS = getOptionSet(B, optionsetName); + if (!OS) + break; + + O=OS->get(optionsName); + if (O) { + if (OS->remove(O)) { + storePlan(P, planFileName); + if (!parseExitValue) { + std::cout << O->Id() << " removed from set " << optionsetName << std::endl; + } + } else { + std::cerr << O->Id() << " can't be removed." << std::endl; + } + delete(O); + } else { + std::cerr << optionsName << " has not been found." << std::endl; + } + delete(P); + break; + case ActionListOptions: + if (!getPlanFileName(planFileName)) + break; + + B=restoreBatch(&P, + planFileName, + batchName); + + if (!P) + break; + + if (!B) { + delete(P); + break; + } + + OS = getOptionSet(B, optionsetName); + if (!OS) + break; + + + n = OS->optionNumber(); + + parseExitValue=0; + if (!n) { + std::cout << "No options registered." << std::endl; + } else { + printf("%d option line(s) found :\n", n); + for (i=0; i<n; i++) { + O=OS->Options(i); + std::cout << " * Id : " << O->Id() << " - Contains : " + << O->Options() << std::endl; + } + } + delete(P); break; |