From: Mikko Rasa Date: Fri, 13 Apr 2012 16:54:47 +0000 (+0300) Subject: Rename Install to InstalledFile X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=8fa75f16e653e22f188bc09c5d04c3cdb5cf8c52;p=builder.git Rename Install to InstalledFile --- diff --git a/source/analyzer.cpp b/source/analyzer.cpp index b064646..70f5f20 100644 --- a/source/analyzer.cpp +++ b/source/analyzer.cpp @@ -2,7 +2,6 @@ #include #include "analyzer.h" #include "builder.h" -#include "install.h" #include "objectfile.h" #include "package.h" #include "sourcefile.h" diff --git a/source/binary.cpp b/source/binary.cpp index 4728cd1..d73c594 100644 --- a/source/binary.cpp +++ b/source/binary.cpp @@ -3,11 +3,10 @@ #include "binary.h" #include "builder.h" #include "component.h" -#include "install.h" #include "link.h" #include "objectfile.h" -#include "package.h" #include "sharedlibrary.h" +#include "sourcepackage.h" #include "staticlibrary.h" using namespace std; diff --git a/source/builder.cpp b/source/builder.cpp index b6f29f8..9c8e27b 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -22,7 +22,7 @@ #include "gnucxxcompiler.h" #include "gnulinker.h" #include "header.h" -#include "install.h" +#include "installedfile.h" #include "misc.h" #include "package.h" #include "pkgconfig.h" @@ -507,7 +507,7 @@ int Builder::create_targets() if(spkg->get_install_flags()&(SourcePackage::LIB|SourcePackage::INCLUDE)) { PkgConfig *pc = new PkgConfig(*this, *spkg); - install->add_depend(new Install(*this, *spkg, *pc)); + install->add_depend(new InstalledFile(*this, *spkg, *pc)); } } diff --git a/source/component.cpp b/source/component.cpp index a7dfc34..2780070 100644 --- a/source/component.cpp +++ b/source/component.cpp @@ -10,7 +10,6 @@ #include "executable.h" #include "file.h" #include "header.h" -#include "install.h" #include "objectfile.h" #include "sharedlibrary.h" #include "sourcepackage.h" diff --git a/source/copy.cpp b/source/copy.cpp index b5ac403..b756e0c 100644 --- a/source/copy.cpp +++ b/source/copy.cpp @@ -7,7 +7,7 @@ #include #include "builder.h" #include "copy.h" -#include "install.h" +#include "installedfile.h" using namespace std; using namespace Msp; @@ -20,20 +20,20 @@ Target *Copy::create_target(const list &sources, const string &arg) co { FileTarget &file_tgt = dynamic_cast(*sources.front()); const SourcePackage &pkg = dynamic_cast(*file_tgt.get_package()); - Install *inst = new Install(builder, pkg, file_tgt, arg); + InstalledFile *inst = new InstalledFile(builder, pkg, file_tgt, arg); inst->set_tool(*this); return inst; } Task *Copy::run(const Target &target) const { - const Install &install = dynamic_cast(target); + const InstalledFile &install = dynamic_cast(target); Worker *worker = new Worker(install); return new InternalTask(worker); } -Copy::Worker::Worker(const Install &t): +Copy::Worker::Worker(const InstalledFile &t): target(t) { launch(); diff --git a/source/copy.h b/source/copy.h index 6150fad..3aa10a9 100644 --- a/source/copy.h +++ b/source/copy.h @@ -6,10 +6,10 @@ #include "internaltask.h" #include "tool.h" -class Install; +class InstalledFile; /** -Copies a file to another place. Used by the Install target. +Copies a file to another place. Used by the InstalledFile target. */ class Copy: public Tool { @@ -20,10 +20,10 @@ private: class Worker: public InternalTask::Worker { private: - const Install ⌖ + const InstalledFile ⌖ public: - Worker(const Install &); + Worker(const InstalledFile &); private: virtual void main(); }; diff --git a/source/install.cpp b/source/install.cpp deleted file mode 100644 index 7c39ed6..0000000 --- a/source/install.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include -#include "builder.h" -#include "copy.h" -#include "executable.h" -#include "datafile.h" -#include "header.h" -#include "install.h" -#include "package.h" -#include "pkgconfig.h" -#include "sharedlibrary.h" -#include "staticlibrary.h" - -using namespace std; -using namespace Msp; - -Install::Install(Builder &b, const SourcePackage &p, FileTarget &s, const std::string &loc): - FileTarget(b, &p, generate_target_path(s, loc)), - source(s) -{ - buildable = true; - add_depend(&source); - - if(const SharedLibrary *shlib = dynamic_cast(&source)) - if(!shlib->get_soname().empty()) - link = FS::dirname(path)/FS::basename(shlib->get_path()); - - if(!link.empty()) - builder.get_vfs().register_path(link, this); -} - -Target *Install::get_real_target() -{ - return source.get_real_target(); -} - -void Install::check_rebuild() -{ - if(!mtime) - mark_rebuild("Does not exist"); - else if(source.get_mtime()>mtime || source.get_size()!=size) - mark_rebuild(source.get_name()+" has changed"); - else if(source.get_rebuild()) - mark_rebuild(source.get_name()+" needs rebuilding"); -} - -FS::Path Install::generate_target_path(const FileTarget &tgt, const std::string &loc) -{ - if(!tgt.get_package()) - throw invalid_argument("Can't install package-less targets"); - - FS::Path base = tgt.get_package()->get_builder().get_prefix(); - string tgtname = FS::basename(tgt.get_path()); - - string mid; - if(!loc.empty()) - mid = loc; - else if(const Header *hdr = dynamic_cast(&tgt)) - { - if(hdr->get_component()->get_type()!=Component::HEADERS) - throw logic_error("Header install from non-header component?"); - mid = "include/"+hdr->get_component()->get_name(); - } - else if(dynamic_cast(&tgt)) - mid = "bin"; - else if(const SharedLibrary *shlib = dynamic_cast(&tgt)) - { - const Component &comp = shlib->get_component(); - if(comp.get_type()==Component::LIBRARY) - { - mid = "lib"; - if(!shlib->get_soname().empty()) - tgtname = shlib->get_soname(); - } - else if(comp.get_type()==Component::MODULE) - mid = "lib/"+tgt.get_package()->get_name(); - } - else if(dynamic_cast(&tgt)) - mid = "lib"; - else if(dynamic_cast(&tgt)) - mid = "lib/pkgconfig"; - else if(dynamic_cast(&tgt)) - mid = "share/"+tgt.get_package()->get_name(); - - if(mid.empty()) - throw invalid_argument("Don't know where to install "+tgtname); - - return base/mid/tgtname; -} diff --git a/source/install.h b/source/install.h deleted file mode 100644 index 2eb88d4..0000000 --- a/source/install.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef INSTALL_H_ -#define INSTALL_H_ - -#include "sourcepackage.h" -#include "filetarget.h" - -/** -Represents the installation of a file. -*/ -class Install: public FileTarget -{ -private: - FileTarget &source; - Msp::FS::Path link; - -public: - Install(Builder &, const SourcePackage &, FileTarget &, const std::string & =std::string()); - virtual const char *get_type() const { return "Install"; } - FileTarget &get_source() const { return source; } - const Msp::FS::Path &get_symlink() const { return link; } - virtual Target *get_real_target(); -private: - virtual void check_rebuild(); - - static Msp::FS::Path generate_target_path(const FileTarget &i, const std::string &); -}; - -#endif diff --git a/source/installedfile.cpp b/source/installedfile.cpp new file mode 100644 index 0000000..2a96066 --- /dev/null +++ b/source/installedfile.cpp @@ -0,0 +1,88 @@ +#include +#include "builder.h" +#include "copy.h" +#include "executable.h" +#include "datafile.h" +#include "header.h" +#include "installedfile.h" +#include "package.h" +#include "pkgconfig.h" +#include "sharedlibrary.h" +#include "staticlibrary.h" + +using namespace std; +using namespace Msp; + +InstalledFile::InstalledFile(Builder &b, const SourcePackage &p, FileTarget &s, const std::string &loc): + FileTarget(b, &p, generate_target_path(s, loc)), + source(s) +{ + buildable = true; + add_depend(&source); + + if(const SharedLibrary *shlib = dynamic_cast(&source)) + if(!shlib->get_soname().empty()) + link = FS::dirname(path)/FS::basename(shlib->get_path()); + + if(!link.empty()) + builder.get_vfs().register_path(link, this); +} + +Target *InstalledFile::get_real_target() +{ + return source.get_real_target(); +} + +void InstalledFile::check_rebuild() +{ + if(!mtime) + mark_rebuild("Does not exist"); + else if(source.get_mtime()>mtime || source.get_size()!=size) + mark_rebuild(source.get_name()+" has changed"); + else if(source.get_rebuild()) + mark_rebuild(source.get_name()+" needs rebuilding"); +} + +FS::Path InstalledFile::generate_target_path(const FileTarget &tgt, const std::string &loc) +{ + if(!tgt.get_package()) + throw invalid_argument("Can't install package-less targets"); + + FS::Path base = tgt.get_package()->get_builder().get_prefix(); + string tgtname = FS::basename(tgt.get_path()); + + string mid; + if(!loc.empty()) + mid = loc; + else if(const Header *hdr = dynamic_cast(&tgt)) + { + if(hdr->get_component()->get_type()!=Component::HEADERS) + throw logic_error("Header install from non-header component?"); + mid = "include/"+hdr->get_component()->get_name(); + } + else if(dynamic_cast(&tgt)) + mid = "bin"; + else if(const SharedLibrary *shlib = dynamic_cast(&tgt)) + { + const Component &comp = shlib->get_component(); + if(comp.get_type()==Component::LIBRARY) + { + mid = "lib"; + if(!shlib->get_soname().empty()) + tgtname = shlib->get_soname(); + } + else if(comp.get_type()==Component::MODULE) + mid = "lib/"+tgt.get_package()->get_name(); + } + else if(dynamic_cast(&tgt)) + mid = "lib"; + else if(dynamic_cast(&tgt)) + mid = "lib/pkgconfig"; + else if(dynamic_cast(&tgt)) + mid = "share/"+tgt.get_package()->get_name(); + + if(mid.empty()) + throw invalid_argument("Don't know where to install "+tgtname); + + return base/mid/tgtname; +} diff --git a/source/installedfile.h b/source/installedfile.h new file mode 100644 index 0000000..6c6a933 --- /dev/null +++ b/source/installedfile.h @@ -0,0 +1,28 @@ +#ifndef INSTALLEDFILE_H_ +#define INSTALLEDFILE_H_ + +#include "sourcepackage.h" +#include "filetarget.h" + +/** +Represents the installation of a file. +*/ +class InstalledFile: public FileTarget +{ +private: + FileTarget &source; + Msp::FS::Path link; + +public: + InstalledFile(Builder &, const SourcePackage &, FileTarget &, const std::string & =std::string()); + virtual const char *get_type() const { return "InstalledFile"; } + FileTarget &get_source() const { return source; } + const Msp::FS::Path &get_symlink() const { return link; } + virtual Target *get_real_target(); +private: + virtual void check_rebuild(); + + static Msp::FS::Path generate_target_path(const FileTarget &i, const std::string &); +}; + +#endif diff --git a/source/objectfile.cpp b/source/objectfile.cpp index 8068bc6..e020c1b 100644 --- a/source/objectfile.cpp +++ b/source/objectfile.cpp @@ -2,7 +2,6 @@ #include #include "builder.h" #include "component.h" -#include "install.h" #include "objectfile.h" #include "sourcefile.h" #include "sourcepackage.h" @@ -39,7 +38,7 @@ void ObjectFile::find_depends() void ObjectFile::find_depends(FileTarget *tgt) { - Target *rtgt = tgt->get_real_target(); + FileTarget *rtgt = dynamic_cast(tgt->get_real_target()); const Dependencies &tdeps = rtgt->get_depends(); Dependencies deps_to_add; if(rtgt==tgt)