summaryrefslogtreecommitdiff
path: root/src/tools.h
blob: b1285ec4010d57613946bfc0c749d6268577f8fc (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
95
96
// -*- c++ -*-
// Distributed under the BSD 2-Clause License.
// See accompanying file LICENSE for details.
#pragma once

#include <vector>
#include <string>
#include <ostream>

#include "ctor.h"


std::ostream& operator<<(std::ostream& stream, const ctor::c_opt& opt);
std::ostream& operator<<(std::ostream& stream, const ctor::cxx_opt& opt);
std::ostream& operator<<(std::ostream& stream, const ctor::ld_opt& opt);
std::ostream& operator<<(std::ostream& stream, const ctor::ar_opt& opt);
std::ostream& operator<<(std::ostream& stream, const ctor::asm_opt& opt);


//! Get tool-chain type from compiler path string
ctor::toolchain getToolChain(const std::string& compiler);

//! Get tool-chain type from output system (via configuration)
ctor::toolchain getToolChain(ctor::output_system system);



//! Get tool argument(s) for specific option type matching the supplied
//! tool-chain
std::vector<std::string> c_option(ctor::toolchain toolchain,
                                  ctor::c_opt option,
                                  const std::string& arg = {});

//! Get tool argument(s) for specific option type matching the supplied
//! tool-chain
std::vector<std::string> cxx_option(ctor::toolchain toolchain,
                                    ctor::cxx_opt option,
                                    const std::string& arg = {});

//! Get tool argument(s) for specific option type matching the supplied
//! tool-chain
std::vector<std::string> ld_option(ctor::toolchain toolchain,
                                   ctor::ld_opt option,
                                   const std::string& arg = {});

//! Get tool argument(s) for specific option type matching the supplied
//! tool-chain
std::vector<std::string> ar_option(ctor::toolchain toolchain,
                                   ctor::ar_opt option,
                                   const std::string& arg = {});

//! Get tool argument(s) for specific option type matching the supplied
//! tool-chain
std::vector<std::string> asm_option(ctor::toolchain toolchain,
                                    ctor::asm_opt option,
                                    const std::string& arg = {});



//! Get ctor::c_opt enum value and argument from string,
//! ie. { ctor::c_opt::inlude_path, "foo/bar" } from "-Ifoo/bar"
//! Returns { ctor::c_opt::custom, flag } if unknown.
ctor::c_flag c_option(const std::string& flag, ctor::toolchain toolchain);

//! Get ctor::cxx_opt enum value and argument from string,
//! ie. { ctor::cxx_opt::inlude_path, "foo/bar" } from "-Ifoo/bar"
//! Returns { ctor::cxx_opt::custom, flag } if unknown.
ctor::cxx_flag cxx_option(const std::string& flag, ctor::toolchain toolchain);

//! Get ctor::ld_opt enum value and argument from string,
//! ie. { ctor::ld_opt::inlude_path, "foo/bar" } from "-Ifoo/bar"
//! Returns { ctor::ld_opt::custom, flag } if unknown.
ctor::ld_flag ld_option(const std::string& flag, ctor::toolchain toolchain);

//! Get ctor::ar_opt enum value and argument from string,
//! ie. { ctor::ar_opt::inlude_path, "foo/bar" } from "-Ifoo/bar"
//! Returns { ctor::ar_opt::custom, flag } if unknown.
ctor::ar_flag ar_option(const std::string& flag, ctor::toolchain toolchain);

//! Get ctor::asm_opt enum value and argument from string,
//! ie. { ctor::asm_opt::inlude_path, "foo/bar" } from "-Ifoo/bar"
//! Returns { ctor::asm_opt::custom, flag } if unknown.
ctor::asm_flag asm_option(const std::string& flag, ctor::toolchain toolchain);



std::vector<std::string> to_strings(ctor::toolchain toolchain,
                                    const ctor::cxx_flag& flag);
std::vector<std::string> to_strings(ctor::toolchain toolchain,
                                    const ctor::c_flag& flag);
std::vector<std::string> to_strings(ctor::toolchain toolchain,
                                    const ctor::ld_flag& flag);
std::vector<std::string> to_strings(ctor::toolchain toolchain,
                                    const ctor::ar_flag& flag);
std::vector<std::string> to_strings(ctor::toolchain toolchain,
                                    const ctor::asm_flag& flag);