From: Mikko Rasa Date: Tue, 14 Nov 2006 00:05:34 +0000 (+0000) Subject: Code reorganizing and cleanup X-Git-Tag: 0.9~49 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=1a46151c99a406123c4ddfc797a7841baf3e4cc2;p=builder.git Code reorganizing and cleanup --- diff --git a/source/analyzer.cpp b/source/analyzer.cpp index 7dceac7..21ed52c 100644 --- a/source/analyzer.cpp +++ b/source/analyzer.cpp @@ -73,9 +73,9 @@ void Analyzer::build_depend_table(Target &tgt, unsigned depth) if(!max_depth || depth &depends=tgt.get_depends(); + const TargetList &depends=tgt.get_depends(); //depends.sort(target_order); - for(list::const_iterator i=depends.begin(); i!=depends.end(); ++i) + for(TargetList::const_iterator i=depends.begin(); i!=depends.end(); ++i) build_depend_table(**i, depth+1); } } diff --git a/source/archive.cpp b/source/archive.cpp index daff233..11c633c 100644 --- a/source/archive.cpp +++ b/source/archive.cpp @@ -18,8 +18,8 @@ Archive::Archive(Builder &b, const StaticLibrary &lib): argv.push_back("rc"); argv.push_back(lib.get_name()); - const list &deps=lib.get_depends(); - for(list::const_iterator i=deps.begin(); i!=deps.end(); ++i) + const TargetList &deps=lib.get_depends(); + for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i) if(dynamic_cast(*i)) argv.push_back((*i)->get_name()); diff --git a/source/builder.cpp b/source/builder.cpp index 28d57d4..5a1d624 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -27,12 +27,12 @@ using namespace std; using namespace Msp; Builder::Builder(int argc, char **argv): + analyzer(0), + do_build(true), verbose(1), + chrome(false), build_file("Build"), - do_build(true), - analyzer(0), - jobs(1), - chrome(false) + jobs(1) { GetOpt getopt; getopt.add_option(GetOpt::Option('a', "analyze", GetOpt::REQUIRED)); @@ -256,7 +256,7 @@ int Builder::main() return 0; } - std::list missing; + StringList missing; for(PackageMap::iterator i=packages.begin(); i!=packages.end(); ++i) if(!i->second) missing.push_back(i->first); @@ -639,8 +639,8 @@ void Builder::package_help() const Config::OptionMap &options=config.get_options(); cout<<"Required packages:\n "; - const list &requires=default_pkg->get_requires(); - for(list::const_iterator i=requires.begin(); i!=requires.end(); ++i) + const PkgRefList &requires=default_pkg->get_requires(); + for(PkgRefList::const_iterator i=requires.begin(); i!=requires.end(); ++i) { if(i!=requires.begin()) cout<<", "; diff --git a/source/builder.h b/source/builder.h index 3dba629..786b48c 100644 --- a/source/builder.h +++ b/source/builder.h @@ -8,10 +8,11 @@ #include #include #include "config.h" +#include "misc.h" +#include "target.h" class Analyzer; class Package; -class Target; class Builder: public Msp::Application { @@ -22,8 +23,8 @@ public: bool get_build_all() const { return build_all; } Package *get_package(const std::string &); Target *get_target(const std::string &); - Target *get_header(const std::string &, const std::string &, const std::list &); - Target *get_library(const std::string &, const std::list &); + Target *get_header(const std::string &, const std::string &, const StringList &); + Target *get_library(const std::string &, const StringList &); const Msp::Path::Path &get_cwd() const { return cwd; } int main(); ~Builder(); @@ -35,49 +36,51 @@ private: public: Loader(Builder &, const Msp::Path::Path &); private: - Builder &bld; + Builder &bld; Msp::Path::Path src; void package(const std::string &); }; + typedef std::list PackageList; typedef std::map PackageMap; typedef std::map TargetMap; typedef std::map ToolMap; - std::list cmdline_targets; + StringList cmdline_targets; RawOptionMap cmdline_options; + Msp::Path::Path cwd; - PackageMap packages; - std::list new_pkgs; - Package *default_pkg; + PackageMap packages; + PackageList new_pkgs; + Package *default_pkg; - TargetMap targets; - std::list new_tgts; - TargetMap includes; - TargetMap libraries; + TargetMap targets; + TargetList new_tgts; + TargetMap includes; + TargetMap libraries; - ToolMap tools; - unsigned verbose; - Msp::Path::Path cwd; + ToolMap tools; /// Not used yet + + Analyzer *analyzer; + bool do_build; + bool dry_run; + bool help; + unsigned verbose; + bool chrome; Msp::Path::Path build_file; - bool do_build; - bool dry_run; - Analyzer *analyzer; - unsigned jobs; - std::list what_if; - bool chrome; - bool conf_all; - bool build_all; - bool help; + unsigned jobs; + StringList what_if; + bool conf_all; + bool build_all; - int load_build_file(const Msp::Path::Path &); - int create_targets(); + int load_build_file(const Msp::Path::Path &); + int create_targets(); Target *check_header(const Msp::Path::Path &); - void add_target(Target *); - void update_hash(std::string &, const std::string &); - int build(); - void package_help(); + void add_target(Target *); + void update_hash(std::string &, const std::string &); + int build(); + void package_help(); static Msp::Application::RegApp reg; }; diff --git a/source/buildinfo.cpp b/source/buildinfo.cpp index 340fd96..f96820b 100644 --- a/source/buildinfo.cpp +++ b/source/buildinfo.cpp @@ -23,10 +23,10 @@ void BuildInfo::unique() unique(libs); } -void BuildInfo::unique(InfoList &l) +void BuildInfo::unique(StringList &l) { - InfoList l2; - for(InfoList::iterator i=l.begin(); i!=l.end(); ++i) + StringList l2; + for(StringList::iterator i=l.begin(); i!=l.end(); ++i) if(!contains(l2, *i)) l2.push_back(*i); swap(l, l2); diff --git a/source/buildinfo.h b/source/buildinfo.h index 2e98906..ccd4b86 100644 --- a/source/buildinfo.h +++ b/source/buildinfo.h @@ -4,6 +4,7 @@ #include #include #include +#include "misc.h" class BuildInfo { @@ -23,19 +24,17 @@ public: void library(const std::string &s) { binfo.libs.push_back(s); } }; - typedef std::list InfoList; - - InfoList cflags; - InfoList defines; - InfoList incpath; - InfoList ldflags; - InfoList libpath; - InfoList libs; + StringList cflags; + StringList defines; + StringList incpath; + StringList ldflags; + StringList libpath; + StringList libs; void add(const BuildInfo &); void unique(); private: - void unique(InfoList &); + void unique(StringList &); }; #endif diff --git a/source/compile.cpp b/source/compile.cpp index d823c30..fd802bb 100644 --- a/source/compile.cpp +++ b/source/compile.cpp @@ -3,18 +3,21 @@ #include "buildinfo.h" #include "compile.h" #include "component.h" +#include "objectfile.h" #include "package.h" using namespace std; using namespace Msp; -Compile::Compile(Builder &b, const Path::Path &s, const Path::Path &o, const Component &c): - ExternalAction(b), - source(s), - object(o), - comp(c) +Compile::Compile(Builder &b, const ObjectFile &obj): + ExternalAction(b) { - string ext=Path::splitext(source.str()).ext; + const Component &comp=obj.get_component(); + + const TargetList &deps=obj.get_depends(); + Path::Path spath=deps.front()->get_name(); + + string ext=Path::splitext(spath.str()).ext; const char *tool=0; if(ext==".cpp" || ext==".cc") { @@ -36,14 +39,15 @@ Compile::Compile(Builder &b, const Path::Path &s, const Path::Path &o, const Com for(list::const_iterator i=binfo.defines.begin(); i!=binfo.defines.end(); ++i) argv.push_back("-D"+*i); + Path::Path opath=obj.get_name(); argv.push_back("-o"); - argv.push_back(object.str()); - argv.push_back(source.str()); + argv.push_back(opath.str()); + argv.push_back(spath.str()); if(!builder.get_dry_run()) - Path::mkpath(object.subpath(0, object.size()-1), 0755); + Path::mkpath(opath.subpath(0, opath.size()-1), 0755); - announce(comp.get_package().get_name(), tool, relative(object.str(), comp.get_package().get_source()).str()); + announce(comp.get_package().get_name(), tool, relative(opath, comp.get_package().get_source()).str()); launch(); } diff --git a/source/compile.h b/source/compile.h index 42ae95c..5e0d47f 100644 --- a/source/compile.h +++ b/source/compile.h @@ -5,15 +5,12 @@ #include "externalaction.h" class Component; +class ObjectFile; class Compile: public ExternalAction { public: - Compile(Builder &, const Msp::Path::Path &, const Msp::Path::Path &, const Component &); -private: - Msp::Path::Path source; - Msp::Path::Path object; - const Component ∁ + Compile(Builder &, const ObjectFile &); }; #endif diff --git a/source/component.cpp b/source/component.cpp index 6d80f3b..6d02ad3 100644 --- a/source/component.cpp +++ b/source/component.cpp @@ -12,7 +12,7 @@ Component::Component(Package &p, Type t, const string &n): void Component::resolve_refs() { - for(list::iterator i=requires.begin(); i!=requires.end(); ++i) + for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i) i->resolve(); } @@ -20,7 +20,7 @@ void Component::create_build_info() { build_info.add(pkg.get_build_info()); - for(list::iterator i=requires.begin(); i!=requires.end(); ++i) + for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i) { if(!i->get_package()) continue; diff --git a/source/component.h b/source/component.h index 04a0a41..ab39068 100644 --- a/source/component.h +++ b/source/component.h @@ -52,7 +52,7 @@ protected: bool install; std::string install_headers; BuildInfo build_info; - std::list requires; + PkgRefList requires; }; typedef std::list ComponentList; diff --git a/source/copy.h b/source/copy.h index 018b3de..3f92b15 100644 --- a/source/copy.h +++ b/source/copy.h @@ -18,7 +18,7 @@ private: { public: Worker(Copy &i): copy(i), done(false), error(false) { launch(); } - bool get_done() const { return done; } + bool get_done() const { return done; } bool get_error() const { return error; } private: Copy © diff --git a/source/executable.h b/source/executable.h index 81637a7..7fefef7 100644 --- a/source/executable.h +++ b/source/executable.h @@ -10,10 +10,10 @@ class Executable: public Target { public: Executable(Builder &, const Component &, const std::list &); - const char *get_type() const { return "Executable"; } + const char *get_type() const { return "Executable"; } const Component &get_component() const { return comp; } - void find_depends(); - Action *build(); + void find_depends(); + Action *build(); private: const Component ∁ diff --git a/source/externalaction.cpp b/source/externalaction.cpp index bae244c..b86d802 100644 --- a/source/externalaction.cpp +++ b/source/externalaction.cpp @@ -36,7 +36,7 @@ void ExternalAction::launch() { if(builder.get_verbose()>=2) { - for(list::const_iterator i=argv.begin(); i!=argv.end(); ++i) + for(StringList::const_iterator i=argv.begin(); i!=argv.end(); ++i) { if(i!=argv.begin()) cout<<' '; @@ -53,7 +53,7 @@ void ExternalAction::launch() if(pid==0) { char *argv_[argv.size()+1]; - for(CountingIterator::iterator> i=argv.begin(); i!=argv.end(); ++i) + for(CountingIterator i=argv.begin(); i!=argv.end(); ++i) argv_[i.count()]=strdup(i->c_str()); argv_[argv.size()]=0; execvp(argv_[0], argv_); diff --git a/source/externalaction.h b/source/externalaction.h index 0d0924a..86f3275 100644 --- a/source/externalaction.h +++ b/source/externalaction.h @@ -4,15 +4,16 @@ #include #include #include "action.h" +#include "misc.h" class ExternalAction: public Action { public: int check(); protected: - std::list argv; - int pid; - int exit_code; + StringList argv; + int pid; + int exit_code; ExternalAction(Builder &b): Action(b), pid(0), exit_code(0) { } void launch(); diff --git a/source/header.h b/source/header.h index 56e5634..c398468 100644 --- a/source/header.h +++ b/source/header.h @@ -15,7 +15,7 @@ class SystemHeader: public Header public: SystemHeader(Builder &b, const std::string &f): Header(b,0,f) { } const char *get_type() const { return "SystemHeader"; } - void find_depends() { deps_ready=true; } + void find_depends() { deps_ready=true; } }; #endif diff --git a/source/install.h b/source/install.h index 2aa3280..503205a 100644 --- a/source/install.h +++ b/source/install.h @@ -8,8 +8,8 @@ class Install: public Target public: Install(Builder &, const Package &, Target &, const std::string &); const char *get_type() const { return "Install"; } - void check_rebuild(); - Action *build(); + void check_rebuild(); + Action *build(); private: }; diff --git a/source/link.cpp b/source/link.cpp index 8b4c564..7cbdc03 100644 --- a/source/link.cpp +++ b/source/link.cpp @@ -14,6 +14,7 @@ Link::Link(Builder &b, const Executable &exe): { const Component &comp=exe.get_component(); + //XXX Determine whether to use g++ or gcc argv.push_back("g++"); if(comp.get_type()==Component::LIBRARY) @@ -29,8 +30,8 @@ Link::Link(Builder &b, const Executable &exe): argv.push_back("-o"); argv.push_back(exe.get_name()); - const list &deps=exe.get_depends(); - for(list::const_iterator i=deps.begin(); i!=deps.end(); ++i) + const TargetList &deps=exe.get_depends(); + for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i) if(dynamic_cast(*i)) argv.push_back((*i)->get_name()); diff --git a/source/misc.h b/source/misc.h index a35c0ed..1e1b16c 100644 --- a/source/misc.h +++ b/source/misc.h @@ -5,8 +5,9 @@ #include #include +typedef std::list StringList; typedef std::list PathList; -std::string run_command(const std::list &); +std::string run_command(const StringList &); #endif diff --git a/source/objectfile.cpp b/source/objectfile.cpp index 8fbbed1..874f069 100644 --- a/source/objectfile.cpp +++ b/source/objectfile.cpp @@ -21,7 +21,7 @@ ObjectFile::ObjectFile(Builder &b, const Component &c, SourceFile &src): void ObjectFile::find_depends() { - for(list::iterator i=new_deps.begin(); i!=new_deps.end();) + for(TargetList::iterator i=new_deps.begin(); i!=new_deps.end();) { Target *tgt=*i; if(tgt->get_depends_ready()) @@ -38,7 +38,7 @@ void ObjectFile::find_depends() Action *ObjectFile::build() { - return Target::build(new Compile(builder, depends.front()->get_name(), name, comp)); + return Target::build(new Compile(builder, *this)); } void ObjectFile::find_depends(Target *tgt) diff --git a/source/objectfile.h b/source/objectfile.h index d3315f7..8306aea 100644 --- a/source/objectfile.h +++ b/source/objectfile.h @@ -10,12 +10,13 @@ class ObjectFile: public Target { public: ObjectFile(Builder &, const Component &, SourceFile &); - const char *get_type() const { return "ObjectFile"; } - void find_depends(); - Action *build(); + const char *get_type() const { return "ObjectFile"; } + const Component &get_component() const { return comp; } + void find_depends(); + Action *build(); private: const Component ∁ - std::list new_deps; + TargetList new_deps; void find_depends(Target *); void add_depend(Target *); diff --git a/source/package.cpp b/source/package.cpp index d4022f5..14d2321 100644 --- a/source/package.cpp +++ b/source/package.cpp @@ -12,30 +12,11 @@ using namespace Msp; Package::Package(Builder &b, const string &n, const Path::Path &s): builder(b), name(n), - source(s), buildable(true), + source(s), build_info_ready(false) { } -Package::Package(Builder &b, const string &n, const vector &info): - builder(b), - name(n), - buildable(false), - build_info_ready(false) -{ - for(vector::const_iterator i=info.begin(); i!=info.end(); ++i) - { - if(!i->compare(0, 2, "-I")) - export_binfo.incpath.push_back(i->substr(2)); - else if(!i->compare(0, 2, "-D")) - export_binfo.defines.push_back(i->substr(2)); - else if(!i->compare(0, 2, "-L")) - export_binfo.libpath.push_back(i->substr(2)); - else if(!i->compare(0, 2, "-l")) - export_binfo.libs.push_back(i->substr(2)); - } -} - void Package::set_path(const Msp::Path::Path &p) { path=builder.get_cwd()/p; @@ -43,7 +24,7 @@ void Package::set_path(const Msp::Path::Path &p) void Package::resolve_refs() { - for(list::iterator i=requires.begin(); i!=requires.end(); ++i) + for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i) i->resolve(); for(ComponentList::iterator i=components.begin(); i!=components.end(); ++i) i->resolve_refs(); @@ -56,7 +37,7 @@ void Package::create_build_info() if(buildable) { - for(list::iterator i=requires.begin(); i!=requires.end(); ++i) + for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i) { Package *pkg=i->get_package(); if(!pkg) @@ -156,6 +137,27 @@ Package *Package::create(Builder &b, const string &name) return pkg; } +/*** private ***/ + +Package::Package(Builder &b, const string &n, const vector &info): + builder(b), + name(n), + buildable(false), + build_info_ready(false) +{ + for(vector::const_iterator i=info.begin(); i!=info.end(); ++i) + { + if(!i->compare(0, 2, "-I")) + export_binfo.incpath.push_back(i->substr(2)); + else if(!i->compare(0, 2, "-D")) + export_binfo.defines.push_back(i->substr(2)); + else if(!i->compare(0, 2, "-L")) + export_binfo.libpath.push_back(i->substr(2)); + else if(!i->compare(0, 2, "-l")) + export_binfo.libs.push_back(i->substr(2)); + } +} + void Package::init_buildable() { buildable=true; @@ -179,7 +181,7 @@ void Package::init_buildable() if(flags&DATA) config.add_option("includedir", "$prefix/share", "Data installation directory");*/ - for(list::iterator i=requires.begin(); i!=requires.end(); ++i) + for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i) config.add_option(i->get_name()+"_path", "", "Path for "+i->get_name()); config.load(source/".options.cache"); diff --git a/source/package.h b/source/package.h index a1a9859..743a962 100644 --- a/source/package.h +++ b/source/package.h @@ -31,18 +31,17 @@ public: }; Package(Builder &, const std::string &, const Msp::Path::Path &); - Package(Builder &, const std::string &, const std::vector &); void set_path(const Msp::Path::Path &); - const std::string &get_name() const { return name; } - const Msp::Path::Path &get_source() const { return source; } - const ComponentList &get_components() const { return components; } - bool get_buildable() const { return buildable; } - const Config &get_config() const { return config; } - const std::list &get_requires() const { return requires; } - const BuildInfo &get_build_info() const { return build_info; } + const std::string &get_name() const { return name; } + const Msp::Path::Path &get_source() const { return source; } + const ComponentList &get_components() const { return components; } + bool get_buildable() const { return buildable; } + const Config &get_config() const { return config; } + const PkgRefList &get_requires() const { return requires; } + const BuildInfo &get_build_info() const { return build_info; } const BuildInfo &get_exported_binfo() const { return export_binfo; } - Builder &get_builder() const { return builder; } - bool get_need_path() const { return need_path; } + Builder &get_builder() const { return builder; } + bool get_need_path() const { return need_path; } void resolve_refs(); void create_build_info(); void process_options(const RawOptionMap &); @@ -58,21 +57,25 @@ private: }; Builder &builder; + std::string name; std::string version; std::string description; - std::list requires; + + bool buildable; + Msp::Path::Path source; + PkgRefList requires; BuildInfo build_info; BuildInfo export_binfo; - Msp::Path::Path source; - bool buildable; ComponentList components; Config config; bool build_info_ready; + bool need_path; Msp::Path::Path path; - void init_buildable(); + Package(Builder &, const std::string &, const std::vector &); + void init_buildable(); unsigned get_install_flags(); }; diff --git a/source/packageref.h b/source/packageref.h index bc44da3..9698b1e 100644 --- a/source/packageref.h +++ b/source/packageref.h @@ -1,6 +1,7 @@ #ifndef PACKAGEREF_H_ #define PACKAGEREF_H_ +#include #include class Builder; @@ -18,5 +19,6 @@ private: std::string name; Package *package; }; +typedef std::list PkgRefList; #endif diff --git a/source/sourcefile.h b/source/sourcefile.h index b1ec829..0bca390 100644 --- a/source/sourcefile.h +++ b/source/sourcefile.h @@ -9,13 +9,13 @@ class SourceFile: public Target { public: SourceFile(Builder &, const Component *, const std::string &); - const std::list &get_includes() const { return includes; } - const char *get_type() const { return "SourceFile"; } - void find_depends(); - Action *build() { rebuild=false; return 0; } + const StringList &get_includes() const { return includes; } + const char *get_type() const { return "SourceFile"; } + void find_depends(); + Action *build() { return 0; } private: const Component *comp; - std::list includes; + StringList includes; }; #endif diff --git a/source/staticlibrary.h b/source/staticlibrary.h index f7f178a..0d1242f 100644 --- a/source/staticlibrary.h +++ b/source/staticlibrary.h @@ -10,9 +10,9 @@ class StaticLibrary: public Target { public: StaticLibrary(Builder &, const Component &, const std::list &); - const char *get_type() const { return "StaticLibrary"; } + const char *get_type() const { return "StaticLibrary"; } const Component &get_component() const { return comp; } - Action *build(); + Action *build(); private: const Component ∁ diff --git a/source/target.cpp b/source/target.cpp index d552022..e034288 100644 --- a/source/target.cpp +++ b/source/target.cpp @@ -11,7 +11,7 @@ using namespace Msp; Target *Target::get_buildable_target() { bool self_ok=true; - for(list::iterator i=depends.begin(); i!=depends.end(); ++i) + for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i) { Target *tgt=(*i)->get_buildable_target(); if(tgt) @@ -37,7 +37,7 @@ void Target::prepare() if(prepared) return; - for(list::iterator i=depends.begin(); i!=depends.end(); ++i) + for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i) (*i)->prepare(); check_rebuild(); @@ -50,7 +50,7 @@ unsigned Target::count_rebuild() counted=true; unsigned count=rebuild; - for(list::iterator i=depends.begin(); i!=depends.end(); ++i) + for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i) count+=(*i)->count_rebuild(); return count; } @@ -64,11 +64,11 @@ Target::Target(Builder &b, const Package *p, const string &n): builder(b), package(p), name(n), + buildable(false), building(false), rebuild(false), deps_ready(false), prepared(false), - buildable(false), counted(false) { struct stat st; @@ -93,7 +93,7 @@ void Target::check_rebuild() mark_rebuild("Does not exist"); else { - for(list::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i) + for(TargetList::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i) { if((*i)->get_mtime()>mtime) mark_rebuild(Path::basename((*i)->get_name())+" has changed"); diff --git a/source/target.h b/source/target.h index 890f123..eb46d9f 100644 --- a/source/target.h +++ b/source/target.h @@ -9,45 +9,51 @@ class Action; class Builder; class Package; +class Target; +typedef std::list TargetList; + class Target { public: - const std::string &get_name() const { return name; } - Target *get_buildable_target(); - bool get_rebuild() const { return rebuild; } - const std::string &get_rebuild_reason() const { return rebuild_reason; } + const std::string &get_name() const { return name; } + Target *get_buildable_target(); + bool get_rebuild() const { return rebuild; } + const std::string &get_rebuild_reason() const { return rebuild_reason; } const Msp::Time::TimeStamp &get_mtime() const { return mtime; } virtual const char *get_type() const=0; - const std::list &get_depends() const { return depends; } - const Package *get_package() const { return package; } - bool get_depends_ready() const { return deps_ready; } - void add_depend(Target *); - virtual void find_depends() { deps_ready=true; } - virtual void prepare(); - virtual Action *build()=0; - void reset_count() { counted=false; } - virtual unsigned count_rebuild(); - void touch(); + const TargetList &get_depends() const { return depends; } + const Package *get_package() const { return package; } + bool get_depends_ready() const { return deps_ready; } + void add_depend(Target *); + virtual void find_depends() { deps_ready=true; } + virtual void prepare(); + virtual Action *build()=0; + void reset_count() { counted=false; } + virtual unsigned count_rebuild(); + void touch(); virtual ~Target() { } protected: - Builder &builder; + Builder &builder; const Package *package; - std::string name; - bool building; - bool rebuild; - std::string rebuild_reason; + std::string name; Msp::Time::TimeStamp mtime; - std::list depends; - std::list rdepends; - bool deps_ready; - bool prepared; - bool buildable; - bool counted; + + bool buildable; + bool building; + bool rebuild; + std::string rebuild_reason; + + TargetList depends; + TargetList rdepends; + bool deps_ready; + + bool prepared; + bool counted; Target(Builder &, const Package *, const std::string &); - void mark_rebuild(const std::string &); + void mark_rebuild(const std::string &); virtual void check_rebuild(); - Action *build(Action *); + Action *build(Action *); virtual void build_done(); }; diff --git a/source/virtualtarget.cpp b/source/virtualtarget.cpp index e44eecc..074647a 100644 --- a/source/virtualtarget.cpp +++ b/source/virtualtarget.cpp @@ -5,7 +5,7 @@ using namespace std; void VirtualTarget::check_rebuild() { - for(list::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i) + for(TargetList::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i) if((*i)->get_rebuild()) mark_rebuild(Msp::Path::basename((*i)->get_name())+" needs rebuilding"); } diff --git a/source/virtualtarget.h b/source/virtualtarget.h index 4f064ba..baccfa6 100644 --- a/source/virtualtarget.h +++ b/source/virtualtarget.h @@ -8,8 +8,8 @@ class VirtualTarget: public Target public: VirtualTarget(Builder &b, const std::string &n): Target(b,0,n) { } const char *get_type() const { return "VirtualTarget"; } - Action *build() { rebuild=false; return 0; } - unsigned count_rebuild(); + Action *build() { rebuild=false; return 0; } + unsigned count_rebuild(); private: void check_rebuild(); };