]> git.tdb.fi Git - builder.git/blobdiff - source/package.cpp
Add comments
[builder.git] / source / package.cpp
index d4022f5f3fae7b0f045ddea2087828d5eb987ad9..14ae5f7878ac99781a701eb9fee6ce82052df204 100644 (file)
@@ -9,46 +9,40 @@ using namespace Msp;
 
 #include <iostream>
 
+/**
+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<string> &info):
-       builder(b),
-       name(n),
-       buildable(false),
-       build_info_ready(false)
-{
-       for(vector<string>::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<PackageRef>::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<PackageRef>::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<string> 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<string> &info):
+       builder(b),
+       name(n),
+       buildable(false),
+       build_info_ready(false)
+{
+       for(vector<string>::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<PackageRef>::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;