]> git.tdb.fi Git - builder.git/commitdiff
Add an option to component to specify whether or not it should be built by default
authorMikko Rasa <tdb@tdb.fi>
Fri, 10 Aug 2007 19:50:21 +0000 (19:50 +0000)
committerMikko Rasa <tdb@tdb.fi>
Fri, 10 Aug 2007 19:50:21 +0000 (19:50 +0000)
Handle building world properly

source/builder.cpp
source/component.cpp
source/component.h
source/target.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;
 }
index fdc0a6d02d572d945dbeb376e6f4a2d63dd217fc..4bdff213abcaf45a404d62444c7fe19b2b343479 100644 (file)
@@ -10,7 +10,8 @@ Component::Component(Package &p, Type t, const string &n):
        name(n),
        install(false),
        module_host(0),
-       modular(false)
+       modular(false),
+       deflt(true)
 { }
 
 /**
@@ -62,6 +63,7 @@ Component::Loader::Loader(Component &c):
        add("require",         &Loader::require);
        add("modular",         &Loader::modular);
        add("host",            &Loader::host);
+       add("default",         &Component::deflt);
 }
 
 void Component::Loader::source(const string &s)
index e1df73a5b232aefd9c554010b2767f9f7697c297..e5057352f0cf86b91787d8af3a7634c389bd6fed 100644 (file)
@@ -34,7 +34,7 @@ public:
                void host(const std::string &);
                void build_info();
        };
-       
+
        enum Type
        {
                PROGRAM,
@@ -53,6 +53,7 @@ public:
        const std::string &get_install_headers() const { return install_headers; }
        bool              get_modular() const          { return modular; }
        const PkgRefList  &get_requires() const        { return requires; }
+       bool              get_default() const          { return deflt; }
        void              resolve_refs();
        void              create_build_info();
 protected:
@@ -66,6 +67,7 @@ protected:
        bool        modular;
        BuildInfo   build_info;
        PkgRefList  requires;
+       bool        deflt;
 };
 typedef std::list<Component> ComponentList;
 
index e8ed647477fcf82823f06195cfa8a7e43edf7441..3b1685324997fcfebce2273d828e39a0a83ea37a 100644 (file)
@@ -36,6 +36,8 @@ Target *Target::get_buildable_target()
 
 void Target::add_depend(Target *dep)
 {
+       if(dep==this)
+               throw InvalidParameterValue("A target can't depend on itself");
        depends.push_back(dep);
        dep->rdepends.push_back(this);
 }