]> git.tdb.fi Git - builder.git/commitdiff
Route InstalledFile target creation through Builder
authorMikko Rasa <tdb@tdb.fi>
Wed, 5 Sep 2012 16:11:03 +0000 (19:11 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 5 Sep 2012 16:11:03 +0000 (19:11 +0300)
source/builder.cpp
source/builder.h
source/component.cpp

index 3ac4b282ad9d19615236714b01cfc75345d55c8c..c61d4a77c71c8f98e53790cd4d95028ebb0cc378 100644 (file)
@@ -339,6 +339,13 @@ void Builder::add_primary_target(Target &t)
                get_target("default")->add_dependency(t);
 }
 
+void Builder::add_installed_target(Target &t)
+{
+       Target *install = get_target("install");
+       const Tool &copy = toolchain.get_tool("CP");
+       install->add_dependency(*copy.create_target(t));
+}
+
 void Builder::usage(const char *reason, const char *argv0, bool brief)
 {
        if(reason)
index 2f70fbd32a14257583e40cd07437f3f22b1af254..67b337553b2ebbfba0df6427b798cb876c7d465e 100644 (file)
@@ -119,6 +119,10 @@ public:
        virtual target. */
        void add_primary_target(Target &);
 
+       /** Adds a target that will be installed.  A new InstalledFile target is
+       created and added as a dependency to the "install" virtual target. */
+       void add_installed_target(Target &);
+
        void problem(const std::string &, const std::string &);
 
        static void usage(const char *, const char *, bool);
index 6bfce1fb6b8682f19c775552812b26af9da1b451..db78917c70fdf63fe1aef7fb95fa599629ca34f9 100644 (file)
@@ -101,7 +101,6 @@ void Component::create_targets() const
        const Toolchain &toolchain = builder.get_toolchain();
 
        SourceList source_filenames = collect_source_files();
-       list<Target *> inst_list;
 
        string inst_loc;
        if(type==TARBALL)
@@ -138,7 +137,8 @@ void Component::create_targets() const
        }
        else if(type==INSTALL)
        {
-               inst_loc = name;
+               Target *inst = builder.get_target("install");
+               const Tool &copy = toolchain.get_tool("CP");
                for(SourceList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i)
                {
                        FileTarget *ft;
@@ -146,7 +146,7 @@ void Component::create_targets() const
                                ft = dynamic_cast<FileTarget *>(tgt);
                        else
                                ft = new File(builder, package, *i);
-                       inst_list.push_back(ft);
+                       inst->add_dependency(*copy.create_target(*ft, name));
                }
        }
        else if(type==DATAFILE)
@@ -162,7 +162,7 @@ void Component::create_targets() const
 
                builder.add_primary_target(*result);
                if(install)
-                       inst_list.push_back(result);
+                       builder.add_installed_target(*result);
        }
 
        if(type==PROGRAM || type==LIBRARY || type==MODULE)
@@ -185,7 +185,7 @@ void Component::create_targets() const
                                }
 
                                if(type==LIBRARY && install && dynamic_cast<FileTarget *>(src)->is_installable())
-                                       inst_list.push_back(src);
+                                       builder.add_installed_target(*src);
                        }
                }
 
@@ -225,17 +225,9 @@ void Component::create_targets() const
                {
                        builder.add_primary_target(**i);
                        if(install)
-                               inst_list.push_back(*i);
+                               builder.add_installed_target(**i);
                }
        }
-
-       Target *inst_tgt = builder.get_target("install");
-       const Tool &copy = toolchain.get_tool("CP");
-       for(list<Target *>::const_iterator i=inst_list.begin(); i!=inst_list.end(); ++i)
-       {
-               Target *inst = copy.create_target(**i, inst_loc);
-               inst_tgt->add_dependency(*inst);
-       }
 }
 
 Component::SourceList Component::collect_source_files() const