1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
#include "CompilerLocatorMSYS2.hpp"
#include "GCCMetadata.hpp"
#include "Platform.hpp"
#include "compiler.h"
#include <wx/filename.h>
// --------------------------------------------------
// --------------------------------------------------
CompilerLocatorMSYS2Usr::CompilerLocatorMSYS2Usr()
{
m_repository = "";
m_msys2.SetChroot("\\usr");
}
CompilerLocatorMSYS2Usr::~CompilerLocatorMSYS2Usr() {}
CompilerLocatorMSYS2Mingw64::CompilerLocatorMSYS2Mingw64()
{
m_repository = "mingw64";
m_msys2.SetChroot("\\mingw64");
}
CompilerLocatorMSYS2Mingw64::~CompilerLocatorMSYS2Mingw64() {}
CompilerLocatorMSYS2Clang64::CompilerLocatorMSYS2Clang64()
{
m_repository = "clang64";
m_msys2.SetChroot("\\clang64");
}
CompilerLocatorMSYS2Clang64::~CompilerLocatorMSYS2Clang64() {}
// --------------------------------------------------
// --------------------------------------------------
CompilerLocatorMSYS2::CompilerLocatorMSYS2() {}
CompilerLocatorMSYS2::~CompilerLocatorMSYS2() {}
bool CompilerLocatorMSYS2::Locate()
{
m_compilers.clear();
// try some defaults
wxString gcc_exe;
if(!m_msys2.Which("gcc", &gcc_exe)) {
return false;
}
auto compiler = Locate(wxFileName(gcc_exe).GetPath());
if(compiler) {
m_compilers.push_back(compiler);
}
return !m_compilers.empty();
}
CompilerPtr CompilerLocatorMSYS2::Locate(const wxString& folder)
{
// check for g++
wxFileName gcc = GetFileName(folder, "gcc");
wxFileName gxx = GetFileName(folder, "g++");
wxFileName ar = GetFileName(folder, "ar");
wxFileName as = GetFileName(folder, "as");
wxFileName make = GetFileName(folder, "mingw32-make");
wxFileName windres = GetFileName(folder, "windres");
wxFileName mkdir = GetFileName(folder, "mkdir");
wxFileName gdb = GetFileName(folder, "gdb");
// make sure that both gcc & g++ exist
if(!(gcc.FileExists() && gxx.FileExists())) {
return nullptr;
}
// define the toolchain name
wxString basename = m_repository;
if(!basename.empty()) {
basename << "/";
}
basename << "gcc";
GCCMetadata cmd(basename);
cmd.Load(gcc.GetFullPath(), folder);
// create new compiler
CompilerPtr compiler(new Compiler(nullptr));
compiler->SetName(cmd.GetName());
compiler->SetCompilerFamily(COMPILER_FAMILY_MSYS2);
compiler->SetInstallationPath(folder);
// add the tools
compiler->SetTool("CXX", gxx.GetFullPath());
compiler->SetTool("CC", gcc.GetFullPath());
compiler->SetTool("AR", ar.GetFullPath() + " -r");
compiler->SetTool("LinkerName", gxx.GetFullPath());
compiler->SetTool("SharedObjectLinkerName", gxx.GetFullPath() + " -shared -fPIC");
compiler->SetTool("AS", as.GetFullPath());
size_t cpu_count = wxThread::GetCPUCount();
compiler->SetTool("MAKE", wxString() << make.GetFullPath() << " -j" << cpu_count);
compiler->SetTool("ResourceCompiler", windres.GetFullPath());
compiler->SetTool("Debugger", gdb.GetFullPath());
return compiler;
}
void CompilerLocatorMSYS2::AddTool(const wxString& tool_name, const wxString& value) {}
wxFileName CompilerLocatorMSYS2::GetFileName(const wxString& bin_dir, const wxString& fullname) const
{
wxFileName tool(bin_dir, fullname);
tool.SetExt("exe");
return tool;
}
|