From 0dea0d850f6690de07933794592916d11c9d3f49 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 5 Sep 2012 19:11:03 +0300 Subject: [PATCH] Route InstalledFile target creation through Builder --- source/builder.cpp | 7 +++++++ source/builder.h | 4 ++++ source/component.cpp | 20 ++++++-------------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/source/builder.cpp b/source/builder.cpp index 3ac4b28..c61d4a7 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -339,6 +339,13 @@ void Builder::add_primary_target(Target &t) get_target("default")->add_dependency(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)); +} + void Builder::usage(const char *reason, const char *argv0, bool brief) { if(reason) diff --git a/source/builder.h b/source/builder.h index 2f70fbd..67b3375 100644 --- a/source/builder.h +++ b/source/builder.h @@ -119,6 +119,10 @@ public: virtual target. */ void add_primary_target(Target &); + /** Adds a target that will be installed. A new InstalledFile target is + created and added as a dependency to the "install" virtual target. */ + void add_installed_target(Target &); + void problem(const std::string &, const std::string &); static void usage(const char *, const char *, bool); diff --git a/source/component.cpp b/source/component.cpp index 6bfce1f..db78917 100644 --- a/source/component.cpp +++ b/source/component.cpp @@ -101,7 +101,6 @@ void Component::create_targets() const const Toolchain &toolchain = builder.get_toolchain(); SourceList source_filenames = collect_source_files(); - list inst_list; string inst_loc; if(type==TARBALL) @@ -138,7 +137,8 @@ void Component::create_targets() const } else if(type==INSTALL) { - inst_loc = name; + Target *inst = builder.get_target("install"); + const Tool © = toolchain.get_tool("CP"); for(SourceList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i) { FileTarget *ft; @@ -146,7 +146,7 @@ void Component::create_targets() const ft = dynamic_cast(tgt); else ft = new File(builder, package, *i); - inst_list.push_back(ft); + inst->add_dependency(*copy.create_target(*ft, name)); } } else if(type==DATAFILE) @@ -162,7 +162,7 @@ void Component::create_targets() const builder.add_primary_target(*result); if(install) - inst_list.push_back(result); + builder.add_installed_target(*result); } if(type==PROGRAM || type==LIBRARY || type==MODULE) @@ -185,7 +185,7 @@ void Component::create_targets() const } if(type==LIBRARY && install && dynamic_cast(src)->is_installable()) - inst_list.push_back(src); + builder.add_installed_target(*src); } } @@ -225,17 +225,9 @@ void Component::create_targets() const { builder.add_primary_target(**i); if(install) - inst_list.push_back(*i); + builder.add_installed_target(**i); } } - - Target *inst_tgt = builder.get_target("install"); - const Tool © = toolchain.get_tool("CP"); - for(list::const_iterator i=inst_list.begin(); i!=inst_list.end(); ++i) - { - Target *inst = copy.create_target(**i, inst_loc); - inst_tgt->add_dependency(*inst); - } } Component::SourceList Component::collect_source_files() const -- 2.43.0