prefix=(FS::get_home_dir()/"local"/current_arch).str();
}
else
- prefix=prfx;
+ prefix=FS::getcwd()/prfx;
warnings.push_back("all");
warnings.push_back("extra");
vector<string> warns=split(*i, ',');
warnings.insert(warnings.end(), warns.begin(), warns.end());
}
+
+ pkg_path.push_back(cwd/".");
+ pkg_path.push_back(cwd/"..");
}
/**
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"))
+ FS::Path path=get_package_location(name);
+ if(!path.empty() && !load_build_file(path/"Build"))
{
- dirs.push_back(cwd/name.substr(3));
- dirs.push_back(cwd/".."/name.substr(3));
+ i=packages.find(name);
+ if(i!=packages.end())
+ return i->second;
}
- // 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);
if(conf_only)
return 0;
- cout<<all_reqs.size()<<" active packages, "<<targets.size()<<" targets\n";
+ if(verbose>=1)
+ cout<<all_reqs.size()<<" active packages, "<<targets.size()<<" targets\n";
if(verbose>=2)
{
for(PackageList::const_iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
}
}
+/**
+Determines the source directory of a package. pkg-config is consulted first,
+and if it fails, the package path is searched for matches.
+*/
+FS::Path Builder::get_package_location(const string &name)
+{
+ // 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));
+ if(!srcdir.empty())
+ return srcdir;
+
+ if(pkg_dirs.empty())
+ {
+ for(list<FS::Path>::const_iterator i=pkg_path.begin(); i!=pkg_path.end(); ++i)
+ {
+ list<string> files=list_files(*i);
+ for(list<string>::const_iterator j=files.begin(); j!=files.end(); ++j)
+ {
+ FS::Path full=*i / *j;
+ if(FS::exists(full/"Build"))
+ pkg_dirs.push_back(full);
+ }
+ }
+ }
+
+ bool msp=!name.compare(0, 3, "msp");
+ for(list<FS::Path>::const_iterator i=pkg_dirs.begin(); i!=pkg_dirs.end(); ++i)
+ {
+ string base=basename(*i);
+ unsigned dash=base.rfind('-');
+
+ if(!base.compare(0, dash, name))
+ return *i;
+ else if(msp && !base.compare(0, dash-3, name, 3, string::npos))
+ return *i;
+ }
+
+ return FS::Path();
+}
+
/**
Loads the given build file.
cout<<"Already up to date\n";
return 0;
}
- cout<<"Will build "<<total<<" target(s)\n";
+ if(verbose>=1)
+ cout<<"Will build "<<total<<" target(s)\n";
vector<Action *> actions;