~lattis/muon

ref: f9a8cbad39b665a9496cd3adb4756e85ee5ec97c muon/include/compilers.h -rw-r--r-- 2.3 KiB
f9a8cbadStone Tickle print stdout/stderr of failing test 4 months ago
                                                                                
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
#ifndef MUON_COMPILERS_H
#define MUON_COMPILERS_H

#include <stdbool.h>
#include <stdint.h>
struct workspace;

enum compiler_type {
	compiler_posix,
	compiler_gcc,
	compiler_clang,
	compiler_type_count,
};

enum linker_type {
	linker_posix,
	linker_gcc,
	linker_type_count,
};

enum compiler_language {
	compiler_language_c,
	compiler_language_c_hdr,
	compiler_language_cpp,
	compiler_language_cpp_hdr,
	compiler_language_count,
};

enum compiler_deps_type {
	compiler_deps_none,
	compiler_deps_gcc,
	compiler_deps_msvc,
};

enum compiler_optimization_lvl {
	compiler_optimization_lvl_0,
	compiler_optimization_lvl_1,
	compiler_optimization_lvl_2,
	compiler_optimization_lvl_3,
	compiler_optimization_lvl_g,
	compiler_optimization_lvl_s,
};

enum compiler_warning_lvl {
	compiler_warning_lvl_0,
	compiler_warning_lvl_1,
	compiler_warning_lvl_2,
	compiler_warning_lvl_3,
};

typedef const struct args *((*compiler_get_arg_func_0)(void));
typedef const struct args *((*compiler_get_arg_func_1i)(uint32_t));
typedef const struct args *((*compiler_get_arg_func_1s)(const char *));
typedef const struct args *((*compiler_get_arg_func_2s)(const char *, const char *));

struct compiler {
	struct {
		compiler_get_arg_func_2s deps;
		compiler_get_arg_func_0 compile_only;
		compiler_get_arg_func_1s output;
		compiler_get_arg_func_1i optimization;
		compiler_get_arg_func_0 debug;
		compiler_get_arg_func_1i warning_lvl;
		compiler_get_arg_func_0 werror;
		compiler_get_arg_func_1s set_std;
		compiler_get_arg_func_1s include;
	} args;
	enum compiler_deps_type deps;
	enum linker_type linker;
};

struct linker {
	struct {
		compiler_get_arg_func_0 as_needed;
		compiler_get_arg_func_0 no_undefined;
		compiler_get_arg_func_0 start_group;
		compiler_get_arg_func_0 end_group;
	} args;
};

struct language {
	bool is_header;
};

extern struct compiler compilers[];
extern struct linker linkers[];
extern const struct language languages[];

const char *compiler_type_to_s(enum compiler_type t);
const char *compiler_language_to_s(enum compiler_language l);
bool s_to_compiler_language(const char *s, enum compiler_language *l);
bool filename_to_compiler_language(const char *str, enum compiler_language *l);
bool compiler_detect(struct workspace *wk, uint32_t *comp, enum compiler_language lang);
void compilers_init(void);
#endif