summaryrefslogtreecommitdiffhomepage
path: root/CompilerFrontend/cl/main.d
blob: fcc4326ca5d1de6029ea8154043a27c22e9aade0 (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
 *	========================================================
 *
 *	MP-UX C Compiler
 * 	Copyright WestCo, all rights reserved.
 *
 * 	========================================================
 */

// @file main.d
// @brief CLI of the X64000 C/C++ compiler

module cl.main;

import cl.compiler;
import std.container.dlist;

///Authors: Amlal EL Mahrouss
///Examples: mcc_summon_manual("foo"); 
void mcc_summon_manual(string path)
{
	import core.stdc.stdlib;
    import std.string;
    import std.file;

    string base = "man ";
    base ~= "/usr/local/bin/man/";

    string extension = ".8";

	core.stdc.stdlib.system(toStringz(base ~ path ~ extension));
}

void main(string[] args) 
{
	import std.range, std.stdio;

    bool shared_library = false;
    bool compile_only = false;
    bool kernel_driver = false;
    string output_file = "a.out";
    size_t index = 0UL;

    string[255] args_list;

    foreach (arg ; args)
    {
        if (arg[0] == '-')
        {
            if (arg == "--version" ||
                arg == "-v")
            {
                writeln("mpcc: version 1.00, (c) WestCo all rights reserved.");
                
                return;
            }
            else if (arg == "--help" ||
                     arg == "-h")
            {
                writeln("mpcc: summoning manual entry for mpcc...");
                mcc_summon_manual("mpcc");

                return;
            }
            else if (arg == "-c")
            {
                compile_only = true;
                continue;
            }
            else if (arg == "--kernel")
            {
                kernel_driver = true;
                continue;
            }
            else if (arg == "--shared")
            {
                output_file = "a.lib";
                shared_library = true;
                continue;
            }

            writeln("mpcc: unknown argument " ~ arg);
            return;
        }

        if (index == 0)
        {
            ++index;
            continue;
        }

        args_list[index] = arg;
        ++index;
    }

    if (args_list[1] == null)
    {
        writeln("mpcc: no input files.");
        return;
    }

    auto compiler = new CompileCommand();

    if (kernel_driver)
        compiler.compile(Platform.getKernelPath(), args_list, shared_library, output_file, compile_only);
    else
        compiler.compile(Platform.getIncludePath(), args_list, shared_library, output_file, compile_only);
}