-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathb.c
More file actions
40 lines (28 loc) · 980 Bytes
/
Copy pathb.c
File metadata and controls
40 lines (28 loc) · 980 Bytes
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
#include "b.h"
#define OBJ_DIR "obj"
#define PROG_NAME "anum"
#define GCC "gcc"
#define FLAGS "-Wall -Wextra -g -O2"
int main(void) {
INFO("Start building Annuum\n");
if (!dir_exists(OBJ_DIR))
make_dir(OBJ_DIR, 0755);
Array *c_filse = find_all_files("./src", "c");
char *current_dir = pwd();
char *obj_dir = pathjoin(current_dir, OBJ_DIR);
Array *o_files = array_new(c_filse->count);
for (size_t i = 0; i < c_filse->count; i++) {
char* name = path_basename((char *)c_filse->items[i]);
char* obj_file_path = pathjoin(obj_dir , name);
obj_file_path = change_extension(obj_file_path , "o");
RUN(GCC , "-c" , (char *)c_filse->items[i] , "-o" , obj_file_path , FLAGS);
array_add(o_files , obj_file_path);
}
char *objs = o_files->items[0];
for(size_t i = 1 ; i < o_files->count; i++){
objs = strcat_new(objs , " ");
objs = strcat_new(objs , o_files->items[i]);
}
RUN(GCC , objs , "-o" , PROG_NAME);
return 0;
}