-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile.c
More file actions
executable file
·76 lines (65 loc) · 1.81 KB
/
Copy pathcompile.c
File metadata and controls
executable file
·76 lines (65 loc) · 1.81 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
63
64
65
66
67
68
69
70
71
72
73
74
75
#if 0
printf "BUILDING SCRIPT...\n"
gcc "$0" \
./build_scripts/utils.c ./build_scripts/args.c \
-o ./.temp-run \
-Wall -Wextra -Wno-gnu -pedantic
printf "\n"
./.temp-run "$@"
rm -f ./.temp-run
exit
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "build_scripts/utils.h"
#include "build_scripts/args.h"
#define BUILD_FILES "main.c", \
"utils/printer.c", \
"utils/string.c", \
"file/utils.c", \
"file/importer.c", \
"file/orderer.c", \
"file/dependencies.c", \
"file/main.c", \
"array.c", \
"globals.c", \
"cJSON.c", \
"config.c", \
"compiler.c", \
"sys_interactions_linux.c"
#define OUTPUT_FILE "./MQForge"
#define BUILD_ARGS "-Wall", "-Wextra", "-pedantic"
int main(int argv, const char **argc) {
args arguments = { .arg_count = argv, .args = argc };
char *output_file_name = arg_pos("windows", arguments) == -1 ? OUTPUT_FILE : (OUTPUT_FILE".exe");
char *compiler;
if (argv < 2 || strcmp(argc[1], "-") == 0) {
printf("No compiler provided, defaulting to `gcc`\n");
compiler = "gcc";
}
else
compiler = (char *) argc[1];
char** debug_args = (char**) ARR_CREATE("-g", "-fsanitize=address", "-fno-omit-frame-pointer" );
char **build_args = (char**) ARR_CREATE(
compiler,
BUILD_FILES,
BUILD_ARGS,
"-o",
output_file_name
);
if (arg_pos("debug", arguments) != -1) {
char **new_build_args = (char **) array_cat((void**) build_args, (void**) debug_args);
free(build_args);
build_args = new_build_args;
}
int time = run_command(build_args, ".", false);
printf("Build finished in %d seconds. DEBUG: '%s'\n", time, arg_pos("debug", arguments) != -1 ? "true" : "false");
free(build_args);
free(debug_args);
if (arg_pos("run", arguments) != -1) {
char *run_args[] = { output_file_name, NULL };
run_command(run_args, ".", false);
}
}