cwd = FS::getcwd();
- toolchain.add_tool(new GnuCCompiler(*this));
- toolchain.add_tool(new GnuCxxCompiler(*this));
- toolchain.add_tool(new GnuLinker(*this));
- toolchain.add_tool(new GnuArchiver(*this));
- toolchain.add_tool(new Copy(*this));
- toolchain.add_tool(new Tar(*this));
- toolchain.add_tool(new PkgConfigGenerator(*this));
-
load_build_file((FS::get_sys_data_dir(argv[0], "builder")/"builderrc").str());
load_build_file((FS::get_user_data_dir("builder")/"rc").str());
}
}
+ toolchain.add_tool(new GnuCCompiler(*this));
+ toolchain.add_tool(new GnuCxxCompiler(*this));
+ toolchain.add_tool(new GnuLinker(*this));
+ toolchain.add_tool(new GnuArchiver(*this));
+ toolchain.add_tool(new Copy(*this));
+ toolchain.add_tool(new Tar(*this));
+ toolchain.add_tool(new PkgConfigGenerator(*this));
+
if(prfx.empty())
{
if(current_arch->is_native())
#include <msp/fs/dir.h>
#include <msp/fs/utils.h>
#include <msp/strings/format.h>
+#include "architecture.h"
#include "builder.h"
#include "component.h"
#include "externaltask.h"
GnuCompiler::GnuCompiler(Builder &b, const string &t, const string &n):
Tool(b, t),
name(n)
-{ }
+{
+ const Architecture &arch = builder.get_current_arch();
+ if(arch.is_native())
+ system_path.push_back("/usr/include");
+ else
+ system_path.push_back("/usr/"+arch.get_cross_prefix()+"/include");
+}
Target *GnuCompiler::create_target(const list<Target *> &sources, const std::string &) const
{
+#include <msp/fs/stat.h>
+#include <msp/io/print.h>
+#include <msp/strings/regex.h>
+#include "builder.h"
#include "csourcefile.h"
+#include "externaltask.h"
#include "gnucxxcompiler.h"
+using namespace std;
using namespace Msp;
GnuCxxCompiler::GnuCxxCompiler(Builder &b):
input_suffixes.push_back(".cpp");
input_suffixes.push_back(".cc");
aux_suffixes.push_back(".hpp");
+
+ ExternalTask::Arguments argv;
+ argv.push_back(name);
+ argv.push_back("--version");
+ ExternalTask task(argv);
+ task.set_stdout(ExternalTask::CAPTURE);
+ task.set_stderr(ExternalTask::IGNORE);
+ task.start();
+ Task::Status status;
+ while((status=task.check())==Task::RUNNING) ;
+ if(status==Task::SUCCESS)
+ if(RegMatch m = Regex("[0-9]\\.[0-9.]+").match(task.get_output()))
+ {
+ string cxx_ver = m[0].str;
+ while(!cxx_ver.empty())
+ {
+ FS::Path cxx_path = FS::Path("/usr/include/c++")/cxx_ver;
+ if(FS::is_dir(cxx_path))
+ {
+ if(builder.get_verbose()>=5)
+ IO::print("%s version is %s\n", name, cxx_ver);
+ system_path.push_back(cxx_path);
+ break;
+ }
+
+ string::size_type dot = cxx_ver.rfind('.');
+ if(dot==string::npos)
+ break;
+ cxx_ver.erase(dot);
+ }
+ }
}
Target *GnuCxxCompiler::create_source(const Component &comp, const FS::Path &path) const
{
input_suffixes.push_back(".o");
input_suffixes.push_back(".a");
+
+ const Architecture &arch = builder.get_current_arch();
+ if(arch.is_native())
+ {
+ system_path.push_back("/lib");
+ system_path.push_back("/usr/lib");
+ if(arch.match_name("pc-32-linux"))
+ system_path.push_back("/usr/lib/i386-linux-gnu");
+ else if(arch.match_name("pc-64-linux"))
+ system_path.push_back("/usr/lib/x86_64-linux-gnu");
+ }
+ else
+ system_path.push_back("/usr/"+arch.get_cross_prefix()+"/lib");
}
Target *GnuLinker::create_target(const list<Target *> &sources, const std::string &arg) const
class Tool
{
public:
+ typedef std::list<Msp::FS::Path> SearchPath;
typedef std::list<std::string> SuffixList;
protected:
std::string tag;
SuffixList input_suffixes;
SuffixList aux_suffixes;
+ SearchPath system_path;
Tool(Builder &, const std::string &);
public:
const SuffixList &get_input_suffixes() const { return input_suffixes; }
const SuffixList &get_auxiliary_suffixes() const { return aux_suffixes; }
bool accepts_suffix(const std::string &, bool = false) const;
+ const SearchPath &get_system_path() const { return system_path; }
virtual Target *create_source(const Component &, const Msp::FS::Path &) const { return 0; }
Target *create_target(Target &, const std::string & = std::string()) const;
if(i!=include_cache.end())
return i->second;
- static string cxx_ver;
- if(cxx_ver.empty())
- {
- // XXX This needs to go elsewhere
- /*StringList argv;
- argv.push_back(current_arch->get_tool("CXX"));
- argv.push_back("--version");
- if(RegMatch m = Regex("[0-9]\\.[0-9.]+").match(run_command(argv)))
- {
- cxx_ver = m[0].str;
- while(!cxx_ver.empty() && !FS::is_dir(FS::Path("/usr/include/c++")/cxx_ver))
- {
- string::size_type dot = cxx_ver.rfind('.');
- if(dot==string::npos)
- break;
- cxx_ver.erase(dot);
- }
- if(verbose>=5)
- IO::print("C++ version is %s\n", cxx_ver);
- }
- else*/
- cxx_ver = "-";
- }
-
if(builder.get_verbose()>=5)
IO::print("Looking for header %s with path %s\n", name, join(path.begin(), path.end()));