Thread: [Compbench-devel] CompBenchmarks++ cloptions.cpp,1.7,1.8
Brought to you by:
xfred
From: Frederic T. <xf...@us...> - 2006-10-10 16:53:40
|
Update of /cvsroot/compbench/CompBenchmarks++ In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv5833 Modified Files: cloptions.cpp Log Message: Many new arguments; New variables for user options. Index: cloptions.cpp =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/cloptions.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** cloptions.cpp 3 Oct 2006 15:43:02 -0000 1.7 --- cloptions.cpp 10 Oct 2006 16:53:36 -0000 1.8 *************** *** 2,7 **** #include <Benchmark/Benchmark-Selector.h> #include <Benchmark/Compiler/BenchmarkContext-Compiler.h> - #include <System/System.h> #include <config.h> --- 2,7 ---- #include <Benchmark/Benchmark-Selector.h> #include <Benchmark/Compiler/BenchmarkContext-Compiler.h> #include <System/System.h> + #include <UI/UI.h> #include <config.h> *************** *** 14,17 **** --- 14,22 ---- extern int optind, opterr, optopt; + int parseExitValue = -1; + + int UO_enableTestSuite = 1; + int UO_force = 0; + void cbmOptionsHelp(void) { *************** *** 33,36 **** --- 38,53 ---- << " use specified compiler and options (if provided)" << std::endl << " to run benchmark b-id" << std::endl + << std::endl + << "Fine grained operations gives more specs :" << std::endl + << " --download <b-id> : download a benchmark" << std::endl + << " --extract <b-id> : extract a benchmark" << std::endl + << " --patch <b-id> : patch a benchmark" << std::endl + << " --preconfigure <b-id> : preconfigure a benchmark" << std::endl + << " --test <b-id> : test a benchmark" << std::endl + << " --release <b-id> : release a benchmark" << std::endl + << std::endl + << "Other options affecting behaviour :" << std::endl + << " --disable-testsuite : disable package's test suite" << std::endl + << " --force : force operation" << std::endl << std::endl; } *************** *** 41,48 **** } int cbmOptionsParse(int argc, char *argv[]) { int c; - int x = -1; int context; CBMBenchmark::Status status; --- 58,86 ---- } + CBMBenchmark *cbmOptionsExpectBenchmark(char *optarg) + { + CBMBenchmarkSelector SB(cbmSystem); + CBMBenchmark *B = 0; + std::string bench; + + if (!optarg) { + std::cerr << "benchmark missing in argument line" << std::endl; + parseExitValue=1; + return(0); + } + + bench=optarg; + B=SB.select((char*) bench.c_str()); + if (!B) { + cbmUnknownBenchmark((char*) bench.c_str()); + parseExitValue=1; + return(0); + } + return(B); + } + int cbmOptionsParse(int argc, char *argv[]) { int c; int context; CBMBenchmark::Status status; *************** *** 50,54 **** CBMBenchmarkSelector SB(cbmSystem); CBMBenchmark *B = 0; ! CBMBenchmarkContextCompilerSelector SC(cbmSystem); CBMBenchmarkContextCompiler *C = 0; --- 88,92 ---- CBMBenchmarkSelector SB(cbmSystem); CBMBenchmark *B = 0; ! CBMBenchmarkContextCompilerSelector SC(cbmSystem); CBMBenchmarkContextCompiler *C = 0; *************** *** 62,66 **** {"version", 0, 0, 'v'}, {"install", 1, 0, 'i' }, ! {"fetch", 1, 0, 'F'}, {"uninstall", 1, 0, 'u' }, {"list-benchmarks", 0, 0, 'L'}, --- 100,104 ---- {"version", 0, 0, 'v'}, {"install", 1, 0, 'i' }, ! {"fetch", 1, 0, 'f'}, {"uninstall", 1, 0, 'u' }, {"list-benchmarks", 0, 0, 'L'}, *************** *** 70,73 **** --- 108,120 ---- {"benchmark-infos", 1, 0, 'I' }, {"bench", 1, 0, 'B'}, + + {"download", 1, 0, 'D' }, + {"extract", 1, 0, 'E' }, + {"patch", 1, 0, 'p' }, + {"preconfigure", 1, 0, 'g' }, + {"test", 1, 0, 't' }, + {"release", 1, 0, 'r' }, + {"disable-testsuite", 0, 0, 'T' }, + {"force", 0, 0, 'F' }, { 0, 0, 0, 0} }; *************** *** 76,80 **** int option_index = 0; ! if (x!=-1) break; --- 123,127 ---- int option_index = 0; ! if (parseExitValue!=-1) break; *************** *** 88,122 **** case 'v': std::cout << VERSION << std::endl; ! x=0; break; case 'h': cbmOptionsHelp(); ! x=0; break; case 'i': ! B=SB.select((char*) optarg); if (B) ! x=B->Install(); ! else ! cbmUnknownBenchmark(optarg); break; case 'u': ! B=SB.select((char*) optarg); if (B) ! x=B->Uninstall(); ! else ! cbmUnknownBenchmark(optarg); break; case 'L': SB.displayList(); ! x=0; break; case 'H': cbmSystem->display(); ! x=0; break; case 'P': cbmSystem->displayPrograms(); ! x=0; break; case 'C': --- 135,171 ---- case 'v': std::cout << VERSION << std::endl; ! parseExitValue=0; break; case 'h': cbmOptionsHelp(); ! parseExitValue=0; break; case 'i': ! B=cbmOptionsExpectBenchmark(optarg); if (B) ! parseExitValue=B->Install(UO_force); break; case 'u': ! B=cbmOptionsExpectBenchmark(optarg); if (B) ! parseExitValue=B->Uninstall(); break; case 'L': SB.displayList(); ! parseExitValue=0; ! break; ! case 'T': ! UO_enableTestSuite=0; ! break; ! case 'F': ! UO_force=1; break; case 'H': cbmSystem->display(); ! parseExitValue=0; break; case 'P': cbmSystem->displayPrograms(); ! parseExitValue=0; break; case 'C': *************** *** 124,169 **** if (C) { C->display(); ! x=0; } else ! x=1; break; case 'I': ! B=SB.select((char*) optarg); if (B) { B->display(); ! x=0; ! } else ! x=1; ! break; ! case 'F': ! if (!optarg) { ! std::cerr << "benchmark missing in argument line" << std::endl; ! x=1; ! break; } ! bench=optarg; ! B=SB.select((char*) bench.c_str()); ! if (!B) { ! cbmUnknownBenchmark((char*) bench.c_str()); ! x=1; break; - } - optind++; if (optind<=argc) { ! B->Fetch(argv[optind-1]); } else { std::cerr << "tarball missing in argument line" << std::endl; ! x=1; break; } break; case 'B': ! bench=optarg; ! B=SB.select((char*) bench.c_str()); ! if (!B) { ! cbmUnknownBenchmark((char*) bench.c_str()); ! x=1; break; - } optind++; if (optind<=argc) { --- 173,238 ---- if (C) { C->display(); ! parseExitValue=0; } else ! parseExitValue=1; break; case 'I': ! B=cbmOptionsExpectBenchmark(optarg); if (B) { B->display(); ! parseExitValue=0; } ! break; ! case 'f': ! B=cbmOptionsExpectBenchmark(optarg); ! if (!B) break; if (optind<=argc) { ! B->Fetch(argv[optind-1], UO_force); } else { std::cerr << "tarball missing in argument line" << std::endl; ! parseExitValue=1; break; } break; + case 'D': + B=cbmOptionsExpectBenchmark(optarg); + if (B) + parseExitValue=!B->Download(); + break; + case 'E': + B=cbmOptionsExpectBenchmark(optarg); + if (B) + parseExitValue=!B->Extract(UO_force); + break; + case 'p': + B=cbmOptionsExpectBenchmark(optarg); + if (B) + parseExitValue=!B->Patch(UO_force); + break; + case 'g': + B=cbmOptionsExpectBenchmark(optarg); + if (B) + parseExitValue=!B->PreConfigure(UO_force); + break; + case 't': + B=cbmOptionsExpectBenchmark(optarg); + if (B) { + if (!UO_enableTestSuite) { + UI->Fatal("Incompatible options : --test and --disable-testsuite"); + } + } + if (B) + parseExitValue=!B->Test(UO_force); + break; + case 'r': + B=cbmOptionsExpectBenchmark(optarg); + if (B) + parseExitValue=!B->Release(); + break; case 'B': ! B=cbmOptionsExpectBenchmark(optarg); ! if (!B) break; optind++; if (optind<=argc) { *************** *** 171,175 **** } else { std::cerr << "compiler missing in argument line" << std::endl; ! x=1; break; } --- 240,244 ---- } else { std::cerr << "compiler missing in argument line" << std::endl; ! parseExitValue=1; break; } *************** *** 177,181 **** if (!C) { std::cerr << "Compiler " << compiler.c_str() << " not found." << std::endl; ! x=1; break; } --- 246,250 ---- if (!C) { std::cerr << "Compiler " << compiler.c_str() << " not found." << std::endl; ! parseExitValue=1; break; } *************** *** 192,196 **** if (B->getStatus()<CBMBenchmark::Preconfigured) { std::cerr << "Benchmark not properly installed" << std::endl; ! x=1; break; } --- 261,265 ---- if (B->getStatus()<CBMBenchmark::Preconfigured) { std::cerr << "Benchmark not properly installed" << std::endl; ! parseExitValue=1; break; } *************** *** 204,217 **** if (!context) { B->Configure(C, O); ! B->Make(); ! B->Test(); } B->Bench(); ! x=0; break; } } cbmSystem->done(); ! exit(x); } --- 273,286 ---- if (!context) { B->Configure(C, O); ! B->Make(UO_force); ! B->Test(UO_force); } B->Bench(); ! parseExitValue=0; break; } } cbmSystem->done(); ! exit(parseExitValue); } |