]> git.tdb.fi Git - builder.git/commitdiff
Package configuration is cached
authorMikko Rasa <tdb@tdb.fi>
Fri, 1 Sep 2006 21:44:35 +0000 (21:44 +0000)
committerMikko Rasa <tdb@tdb.fi>
Fri, 1 Sep 2006 21:44:35 +0000 (21:44 +0000)
Correct behavior with build errors when jobs>1

source/builder.cpp
source/config.cpp
source/config.h
source/package.cpp

index cb8ddf610fe7b0237fb5a9f078ebcd122144e3ee..1de726bcb2b3393f267e363741525da20d6c72e6 100644 (file)
@@ -233,15 +233,6 @@ int Builder::main()
 
        default_pkg->create_build_info();
 
-       /*cout<<"Active packages:";
-       for(PackageMap::iterator i=packages.begin(); i!=packages.end(); ++i)
-       {
-               cout<<' '<<i->second->get_name();
-               if(i->second->get_buildable())
-                       cout<<'*';
-       }
-       cout<<'\n';*/
-       
        if(create_targets())
                return 1;
 
@@ -261,8 +252,6 @@ int Builder::main()
                }
        }
 
-       //cout<<"Active targets: "<<targets.size()<<'\n';
-
        if(analyzer)
                analyzer->analyze();
 
@@ -465,7 +454,7 @@ int Builder::build()
 
        while(!finish)
        {
-               if(actions.size()<jobs && !finish)
+               if(actions.size()<jobs && !fail)
                {
                        Target *tgt=cmdline->get_buildable_target();
                        if(tgt)
@@ -506,7 +495,9 @@ int Builder::build()
                                delete actions[i];
                                actions.erase(actions.begin()+i);
                                if(status>0)
-                                       finish=fail=true;
+                                       fail=true;
+                               if(actions.empty() && fail)
+                                       finish=true;
                        }
                        else
                                ++i;
index de6b9bce34525c0f86e4dd4f2b3a306840807649..61f7322e742ead72279f2d89a33f1012a4c8f497 100644 (file)
@@ -54,6 +54,19 @@ void Config::load(const Path::Path &fn)
        struct stat st;
        Path::stat(fn, st);
        mtime=Time::TimeStamp::from_unixtime(st.st_mtime);
+
+       Parser::Parser parser(in, fn.str());
+       Loader loader(*this);
+       loader.load(parser);
+}
+
+void Config::save(const Path::Path &fn) const
+{
+       ofstream out(fn.str().c_str());
+       if(!out) return;
+       
+       for(OptionMap::const_iterator i=options.begin(); i!=options.end(); ++i)
+               out<<"option \""<<i->second.name<<"\" \""<<i->second.value<<"\";\n";
 }
 
 Config::Option::Option(const string &n, const string &v, const string &d):
@@ -62,3 +75,16 @@ Config::Option::Option(const string &n, const string &v, const string &d):
        descr(d),
        value(v)
 { }
+
+Config::Loader::Loader(Config &c):
+       conf(c)
+{
+       add("option", &Loader::option);
+}
+
+void Config::Loader::option(const string &n, const string &v)
+{
+       OptionMap::iterator i=conf.options.find(n);
+       if(i!=conf.options.end())
+               i->second.value=v;
+}
index e5c90de0ce597f5bb14607a0f0b0e49481682202..9a73880ac887f331e9eae93d0ccbd48892aff7fd 100644 (file)
@@ -30,9 +30,16 @@ public:
        bool is_option(const std::string &) const;
        bool process(const RawOptionMap &);
        void load(const Msp::Path::Path &); 
+       void save(const Msp::Path::Path &) const;
 private:
        class Loader: public Msp::Parser::Loader
        {
+       public:
+               Loader(Config &);
+       private:
+               Config &conf;
+               
+               void option(const std::string &, const std::string &);
        };
        
        OptionMap options;
index 3072fd6a65ccd1d6a6303d54b80ffdb789ca35da..cb1940341722608c25e80f1e19794ba741e6ce66 100644 (file)
@@ -107,7 +107,8 @@ void Package::create_build_info()
 
 void Package::process_options(const RawOptionMap &opts)
 {
-       config.process(opts);
+       if(config.process(opts))
+               config.save(source/".options.cache");
 }
 
 Package *Package::create(Builder &b, const string &name)
@@ -156,6 +157,8 @@ void Package::init_buildable()
                config.add_option("includedir", "$prefix/lib",     "Library installation directory");
        if(flags&DATA)
                config.add_option("includedir", "$prefix/share",   "Data installation directory");*/
+
+       config.load(source/".options.cache");
 }
 
 unsigned Package::get_install_flags()