]> git.tdb.fi Git - builder.git/commitdiff
Output cleanup
authorMikko Rasa <tdb@tdb.fi>
Sun, 27 Aug 2006 22:10:00 +0000 (22:10 +0000)
committerMikko Rasa <tdb@tdb.fi>
Sun, 27 Aug 2006 22:10:00 +0000 (22:10 +0000)
Support configuration (no caching yet)

source/builder.cpp
source/config.cpp
source/config.h
source/copy.h [new file with mode: 0644]
source/externalaction.cpp
source/install.h [deleted file]
source/package.cpp
source/target.cpp

index 05ecf877c7f47265131491fa50f0e00189015c1d..c900837a2d6e978079294606ccbf4f182ae520e8 100644 (file)
@@ -44,7 +44,6 @@ Package *Builder::get_package(const string &n)
        argv.push_back("--variable=source");
        argv.push_back(n);
        string srcdir=strip(run_command(argv));
-       cout<<srcdir;
        
        list<Path::Path> dirs;
        if(!srcdir.empty())
@@ -88,7 +87,7 @@ Target *Builder::get_header(const string &include, const string &from, const lis
                return i->second;
 
        string fn=include.substr(1);
-       Target *tgt;
+       Target *tgt=0;
        if(include[0]=='"' && (tgt=check_header(Path::Path(from)/fn)))
                return tgt;
        if((tgt=check_header(Path::Path("/usr/include")/fn)))
@@ -115,6 +114,8 @@ int Builder::main()
        while(!new_pkgs.empty())
        {
                Package *pkg=new_pkgs.front();
+               if(pkg==default_pkg)
+                       pkg->process_options(cmdline_options);
                new_pkgs.erase(new_pkgs.begin());
                pkg->resolve_refs();
        }
@@ -152,8 +153,8 @@ int Builder::main()
        if(create_targets())
                return 1;
 
-       for(TargetMap::iterator i=targets.begin(); i!=targets.end(); ++i)
-               cout<<i->second->get_name()<<' '<<i->second->get_type()<<' '<<i->second->get_rebuild()<<' '<<i->second->get_rebuild_reason()<<'\n';
+       /*for(TargetMap::iterator i=targets.begin(); i!=targets.end(); ++i)
+               cout<<i->second->get_name()<<' '<<i->second->get_type()<<' '<<i->second->get_rebuild()<<' '<<i->second->get_rebuild_reason()<<'\n';*/
 
        cout<<"Active targets: "<<targets.size()<<'\n';
 
@@ -275,6 +276,9 @@ int Builder::build()
        list<Action *> actions;
        bool fail=false;
 
+       if(!cmdline->get_rebuild())
+               cout<<"Already up to date\n";
+
        while(cmdline->get_rebuild() && !fail)
        {
                if(actions.empty() && !fail)
@@ -282,7 +286,7 @@ int Builder::build()
                        Target *tgt=cmdline->get_buildable_target();
                        if(tgt)
                        {
-                               cout<<"Build "<<tgt->get_name()<<'\n';
+                               //cout<<"Build "<<tgt->get_name()<<'\n';
                                Action *action=tgt->build();
                                if(action)
                                        actions.push_back(action);
@@ -301,6 +305,8 @@ int Builder::build()
                                if(status>0)
                                        fail=true;
                        }
+                       else
+                               ++i;
                }
        }
 
index 50e0de9f9a165bfd9e461c6d8a194e1a756c316c..de6b9bce34525c0f86e4dd4f2b3a306840807649 100644 (file)
@@ -1,4 +1,7 @@
+#include <fstream>
 #include <msp/error.h>
+#include <msp/path/utils.h>
+#include <msp/time/utils.h>
 #include "config.h"
 
 using namespace std;
@@ -37,9 +40,22 @@ bool Config::process(const RawOptionMap &opts)
                }
        }
 
+       if(changed)
+               mtime=Time::now();
+
        return changed;
 }
 
+void Config::load(const Path::Path &fn)
+{
+       ifstream in(fn.str().c_str());
+       if(!in) return;
+
+       struct stat st;
+       Path::stat(fn, st);
+       mtime=Time::TimeStamp::from_unixtime(st.st_mtime);
+}
+
 Config::Option::Option(const string &n, const string &v, const string &d):
        name(n),
        defv(v),
index 1b78e3a4e4d2e8a1168be85f6ec0f78187d60202..e5c90de0ce597f5bb14607a0f0b0e49481682202 100644 (file)
@@ -3,6 +3,9 @@
 
 #include <map>
 #include <string>
+#include <msp/parser/loader.h>
+#include <msp/path/path.h>
+#include <msp/time/timestamp.h>
 #include "option.h"
 
 typedef std::map<std::string, std::string> RawOptionMap;
@@ -23,11 +26,17 @@ public:
 
        void add_option(const std::string &, const std::string &, const std::string &);
        const Option &get_option(const std::string &) const;
+       const Msp::Time::TimeStamp &get_mtime() const { return mtime; }
        bool is_option(const std::string &) const;
        bool process(const RawOptionMap &);
-       void load(const std::string &); 
+       void load(const Msp::Path::Path &); 
 private:
+       class Loader: public Msp::Parser::Loader
+       {
+       };
+       
        OptionMap options;
+       Msp::Time::TimeStamp mtime;
 };
 
 #endif
diff --git a/source/copy.h b/source/copy.h
new file mode 100644 (file)
index 0000000..e39be16
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef COPY_H_
+#define COPY_H_
+
+#include <msp/core/thread.h>
+#include <msp/path/path.h>
+#include "action.h"
+
+class Copy: public Action
+{
+public:
+       Copy(Builder &, const Msp::Path::Path &, const Msp::Path::Path &);
+       int check();
+private:
+       class Worker: public Msp::Thread
+       {
+       public:
+               Worker(Copy &i): copy(i), done(false) { launch(); }
+               bool get_done() const { return done; }
+       private:
+               Copy &copy;
+               bool done;
+
+               void main();
+       };
+
+       Msp::Path::Path src;
+       Msp::Path::Path dest;
+       Worker worker;
+};
+
+#endif
index d4a48d730513d401738f8e6ba65d4e15739dc439..81d28b37a6a7398fd0b186256c328a912ae87168 100644 (file)
@@ -26,7 +26,7 @@ int ExternalAction::check()
 
 void ExternalAction::launch()
 {
-       if(builder.get_verbose()>=1)
+       if(builder.get_verbose()>=2)
        {
                for(list<string>::const_iterator i=argv.begin(); i!=argv.end(); ++i)
                {
diff --git a/source/install.h b/source/install.h
deleted file mode 100644 (file)
index 3c179c6..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef INSTALL_H_
-#define INSTALL_H_
-
-#include <msp/core/thread.h>
-#include <msp/path/path.h>
-#include "action.h"
-
-class Install: public Action
-{
-public:
-       Install(const Msp::Path::Path &, const Msp::Path::Path &);
-private:
-       class Worker: public Msp::Thread
-       {
-       public:
-               Worker(Install &i): install(i), done(false) { launch(); }
-       private:
-               Install &install;
-               bool done;
-
-               void main();
-       };
-
-       Msp::Path::Path src;
-       Msp::Path::Path dest;
-       Worker worker;
-};
-
-#endif
index fcbe9f7a6208fe8c10f3bac150f78d5c6986138c..e6e3b5099c1814a46ab02586e750f936843e3c27 100644 (file)
@@ -1,3 +1,4 @@
+#include <msp/strconv.h>
 #include <msp/strutils.h>
 #include "builder.h"
 #include "misc.h"
@@ -79,6 +80,18 @@ void Package::create_build_info()
        if(flags&LIB)
                export_binfo.libpath.push_back((Path::Path(config.get_option("prefix").value)/"lib").str());
 
+       string optimize=config.get_option("optimize").value;
+       if(strtol(optimize))
+       {
+               build_info.cflags.push_back("-O"+optimize);
+               string cpu=config.get_option("cpu").value;
+               if(cpu!="auto")
+                       build_info.cflags.push_back("-march="+cpu);
+       }
+
+       if(strtobool(config.get_option("debug").value))
+               build_info.cflags.push_back("-ggdb");
+
        build_info.unique();
        export_binfo.unique();
 
@@ -117,9 +130,11 @@ void Package::init_buildable()
 {
        buildable=true;
 
-       config.add_option("tempdir",  "temp", "Directory for storing temporary files");
-       config.add_option("optimize", "0",    "Apply compiler optimizations");
-       config.add_option("debug",    "0",    "Produce debugging symbols");
+       config.add_option("tempdir",  "temp",   "Directory for storing temporary files");
+       config.add_option("optimize", "0",      "Apply compiler optimizations");
+       config.add_option("debug",    "0",      "Produce debugging symbols");
+       config.add_option("cpu",      "auto",   "CPU type to optimize for");
+       config.add_option("arch",     "native", "Architecture for cross-compiling");
 
        const char *home=getenv("HOME");
        unsigned flags=get_install_flags();
index 8ba3cc38896faefc3493329da6a2570dfd83a268..b3dc50904717450c938f65f47add7b490073a317 100644 (file)
@@ -1,6 +1,7 @@
 #include <msp/path/utils.h>
 #include "action.h"
 #include "builder.h"
+#include "package.h"
 #include "target.h"
 
 using namespace std;
@@ -81,6 +82,8 @@ void Target::check_rebuild()
                                mark_rebuild((*i)->get_name()+" needs rebuilding");
                }
        }
+       if(!rebuild && package && package->get_config().get_mtime()>mtime)
+               mark_rebuild("Package options changed");
 }
 
 Action *Target::build(Action *action)