1 #include <msp/fs/stat.h>
2 #include <msp/io/print.h>
3 #include <msp/strings/regex.h>
5 #include "csourcefile.h"
6 #include "externaltask.h"
7 #include "gnucxxcompiler.h"
12 GnuCxxCompiler::GnuCxxCompiler(Builder &b):
13 GnuCompiler(b, "CXX", "g++")
15 input_suffixes.push_back(".cpp");
16 input_suffixes.push_back(".cc");
17 aux_suffixes.push_back(".hpp");
19 ExternalTask::Arguments argv;
21 argv.push_back("--version");
22 ExternalTask task(argv);
23 task.set_stdout(ExternalTask::CAPTURE);
24 task.set_stderr(ExternalTask::IGNORE);
27 while((status=task.check())==Task::RUNNING) ;
28 if(status==Task::SUCCESS)
29 if(RegMatch m = Regex("[0-9]\\.[0-9.]+").match(task.get_output()))
31 string cxx_ver = m[0].str;
32 while(!cxx_ver.empty())
34 FS::Path cxx_path = FS::Path("/usr/include/c++")/cxx_ver;
35 if(FS::is_dir(cxx_path))
37 if(builder.get_verbose()>=5)
38 IO::print("%s version is %s\n", name, cxx_ver);
39 system_path.push_back(cxx_path);
43 string::size_type dot = cxx_ver.rfind('.');
51 Target *GnuCxxCompiler::create_source(const Component &comp, const FS::Path &path) const
53 return new CSourceFile(builder, comp, path);