]> git.tdb.fi Git - builder.git/blobdiff - source/builder.cpp
Converted from iostreams to mspio
[builder.git] / source / builder.cpp
index 15c9e5455f84e0946fc01ef8c569181063d79394..21e7dcdf629c4a97780059c5d1615cb12dca60b2 100644 (file)
@@ -5,12 +5,13 @@ Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <fstream>
 #include <iostream>
 #include <set>
 #include <msp/core/except.h>
 #include <msp/core/getopt.h>
 #include <msp/datafile/parser.h>
+#include <msp/io/buffered.h>
+#include <msp/io/file.h>
 #include <msp/path/utils.h>
 #include <msp/strings/formatter.h>
 #include <msp/strings/regex.h>
@@ -217,7 +218,7 @@ Target *Builder::get_header(const string &include, const string &arch, const str
                StringList argv;
                argv.push_back(get_architecture(arch).get_tool("CXX"));
                argv.push_back("--version");
-               cxx_ver=Regex(" ([0-9.]+) ").match(run_command(argv))[1].str;
+               cxx_ver=Regex("[0-9]\\.[0-9.]+").match(run_command(argv))[0].str;
                while(!cxx_ver.empty() && !exists(Path("/usr/include/c++")/cxx_ver))
                {
                        unsigned dot=cxx_ver.rfind('.');
@@ -234,8 +235,6 @@ Target *Builder::get_header(const string &include, const string &arch, const str
                cout<<"Looking for include "<<fn<<" with path "<<join(path.begin(), path.end())<<'\n';
 
        StringList syspath;
-       if(include[0]=='\"')
-               syspath.push_back(from);
        if(arch=="native")
                syspath.push_back("/usr/include");
        else
@@ -243,6 +242,8 @@ Target *Builder::get_header(const string &include, const string &arch, const str
        syspath.push_back((Path("/usr/include/c++/")/cxx_ver/fn).str());
 
        Target *tgt=0;
+       if(include[0]=='\"')
+               tgt=get_header(Path(from)/fn);
        for(list<string>::const_iterator j=path.begin(); (!tgt && j!=path.end()); ++j)
                tgt=get_header(cwd/ *j/fn);
        for(list<string>::const_iterator j=syspath.begin(); (!tgt && j!=syspath.end()); ++j)
@@ -472,9 +473,8 @@ Loads the given build file.
 */
 int Builder::load_build_file(const Path &fn)
 {
-       ifstream in(fn.str().c_str());
-       if(!in)
-               return -1;
+       IO::File inf(fn.str());
+       IO::Buffered in(inf);
 
        if(verbose>=3)
                cout<<"Reading "<<fn<<'\n';
@@ -608,7 +608,10 @@ Target *Builder::get_library(const string &lib, const string &arch, const Path &
        if(mode!=ALL_STATIC)
        {
                if(arch=="win32")
+               {
                        candidates.push_back("lib"+lib+".dll");
+                       candidates.push_back(lib+".dll");
+               }
                else
                        candidates.push_back("lib"+lib+".so");
        }