]> git.tdb.fi Git - builder.git/blobdiff - source/builder.cpp
Support custom build info
[builder.git] / source / builder.cpp
index 1de726bcb2b3393f267e363741525da20d6c72e6..7ba6be89a55fd03ccc5d570f4a325ff2c0b29300 100644 (file)
@@ -132,11 +132,15 @@ Package *Builder::get_package(const string &n)
        
        Package *pkg=Package::create(*this, n);
        packages.insert(PackageMap::value_type(n, pkg));
-       new_pkgs.push_back(pkg);
+       if(pkg)
+               new_pkgs.push_back(pkg);
 
        return pkg;
 }
 
+/**
+Returns the target with the given name, or 0 if no such target exists.
+*/
 Target *Builder::get_target(const string &n)
 {
        TargetMap::iterator i=targets.find(n);
@@ -213,17 +217,12 @@ int Builder::main()
 
        std::list<std::string> missing;
        for(PackageMap::iterator i=packages.begin(); i!=packages.end(); ++i)
-       {
-               const list<PackageRef> &requires=i->second->get_requires();
-               for(list<PackageRef>::const_iterator j=requires.begin(); j!=requires.end(); ++j)
-                       if(!j->get_package())
-                               missing.push_back(j->get_name());
-       }
+               if(!i->second)
+                       missing.push_back(i->first);
 
        if(!missing.empty())
        {
                missing.sort();
-               missing.unique();
                cerr<<"The following packages were not found on the system:\n";
                for(list<string>::iterator i=missing.begin(); i!=missing.end(); ++i)
                        cerr<<"  "<<*i<<'\n';
@@ -302,6 +301,10 @@ int Builder::create_targets()
                if(!i->second->get_buildable())
                        continue;
 
+               Path::Path inst_base;
+               if(i->second->get_config().is_option("prefix"))
+                       inst_base=i->second->get_config().get_option("prefix").value;
+
                const ComponentList &components=i->second->get_components();
                for(ComponentList::const_iterator j=components.begin(); j!=components.end(); ++j)
                {
@@ -309,13 +312,18 @@ int Builder::create_targets()
                        const PathList &sources=j->get_sources();
                        for(PathList::const_iterator k=sources.begin(); k!=sources.end(); ++k)
                        {
-                               list<string> sfiles=list_files(*k);
-                               for(list<string>::iterator l=sfiles.begin(); l!=sfiles.end(); ++l)
-                                       files.push_back(*k / *l);
+                               struct stat st;
+                               stat(*k, st);
+                               if(S_ISDIR(st.st_mode))
+                               {
+                                       list<string> sfiles=list_files(*k);
+                                       for(list<string>::iterator l=sfiles.begin(); l!=sfiles.end(); ++l)
+                                               files.push_back(*k / *l);
+                               }
+                               else
+                                       files.push_back(*k);
                        }
 
-                       Path::Path inst_base=i->second->get_config().get_option("prefix").value;
-
                        bool build_exe=j->get_type()!=Component::HEADERS;
                        
                        list<ObjectFile *> objs;
@@ -385,6 +393,8 @@ int Builder::create_targets()
                Target *tgt=new_tgts.front();
                new_tgts.erase(new_tgts.begin());
                tgt->find_depends();
+               if(!tgt->get_depends_ready())
+                       new_tgts.push_back(tgt);
        }
 
        Target *cmdline=new VirtualTarget(*this, "cmdline");
@@ -441,12 +451,8 @@ int Builder::build()
 
        vector<Action *> actions;
 
-       //ProgressBar  *progress=0;
        if(chrome)
-       {
-               //progress=new ProgressBar(cout, total);
                cout<<"0 targets built\n";
-       }
        unsigned count=0;
 
        bool fail=false;
@@ -459,12 +465,6 @@ int Builder::build()
                        Target *tgt=cmdline->get_buildable_target();
                        if(tgt)
                        {
-                               /*if(chrome)
-                               {
-                                       cout<<"\e["<<actions.size()+1<<'A';
-                                       //progress->set(count);
-                                       cout<<"\e["<<actions.size()+1<<'B';
-                               }*/
                                Action *action=tgt->build();
                                if(action)
                                        actions.push_back(action);
@@ -504,8 +504,6 @@ int Builder::build()
                }
        }
 
-       //delete progress;
-
        return fail?-1:0;
 }