X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpackage.cpp;h=14ae5f7878ac99781a701eb9fee6ce82052df204;hb=74266a6e650f019063cdcd1c9a7bd26d8f99041b;hp=d4022f5f3fae7b0f045ddea2087828d5eb987ad9;hpb=63adab21a6f229f434b41eb59c5718fdc3c37b15;p=builder.git diff --git a/source/package.cpp b/source/package.cpp index d4022f5..14ae5f7 100644 --- a/source/package.cpp +++ b/source/package.cpp @@ -9,46 +9,40 @@ using namespace Msp; #include +/** +Creates a buildable package. +*/ Package::Package(Builder &b, const string &n, const Path::Path &s): builder(b), name(n), - source(s), buildable(true), + source(s), build_info_ready(false) { } -Package::Package(Builder &b, const string &n, const vector &info): - builder(b), - name(n), - buildable(false), - build_info_ready(false) -{ - for(vector::const_iterator i=info.begin(); i!=info.end(); ++i) - { - if(!i->compare(0, 2, "-I")) - export_binfo.incpath.push_back(i->substr(2)); - else if(!i->compare(0, 2, "-D")) - export_binfo.defines.push_back(i->substr(2)); - else if(!i->compare(0, 2, "-L")) - export_binfo.libpath.push_back(i->substr(2)); - else if(!i->compare(0, 2, "-l")) - export_binfo.libs.push_back(i->substr(2)); - } -} - +/** +Sets the path where the package files were installed. This is only useful for +non-buildable packages that don't use pkg-config. +*/ void Package::set_path(const Msp::Path::Path &p) { path=builder.get_cwd()/p; } +/** +Tries to resolve all references to dependency packages. +*/ void Package::resolve_refs() { - for(list::iterator i=requires.begin(); i!=requires.end(); ++i) + for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i) i->resolve(); for(ComponentList::iterator i=components.begin(); i!=components.end(); ++i) i->resolve_refs(); } +/** +Fills in build info based on configuration. +*/ void Package::create_build_info() { if(build_info_ready) @@ -56,7 +50,7 @@ void Package::create_build_info() if(buildable) { - for(list::iterator i=requires.begin(); i!=requires.end(); ++i) + for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i) { Package *pkg=i->get_package(); if(!pkg) @@ -120,12 +114,21 @@ void Package::create_build_info() build_info_ready=true; } +/** +Processes configuration options that were most likely obtained from the command +line. +*/ void Package::process_options(const RawOptionMap &opts) { if(config.process(opts)) config.save(source/".options.cache"); } +/** +Creates a non-buildable package with the given name. Pkg-config is tried first +to get build information. If it fails, a built-in list of known packages is +consulted. +*/ Package *Package::create(Builder &b, const string &name) { list argv; @@ -139,6 +142,7 @@ Package *Package::create(Builder &b, const string &name) bool need_path=false; if(info.empty()) { + //XXX Put these in an external file if(name=="opengl") info.push_back("-lGL"); else if(name=="pthread") @@ -156,6 +160,30 @@ Package *Package::create(Builder &b, const string &name) return pkg; } +/*** private ***/ + +Package::Package(Builder &b, const string &n, const vector &info): + builder(b), + name(n), + buildable(false), + build_info_ready(false) +{ + for(vector::const_iterator i=info.begin(); i!=info.end(); ++i) + { + if(!i->compare(0, 2, "-I")) + export_binfo.incpath.push_back(i->substr(2)); + else if(!i->compare(0, 2, "-D")) + export_binfo.defines.push_back(i->substr(2)); + else if(!i->compare(0, 2, "-L")) + export_binfo.libpath.push_back(i->substr(2)); + else if(!i->compare(0, 2, "-l")) + export_binfo.libs.push_back(i->substr(2)); + } +} + +/** +Initializes a buildable package. Mostly adds configuration options. +*/ void Package::init_buildable() { buildable=true; @@ -179,12 +207,17 @@ void Package::init_buildable() if(flags&DATA) config.add_option("includedir", "$prefix/share", "Data installation directory");*/ - for(list::iterator i=requires.begin(); i!=requires.end(); ++i) + for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i) config.add_option(i->get_name()+"_path", "", "Path for "+i->get_name()); config.load(source/".options.cache"); } +/** +Checks which kinds of things the components of this package install. + +@return A bitmask of installed things +*/ unsigned Package::get_install_flags() { unsigned flags=0;