- chdir(work_dir.c_str());
-
- cwd=getcwd();
-
- Architecture &native_arch=archs.insert(ArchMap::value_type("native", Architecture(*this, "native"))).first->second;
- native_arch.set_tool("CC", "gcc");
- native_arch.set_tool("CXX", "g++");
- native_arch.set_tool("LD", "gcc");
- native_arch.set_tool("LXX", "g++");
- native_arch.set_tool("AR", "ar");
-
- load_build_file((get_home_dir()/".builderrc").str());
-
- if(prefix.empty())
- {
- if(current_arch=="native")
- prefix=(get_home_dir()/"local").str();
- else
- prefix=(get_home_dir()/"local"/current_arch).str();
- }
-
- warnings.push_back("all");
- warnings.push_back("extra");
- warnings.push_back("shadow");
- warnings.push_back("pointer-arith");
- warnings.push_back("error");
- for(StringList::iterator i=cmdline_warn.begin(); i!=cmdline_warn.end(); ++i)
- {
- vector<string> warns=split(*i, ',');
- warnings.insert(warnings.end(), warns.begin(), warns.end());
- }
-}
-
-/**
-Gets a package by name, possibly creating it.
-
-@param name Package name
-
-@return Pointer to the package, or 0 if the package could not be located
-*/
-Package *Builder::get_package(const string &name)
-{
- PackageMap::iterator i=packages.find(format("%s/%s", name, current_arch));
- if(i==packages.end())
- i=packages.find(name);
- if(i!=packages.end())
- return i->second;
-
- // Try to get source directory with pkgconfig
- list<string> argv;
- argv.push_back("pkg-config");
- argv.push_back("--variable=source");
- argv.push_back(name);
- if(verbose>=4)
- cout<<"Running "<<join(argv.begin(), argv.end())<<'\n';
- string srcdir=strip(run_command(argv));
-
- PathList dirs;
- if(!srcdir.empty())
- dirs.push_back(srcdir);
-
- // Make some other guesses about the source directory
- dirs.push_back(cwd/name);
- dirs.push_back(cwd/".."/name);
- if(!name.compare(0, 3, "msp"))
- {
- dirs.push_back(cwd/name.substr(3));
- dirs.push_back(cwd/".."/name.substr(3));
- }
-
- // Go through the candidate directories and look for a Build file
- for(PathList::iterator j=dirs.begin(); j!=dirs.end(); ++j)
- if(!load_build_file(*j/"Build"))
- {
- i=packages.find(name);
- if(i!=packages.end())
- return i->second;
- break;
- }
-
- // Package source not found - create a binary package
- Package *pkg=BinaryPackage::from_pkgconfig(*this, name);
-
- packages.insert(PackageMap::value_type(name, pkg));
-
- if(!pkg)
- problem(name, "not found");
-
- return pkg;
-}
-
-/**
-Returns the target with the given name, or 0 if no such target exists.
-*/
-Target *Builder::get_target(const string &n) const
-{
- TargetMap::const_iterator i=targets.find(n);
- if(i!=targets.end())
- return i->second;
- return 0;
-}
-
-/**
-Tries to locate a header included from a given location and with a given include
-path. Considers known targets as well as existing files. If a matching target
-is not found but a file exists, a new SystemHeader target will be created and
-returned.
-*/
-Target *Builder::get_header(const string &include, const string &from, const list<string> &path)
-{
- string hash(8, 0);
- update_hash(hash, from);
- for(list<string>::const_iterator i=path.begin(); i!=path.end(); ++i)
- update_hash(hash, *i);
-
- string id=hash+include;
- TargetMap::iterator i=includes.find(id);
- if(i!=includes.end())
- return i->second;