[Compbench-devel] CompBenchmarks++/Compiler/Compiler-GCC Compiler-GCC.cpp, NONE, 1.1 Compiler-GCC.h
Brought to you by:
xfred
From: Frederic T. <xf...@us...> - 2006-11-01 11:19:01
|
Update of /cvsroot/compbench/CompBenchmarks++/Compiler/Compiler-GCC In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3527 Added Files: Compiler-GCC.cpp Compiler-GCC.h Makefile.am Log Message: Moved from Benchmark/Compiler. Refactorying. --- NEW FILE: Compiler-GCC.h --- /* ---------------------------------------------------------------------------- $Id: Compiler-GCC.h,v 1.1 2006/11/01 11:18:54 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #ifndef H_CBMCOMPILER_GCC #define H_CBMCOMPILER_GCC #include <Compiler/Compiler.h> /** \brief Defines the gcc compiler */ class CBMBenchmarkContextCompilerGCC : public CBMBenchmarkContextCompiler { private: protected: virtual std::string getCompilerName(void); virtual std::string getCompilerVersion(void); virtual char *language(void); public: CBMBenchmarkContextCompilerGCC (class CBMSystem *_system, char *_compilerBinary); virtual std::string compiler(void); virtual ~CBMBenchmarkContextCompilerGCC(); }; /** \brief Defines the g++ compiler */ class CBMBenchmarkContextCompilerGCC_cpp : public CBMBenchmarkContextCompiler { private: protected: virtual std::string getCompilerName(void); virtual std::string getCompilerVersion(void); virtual char *language(void); public: CBMBenchmarkContextCompilerGCC_cpp (class CBMSystem *_system, char *_compilerBinary); virtual std::string compiler(void); virtual ~CBMBenchmarkContextCompilerGCC_cpp(); }; #endif --- NEW FILE: Makefile.am --- noinst_LTLIBRARIES = libCompilerGCC.la sources = Compiler-GCC.cpp libCompilerGCC_la_SOURCES = $(sources) libCompilerinclude_HEADERS = $(sources:.cpp=.h) libCompilerincludedir = $(includedir)/Compiler/Compiler-GCC INCLUDES = -I $(top_srcdir) --- NEW FILE: Compiler-GCC.cpp --- /* ---------------------------------------------------------------------------- $Id: Compiler-GCC.cpp,v 1.1 2006/11/01 11:18:54 xfred Exp $ This is free software. For details, see the GNU Public License in the COPYING file, or Look http://www.fsf.org ------------------------------------------------------------------------- */ #include <Compiler/Compiler-GCC/Compiler-GCC.h> #include <System/System.h> #include <config.h> CBMBenchmarkContextCompilerGCC::CBMBenchmarkContextCompilerGCC(CBMSystem *_system, char *_compilerBinary) : CBMBenchmarkContextCompiler(_system, _compilerBinary) { } std::string CBMBenchmarkContextCompilerGCC::compiler(void) { std::string str = "gcc"; return(str); } std::string CBMBenchmarkContextCompilerGCC::getCompilerName(void) { std::string cmd = compilerBinary; std::string result; std::string tmp; cmd+=" --version | "; cmd+=CBM_PROG_HEAD; cmd+=" -1"; system->exec(cmd, result); /* !!! */ if ((int) result.find("gcc")<0) { tmp="gcc "; tmp+=result; result=tmp; } return(result); } std::string CBMBenchmarkContextCompilerGCC::getCompilerVersion(void) { std::string cmd = "I=`"; std::string result; cmd+=compilerBinary; cmd+=" --version | "; cmd+=CBM_PROG_HEAD; cmd+=" -1`; echo $I | "; cmd+=CBM_PROG_GREP; cmd+=" prerelease > /dev/null; if test $? = 0; then echo $I | "; cmd+=CBM_PROG_CUT; cmd+=" -f3-5 -d' '; else echo $I | "; cmd+=CBM_PROG_CUT; cmd+=" -f3 -d' '; fi"; /* !!! */ system->exec(cmd, result); /* !!! */ return(result); } char *CBMBenchmarkContextCompilerGCC::language(void) { return("C"); } CBMBenchmarkContextCompilerGCC::~CBMBenchmarkContextCompilerGCC() { } CBMBenchmarkContextCompilerGCC_cpp::CBMBenchmarkContextCompilerGCC_cpp(CBMSystem *_system, char *_compilerBinary) : CBMBenchmarkContextCompiler(_system, _compilerBinary) { } std::string CBMBenchmarkContextCompilerGCC_cpp::compiler(void) { std::string str = "g++"; return(str); } std::string CBMBenchmarkContextCompilerGCC_cpp::getCompilerName(void) { std::string cmd = compilerBinary; std::string result; std::string tmp; cmd+=" --version | "; cmd+=CBM_PROG_HEAD; cmd+=" -1"; system->exec(cmd, result); /* !!! */ if ((int) result.find("g++")<0) { tmp="g++ "; tmp+=result; result=tmp; } return(result); } std::string CBMBenchmarkContextCompilerGCC_cpp::getCompilerVersion(void) { std::string cmd = "I=`"; std::string result; cmd+=compilerBinary; cmd+=" --version | "; cmd+=CBM_PROG_HEAD; cmd+=" -1`; echo $I | "; cmd+=CBM_PROG_GREP; cmd+=" prerelease > /dev/null; if test $? = 0; then echo $I | "; cmd+=CBM_PROG_CUT; cmd+=" -f3-5 -d' '; else echo $I | "; cmd+=CBM_PROG_CUT; cmd+=" -f3 -d' '; fi"; /* !!! */ system->exec(cmd, result); /* !!! */ return(result); } char *CBMBenchmarkContextCompilerGCC_cpp::language(void) { return("C++"); } CBMBenchmarkContextCompilerGCC_cpp::~CBMBenchmarkContextCompilerGCC_cpp() { } |