]> git.tdb.fi Git - builder.git/blobdiff - source/package.cpp
Don't throw up if a package doesn't install anything
[builder.git] / source / package.cpp
index 5255b864dd8aac6b44eff025dd736fdbdacd5de2..0bea2a96b03048c4d476815b56a799d7270526f2 100644 (file)
@@ -31,6 +31,16 @@ void Package::set_path(const Msp::Path::Path &p)
        path=builder.get_cwd()/p;
 }
 
+Msp::Path::Path Package::get_temp_dir() const
+{
+       return source/config.get_option("tempdir").value/config.get_option("profile").value;
+}
+
+Msp::Path::Path Package::get_out_dir() const
+{
+       return source/config.get_option("outdir").value;
+}
+
 /**
 Checks which kinds of things the components of this package install.
 
@@ -55,6 +65,19 @@ unsigned Package::get_install_flags()
        return flags;
 }
 
+LibMode Package::get_library_mode() const
+{
+       const string &mode=config.get_option("staticlibs").value;
+       if(mode=="all")
+               return ALL_STATIC;
+       else if(mode=="local")
+               return LOCAL_STATIC;
+       else if(mode=="none")
+               return DYNAMIC;
+       else
+               throw Exception("Unknown library mode");
+}
+
 /**
 Tries to resolve all references to dependency packages.
 */
@@ -81,28 +104,38 @@ line.
 */
 void Package::configure(const RawOptionMap &opts, unsigned flag)
 {
-       if(conf_done || !buildable)
+       if(conf_done)
                return;
-       
+
        if(builder.get_verbose()>=3)
                cout<<"Configuring "<<name<<'\n';
-       
-       init_config();
 
-       if(flag && config.process(opts) && !builder.get_dry_run())
-       {
-               if(builder.get_verbose()>=2)
-                       cout<<"Configuration of "<<name<<" changed.\n";
-               config.save(source/".options.cache");
-       }
-       
-       for(PackageList::iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
+       if(buildable)
        {
-               (*i)->configure(opts, flag&2);
-               if((*i)->get_need_path())
-                       (*i)->set_path(config.get_option((*i)->get_name()+"_path").value);
+               init_config();
+
+               RawOptionMap::const_iterator prof=opts.find("profile");
+               if(prof!=opts.end())
+                       config.select_profile(prof->second);
+               else
+                       config.select_last_profile();
+                       
+               if(flag && config.update(opts))
+               {
+                       if(builder.get_verbose()>=2)
+                               cout<<"Configuration of "<<name<<" changed\n";
+                       if(!builder.get_dry_run())
+                               config.save();
+               }
+
+               for(PackageList::iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
+               {
+                       if((*i)->get_need_path())
+                               (*i)->set_path(config.get_option((*i)->get_name()+"_path").value);
+                       (*i)->configure(opts, flag&2);
+               }
        }
-       
+
        create_build_info();
 
        conf_done=true;
@@ -138,6 +171,8 @@ Package *Package::create(Builder &b, const string &name)
                        info.push_back("-lgmpxx");
                else if(name=="fmod4")
                        need_path=true;
+               else if(name=="devil")
+                       info.push_back("-lIL");
                else
                        return 0;
        }
@@ -173,12 +208,14 @@ Initializes configuration options and loads cached values.
 */
 void Package::init_config()
 {
-       config.add_option("tempdir",    "temp",   "Directory for storing temporary files");
-       config.add_option("optimize",   "0",      "Apply compiler optimizations");
-       config.add_option("debug",      "0",      "Produce debugging symbols");
-       config.add_option("cpu",        "auto",   "CPU type to optimize for");
-       config.add_option("arch",       "native", "Architecture for cross-compiling");
-       config.add_option("staticlibs", "local",  "Use static libraries");
+       config.add_option("profile",    "default", "Configuration profile");
+       config.add_option("tempdir",    "temp",    "Directory for storing temporary files");
+       config.add_option("outdir",     ".",       "Directory to put build results in");
+       config.add_option("optimize",   "0",       "Apply compiler optimizations");
+       config.add_option("debug",      "0",       "Produce debugging symbols");
+       config.add_option("cpu",        "auto",    "CPU type to optimize for");
+       config.add_option("arch",       "native",  "Architecture for cross-compiling");
+       config.add_option("staticlibs", "local",   "Use static libraries");
 
        const char *home=getenv("HOME");
        unsigned flags=get_install_flags();
@@ -197,7 +234,7 @@ void Package::init_config()
                if(i->get_package() && i->get_package()->get_need_path())
                        config.add_option(i->get_name()+"_path", "", "Path for "+i->get_name());
 
-       config.load(source/".options.cache");
+       config.set_source(source);
 }
 
 /**