#include <msp/fs/dir.h>
#include <msp/fs/utils.h>
#include <msp/strings/format.h>
+#include <msp/strings/utils.h>
#include "architecture.h"
#include "builder.h"
#include "component.h"
return result;
}
+void GnuCompiler::do_prepare()
+{
+ executable = builder.get_vfs().find_binary(command);
+ if(executable)
+ {
+ ExternalTask::Arguments argv;
+ argv.push_back(executable->get_path().str());
+ argv.push_back("-dumpversion");
+
+ builder.get_logger().log("auxcommands", format("Running %s", join(argv.begin(), argv.end())));
+ try
+ {
+ version = strip(ExternalTask::run_and_capture_output(argv));
+ builder.get_logger().log("tools", format("%s version is %s", FS::basename(executable->get_path()), version));
+ }
+ catch(const runtime_error &)
+ { }
+ }
+}
+
Task *GnuCompiler::run(const Target &target) const
{
const ObjectFile &object = dynamic_cast<const ObjectFile &>(target);
class GnuCompiler: public Tool
{
protected:
+ std::string version;
+
GnuCompiler(Builder &, const Architecture &, const std::string &);
public:
virtual Target *create_target(const std::list<Target *> &, const std::string &);
virtual std::string create_build_signature(const BuildInfo &) const;
+protected:
+ virtual void do_prepare();
+public:
virtual Task *run(const Target &) const;
};
#include <msp/fs/stat.h>
-#include <msp/fs/utils.h>
-#include <msp/io/print.h>
-#include <msp/strings/utils.h>
-#include "builder.h"
#include "csourcefile.h"
-#include "externaltask.h"
#include "gnucxxcompiler.h"
using namespace std;
aux_suffixes.push_back(".hpp");
}
-void GnuCxxCompiler::query_version()
-{
- ExternalTask::Arguments argv;
- argv.push_back(executable->get_path().str());
- argv.push_back("-dumpversion");
- builder.get_logger().log("auxcommands", format("Running %s", join(argv.begin(), argv.end())));
- try
- {
- string cxx_ver = strip(ExternalTask::run_and_capture_output(argv));
- FS::Path cxx_path = FS::Path("/usr/include/c++")/cxx_ver;
- if(FS::is_dir(cxx_path))
- {
- builder.get_logger().log("tools", format("%s version is %s", FS::basename(executable->get_path()), cxx_ver));
- system_path.push_back(cxx_path);
- }
- }
- catch(const runtime_error &)
- { }
-}
-
Target *GnuCxxCompiler::create_source(const Component &comp, const FS::Path &path) const
{
return new CSourceFile(builder, comp, path);
void GnuCxxCompiler::do_prepare()
{
GnuCompiler::do_prepare();
- executable = builder.get_vfs().find_binary(command);
- if(executable)
- query_version();
+ if(!version.empty())
+ {
+ FS::Path cxx_path = FS::Path("/usr/include/c++")/version;
+ if(FS::is_dir(cxx_path))
+ system_path.push_back(cxx_path);
+ }
}
{
public:
GnuCxxCompiler(Builder &, const Architecture &);
-private:
- void query_version();
-public:
virtual Target *create_source(const Component &, const Msp::FS::Path &) const;
virtual Target *create_source(const Msp::FS::Path &) const;
-private:
+protected:
virtual void do_prepare();
};