diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-04-19 17:33:26 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-04-19 17:33:26 +0200 |
| commit | befde76cfa46c766e81f74eb5ac65d3dae2dde87 (patch) | |
| tree | 45b2f9fd6b3f9605c2747485bd24483192f99e73 /tools | |
| parent | 3afc481dc64a07fe7fcaff9ce7a12a492c3ec8e7 (diff) | |
dev, LibCompiler, tooling: refactor and separate components into modules
(cppdrv, cxxdrv)
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/cppdrv.cc | 30 | ||||
| -rw-r--r-- | tools/cppdrv.json | 12 | ||||
| -rw-r--r-- | tools/cxxdrv.cc | 29 | ||||
| -rw-r--r-- | tools/dbg.cc | 4 |
4 files changed, 47 insertions, 28 deletions
diff --git a/tools/cppdrv.cc b/tools/cppdrv.cc new file mode 100644 index 0000000..209b86e --- /dev/null +++ b/tools/cppdrv.cc @@ -0,0 +1,30 @@ +/* ------------------------------------------- + + Copyright (C) 2024-2025 Amlal EL Mahrous, all rights reserved + +------------------------------------------- */ + +/// @file cxxdrv.cc +/// @brief NE C++ frontend compiler. + +#include <LibCompiler/Defines.h> +#include <LibCompiler/ErrorID.h> +#include <LibCompiler/Version.h> +#include <iostream> +#include <cstring> +#include <vector> + +LC_IMPORT_C int CPlusPlusPreprocessorMain(int argc, char const* argv[]); + +int main(int argc, char const* argv[]) +{ + if (auto code = CPlusPlusPreprocessorMain(2, argv); + code > 0) + { + std::printf("cxxdrv: compiler exited with code %i.\n", code); + + return LIBCOMPILER_EXEC_ERROR; + } + + return LIBCOMPILER_SUCCESSS; +}
\ No newline at end of file diff --git a/tools/cppdrv.json b/tools/cppdrv.json new file mode 100644 index 0000000..9a4282c --- /dev/null +++ b/tools/cppdrv.json @@ -0,0 +1,12 @@ +{ + "compiler_path": "g++", + "compiler_std": "c++20", + "headers_path": ["../dev/LibCompiler", "../dev/", "../dev/LibCompiler/src/Detail"], + "sources_path": ["cppdrv.cc"], + "output_name": "cppdrv", + "compiler_flags": ["-L/usr/local/lib", "-lCompiler"], + "cpp_macros": [ + "__CXXDRV__=202504", + "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" + ] +} diff --git a/tools/cxxdrv.cc b/tools/cxxdrv.cc index e5d6334..1d59c5c 100644 --- a/tools/cxxdrv.cc +++ b/tools/cxxdrv.cc @@ -8,39 +8,17 @@ /// @brief NE C++ frontend compiler. #include <LibCompiler/Defines.h> -#include <LibCompiler/NFC/ErrorID.h> +#include <LibCompiler/ErrorID.h> #include <LibCompiler/Version.h> #include <iostream> #include <cstring> #include <vector> -LC_IMPORT_C int CPlusPlusPreprocessorMain(int argc, char const* argv[]); LC_IMPORT_C int CompilerCPlusPlusAMD64(int argc, char const* argv[]); LC_IMPORT_C int AssemblerMainAMD64(int argc, char const* argv[]); int main(int argc, char const* argv[]) { - for (size_t index_arg = 0; index_arg < argc; ++index_arg) - { - if (strstr(argv[index_arg], "--cxxdrv:h")) - { - std::printf("cxxdrv: C++ Compiler Driver.\n"); - std::printf("cxxdrv: Version: %s, Release: %s.\n", kDistVersion, kDistRelease); - std::printf("cxxdrv: Designed by Amlal El Mahrouss, Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved.\n"); - std::printf("libCompiler.dylib: Designed by Amlal El Mahrouss, Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved.\n"); - - return 0; - } - } - - if (auto code = CPlusPlusPreprocessorMain(2, argv); - code > 0) - { - std::printf("cxxdrv: compiler exited with code %i.", code); - - return LIBCOMPILER_EXEC_ERROR; - } - std::vector<std::string> args_list_cxx; std::vector<std::string> args_list_asm; @@ -69,7 +47,6 @@ int main(int argc, char const* argv[]) } } - for (auto& cli : args_list_cxx) { const char* arr_cli[] = {argv[0], cli.data()}; @@ -77,7 +54,7 @@ int main(int argc, char const* argv[]) if (auto code = CompilerCPlusPlusAMD64(2, arr_cli); code > 0) { - std::printf("cxxdrv: compiler exited with code %i.", code); + std::printf("cxxdrv: compiler exited with code %i.\n", code); return LIBCOMPILER_EXEC_ERROR; } @@ -90,7 +67,7 @@ int main(int argc, char const* argv[]) if (auto code = AssemblerMainAMD64(2, arr_cli); code > 0) { - std::printf("cxxdrv: assembler exited with code %i.", code); + std::printf("cxxdrv: assembler exited with code %i.\n", code); } } diff --git a/tools/dbg.cc b/tools/dbg.cc index d63f574..67b942e 100644 --- a/tools/dbg.cc +++ b/tools/dbg.cc @@ -9,11 +9,11 @@ /// @file dbg.cxx /// @brief NE debugger. -LC_IMPORT_C int DebuggerPOSIX(int argc, char const* argv[]); +LC_IMPORT_C int DebuggerMachPOSIX(int argc, char const* argv[]); /// @brief Debugger entrypoint. /// @return Status code of debugger. int main(int argc, char const* argv[]) { - return DebuggerPOSIX(argc, argv); + return DebuggerMachPOSIX(argc, argv); } |
