-
Notifications
You must be signed in to change notification settings - Fork 9
/
nobuild.c
57 lines (49 loc) · 1.38 KB
/
nobuild.c
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
#define NOBUILD_IMPLEMENTATION
#include "./nobuild.h"
#define CFLAGS "-Wall", "-Wextra", "-Wswitch-enum", "-std=c11", "-pedantic", "-ggdb"
#define CSV_FILE_PATH "./csv/stress-copy.csv"
// #define CSV_FILE_PATH "./csv/sum.csv"
// #define CSV_FILE_PATH "./csv/foo.csv"
// #define CSV_FILE_PATH "./csv/bills.csv"
const char *cc(void)
{
const char *result = getenv("CC");
return result ? result : "cc";
}
int posix_main(int argc, char **argv)
{
CMD(cc(), CFLAGS, "-o", "minicel", "src/main.c");
if (argc > 1) {
if (strcmp(argv[1], "run") == 0) {
CMD("./minicel", CSV_FILE_PATH);
} else if (strcmp(argv[1], "gdb") == 0) {
CMD("gdb", "./minicel");
} else if (strcmp(argv[1], "valgrind") == 0) {
CMD("valgrind", "--error-exitcode=1", "./minicel", CSV_FILE_PATH);
} else {
PANIC("%s is unknown subcommand", argv[1]);
}
}
return 0;
}
int msvc_main(int argc, char **argv)
{
CMD("cl.exe", "/Feminicel", "src/main.c");
if (argc > 1) {
if (strcmp(argv[1], "run") == 0) {
CMD(".\\minicel.exe", CSV_FILE_PATH);
} else {
PANIC("%s is unknown subcommand", argv[1]);
}
}
return 0;
}
int main(int argc, char **argv)
{
GO_REBUILD_URSELF(argc, argv);
#ifndef _WIN32
return posix_main(argc, argv);
#else
return msvc_main(argc, argv);
#endif
}