[Compbench-devel] CompBenchmarks++/compbenchmarks-plan cloptions.cpp, 1.4, 1.5
Brought to you by:
xfred
From: Frederic T. <xf...@us...> - 2007-07-31 17:22:35
|
Update of /cvsroot/compbench/CompBenchmarks++/compbenchmarks-plan In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv27741 Modified Files: cloptions.cpp Log Message: Fixes in CBM::Options* handling. Index: cloptions.cpp =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/compbenchmarks-plan/cloptions.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** cloptions.cpp 30 May 2007 19:27:46 -0000 1.4 --- cloptions.cpp 31 Jul 2007 17:22:27 -0000 1.5 *************** *** 29,32 **** --- 29,33 ---- typedef enum { ActionUndef, + ActionHelp, ActionRegisterPlan, ActionUnregisterPlan, ActionRegisterBatch, ActionUnregisterBatch, ActionListBatch, *************** *** 34,37 **** --- 35,39 ---- ActionRegisterOptionset, ActionUnregisterOptionset, ActionListOptionset, ActionRegisterOptions, ActionUnregisterOptions, ActionListOptions, + ActionRegisterOption, ActionUnregisterOption, ActionListOption, ActionRegisterBenchmark, ActionUnregisterBenchmark, ActionListBenchmark } OptAction; *************** *** 102,105 **** --- 104,108 ---- { CBM::PlanBatch *B; + std::string t; (*P)=restorePlan(planFileName); *************** *** 107,111 **** B=(*P)->getBatch(batchId); if (!B) { ! std::cerr << "Batch " << batchId << " not found in " << planFileName << std::endl; } --- 110,121 ---- B=(*P)->getBatch(batchId); if (!B) { ! if (batchId=="") { ! t="not specified. Look at --batch-use <batch-id>."; ! } else { ! t=batchId; ! t+=" not found in "; ! t+=planFileName; ! } ! std::cerr << "Batch " << t << std::endl; } *************** *** 130,134 **** { CBM::CompilerOptionSet *OS; ! OS = B->getCompilerOptions(optionsetName); if (!OS) std::cerr << "No option set defined. Look at --optionset-use." << std::endl; --- 140,144 ---- { CBM::CompilerOptionSet *OS; ! OS = B->getCompilerOptionSet(optionsetName); if (!OS) std::cerr << "No option set defined. Look at --optionset-use." << std::endl; *************** *** 161,164 **** --- 171,175 ---- std::string optionsName; std::string options; + std::string option; std::string benchmarkName; *************** *** 199,206 **** {"options-unregister", required_argument, 0, 5002}, {"options-list", no_argument, 0, 5003}, ! {"benchmark-register", required_argument, 0, 6001}, ! {"benchmark-unregister", required_argument, 0, 6002}, ! {"benchmark-list", no_argument, 0, 6003}, { 0, 0, 0, 0 } --- 210,221 ---- {"options-unregister", required_argument, 0, 5002}, {"options-list", no_argument, 0, 5003}, + {"options-use", required_argument, 0, 5004}, ! {"option-register", required_argument, 0, 6001}, ! {"option-unregister", required_argument, 0, 6002}, ! ! {"benchmark-register", required_argument, 0, 7001}, ! {"benchmark-unregister", required_argument, 0, 7002}, ! {"benchmark-list", no_argument, 0, 7003}, { 0, 0, 0, 0 } *************** *** 223,226 **** --- 238,242 ---- break; case 'h': + action=ActionHelp; break; case 1001: *************** *** 287,294 **** action=ActionRegisterOptions; optionsName=optarg; - optind++; - if (optind<=argc) { - options=argv[optind-1]; - } break; case 5002: --- 303,306 ---- *************** *** 296,311 **** optionsName=optarg; break; case 5003: action=ActionListOptions; break; ! case 6001: action=ActionRegisterBenchmark; benchmarkName=optarg; break; ! case 6002: action=ActionUnregisterBenchmark; benchmarkName=optarg; break; ! case 6003: action=ActionListBenchmark; break; --- 308,334 ---- optionsName=optarg; break; + case 6001: + action=ActionRegisterOption; + option=optarg; + break; + case 6002: + action=ActionUnregisterOption; + option=optarg; + break; case 5003: action=ActionListOptions; break; ! case 5004: ! optionsName=optarg; ! break; ! case 7001: action=ActionRegisterBenchmark; benchmarkName=optarg; break; ! case 7002: action=ActionUnregisterBenchmark; benchmarkName=optarg; break; ! case 7003: action=ActionListBenchmark; break; *************** *** 317,320 **** --- 340,346 ---- switch(action) { + case ActionHelp: + cbmOptionsHelp(); + break; case ActionRegisterPlan: if (cbmSystem->fileExists(planFileName)) { *************** *** 372,382 **** P=restorePlan(planFileName); if (P) { ! CBM::PlanBatch *B = new CBM::PlanBatch(batchName); P->addBatch(B); parseExitValue=!(P->store(planFileName)); storePlan(P, planFileName); - if (!parseExitValue) { - std::cout << "Batch " << batchName << " added in " << planFileName << std::endl; - } delete(P); } --- 398,405 ---- P=restorePlan(planFileName); if (P) { ! CBM::PlanBatch *B = new CBM::PlanBatch(P, batchName); P->addBatch(B); parseExitValue=!(P->store(planFileName)); storePlan(P, planFileName); delete(P); } *************** *** 391,398 **** parseExitValue=!(P->removeBatch(batchName)); if (!parseExitValue) { - std::cout << "Batch " << batchName << " removed from " << planFileName << std::endl; storePlan(P, planFileName); - } else { - std::cerr << "Cant't find such batch in plan " << planFileName << std::endl; } } --- 414,418 ---- *************** *** 443,455 **** if (B->add(C)) { storePlan(P, planFileName); - if (!parseExitValue) { - std::cout << C->Name() << " added in batch " << batchName << std::endl; - } - } else { - std::cerr << compilerName << " has not been added (probably because it was already present in that plan)." << std::endl; } delete(C); - } else { - std::cerr << compilerName << " is not a supported compiler." << std::endl; } delete(CS); --- 463,468 ---- *************** *** 479,491 **** if (B->remove(C)) { storePlan(P, planFileName); - if (!parseExitValue) { - std::cout << C->Name() << " removed from batch " << batchName << std::endl; - } - } else { - std::cerr << compilerName << " not found in that plan" << std::endl; } delete(C); - } else { - std::cerr << compilerName << " is not a supported compiler." << std::endl; } delete(CS); --- 492,497 ---- *************** *** 527,531 **** if (!getPlanFileName(planFileName)) break; ! B=restoreBatch(&P, planFileName, --- 533,537 ---- if (!getPlanFileName(planFileName)) break; ! B=restoreBatch(&P, planFileName, *************** *** 543,551 **** if (B->add(OS)) { storePlan(P, planFileName); - if (!parseExitValue) { - std::cout << OS->Id() << " added in batch " << batchName << std::endl; - } - } else { - std::cerr << optionsetName << " has not been added." << std::endl; } delete(P); --- 549,552 ---- *************** *** 568,581 **** } ! OS = B->getCompilerOptions(optionsetName); ! if (B->remove(OS)) { ! storePlan(P, planFileName); ! if (!parseExitValue) { ! std::cout << OS->Id() << " removed from batch " << batchName << std::endl; } } else { ! std::cerr << optionsetName << " not found in batch." << std::endl; } - delete(P); --- 569,580 ---- } ! OS = B->getCompilerOptionSet(optionsetName); ! if (OS) { ! if (B->remove(OS)) { ! storePlan(P, planFileName); } } else { ! std::cerr << "No such option set." << std::endl; } delete(P); *************** *** 597,601 **** } ! n=B->compilerOptionNumber(); if (!n) { std::cout << "No option set registered." << std::endl; --- 596,600 ---- } ! n=B->compilerOptionSetNumber(); if (!n) { std::cout << "No option set registered." << std::endl; *************** *** 604,608 **** for(i=0; i<n; i++) { ! OS=B->getCompilerOptions(i); std::cout << " * " << OS->Id() << std::endl; } --- 603,607 ---- for(i=0; i<n; i++) { ! OS=B->getCompilerOptionSet(i); std::cout << " * " << OS->Id() << std::endl; } *************** *** 629,641 **** 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); --- 628,634 ---- if (!OS) break; ! O=new CBM::CompilerOptions(optionsName, ""); if (OS->add(O)) { storePlan(P, planFileName); } delete(P); *************** *** 666,678 **** 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); --- 659,664 ---- if (OS->remove(O)) { storePlan(P, planFileName); ! } delete(O); } delete(P); *************** *** 714,719 **** delete(P); break; ! case ActionRegisterBenchmark: if (!getPlanFileName(planFileName)) break; --- 700,734 ---- delete(P); break; + case ActionRegisterOption: + 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 (O->add(option)) { + storePlan(P, planFileName); + } + delete(O); + } + delete(P); + break; ! case ActionUnregisterOption: if (!getPlanFileName(planFileName)) break; *************** *** 731,750 **** } ! BM=getBenchmark(benchmarkName); ! if (!BM) break; ! if (B->add(BM)) { ! storePlan(P, planFileName); ! if (!parseExitValue) { ! std::cout << BM->Name() << " added in " << B->Id() << std::endl; } else { ! std::cerr << BM->Name() << " can't be added." << std::endl; } - } else { - std::cerr << benchmarkName << " can't be added; see ./compbenchmarks-core -qib" << std::endl; - std::cerr << "Possible causes are either that " << BM->Name() << " is already present" - << "in that plan or not fully installed." << std::endl; } delete(BM); delete(P); --- 746,821 ---- } ! OS = getOptionSet(B, optionsetName); ! if (!OS) break; ! O=OS->get(optionsName); ! if (O) { ! if (O->remove(option)) { ! storePlan(P, planFileName); ! } ! delete(O); ! } ! delete(P); ! break; ! case ActionListOption: ! 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) { ! n=O->optionNumber(); ! if (!n) { ! std::cout << "No option set registered." << std::endl; } else { ! printf("%d option found :\n", n); ! ! for(i=0; i<n; i++) { ! OS=B->getCompilerOptionSet(i); ! std::cout << " * " << O->Option(i) << std::endl; ! } } } + delete(P); + break; + case ActionRegisterBenchmark: + if (!getPlanFileName(planFileName)) + break; + + B=restoreBatch(&P, + planFileName, + batchName); + + if (!P) + break; + + if (!B) { + delete(P); + break; + } + + BM=getBenchmark(benchmarkName); + if (!BM) + break; + + if (B->add(BM)) + storePlan(P, planFileName); + delete(BM); delete(P); *************** *** 773,781 **** if (B->remove(BM)) { storePlan(P, planFileName); - if (!parseExitValue) { - std::cout << BM->Name() << " removed from " << B->Id() << std::endl; - } else { - std::cerr << BM->Name() << " can't be removed." << std::endl; - } } else { std::cerr << benchmarkName << " can't be removed; see ./compbenchmarks-core -qib" << std::endl; --- 844,847 ---- |