]> git.tdb.fi Git - builder.git/commitdiff
Support custom build info
authorMikko Rasa <tdb@tdb.fi>
Mon, 18 Sep 2006 22:08:52 +0000 (22:08 +0000)
committerMikko Rasa <tdb@tdb.fi>
Mon, 18 Sep 2006 22:08:52 +0000 (22:08 +0000)
Support single source files

source/builder.cpp
source/buildinfo.cpp
source/buildinfo.h
source/component.cpp
source/component.h
source/package.cpp
source/package.h

index 2c137ca406841a1159269851f8177261504c91c9..7ba6be89a55fd03ccc5d570f4a325ff2c0b29300 100644 (file)
@@ -312,9 +312,16 @@ 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);
                        }
 
                        bool build_exe=j->get_type()!=Component::HEADERS;
@@ -444,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;
@@ -462,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);
@@ -507,8 +504,6 @@ int Builder::build()
                }
        }
 
-       //delete progress;
-
        return fail?-1:0;
 }
 
index 766954623cc3679e0f063179a5fee870244e0da7..340fd9660bbdfd6333d9eb219df6389ff545108f 100644 (file)
@@ -31,3 +31,16 @@ void BuildInfo::unique(InfoList &l)
                        l2.push_back(*i);
        swap(l, l2);
 }
+
+BuildInfo::Loader::Loader(BuildInfo &bi):
+       binfo(bi)
+{
+       add("cflag",   &Loader::cflag);
+       add("incpath", &Loader::incpath);
+       add("define",  &Loader::define);
+       add("ldflag",  &Loader::ldflag);
+       add("libpath", &Loader::libpath);
+       add("library", &Loader::library);
+}
+
+
index a4035b1c47c3ecb06ce572a388d48dbe3b8219b7..2e98906b36c3ef86debaac053ab37c4ae962c489 100644 (file)
@@ -3,10 +3,26 @@
 
 #include <list>
 #include <string>
+#include <msp/parser/loader.h>
 
 class BuildInfo
 {
 public:
+       class Loader: public Msp::Parser::Loader
+       {
+       public:
+               Loader(BuildInfo &);
+       private:
+               BuildInfo &binfo;
+               
+               void cflag(const std::string &s)   { binfo.cflags.push_back(s); }
+               void incpath(const std::string &s) { binfo.incpath.push_back(s); }
+               void define(const std::string &s)  { binfo.defines.push_back(s); }
+               void ldflag(const std::string &s)  { binfo.ldflags.push_back(s); }
+               void libpath(const std::string &s) { binfo.libpath.push_back(s); }
+               void library(const std::string &s) { binfo.libs.push_back(s); }
+       };
+       
        typedef std::list<std::string> InfoList;
        
        InfoList cflags;
index 1fd6b24bfc89676324cd80eb7fe3469c6263b86a..e0630e6cf8a69547ecb27f6c845f5daa6857f041 100644 (file)
@@ -22,7 +22,7 @@ Component::Loader::Loader(Component &c):
        add("source",          &Loader::source);
        add("install",         &Component::install);
        add("install_headers", &Component::install_headers);
-       add("cflag",           &Loader::cflag);
+       add("build_info",      &Loader::build_info);
 }
 
 void Component::Loader::source(const string &s)
@@ -30,7 +30,7 @@ void Component::Loader::source(const string &s)
        comp.sources.push_back(comp.pkg.get_source()/s);
 }
 
-void Component::Loader::cflag(const string &f)
+void Component::Loader::build_info()
 {
-       comp.build_info.cflags.push_back(f);
+       load_sub(comp.build_info);
 }
index d0b3cc2aff060c8031ff8111ad3c0725bfcc8ece..b1ce222de40ce0bed9694ec9d585b2bb9dce77ba 100644 (file)
@@ -21,7 +21,7 @@ public:
                Component &comp;
 
                void source(const std::string &);
-               void cflag(const std::string &);
+               void build_info();
        };
        
        enum Type
index 121213f19b068147f062d3afb5f4233f143ced26..58611800db87bc510db83997daddc0d352499cc0 100644 (file)
@@ -191,6 +191,7 @@ Package::Loader::Loader(Package &p):
        add("program",     &Loader::program);
        add("library",     &Loader::library);
        add("headers",     &Loader::headers);
+       add("build_info",  &Loader::build_info);
 }
 
 Package::Loader::~Loader()
@@ -223,3 +224,8 @@ void Package::Loader::headers(const string &n)
        load_sub(prog);
        pkg.components.push_back(prog);
 }
+
+void Package::Loader::build_info()
+{
+       load_sub(pkg.build_info);
+}
index 06a68ba65ca78656d9c91ebed35c2cb8fe81c8d7..eee157234f6df23b6ec4acbc912bd4bc22e53dee 100644 (file)
@@ -40,6 +40,7 @@ public:
                void program(const std::string &);
                void library(const std::string &);
                void headers(const std::string &);
+               void build_info();
        };
 
        Package(Builder &, const std::string &, const Msp::Path::Path &);