From: Mikko Rasa Date: Thu, 6 Sep 2012 06:51:42 +0000 (+0300) Subject: Let tools have a say in installing their targets X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=aa8d09ccd31c59c6499cf624520c20e5684da7ee;p=builder.git Let tools have a say in installing their targets --- diff --git a/source/builder.cpp b/source/builder.cpp index c61d4a7..3344429 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -341,9 +341,12 @@ void Builder::add_primary_target(Target &t) void Builder::add_installed_target(Target &t) { - Target *install = get_target("install"); - const Tool © = toolchain.get_tool("CP"); - install->add_dependency(*copy.create_target(t)); + Target *inst_tgt = 0; + if(const Tool *tool = t.get_tool()) + inst_tgt = tool->create_install(t); + if(!inst_tgt) + inst_tgt = toolchain.get_tool("CP").create_target(t); + get_target("install")->add_dependency(*inst_tgt); } void Builder::usage(const char *reason, const char *argv0, bool brief) diff --git a/source/tool.h b/source/tool.h index d5d7e78..2948053 100644 --- a/source/tool.h +++ b/source/tool.h @@ -74,6 +74,10 @@ public: alternative target type for tools that can create multiple kinds of targets. */ virtual Target *create_target(const std::list &, const std::string & = std::string()) const = 0; + /** Creates an install target for a target created by this tool. Can return + null if the tool does not want to handle installing in a special way. */ + virtual Target *create_install(Target &) const { return 0; } + virtual std::string create_build_signature(const BuildInfo &) const { return std::string(); } /** Invokes the tool to build a target. This should not be called directly;