]> git.tdb.fi Git - builder.git/blobdiff - source/builder.cpp
Add an option to component to specify whether or not it should be built by default
[builder.git] / source / builder.cpp
index ccfb407276ee1a619b1bf85e1869a7acd75eab0a..38a71390ac5b5130a940da0f9c707ec24fa99b29 100644 (file)
@@ -579,7 +579,7 @@ int Builder::create_targets()
                                        exe=new Executable(*this, *j, objs);
 
                                add_target(exe);
-                               if(i->second==default_pkg)
+                               if(i->second==default_pkg && j->get_default())
                                {
                                        def_tgt->add_depend(exe);
                                        if(slib) def_tgt->add_depend(slib);
@@ -649,7 +649,7 @@ int Builder::create_targets()
        // Make the cmdline target depend on all targets mentioned on the command line
        Target *cmdline=new VirtualTarget(*this, "cmdline");
        add_target(cmdline);
-       world->add_depend(cmdline);
+       bool build_world=false;
        for(list<string>::iterator i=cmdline_targets.begin(); i!=cmdline_targets.end(); ++i)
        {
                Target *tgt=get_target(*i);
@@ -660,10 +660,21 @@ int Builder::create_targets()
                        cerr<<"I don't know anything about "<<*i<<'\n';
                        return -1;
                }
+               if(tgt==world)
+                       build_world=true;
                cmdline->add_depend(tgt);
        }
 
-       world->prepare();
+       /* If world is to be built, prepare cmdline.  If not, add cmdline to world
+          and prepare world.  I don't really like this, but it keeps the graph
+          acyclic. */
+       if(build_world)
+               cmdline->prepare();
+       else
+       {
+               world->add_depend(cmdline);
+               world->prepare();
+       }
 
        return 0;
 }