#include "Gcc4Compiler.h" #include "CCSource.h" #include "Component.h" #include "Executable.h" #include "FileSystemUtilities.h" #include "MakeDependencyFile.h" #include "Project.h" #include "SystemConfiguration.h" #include #include class Gcc4Compilation : public ProcessController, public LoudMouth { public: Gcc4Compilation(const std::string& CompilerPath, CCSource& aSource); virtual void finished(int ret); virtual void standardOutput(const std::string& aString); virtual void standardError(const std::string& aString); virtual void failed(); private: Gcc4Compilation& operator=(const Gcc4Compilation&) { return *this; } CCSource& theSource; }; Gcc4Compilation::Gcc4Compilation(const std::string& CompilerPath, CCSource& aSource) : theSource(aSource) { std::vector Args; if (theSource.configuration().includeDebugInformation()) Args.push_back("-g"); for (unsigned int i=0; i Args; for (unsigned int i=0; iobjectName()); for (unsigned int i=0; iobjectName(),aExec.executableName())) return new Gcc4Linkage(Path, aExec); return 0; } void Gcc4ToolChain::storeToCache() const { SystemConfiguration& Cache(Project::it().systemConfiguration()); std::string Prefix("toolchain."+name()+"."); Cache.configureComment("GNU Compiler Collection 4"); Cache.configureKey(isValid(),"toolchain."+name()+".type",IsMingW?"mingw":"gcc4"); if (Path.length() != 0) Project::it().systemConfiguration().configureKey(true,Prefix+"cc_compiler",Path); else Project::it().systemConfiguration().configureKey(false,Prefix+"cc_compiler", ""); } static bool discoverCcFromProcessName(bool LookForMingW, const std::string& ProcessName) { if (!ProcessName.length()) return false; std::string StdOut, StdErr; std::vector Args; Args.push_back("-v"); int r = syncExecuteProcess(ProcessName,Args,StdOut,StdErr); if (r) return false; bool IsMingW = (StdErr.find("--target=mingw32") != std::string::npos) || (StdErr.find("Target: mingw32") != std::string::npos); if (IsMingW != LookForMingW) return false; return true; } SharedPtr Gcc4ToolChain::discoverMingW(const std::string& Name) { std::string CompilerProcessName(findExecutableInPath("g++.exe", "c:\\MinGW\\bin\\")); if (!discoverCcFromProcessName(true, CompilerProcessName)) CompilerProcessName = ""; return SharedPtr(new Gcc4ToolChain(Name,true,CompilerProcessName)); } SharedPtr Gcc4ToolChain::discoverRegular(const std::string& Name) { std::string CompilerProcessName(findExecutableInPath("g++")); if (!discoverCcFromProcessName(false, CompilerProcessName)) CompilerProcessName = ""; return SharedPtr(new Gcc4ToolChain(Name,false,CompilerProcessName)); } SharedPtr Gcc4ToolChain::createFromCache(const VariablePtr& Item, const std::string& Name) { std::string Type(stringValue(childOrVoid(Item,"type"))); bool IsMingW; if (Type == "mingw") IsMingW = true; else if (Type == "gcc4") IsMingW = false; else return SharedPtr(); std::string ExecutableCompiler(stringValue(childOrVoid(Item,"cc_compiler"))); if ( ExecutableCompiler.length() != 0) return SharedPtr(new Gcc4ToolChain(Name,IsMingW,ExecutableCompiler)); return SharedPtr(); }