diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-09 21:47:33 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-09 21:47:33 +0100 |
| commit | 9cef856478cebe4bfe00e1d39c9e2d49015dd0e4 (patch) | |
| tree | f04c6b6b1156057748c7044a766120485c45c885 /Frontend/Compiler/main.d | |
| parent | a8a55bc93e06cd8f75f7d397c013f7a312ea29a4 (diff) | |
MP-UX/hCore Assembler for 64x0, Release I.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Frontend/Compiler/main.d')
| -rw-r--r-- | Frontend/Compiler/main.d | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/Frontend/Compiler/main.d b/Frontend/Compiler/main.d new file mode 100644 index 0000000..aabc0ff --- /dev/null +++ b/Frontend/Compiler/main.d @@ -0,0 +1,112 @@ +/* + * ======================================================== + * + * MP-UX C Compiler + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +// @file main.d +// @brief CLI of the X64000 C/C++ compiler + +module mpcc.main; + +import mpcc.compiler; +import std.container.dlist; + +///Authors: Amlal EL Mahrouss +///Examples: mpcc_summon_manual("foo"); +void mpcc_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.01, (c) Mahrouss Logic all rights reserved."); + return; + } + else if (arg == "--dialect") + { + mpcc_summon_executable("/usr/local/bin/bin/cc --asm=masm --compiler=dolvik --dialect"); + return; + } + else if (arg == "--help" || + arg == "-h") + { + writeln("mpcc: summoning manual entry for mpcc..."); + mpcc_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); +}
\ No newline at end of file |
