From 97001ddfa2463e6a3526eff772962acdad45f995 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 27 Aug 2006 22:10:00 +0000 Subject: [PATCH] Output cleanup Support configuration (no caching yet) --- source/builder.cpp | 16 +++++++++++----- source/config.cpp | 16 ++++++++++++++++ source/config.h | 11 ++++++++++- source/{install.h => copy.h} | 14 ++++++++------ source/externalaction.cpp | 2 +- source/package.cpp | 21 ++++++++++++++++++--- source/target.cpp | 3 +++ 7 files changed, 67 insertions(+), 16 deletions(-) rename source/{install.h => copy.h} (50%) diff --git a/source/builder.cpp b/source/builder.cpp index 05ecf87..c900837 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -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< 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<second->get_name()<<' '<second->get_type()<<' '<second->get_rebuild()<<' '<second->get_rebuild_reason()<<'\n'; + /*for(TargetMap::iterator i=targets.begin(); i!=targets.end(); ++i) + cout<second->get_name()<<' '<second->get_type()<<' '<second->get_rebuild()<<' '<second->get_rebuild_reason()<<'\n';*/ cout<<"Active targets: "< 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 "<get_name()<<'\n'; + //cout<<"Build "<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; } } diff --git a/source/config.cpp b/source/config.cpp index 50e0de9..de6b9bc 100644 --- a/source/config.cpp +++ b/source/config.cpp @@ -1,4 +1,7 @@ +#include #include +#include +#include #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), diff --git a/source/config.h b/source/config.h index 1b78e3a..e5c90de 100644 --- a/source/config.h +++ b/source/config.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "option.h" typedef std::map 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/install.h b/source/copy.h similarity index 50% rename from source/install.h rename to source/copy.h index 3c179c6..e39be16 100644 --- a/source/install.h +++ b/source/copy.h @@ -1,21 +1,23 @@ -#ifndef INSTALL_H_ -#define INSTALL_H_ +#ifndef COPY_H_ +#define COPY_H_ #include #include #include "action.h" -class Install: public Action +class Copy: public Action { public: - Install(const Msp::Path::Path &, const Msp::Path::Path &); + Copy(Builder &, const Msp::Path::Path &, const Msp::Path::Path &); + int check(); private: class Worker: public Msp::Thread { public: - Worker(Install &i): install(i), done(false) { launch(); } + Worker(Copy &i): copy(i), done(false) { launch(); } + bool get_done() const { return done; } private: - Install &install; + Copy © bool done; void main(); diff --git a/source/externalaction.cpp b/source/externalaction.cpp index d4a48d7..81d28b3 100644 --- a/source/externalaction.cpp +++ b/source/externalaction.cpp @@ -26,7 +26,7 @@ int ExternalAction::check() void ExternalAction::launch() { - if(builder.get_verbose()>=1) + if(builder.get_verbose()>=2) { for(list::const_iterator i=argv.begin(); i!=argv.end(); ++i) { diff --git a/source/package.cpp b/source/package.cpp index fcbe9f7..e6e3b50 100644 --- a/source/package.cpp +++ b/source/package.cpp @@ -1,3 +1,4 @@ +#include #include #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(); diff --git a/source/target.cpp b/source/target.cpp index 8ba3cc3..b3dc509 100644 --- a/source/target.cpp +++ b/source/target.cpp @@ -1,6 +1,7 @@ #include #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) -- 2.45.2