need_path true;
};
+binary_package "ode"
+{
+ build_info
+ {
+ library "ode";
+ };
+};
+
binary_package "xlib"
{
build_info
#include <iostream>
#include <sstream>
#include <msp/path/path.h>
+#include <msp/path/utils.h>
#include "analyzer.h"
#include "builder.h"
#include "install.h"
if(full_paths)
fn=tgt.get_name();
else
- fn=Path::Path(tgt.get_name())[-1];
+ fn=basename(tgt.get_name());
row.push_back(string(depth*2, ' ')+fn);
const Package *pkg=tgt.get_package();
if(dynamic_cast<ObjectFile *>(*i))
argv.push_back((*i)->get_name());
- Path::Path lpath=lib.get_name();
+ Path lpath=lib.get_name();
if(!builder.get_dry_run())
- Path::mkpath(lpath.subpath(0, lpath.size()-1), 0755);
+ mkpath(lpath.subpath(0, lpath.size()-1), 0755);
announce(comp.get_package().get_name(), tool, relative(lpath, comp.get_package().get_source()).str());
Distributed under the LGPL
*/
+#include <iostream>
#include <msp/strings/utils.h>
#include "binarypackage.h"
#include "builder.h"
Sets the path where the package files were installed. This is only useful if
the package doesn't use pkg-config.
*/
-void BinaryPackage::set_path(const Msp::Path::Path &p)
+void BinaryPackage::set_path(const Msp::Path &p)
{
path=builder.get_cwd()/p;
}
argv.push_back("--cflags");
argv.push_back("--libs");
argv.push_back(name);
+ if(builder.get_verbose()>=4)
+ cout<<"Running "<<join(argv.begin(), argv.end())<<'\n';
string info=run_command(argv);
if(info.empty())
};
BinaryPackage(Builder &, const std::string &);
- void set_path(const Msp::Path::Path &);
+ void set_path(const Msp::Path &);
bool get_need_path() const { return need_path; }
static BinaryPackage *from_pkgconfig(Builder &, const std::string &);
private:
bool need_path;
- Msp::Path::Path path;
+ Msp::Path path;
virtual void create_build_info();
};
if(!work_dir.empty())
chdir(work_dir.c_str());
- cwd=Path::getcwd();
+ cwd=getcwd();
Architecture &native_arch=archs.insert(ArchMap::value_type("native", Architecture(*this, "native"))).first->second;
native_arch.set_tool("CC", "gcc");
const char *home=getenv("HOME");
if(home)
- load_build_file((Path::Path(home)/".builderrc").str());
+ load_build_file((Path(home)/".builderrc").str());
}
/**
argv.push_back("pkg-config");
argv.push_back("--variable=source");
argv.push_back(n);
+ if(verbose>=4)
+ cout<<"Running "<<join(argv.begin(), argv.end())<<'\n';
string srcdir=strip(run_command(argv));
PathList dirs;
string fn=include.substr(1);
Target *tgt=0;
- if(include[0]=='"' && (tgt=get_header(Path::Path(from)/fn)))
+ if(include[0]=='"' && (tgt=get_header(Path(from)/fn)))
;
- else if((tgt=get_header(Path::Path("/usr/include")/fn)))
+ else if((tgt=get_header(Path("/usr/include")/fn)))
;
//XXX Determine the C++ header location dynamically
- else if((tgt=get_header(Path::Path("/usr/include/c++/4.1.2")/fn)))
+ else if((tgt=get_header(Path("/usr/include/c++/4.1.2")/fn)))
;
else
{
@return 0 on success, -1 if the file could not be opened
*/
-int Builder::load_build_file(const Path::Path &fn)
+int Builder::load_build_file(const Path &fn)
{
ifstream in(fn.str().c_str());
if(!in)
Check if a header exists, either as a target or a file. Either an existing
target or a new SystemHeader target will be returned.
*/
-Target *Builder::get_header(const Msp::Path::Path &fn)
+Target *Builder::get_header(const Msp::Path &fn)
{
Target *tgt=get_target(fn.str());
if(tgt) return tgt;
- if(Path::exists(fn))
+ if(exists(fn))
{
tgt=new SystemHeader(*this, fn.str());
return tgt;
return 0;
}
-Target *Builder::get_library(const string &lib, const string &arch, const Path::Path &path, LibMode mode)
+Target *Builder::get_library(const string &lib, const string &arch, const Path &path, LibMode mode)
{
// Populate a list of candidate filenames
StringList candidates;
else if(tgt)
return tgt;
}
- else if(Path::exists(full))
+ else if(exists(full))
{
tgt=new SystemLibrary(*this, full);
return tgt;
Application::RegApp<Builder> Builder::reg;
-Builder::Loader::Loader(Builder &b, const Path::Path &s):
+Builder::Loader::Loader(Builder &b, const Path &s):
bld(b),
src(s)
{
const TargetMap &get_targets() const { return targets; }
Target *get_header(const std::string &, const std::string &, const std::string &, const StringList &);
Target *get_library(const std::string &, const std::string &, const StringList &, LibMode);
- const Msp::Path::Path &get_cwd() const { return cwd; }
+ const Msp::Path &get_cwd() const { return cwd; }
const Architecture &get_architecture(const std::string &) const;
void apply_profile_template(Config &, const std::string &) const;
void add_target(Target *);
class Loader: public Msp::DataFile::Loader
{
public:
- Loader(Builder &, const Msp::Path::Path &);
+ Loader(Builder &, const Msp::Path &);
private:
Builder &bld;
- Msp::Path::Path src;
+ Msp::Path src;
void architecture(const std::string &);
void binpkg(const std::string &);
StringList cmdline_targets;
StringMap cmdline_options;
- Msp::Path::Path cwd;
+ Msp::Path cwd;
PackageMap packages;
SourcePackage *main_pkg;
bool build_all;
bool create_makefile;
- int load_build_file(const Msp::Path::Path &);
+ int load_build_file(const Msp::Path &);
int create_targets();
- Target *get_header(const Msp::Path::Path &);
- Target *get_library(const std::string &, const std::string &, const Msp::Path::Path &, LibMode);
+ Target *get_header(const Msp::Path &);
+ Target *get_library(const std::string &, const std::string &, const Msp::Path &, LibMode);
void update_hash(std::string &, const std::string &);
int do_build();
int do_clean();
const Component &comp=obj.get_component();
const TargetList &deps=obj.get_depends();
- Path::Path spath=deps.front()->get_name();
+ Path spath=deps.front()->get_name();
- string ext=Path::splitext(spath.str()).ext;
+ string ext=splitext(spath.str()).ext;
const char *tool=0;
if(ext==".cpp" || ext==".cc")
tool="CXX";
for(list<string>::const_iterator i=binfo.defines.begin(); i!=binfo.defines.end(); ++i)
argv.push_back("-D"+*i);
- Path::Path opath=obj.get_name();
+ Path opath=obj.get_name();
argv.push_back("-o");
argv.push_back(opath.str());
argv.push_back(spath.str());
if(!builder.get_dry_run())
- Path::mkpath(opath.subpath(0, opath.size()-1), 0755);
+ mkpath(opath.subpath(0, opath.size()-1), 0755);
announce(comp.get_package().get_name(), tool, relative(opath, comp.get_package().get_source()).str());
for(PathList::const_iterator i=files.begin(); i!=files.end(); ++i)
{
string basename=(*i)[-1];
- string ext=Path::splitext(basename).ext;
+ string ext=splitext(basename).ext;
if((ext==".cpp" || ext==".c") && build_exe)
{
SourceFile *src=new SourceFile(builder, this, i->str());
PathList files;
for(PathList::const_iterator i=sources.begin(); i!=sources.end(); ++i)
{
- struct stat st;
- stat(*i, st);
+ struct stat st=stat(*i);
if(S_ISDIR(st.st_mode))
{
list<string> sfiles=list_files(*i);
void Config::save() const
{
- Path::Path fn=package.get_source()/".options.cache";
+ Path fn=package.get_source()/".options.cache";
OptionMap::const_iterator i=options.find("profile");
if(i!=options.end())
void Config::load()
{
- Path::Path fn=package.get_source()/".options.cache";
+ Path fn=package.get_source()/".options.cache";
OptionMap::iterator i=options.find("profile");
if(i!=options.end())
ifstream in(fn.str().c_str());
if(!in) return;
- struct stat st;
- Path::stat(fn, st);
- mtime=Time::TimeStamp::from_unixtime(st.st_mtime);
+ mtime=Time::TimeStamp::from_unixtime(stat(fn).st_mtime);
DataFile::Parser parser(in, fn.str());
Loader loader(*this);
using namespace std;
using namespace Msp;
-Copy::Copy(Builder &b, const Package &pkg, const Path::Path &s, const Path::Path &d):
+Copy::Copy(Builder &b, const Package &pkg, const Path &s, const Path &d):
InternalAction(b),
src(s),
dest(d)
void Copy::Worker::main()
{
- Path::mkpath(copy.dest.subpath(0, copy.dest.size()-1), 0755);
+ mkpath(copy.dest.subpath(0, copy.dest.size()-1), 0755);
- // Remove old file. Not doing this would cause Bad Stuff when installing libraries.
- if(unlink(copy.dest.str().c_str())<0 && errno!=ENOENT)
+ try
{
- int err=errno;
- cerr<<"Can't unlink "<<copy.dest<<": "<<strerror(err)<<'\n';
- done=error=true;
- return;
+ // Remove old file. Not doing this would cause Bad Stuff when installing libraries.
+ unlink(copy.dest);
+ }
+ catch(const SystemError &e)
+ {
+ if(e.get_error_code()!=ENOENT)
+ {
+ cerr<<e.what()<<'\n';
+ done=error=true;
+ return;
+ }
}
ifstream in(copy.src.str().c_str());
}
// Preserve file permissions
- struct stat st;
- Path::stat(copy.src, st);
+ struct stat st=stat(copy.src);
chmod(copy.dest.str().c_str(), st.st_mode&0777);
done=true;
class Copy: public InternalAction
{
public:
- Copy(Builder &, const Package &, const Msp::Path::Path &, const Msp::Path::Path &);
+ Copy(Builder &, const Package &, const Msp::Path &, const Msp::Path &);
private:
/**
A worker thread that actually does the data transfer.
void main();
};
- Msp::Path::Path src;
- Msp::Path::Path dest;
+ Msp::Path src;
+ Msp::Path dest;
};
#endif
deps[parts[0]]=StringList(parts.begin()+1, parts.end());
}
- struct stat st;
- Path::stat(fn, st);
- mtime=Time::TimeStamp::from_unixtime(st.st_mtime);
+ mtime=Time::TimeStamp::from_unixtime(stat(fn).st_mtime);
}
queue.push_back(&stlib->get_component());
}
else
- builder.problem(comp.get_package().get_name(), format("Couldn't find library %s for %s", *i, Path::basename(name)));
+ builder.problem(comp.get_package().get_name(), format("Couldn't find library %s for %s", *i, basename(name)));
}
}
{
Target *dep=depends.front();
if(dep->get_mtime()>mtime)
- mark_rebuild(Path::basename(dep->get_name())+" has changed");
+ mark_rebuild(basename(dep->get_name())+" has changed");
else if(dep->get_rebuild())
- mark_rebuild(Path::basename(dep->get_name())+" needs rebuilding");
+ mark_rebuild(basename(dep->get_name())+" needs rebuilding");
}
}
{
const SourcePackage *spkg=dynamic_cast<const SourcePackage *>(tgt.get_package());
- Path::Path base=spkg->get_prefix();
+ Path base=spkg->get_prefix();
string tgtname=tgt.get_name().substr(tgt.get_name().rfind('/')+1);
string mid;
argv.push_back("-l"+syslib->get_libname());
}
- Path::Path epath=exe.get_name();
+ Path epath=exe.get_name();
if(!builder.get_dry_run())
- Path::mkpath(epath.subpath(0, epath.size()-1), 0755);
+ mkpath(epath.subpath(0, epath.size()-1), 0755);
announce(comp.get_package().get_name(), tool, relative(epath, comp.get_package().get_source()).str());
};
typedef std::list<std::string> StringList;
-typedef std::list<Msp::Path::Path> PathList;
+typedef std::list<Msp::Path> PathList;
typedef std::map<std::string, std::string> StringMap;
std::string run_command(const StringList &);
string ObjectFile::generate_target_name(const Component &comp, const string &src)
{
- return (comp.get_package().get_temp_dir()/comp.get_name()/(Path::splitext(src.substr(src.rfind('/')+1)).base+".o")).str();
+ return (comp.get_package().get_temp_dir()/comp.get_name()/(splitext(basename(src)).base+".o")).str();
}
*/
#include <fstream>
+#include <iostream>
#include <msp/strings/regex.h>
#include "builder.h"
#include "component.h"
ifstream in(name.c_str());
if(!in) return;
+ if(builder.get_verbose()>=4)
+ cout<<"Reading includes from "<<name<<'\n';
+
Regex r_include("^[ \t]*#include[ \t]+([\"<].*)[\">]");
string line;
/**
Creates a buildable package.
*/
-SourcePackage::SourcePackage(Builder &b, const string &n, const Path::Path &s):
+SourcePackage::SourcePackage(Builder &b, const string &n, const Path &s):
Package(b, n),
source(s),
config(*this),
tar_files.push_back(source/"Build");
}
-Msp::Path::Path SourcePackage::get_temp_dir() const
+Msp::Path SourcePackage::get_temp_dir() const
{
return source/config.get_option("tempdir").value/config.get_option("profile").value;
}
-Msp::Path::Path SourcePackage::get_out_dir() const
+Msp::Path SourcePackage::get_out_dir() const
{
return source/config.get_option("outdir").value;
}
unsigned flags=get_install_flags();
if(flags&INCLUDE)
- export_binfo.incpath.push_back((Path::Path(config.get_option("prefix").value)/"include").str());
+ export_binfo.incpath.push_back((Path(config.get_option("prefix").value)/"include").str());
if(flags&LIB)
- export_binfo.libpath.push_back((Path::Path(config.get_option("prefix").value)/"lib").str());
+ export_binfo.libpath.push_back((Path(config.get_option("prefix").value)/"lib").str());
string optimize=config.get_option("optimize").value;
if(lexical_cast<unsigned>(optimize))
void tar_file(const std::string &);
};
- SourcePackage(Builder &, const std::string &, const Msp::Path::Path &);
- void set_path(const Msp::Path::Path &);
+ SourcePackage(Builder &, const std::string &, const Msp::Path &);
+ void set_path(const Msp::Path &);
const std::string &get_name() const { return name; }
const std::string &get_version() const { return version; }
const std::string &get_description() const { return description; }
- const Msp::Path::Path &get_source() const { return source; }
- Msp::Path::Path get_temp_dir() const;
- Msp::Path::Path get_out_dir() const;
- Msp::Path::Path get_prefix() const { return config.get_option("prefix").value; }
+ const Msp::Path &get_source() const { return source; }
+ Msp::Path get_temp_dir() const;
+ Msp::Path get_out_dir() const;
+ Msp::Path get_prefix() const { return config.get_option("prefix").value; }
const ComponentList &get_components() const { return components; }
const Config &get_config() const { return config; }
const BuildInfo &get_build_info() const { return build_info; }
std::string version;
std::string description;
- Msp::Path::Path source;
+ Msp::Path source;
PackageList base_reqs;
FeatureList features;
BuildInfo build_info;
SystemLibrary::SystemLibrary(Builder &b, const string &n):
Target(b, 0, n)
{
- libname=Path::splitext(Path::basename(n)).base;
+ libname=splitext(basename(n)).base;
if(!libname.compare(0, 3, "lib"))
libname.erase(0, 3);
}
void Tar::Worker::main()
{
- const Path::Path &pkg_src=tar.tarball.get_package()->get_source();
- Path::Path basedir=Path::splitext(Path::basename(tar.tarball.get_name())).base;
+ const Path &pkg_src=tar.tarball.get_package()->get_source();
+ Path basedir=splitext(basename(tar.tarball.get_name())).base;
ofstream out(tar.tarball.get_name().c_str());
const TargetList &deps=tar.tarball.get_depends();
memcpy(buf, rel_path.data(), rel_path.size());
- struct stat st;
- Path::stat((*i)->get_name(), st);
+ struct stat st=stat((*i)->get_name());
store_number(buf+100, st.st_mode, 7);
store_number(buf+108, st.st_uid, 7);
store_number(buf+116, st.st_gid, 7);
builder.add_target(this);
struct stat st;
- if(!Path::stat(name, st))
+ if(!stat(name, st))
mtime=Time::TimeStamp::from_unixtime(st.st_mtime);
}
for(TargetList::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i)
{
if((*i)->get_mtime()>mtime)
- mark_rebuild(Path::basename((*i)->get_name())+" has changed");
+ mark_rebuild(basename((*i)->get_name())+" has changed");
else if((*i)->get_rebuild())
- mark_rebuild(Path::basename((*i)->get_name())+" needs rebuilding");
+ mark_rebuild(basename((*i)->get_name())+" needs rebuilding");
}
}
{
for(TargetList::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i)
if((*i)->get_rebuild())
- mark_rebuild(Msp::Path::basename((*i)->get_name())+" needs rebuilding");
+ mark_rebuild(Msp::basename((*i)->get_name())+" needs rebuilding");
}
/**