]> git.tdb.fi Git - builder.git/blobdiff - source/component.cpp
Try other methods if the source path given by pkg-config is invalid
[builder.git] / source / component.cpp
index 5a735d09c4e6561484704d33e388906d542e404c..a63e3b05d371571af52888dce3b8a8a2f749138b 100644 (file)
@@ -93,38 +93,33 @@ void Component::create_targets() const
        string inst_loc;
        if(type==TARBALL)
        {
-               //const Tool &tar = toolchain.get_tool("TAR");
-
-               string tarname = name;
-               if(name=="@src")
-               {
-                       tarname = package.get_name()+"-"+package.get_version();
-                       source_filenames.push_back(package.get_source_directory()/"Build");
-               }
+               const Tool &tar = toolchain.get_tool("TAR");
 
                list<Target *> files;
                for(PathList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i)
                {
                        FileTarget *file = builder.get_vfs().get_target(*i);
                        if(!file)
-                               file = new File(builder, *i);
+                               file = new File(builder, package, *i);
                        files.push_back(file);
                }
 
+               string tarname = name;
                if(name=="@src")
                {
+                       tarname = package.get_name()+"-"+package.get_version();
+                       files.insert(files.begin(), &package.get_build_file());
+
                        const Builder::TargetMap &targets = builder.get_targets();
                        for(Builder::TargetMap::const_iterator i=targets.begin(); i!=targets.end(); ++i)
                                if(i->second->get_package()==&package && !i->second->is_buildable())
-                                       files.push_back(i->second);
+                                       if(find(files.begin(), files.end(), i->second)==files.end())
+                                               files.push_back(i->second);
                }
 
-               /* XXX The source files don't have a package at the moment, so we can't
-               create the tarball target until things get fixed up a bit */
-               /*Target *result = tar.create_target(files, tarname);
+               Target *result = tar.create_target(files, tarname);
 
-               Target *tarballs_tgt = builder.get_target("tarballs");
-               tarballs_tgt->add_dependency(*result);*/
+               builder.get_target("tarballs")->add_dependency(*result);
 
                return;
        }
@@ -167,13 +162,16 @@ void Component::create_targets() const
                        if(tool)
                        {
                                Target *src = tool->create_source(*this, *i);
+                               if(!src)
+                                       continue;
+
                                if(tool->accepts_suffix(ext))
                                {
                                        Target *obj = tool->create_target(*src);
                                        objs.push_back(obj);
                                }
 
-                               if(type==LIBRARY && install && !dynamic_cast<FileTarget *>(src)->get_install_location().empty())
+                               if(type==LIBRARY && install && dynamic_cast<FileTarget *>(src)->is_installable())
                                        inst_list.push_back(src);
                        }
                }