aboutsummaryrefslogtreecommitdiff
path: root/build/cxx/install.cxx
blob: f8c2c06bc2634541102d6f3879ebe50de21a912e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// file      : build/cxx/install.cxx -*- C++ -*-
// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

#include <build/cxx/install>

#include <build/bin/target>

#include <build/cxx/target>
#include <build/cxx/link>

using namespace std;

namespace build
{
  namespace cxx
  {
    using namespace bin;

    target* install::
    filter (action a, target& t, prerequisite_member p) const
    {
      if (t.is_a<exe> ())
      {
        // Don't install executable's prerequisite headers.
        //
        if (p.is_a<hxx> () || p.is_a<ixx> () || p.is_a<txx> () || p.is_a<h> ())
          return nullptr;
      }

      // If this is a shared library prerequisite, install it as long as it
      // is in the same amalgamation as we are.
      //
      if ((t.is_a<exe> () || t.is_a<libso> ()) &&
          (p.is_a<lib> () || p.is_a<libso> ()))
      {
        target* pt (&p.search ());

        // If this is the lib{} group, pick a member which we would link.
        //
        if (lib* l = pt->is_a<lib> ())
          pt = &link::link_member (*l, link::link_order (t));

        if (pt->is_a<libso> ()) // 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 std::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::instance.match (a, t, hint));
      return r ? install::file_rule::match (a, t, "") : r;
    }

    install install::instance;
  }
}