From: Mikko Rasa Date: Tue, 7 May 2013 18:21:38 +0000 (+0300) Subject: Resolve cmdline targets and what-ifs the same way X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=28bc25948ff58612600ce29a6a0b2cf58548dff9;p=builder.git Resolve cmdline targets and what-ifs the same way --- diff --git a/source/buildercli.cpp b/source/buildercli.cpp index 0bdf877..35eba9c 100644 --- a/source/buildercli.cpp +++ b/source/buildercli.cpp @@ -279,18 +279,13 @@ bool BuilderCLI::prepare_build() during preparation. */ BuildGraph &build_graph = builder.get_build_graph(); PackageManager &package_manager = builder.get_package_manager(); - VirtualFileSystem &vfs = builder.get_vfs(); package_manager.get_main_package().prepare(); // Add targets from command line as goals for(NameList::iterator i=cmdline_targets.begin(); i!=cmdline_targets.end(); ++i) { - Target *tgt = build_graph.get_target(*i); - if(!tgt) - tgt = vfs.get_target(*i); - if(!tgt) - tgt = vfs.get_target(cwd/ *i); + Target *tgt = resolve_target(*i); if(!tgt) { IO::print("I don't know anything about %s\n", *i); @@ -305,7 +300,7 @@ bool BuilderCLI::prepare_build() // Apply what-ifs for(NameList::iterator i=what_if.begin(); i!=what_if.end(); ++i) { - FileTarget *tgt = vfs.get_target(cwd/ *i); + FileTarget *tgt = dynamic_cast(resolve_target(*i)); if(!tgt) { IO::print(IO::cerr, "Unknown what-if target %s\n", *i); @@ -327,6 +322,14 @@ bool BuilderCLI::prepare_build() return true; } +Target *BuilderCLI::resolve_target(const string &name) +{ + Target *tgt = builder.get_build_graph().get_target(name); + if(!tgt) + tgt = builder.get_vfs().get_target(cwd/name); + return tgt; +} + void BuilderCLI::package_help() { PackageManager &package_manager = builder.get_package_manager(); diff --git a/source/buildercli.h b/source/buildercli.h index f9d7ee2..efc2cc9 100644 --- a/source/buildercli.h +++ b/source/buildercli.h @@ -43,6 +43,7 @@ public: private: bool prepare_build(); + Target *resolve_target(const std::string &); void package_help(); };