X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finstall.cpp;h=a0029ac1eed33244fea945686d43347d3a8b6628;hb=1fdef3ec9d6291af8a467ea0e2c90e7f19141ae2;hp=d80f9a74d80e15f9c2110f4c9745e6ba0dd7a8d9;hpb=5006279d7b92e578ecfa8a04186f675c6b9f1eea;p=builder.git diff --git a/source/install.cpp b/source/install.cpp index d80f9a7..a0029ac 100644 --- a/source/install.cpp +++ b/source/install.cpp @@ -19,8 +19,8 @@ Distributed under the LGPL using namespace std; using namespace Msp; -Install::Install(Builder &b, const SourcePackage &p, FileTarget &s): - FileTarget(b, &p, generate_target_path(s)), +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; @@ -42,15 +42,18 @@ Action *Install::create_action() return new Copy(builder, *package, source.get_path(), path); } -FS::Path Install::generate_target_path(const FileTarget &tgt) +FS::Path Install::generate_target_path(const FileTarget &tgt, const std::string &loc) { - const SourcePackage *spkg=dynamic_cast(tgt.get_package()); + if(!tgt.get_package()) + throw InvalidParameterValue("Can't install package-less targets"); - FS::Path base=spkg->get_builder().get_prefix(); + FS::Path base=tgt.get_package()->get_builder().get_prefix(); string tgtname=FS::basename(tgt.get_path()); string mid; - if(const Header *hdr=dynamic_cast(&tgt)) + if(!loc.empty()) + mid=loc; + else if(const Header *hdr=dynamic_cast(&tgt)) { if(hdr->get_component()->get_type()!=Component::HEADERS) throw Exception("Header install from non-header component?");