summaryrefslogtreecommitdiff
path: root/source/scb/scb.h
blob: 09c48521598cf88d3f8776bc70219789e970b91a (plain)
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
/* descrition: meta program, build tool
   author: Abdellah El Morabit */
#define BASE_UNITY
#include "../base/base_include.h"

#define  scbdef static

typedef struct config config;

struct config {
    string8 compiler;
    string8 output;
    string8 flags[];
};

typedef struct file_metad file_metad;
struct file_metad
{
    string8     name;
    u32         time;
};

internal b32
is_file_modified(const char *path)
{
    struct stat scb_bstats;
    s8 err = lstat(path, &scb_bstats);
    assert_msg((err), "lstat failed.");

    if(scb_bstats.st_mtime)
    {

    }
    return 0;
}

//@documentatie: hebfjlberln
internal void
init(int argument_count, char **argument, char **env)
{
    mem_arena *global_arena = arena_create(KiB(2));
    assert_msg(argument_count > 2, "no program passed");

    string8 command = PushString(global_arena, Len(*argument[2]));

    command.data = (u8 *) *argument;
    command.size = Len(*argument[2]);

    //- load files into buffer
    {
        if(is_file_modified)
        {
            self_rebuild();
        }

        //- TODO(nasr): ...
    }

    if(string8_cmp(command, StringCastUTF8("doc", 3)))
    {
        //- run meta program that builds tool documentation
        //- hmmm how do i store the documentation
        {
        }
    }
    else if(string8_cmp(command, StringCast("build", 5)))
    {


        //- search for the binary in PATH
        {
            for(s32 index = 0; *env[index]; ++index)
            {

            }
        }

        //- run the simple build tool
        pid_t pid = fork();
        assert_msg(pid == -1, "failed to start fork process");


        if(pid == 0) {

        }
    }
    else if(string8_cmp(command, StringCast("meta", 5)))
    {
        //- run the meta program
    }

    return;
}