X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finstallmap.cpp;h=8f1995bc905c3a4a6d38dfea113958570191712e;hb=HEAD;hp=448f997b2e0822381707238e556be304a7c808d2;hpb=7c2db9e2b91da953701be233336c5bfa1f3c4af0;p=builder.git diff --git a/source/installmap.cpp b/source/installmap.cpp deleted file mode 100644 index 448f997..0000000 --- a/source/installmap.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include -#include -#include "component.h" -#include "filetarget.h" -#include "installmap.h" -#include "sourcepackage.h" -#include "templatefile.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()) - { - // Check if the target resides in an overlay directory - string last_dir = FS::basename(FS::dirname(target.get_path())); - if(any_equals(comp->get_overlays(), last_dir)) - overlay_depth = 1; - } - - FS::Path source = target.get_path(); - if(comp) - { - /* Check if the target is a generated source file, residing in the - temporary directory */ - const SourcePackage &pkg = comp->get_package(); - int temp_depth = FS::descendant_depth(source, pkg.get_temp_directory()); - if(temp_depth>0) - { - // If it is, use the generating template's directory instead - for(Target *d: target.get_dependencies()) - if(const TemplateFile *tmpl = dynamic_cast(d)) - { - source = FS::dirname(tmpl->get_path())/FS::basename(source); - break; - } - } - } - - /* Look for a mapping entry matching both the target's original location - and default install location */ - FS::Path install = target.get_install_location(); - for(const Entry &e: entries) - { - int source_depth = FS::descendant_depth(source, e.source); - if(source_depth>=0) - { - FS::Path install_base = FS::common_ancestor(install, e.install); - if(install_base.size()>1) - { - install = e.install/source.subpath(e.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); -}