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

#include <vector>
#include <string>

#include "ctor.h"

enum class ToolChain
{
	gcc,
	clang,
};

enum class opt
{
	//                                  gcc/clang
	output,                          //  -o
	debug,                           //  -g
	strip,                           //  -s
	warn_all,                        //  -Wall
	warnings_as_errors,              //  -Werror
	generate_dep_tree,               //  -MMD
	no_link,                         //  -c
	include_path,                    //  -I<arg>
	library_path,                    //  -L<arg>
	link,                            //  -l<arg>
	cpp_std,                         //  -std=<arg>
	build_shared,                    //  -shared
	threads,                         //  -pthread
	optimization,                    //  -O<arg>
	position_independent_code,       //  -fPIC
	position_independent_executable, //  -fPIE
	custom,                          // entire option taken verbatim from <arg>
};

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

//! Get tool argument(s) for specific option type matching the supplied
//! tool-chain
std::vector<std::string> getOption(ToolChain tool_chain,
                                   opt option,
                                   const std::string& arg = {});

//! Get opt enum value and argument from string,
//! ie. { opt::InludePath, "foo/bar" } from "-Ifoo/bar"
//! Returns { opt::Custom, flag } if unknown.
std::pair<opt, std::string> getOption(const std::string& flag,
                                      ToolChain tool_chain = ToolChain::gcc);