aboutsummaryrefslogtreecommitdiff
path: root/bpkg/satisfaction
blob: 6f8ce45a7c7ff920e788ae5824b818f8dbc4e151 (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
// file      : bpkg/satisfaction -*- C++ -*-
// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

#ifndef BPKG_SATISFACTION
#define BPKG_SATISFACTION

#include <bpkg/types>
#include <bpkg/utility>

#include <bpkg/package>
#include <bpkg/common-options>

namespace bpkg
{
  // Return true if version satisfies the constraint.
  //
  bool
  satisfies (const version&, const dependency_constraint&);

  inline bool
  satisfies (const version& v, const optional<dependency_constraint>& c)
  {
    return !c || satisfies (v, *c);
  }

  // Return true if any version that satisfies l also satisfies r, or, in
  // other words, l is stricter than or equal to r. Or, in yet other words,
  // l is a subset of r.
  //
  bool
  satisfies (const dependency_constraint& l, const dependency_constraint& r);

  inline bool
  satisfies (const optional<dependency_constraint>& l,
             const optional<dependency_constraint>& r)
  {
    return l ? (!r || satisfies (*l, *r)) : !r;
  }

  // Special build-time dependencies.
  //
  void
  satisfy_build2 (const common_options&, const string& pkg, const dependency&);

  void
  satisfy_bpkg (const common_options&, const string& pkg, const dependency&);
}

#endif // BPKG_SATISFACTION