From 9fa5f73d00905568e8979d0c93ec4a8f645c81d5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 9 Aug 2016 11:31:53 +0200 Subject: Implement support for C compilation We now have two new modules: cc (c-common) and c. --- build2/cc/install.cxx | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 build2/cc/install.cxx (limited to 'build2/cc/install.cxx') diff --git a/build2/cc/install.cxx b/build2/cc/install.cxx new file mode 100644 index 0000000..b674886 --- /dev/null +++ b/build2/cc/install.cxx @@ -0,0 +1,70 @@ +// file : build2/cc/install.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include + +#include + +#include // match() +#include + +using namespace std; + +namespace build2 +{ + namespace cc + { + using namespace bin; + + install:: + install (data&& d, const link& l): common (move (d)), link_ (l) {} + + target* install:: + filter (action a, target& t, prerequisite_member p) const + { + if (t.is_a ()) + { + // Don't install executable's prerequisite headers. + // + if (x_header (p)) + return nullptr; + } + + // If this is a shared library prerequisite, install it as long as it + // is in the same amalgamation as we are. + // + // @@ Shouldn't we also install a static library prerequisite of a + // static library? + // + if ((t.is_a () || t.is_a ()) && + (p.is_a () || p.is_a ())) + { + target* pt (&p.search ()); + + // If this is the lib{} group, pick a member which we would link. + // + if (lib* l = pt->is_a ()) + pt = &link_member (*l, link_order (t.base_scope (), link_type (t))); + + if (pt->is_a ()) // Can be liba{}. + return pt->in (t.weak_scope ()) ? pt : nullptr; + } + + return file_rule::filter (a, t, p); + } + + match_result install:: + match (action a, target& t, const string& hint) const + { + // @@ How do we split the hint between the two? + // + + // We only want to handle installation if we are also the + // ones building this target. So first run link's match(). + // + match_result r (link_.match (a, t, hint)); + return r ? install::file_rule::match (a, t, "") : r; + } + } +} -- cgit v1.1