1 #include <msp/fs/stat.h>
2 #include <msp/fs/utils.h>
3 #include <msp/io/print.h>
4 #include <msp/strings/utils.h>
6 #include "csourcefile.h"
7 #include "externaltask.h"
8 #include "gnucxxcompiler.h"
13 GnuCxxCompiler::GnuCxxCompiler(Builder &b, const Architecture &a):
14 GnuCompiler(b, a, "CXX", "g++")
16 input_suffixes.push_back(".cpp");
17 input_suffixes.push_back(".cc");
18 aux_suffixes.push_back(".hpp");
20 ExternalTask::Arguments argv;
21 argv.push_back(executable->get_path().str());
22 argv.push_back("-dumpversion");
23 builder.get_logger().log("auxcommands", format("Running %s", join(argv.begin(), argv.end())));
24 ExternalTask task(argv);
25 task.set_stdout(ExternalTask::CAPTURE);
26 task.set_stderr(ExternalTask::IGNORE);
29 while((status=task.check())==Task::RUNNING) ;
30 if(status==Task::SUCCESS)
32 string cxx_ver = strip(task.get_output());
33 FS::Path cxx_path = FS::Path("/usr/include/c++")/cxx_ver;
34 if(FS::is_dir(cxx_path))
36 builder.get_logger().log("tools", format("%s version is %s", FS::basename(executable->get_path()), cxx_ver));
37 system_path.push_back(cxx_path);
42 Target *GnuCxxCompiler::create_source(const Component &comp, const FS::Path &path) const
44 return new CSourceFile(builder, comp, path);
47 Target *GnuCxxCompiler::create_source(const FS::Path &path) const
49 return new CSourceFile(builder, path);