]> git.tdb.fi Git - builder.git/commitdiff
Make Target::add_depend take a reference since null is not allowed
authorMikko Rasa <tdb@tdb.fi>
Tue, 10 Jul 2012 20:54:55 +0000 (23:54 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 10 Jul 2012 20:55:53 +0000 (23:55 +0300)
12 files changed:
source/binary.cpp
source/builder.cpp
source/component.cpp
source/csourcefile.cpp
source/datafile.cpp
source/installedfile.cpp
source/objectfile.cpp
source/sourcepackage.cpp
source/staticlibrary.cpp
source/tar.cpp
source/target.cpp
source/target.h

index 2d0a409c5f2c53835fd38f6457e8fcccabb37ee6..7a3e7a5b6a34e0a58694323fd203f87c42bfd7e0 100644 (file)
@@ -20,7 +20,7 @@ Binary::Binary(Builder &b, const Component &c, const string &p, const list<Objec
 {
        component = &c;
        for(list<ObjectFile *>::const_iterator i=objs.begin(); i!=objs.end(); ++i)
-               add_depend(*i);
+               add_depend(**i);
 }
 
 void Binary::find_depends()
@@ -68,6 +68,6 @@ void Binary::find_depends()
                for(list<Target *>::iterator j=i; (last && j!=dep_libs.end()); ++j)
                        last = (j==i || *j!=*i);
                if(last)
-                       add_depend(*i);
+                       add_depend(**i);
        }
 }
index df6eda42fcfe535f2074b1939b5a0c6afe677782..0b1cd2cf0b02cc061383df31d4201670cb029722 100644 (file)
@@ -392,13 +392,13 @@ int Builder::create_targets()
        Target *world = new VirtualTarget(*this, "world");
 
        Target *def_tgt = new VirtualTarget(*this, "default");
-       world->add_depend(def_tgt);
+       world->add_depend(*def_tgt);
 
        Target *install = new VirtualTarget(*this, "install");
-       world->add_depend(install);
+       world->add_depend(*install);
 
        Target *tarballs = new VirtualTarget(*this, "tarballs");
-       world->add_depend(tarballs);
+       world->add_depend(*tarballs);
 
        const PackageManager::PackageMap &packages = package_manager.get_packages();
        for(PackageManager::PackageMap::const_iterator i=packages.begin(); i!=packages.end(); ++i)
@@ -420,7 +420,7 @@ int Builder::create_targets()
                        return -1;
                }
 
-               cmdline->add_depend(tgt);
+               cmdline->add_depend(*tgt);
        }
 
        cmdline->prepare();
index 0bfc2fc4da119e614c9017e7b6093fc82c60a457..708293e7575da7e4ef67ca3e9fc0217f9ea7ab7a 100644 (file)
@@ -123,7 +123,7 @@ void Component::create_targets() const
                /*Target *result = tar.create_target(files, tarname);
 
                Target *tarballs_tgt = builder.get_target("tarballs");
-               tarballs_tgt->add_depend(result);*/
+               tarballs_tgt->add_depend(*result);*/
 
                return;
        }
@@ -152,9 +152,9 @@ void Component::create_targets() const
                Target *result = dcomp.create_target(*source);
 
                if(&pkg==builder.get_main_package() && deflt)
-                       def_tgt->add_depend(result);
+                       def_tgt->add_depend(*result);
                else
-                       world->add_depend(result);
+                       world->add_depend(*result);
                if(install)
                        inst_list.push_back(result);
        }
@@ -197,9 +197,9 @@ void Component::create_targets() const
                for(list<Target *>::const_iterator i=results.begin(); i!=results.end(); ++i)
                {
                        if(&pkg==builder.get_main_package() && deflt)
-                               def_tgt->add_depend(*i);
+                               def_tgt->add_depend(**i);
                        else
-                               world->add_depend(*i);
+                               world->add_depend(**i);
                        if(install)
                                inst_list.push_back(*i);
                }
@@ -210,7 +210,7 @@ void Component::create_targets() const
        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_depend(inst);
+               inst_tgt->add_depend(*inst);
        }
 }
 
index e2b029a0d1f7080d29a409f7962356db6799c966..b0346e46cd01d94dc5d57ef01daf2823f8bb37cb 100644 (file)
@@ -57,6 +57,6 @@ void CSourceFile::find_depends()
        {
                Target *hdr = builder.get_vfs().find_header(i->substr(1), ((*i)[0]=='"' ? local_incpath : incpath));
                if(hdr)
-                       add_depend(hdr);
+                       add_depend(*hdr);
        }
 }
index 2e9a7e5bcd067dfe79c2eaa936f627f49e935403..188bbdb8d88c44966080ca3e1da835c1725732f1 100644 (file)
@@ -8,7 +8,7 @@ DataFile::DataFile(Builder &b, const Component &c, File &s):
        component(c),
        source(s)
 {
-       add_depend(&source);
+       add_depend(source);
 
        install_location = Msp::FS::Path("share")/package->get_name();
 }
index 15bd08b06f7b507b16109c8f08f7933306d1e092..09cfed6db03a47165b3cb7c1834e2758244cc803 100644 (file)
@@ -10,7 +10,7 @@ InstalledFile::InstalledFile(Builder &b, const SourcePackage &p, FileTarget &s,
        FileTarget(b, p, generate_target_path(b.get_prefix(), s, loc)),
        source(s)
 {
-       add_depend(&source);
+       add_depend(source);
 
        if(const SharedLibrary *shlib = dynamic_cast<const SharedLibrary *>(&source))
                if(!shlib->get_soname().empty())
index 70bef6c25c8acbf58f8b201c32b0aff6b705c5d8..7aafe90d68c1412594a086b998cb828d78605269 100644 (file)
@@ -14,7 +14,7 @@ ObjectFile::ObjectFile(Builder &b, const Component &c, SourceFile &s):
        source(s)       
 {
        component = &c;
-       add_depend(&source);
+       add_depend(source);
 }
 
 FS::Path ObjectFile::generate_target_path(const Component &comp, const string &src)
@@ -70,5 +70,5 @@ void ObjectFile::find_depends(FileTarget *tgt)
 
        for(Dependencies::const_iterator i=deps_to_add.begin(); i!=deps_to_add.end(); ++i)
                if(find(depends.begin(), depends.end(), *i)==depends.end())
-                       add_depend(*i);
+                       add_depend(**i);
 }
index 63f3bba5848c47c4bbaa6c534dd3bb7e9a41d4ab..2371d2cea44dd61415ebc2d8318b9a1642584fba 100644 (file)
@@ -238,7 +238,7 @@ void SourcePackage::create_targets()
        if(pc_needed)
        {
                PkgConfigFile *pc = new PkgConfigFile(builder, *this);
-               builder.get_target("install")->add_depend(builder.get_toolchain().get_tool("CP").create_target(*pc));
+               builder.get_target("install")->add_depend(*builder.get_toolchain().get_tool("CP").create_target(*pc));
        }
 }
 
index f63eb166e707cf9908190eeb276a29beec7b14ad..8e3950f7d97eea35e62c805fa99540f2c6b1d411 100644 (file)
@@ -16,7 +16,7 @@ StaticLibrary::StaticLibrary(Builder &b, const Component &c, const list<ObjectFi
 {
        component = &c;
        for(list<ObjectFile *>::const_iterator i=objs.begin(); i!=objs.end(); ++i)
-               add_depend(*i);
+               add_depend(**i);
 
        install_location = "lib";
 }
index 3bcf3cbc5fb1ebab8d83b3dd352af2c955518a15..a85ee3d4ad01b1c5b07f905204e6054456515528 100644 (file)
@@ -22,7 +22,7 @@ Target *Tar::create_target(const list<Target *> &sources, const string &arg) con
 
        TarBall *tarball = new TarBall(builder, *sources.front()->get_package(), arg);
        for(list<Target *>::const_iterator i=sources.begin(); i!=sources.end(); ++i)
-               tarball->add_depend(*i);
+               tarball->add_depend(**i);
 
        return tarball;
 }
index 2d4a2de034f45a49186792dcb7a64d8919fe24b6..577438b3528dce736aa3c22077e0857a24f5a0b4 100644 (file)
@@ -55,13 +55,13 @@ void Target::force_rebuild()
        mark_rebuild("Forced rebuild");
 }
 
-void Target::add_depend(Target *dep)
+void Target::add_depend(Target &dep)
 {
-       if(dep==this)
+       if(&dep==this)
                throw invalid_argument("Target::add_depend");
-       depends.push_back(dep);
+       depends.push_back(&dep);
        if(state>PREPARING)
-               dep->signal_bubble_rebuild.connect(sigc::mem_fun(this, &Target::check_rebuild));
+               dep.signal_bubble_rebuild.connect(sigc::mem_fun(this, &Target::check_rebuild));
 }
 
 void Target::prepare()
@@ -79,7 +79,7 @@ void Target::prepare()
        if(tool)
        {
                if(FileTarget *tool_exe = tool->get_executable())
-                       add_depend(tool_exe);
+                       add_depend(*tool_exe);
        }
 
        for(Dependencies::iterator i=depends.begin(); i!=depends.end(); ++i)
index f4a4efc9a262ee55cf145f56fe5a4fc1d7602d99..f9d8b24b4ef25268e28ff8e2637c4e0421e28ecf 100644 (file)
@@ -91,7 +91,7 @@ public:
        /** Adds a dependency for the target.  Order is preseved and is important
        for some target types.  It is an error to create dependency cycles, although
        this won't be detected until the targets are prepared. */
-       void add_depend(Target *);
+       void add_depend(Target &);
 
        /// Returns the dependencies of the target, in the order they were added.
        const Dependencies &get_depends() const { return depends; }