aboutsummaryrefslogtreecommitdiff
path: root/libbbot/build-config.hxx
blob: 5c9296d84fbe879c62877aaf026b1acd66d62582 (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      : libbbot/build-config.hxx -*- C++ -*-
// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

#ifndef LIBBBOT_BUILD_CONFIG_HXX
#define LIBBBOT_BUILD_CONFIG_HXX

#include <map>
#include <string>
#include <vector>
#include <iosfwd>

#include <libbutl/path.mxx>
#include <libbutl/tab-parser.mxx>
#include <libbutl/target-triplet.mxx>

#include <libbbot/export.hxx>
#include <libbbot/version.hxx>

namespace bbot
{
  // Build configuration matching specific machine names. Used by bbot
  // controllers.
  //
  struct build_config
  {
    std::string machine_pattern;      // Machine name pattern.
    std::string name;                 // Configuration name.
    butl::target_triplet target;
    std::vector<std::string> classes;
    std::vector<std::string> args;    // Note: quoting is preserved.

    // Warning-detecting regular expressions. Note that quoting is preserved.
    //
    std::vector<std::string> warning_regexes;
  };

  struct build_configs: std::vector<build_config>
  {
    // List of all configuration class names. Starts with the all and default
    // classes. The rest follows in the same order as in the buildtab.
    //
    std::vector<std::string> classes;

    // A map of derived class names to their bases.
    //
    std::map<std::string, std::string> class_inheritance_map;
  };

  // Parse buildtab stream or file. Throw tab_parsing on parsing error,
  // ios::failure on the underlying OS error.
  //
  // buildtab consists of lines in the following format:
  //
  // <machine-pattern> <config> <target> <classes> [<config-arg>]* [<warning-regex>]*
  //
  using butl::tab_parsing;

  LIBBBOT_EXPORT build_configs
  parse_buildtab (std::istream&, const std::string& name);

  LIBBBOT_EXPORT build_configs
  parse_buildtab (const butl::path&);
}

#endif // LIBBBOT_BUILD_CONFIG_HXX