X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finstallmap.cpp;h=8f1995bc905c3a4a6d38dfea113958570191712e;hb=HEAD;hp=942b932b98c29babf1fd0d59eb090d53cb1cda30;hpb=c51e8844f19c31b2809ba459a1659d3b94a86f89;p=builder.git diff --git a/source/installmap.cpp b/source/installmap.cpp deleted file mode 100644 index 942b932..0000000 --- a/source/installmap.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include "component.h" -#include "filetarget.h" -#include "installmap.h" - -using namespace std; -using namespace Msp; - -void InstallMap::add_mapping(const FS::Path &src, const FS::Path &inst) -{ - Entry e; - e.source = src; - e.install = inst; - entries.push_back(e); -} - -FS::Path InstallMap::get_install_location(const FileTarget &target) const -{ - const Component *comp = target.get_component(); - unsigned overlay_depth = 0; - if(comp && !comp->get_overlays().empty()) - { - const Component::OverlayList &overlays = comp->get_overlays(); - string last_dir = FS::basename(FS::dirname(target.get_path())); - for(Component::OverlayList::const_iterator i=overlays.begin(); i!=overlays.end(); ++i) - if(last_dir==*i) - overlay_depth = 1; - } - - const FS::Path &source = target.get_path(); - FS::Path install = target.get_install_location(); - for(list::const_iterator i=entries.begin(); i!=entries.end(); ++i) - { - int source_depth = FS::descendant_depth(source, i->source); - if(source_depth>=0) - { - FS::Path install_base = FS::common_ancestor(install, i->install); - if(install_base.size()>1) - { - install = i->install/source.subpath(i->source.size(), source_depth-1-overlay_depth); - break; - } - } - } - - return install; -} - - -InstallMap::Loader::Loader(InstallMap &m, const FS::Path &s): - DataFile::ObjectLoader(m), - source_base(s) -{ - add("map", &Loader::map); -} - -void InstallMap::Loader::map(const string &src, const string &inst) -{ - obj.add_mapping(source_base/src, inst); -}