1 #include <msp/fs/stat.h>
2 #include <msp/io/print.h>
3 #include <msp/strings/regex.h>
4 #include <msp/strings/utils.h>
6 #include "csourcefile.h"
7 #include "externaltask.h"
8 #include "gnucxxcompiler.h"
13 GnuCxxCompiler::GnuCxxCompiler(Builder &b):
14 GnuCompiler(b, "CXX", "g++")
16 input_suffixes.push_back(".cpp");
17 input_suffixes.push_back(".cc");
18 aux_suffixes.push_back(".hpp");
20 ExternalTask::Arguments argv;
22 argv.push_back("--version");
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)
31 if(RegMatch m = Regex("[0-9]\\.[0-9.]+").match(task.get_output()))
33 string cxx_ver = m[0].str;
34 while(!cxx_ver.empty())
36 FS::Path cxx_path = FS::Path("/usr/include/c++")/cxx_ver;
37 if(FS::is_dir(cxx_path))
39 builder.get_logger().log("tools", format("%s version is %s", name, cxx_ver));
40 system_path.push_back(cxx_path);
44 string::size_type dot = cxx_ver.rfind('.');
52 Target *GnuCxxCompiler::create_source(const Component &comp, const FS::Path &path) const
54 return new CSourceFile(builder, comp, path);
57 Target *GnuCxxCompiler::create_source(const FS::Path &path) const
59 return new CSourceFile(builder, path);