]> git.tdb.fi Git - builder.git/blobdiff - source/builder.cpp
Don't b0rk if C++ compiler is not found while trying to determine its version
[builder.git] / source / builder.cpp
index 0905bb6779530af63a6fd2f25151cf4248609715..3a9f3d40eea213f64bb2ecb04c7ab1e21d8514f7 100644 (file)
@@ -124,7 +124,7 @@ Builder::Builder(int argc, char **argv):
        const vector<string> &args=getopt.get_args();
        for(vector<string>::const_iterator i=args.begin(); i!=args.end(); ++i)
        {
-               unsigned equal=i->find('=');
+               string::size_type equal=i->find('=');
                if(equal!=string::npos)
                        cmdline_options.insert(StringMap::value_type(i->substr(0, equal), i->substr(equal+1)));
                else
@@ -152,7 +152,7 @@ Builder::Builder(int argc, char **argv):
        native_arch->set_tool("AR",  "ar");
 
        load_build_file((FS::get_sys_data_dir(argv[0], "builder")/"builderrc").str());
-       load_build_file((FS::get_home_dir()/".builderrc").str());
+       load_build_file((FS::get_user_data_dir("builder")/"rc").str());
 
        if(arch.empty())
                current_arch=native_arch;
@@ -384,16 +384,21 @@ Target *Builder::get_header(const string &include, const FS::Path &from, const l
                StringList argv;
                argv.push_back(current_arch->get_tool("CXX"));
                argv.push_back("--version");
-               cxx_ver=Regex("[0-9]\\.[0-9.]+").match(run_command(argv))[0].str;
-               while(!cxx_ver.empty() && !FS::is_dir(FS::Path("/usr/include/c++")/cxx_ver))
+               if(RegMatch m=Regex("[0-9]\\.[0-9.]+").match(run_command(argv)))
                {
-                       unsigned dot=cxx_ver.rfind('.');
-                       if(dot==string::npos)
-                               break;
-                       cxx_ver.erase(dot);
+                       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);
                }
-               if(verbose>=5)
-                       IO::print("C++ version is %s\n", cxx_ver);
+               else
+                       cxx_ver="-";
        }
 
        string fn=include.substr(1);
@@ -405,7 +410,8 @@ Target *Builder::get_header(const string &include, const FS::Path &from, const l
                syspath.push_back("/usr/include");
        else
                syspath.push_back("/usr/"+current_arch->get_prefix()+"/include");
-       syspath.push_back((FS::Path("/usr/include/c++/")/cxx_ver).str());
+       if(cxx_ver!="-")
+               syspath.push_back((FS::Path("/usr/include/c++/")/cxx_ver).str());
 
        Target *tgt=0;
        if(include[0]=='\"')