aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/install/utility.cxx
blob: 12215f814963fe8ee3364d493d575aa9d6b5479b (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
// file      : libbuild2/install/utility.cxx -*- C++ -*-
// license   : MIT; see accompanying LICENSE file

#include <libbuild2/install/utility.hxx>

namespace build2
{
  namespace install
  {
    const scope*
    install_scope (const target& t)
    {
      context& ctx (t.ctx);

      const variable& var (*ctx.var_pool.find ("config.install.scope"));

      if (const string* s = cast_null<string> (ctx.global_scope[var]))
      {
        if (*s == "project")
          return &t.root_scope ();
        else if (*s == "strong")
          return &t.strong_scope ();
        else if (*s == "weak")
          return &t.weak_scope ();
        else if (*s != "global")
          fail << "invalid " << var << " value '" << *s << "'";
      }

      return nullptr;
    }
  }
}