aboutsummaryrefslogtreecommitdiff
path: root/build/file
blob: 8e96f4a35598ea7a94e622f95208b1ad229b3ffa (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// file      : build/file -*- C++ -*-
// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

#ifndef BUILD_FILE
#define BUILD_FILE

#include <build/types>
#include <build/variable> // list_value

namespace build
{
  class scope;
  class location;

  bool
  is_src_root (const dir_path&);

  bool
  is_out_root (const dir_path&);

  // Given an src_base directory, look for a project's src_root
  // based on the presence of known special files. Return empty
  // path if not found.
  //
  dir_path
  find_src_root (const dir_path&);

  // The same as above but for project's out. Note that we also
  // check whether a directory happens to be src_root, in case
  // this is an in-tree build. The second argument is the out
  // flag that is set to true if this is src_root.
  //
  dir_path
  find_out_root (const dir_path&, bool* src = nullptr);

  void
  source (const path& buildfile, scope& root, scope& base);

  // As above but first check if this buildfile has already been
  // sourced for the base scope.
  //
  void
  source_once (const path& buildfile, scope& root, scope& base);

  // As above but checks against the specified scope rather than base.
  //
  void
  source_once (const path& buildfile, scope& root, scope& base, scope& once);

  // Create project's root scope. Only set the src_root variable if the
  // passed src_root value is not empty.
  //
  scope&
  create_root (const dir_path& out_root, const dir_path& src_root);

  // Bootstrap the project's root scope, the out part.
  //
  void
  bootstrap_out (scope& root);

  // Bootstrap the project's root scope, the src part. Return true if
  // we loaded anything (which confirms the src_root is not bogus).
  //
  bool
  bootstrap_src (scope& root);

  // Create and bootstrap outer root scopes, if any. Loading is
  // done by load_root_pre() below.
  //
  void
  create_bootstrap_outer (scope& root);

  // Create and bootstrap inner root scopes between root and base,
  // if any. Return the innermost created root scope or root if
  // none were created. Loading is done by load_root_pre() below.
  //
  scope&
  create_bootstrap_inner (scope& root, const dir_path& out_base);

  // Load project's root[-pre].build unless already loaded. Also
  // make sure all outer root scopes are loaded prior to loading
  // this root scope.
  //
  void
  load_root_pre (scope& root);

  list_value
  import (scope& base, const name&, const location&);
}

#include <build/file.ixx>

#endif // BUILD_FILE