-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmate.c
More file actions
62 lines (48 loc) · 1.83 KB
/
Copy pathmate.c
File metadata and controls
62 lines (48 loc) · 1.83 KB
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
#define MATE_IMPLEMENTATION
#include "mate.h"
#include <stdio.h>
#define OUTPUT "cbc"
#ifndef COMPILER
#define COMPILER GCC
#endif
#ifdef DEBUG
#define OPTS \
(ExecutableOptions) { \
.output = OUTPUT, .warnings = FLAG_WARNINGS_VERBOSE, \
.error = FLAG_ERROR_MAX, .debug = FLAG_DEBUG, .std = FLAG_STD_C11, \
.optimization = FLAG_OPTIMIZATION_NONE, \
.sanitizer = FLAG_SANITIZER_ADDRESS, \
}
#else
#define OPTS \
(ExecutableOptions) { \
.output = OUTPUT, .optimization = FLAG_OPTIMIZATION_AGGRESSIVE, \
.std = FLAG_STD_C11 \
}
#endif
#define CheckRunCommand(s) \
if (RunCommand(S(s)) != SUCCESS) { \
fprintf(stderr, "could not execute command `" s "`\n"); \
abort(); \
}
// ===== actual source code/building logic goes here =====
static void build(void) {
CreateConfig(
(MateOptions){.compiler = COMPILER, .buildDirectory = ".build"});
StartBuild();
Executable exec = CreateExecutable(OPTS);
AddFile(exec, "./src/*.c");
InstallExecutable(exec);
EndBuild();
}
int main(int argc, char** argv) {
#ifdef DEBUG
fprintf(stderr, "compiling with debug flags\n");
#else
fprintf(stderr, "compiling with release flags\n");
#endif
argc--;
argv++;
if (argc == 0)
build();
}