]> git.tdb.fi Git - builder.git/commitdiff
Resolve cmdline targets and what-ifs the same way
authorMikko Rasa <tdb@tdb.fi>
Tue, 7 May 2013 18:21:38 +0000 (21:21 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 7 May 2013 18:21:38 +0000 (21:21 +0300)
source/buildercli.cpp
source/buildercli.h

index 0bdf8777d0f51cfb5909821d0b119db0ccfc0860..35eba9c03512fe9024c68aad1fe5e986cb9357de 100644 (file)
@@ -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<FileTarget *>(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();
index f9d7ee208171474b7f1d8f9756afc17a87c8b2fc..efc2cc9bdc5431d4541ac2903d1d79a7c0c5835c 100644 (file)
@@ -43,6 +43,7 @@ public:
 
 private:
        bool prepare_build();
+       Target *resolve_target(const std::string &);
 
        void package_help();
 };