diff options
Diffstat (limited to 'src/CommandLine')
| -rw-r--r-- | src/CommandLine/asm.cc | 95 | ||||
| -rw-r--r-- | src/CommandLine/asm.json | 12 | ||||
| -rw-r--r-- | src/CommandLine/cppdrv.cc | 23 | ||||
| -rw-r--r-- | src/CommandLine/cppdrv.json | 12 | ||||
| -rw-r--r-- | src/CommandLine/dbg.cc | 18 | ||||
| -rw-r--r-- | src/CommandLine/dbg.json | 12 | ||||
| -rw-r--r-- | src/CommandLine/kdbg.cc | 18 | ||||
| -rw-r--r-- | src/CommandLine/kdbg.json | 12 | ||||
| -rw-r--r-- | src/CommandLine/ld64.cc | 16 | ||||
| -rw-r--r-- | src/CommandLine/ld64.json | 12 | ||||
| -rw-r--r-- | src/CommandLine/pef-amd64-cxxdrv.cc | 38 | ||||
| -rw-r--r-- | src/CommandLine/pef-amd64-cxxdrv.json | 19 | ||||
| -rw-r--r-- | src/CommandLine/pef-arm64-cdrv.cc | 38 | ||||
| -rw-r--r-- | src/CommandLine/pef-arm64-cdrv.json | 19 |
14 files changed, 344 insertions, 0 deletions
diff --git a/src/CommandLine/asm.cc b/src/CommandLine/asm.cc new file mode 100644 index 0000000..3773ff3 --- /dev/null +++ b/src/CommandLine/asm.cc @@ -0,0 +1,95 @@ +/* ======================================== + + Copyright (C) 2024-2025 Amlal El Mahrouss, licensed under the Apache 2.0 license + +======================================== */ + +/// @file asm.cc +/// @brief Assembler frontend. + +#include <CompilerKit/Detail/Config.h> +#include <cstring> +#include <vector> + +CK_IMPORT_C Int32 AssemblerMainPower64(Int32 argc, Char const* argv[]); +CK_IMPORT_C Int32 AssemblerMainARM64(Int32 argc, Char const* argv[]); +CK_IMPORT_C Int32 AssemblerMain64x0(Int32 argc, Char const* argv[]); +CK_IMPORT_C Int32 AssemblerMainAMD64(Int32 argc, Char const* argv[]); + +enum AsmKind : Int32 { + kInvalidAssembler = 0, + kX64Assembler = 100, + k64X0Assembler, + kPOWER64Assembler, + kARM64Assembler, + kAssemblerCount = kARM64Assembler - kX64Assembler + 1, +}; + +Int32 main(Int32 argc, Char const* argv[]) { + std::vector<const Char*> arg_vec_cstr; + arg_vec_cstr.push_back(argv[0]); + + const Int32 kInvalidAssembler = -1; + Int32 asm_type = kInvalidAssembler; + + for (size_t index_arg = 1; index_arg < argc; ++index_arg) { + if (strcmp(argv[index_arg], "-asm-h") == 0) { + std::printf("asm: Frontend Assembler (64x0, power64, arm64, x64).\n"); + std::printf("asm: Version: %s, Release: %s.\n", kDistVersion, kDistRelease); + std::printf( + "asm: Designed by Amlal El Mahrouss, Copyright (C) 2024-2025 Amlal El Mahrouss, all " + "rights reserved.\n"); + std::printf( + "CompilerKit: Designed by Amlal El Mahrouss, Copyright (C) 2024-2025 Amlal El Mahrouss, " + "Licensed under the Apache 2.0 license.\n"); + + return 0; + } else if (strcmp(argv[index_arg], "-asm-x64") == 0) { + asm_type = kX64Assembler; + } else if (strcmp(argv[index_arg], "-asm-aarch64") == 0) { + asm_type = kARM64Assembler; + } else if (strcmp(argv[index_arg], "-asm-64x0") == 0) { + asm_type = k64X0Assembler; + } else if (strcmp(argv[index_arg], "-asm-power64") == 0) { + asm_type = kPOWER64Assembler; + } else { + arg_vec_cstr.push_back(argv[index_arg]); + } + } + + switch (asm_type) { + case kPOWER64Assembler: { + if (int32_t code = AssemblerMainPower64(arg_vec_cstr.size(), arg_vec_cstr.data()); code) { + std::printf("asm: frontend exited with code %i.\n", code); + return code; + } + break; + } + case k64X0Assembler: { + if (int32_t code = AssemblerMain64x0(arg_vec_cstr.size(), arg_vec_cstr.data()); code) { + std::printf("asm: frontend exited with code %i.\n", code); + return code; + } + break; + } + case kARM64Assembler: { + if (int32_t code = AssemblerMainARM64(arg_vec_cstr.size(), arg_vec_cstr.data()); code) { + std::printf("asm: frontend exited with code %i.\n", code); + return code; + } + break; + } + case kX64Assembler: { + if (int32_t code = AssemblerMainAMD64(arg_vec_cstr.size(), arg_vec_cstr.data()); code) { + std::printf("asm: frontend exited with code %i.\n", code); + return code; + } + break; + } + default: { + return EXIT_FAILURE; + } + } + + return EXIT_SUCCESS; +} diff --git a/src/CommandLine/asm.json b/src/CommandLine/asm.json new file mode 100644 index 0000000..bfb8ac7 --- /dev/null +++ b/src/CommandLine/asm.json @@ -0,0 +1,12 @@ +{ + "compiler_path": "clang++", + "compiler_std": "c++20", + "headers_path": ["../CompilerKit", "../", "../CompilerKit/src/Detail"], + "sources_path": ["asm.cc"], + "output_name": "asm", + "compiler_flags": ["-L/usr/lib", "-lCompilerKit"], + "cpp_macros": [ + "__ASM__=202401", + "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" + ] +} diff --git a/src/CommandLine/cppdrv.cc b/src/CommandLine/cppdrv.cc new file mode 100644 index 0000000..92bc5ae --- /dev/null +++ b/src/CommandLine/cppdrv.cc @@ -0,0 +1,23 @@ +/* ======================================== + + Copyright (C) 2024-2025 Amlal El Mahrouss, licensed under the Apache 2.0 license + +======================================== */ + +/// @file cppdrv.cc +/// @brief Nectar frontend preprocessor. + +#include <CompilerKit/Detail/Config.h> +#include <CompilerKit/ErrorID.h> + +CK_IMPORT_C int CPlusPlusPreprocessorMain(int argc, char const* argv[]); + +int main(int argc, char const* argv[]) { + if (auto code = CPlusPlusPreprocessorMain(argc, argv); code > 0) { + std::printf("cppdrv: preprocessor exited with code %i.\n", code); + + return NECTI_EXEC_ERROR; + } + + return NECTI_SUCCESS; +} diff --git a/src/CommandLine/cppdrv.json b/src/CommandLine/cppdrv.json new file mode 100644 index 0000000..9eb5e54 --- /dev/null +++ b/src/CommandLine/cppdrv.json @@ -0,0 +1,12 @@ +{ + "compiler_path": "clang++", + "compiler_std": "c++20", + "headers_path": ["../CompilerKit", "../", "../CompilerKit/src/Detail"], + "sources_path": ["cppdrv.cc"], + "output_name": "cppdrv", + "compiler_flags": ["-L/usr/local/lib", "-lCompilerKit"], + "cpp_macros": [ + "__CPPDRV__=202504", + "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" + ] +} diff --git a/src/CommandLine/dbg.cc b/src/CommandLine/dbg.cc new file mode 100644 index 0000000..290b183 --- /dev/null +++ b/src/CommandLine/dbg.cc @@ -0,0 +1,18 @@ +/* ======================================== + + Copyright (C) 2024-2025 Amlal El Mahrouss, licensed under the Apache 2.0 license + +======================================== */ + +#include <CompilerKit/Detail/Config.h> + +/// @file dbg.cc +/// @brief Nectar debugger. + +CK_IMPORT_C Int32 DebuggerMachPOSIX(Int32 argc, Char const* argv[]); + +/// @brief Debugger entrypoint. +/// @return Status code of debugger. +Int32 main(Int32 argc, Char const* argv[]) { + return DebuggerMachPOSIX(argc, argv); +} diff --git a/src/CommandLine/dbg.json b/src/CommandLine/dbg.json new file mode 100644 index 0000000..8e786a7 --- /dev/null +++ b/src/CommandLine/dbg.json @@ -0,0 +1,12 @@ +{ + "compiler_path": "clang++", + "compiler_std": "c++20", + "headers_path": ["../CompilerKit", "../", "../CompilerKit/src/Detail"], + "sources_path": ["dbg.cc"], + "output_name": "dbg", + "compiler_flags": ["-L/usr/lib", "-lDebuggerKit"], + "cpp_macros": [ + "__DBG__=202401", + "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" + ] +} diff --git a/src/CommandLine/kdbg.cc b/src/CommandLine/kdbg.cc new file mode 100644 index 0000000..3a6eaa3 --- /dev/null +++ b/src/CommandLine/kdbg.cc @@ -0,0 +1,18 @@ +/* ======================================== + + Copyright (C) 2024-2025 Amlal El Mahrouss, licensed under the Apache 2.0 license + +======================================== */ + +#include <CompilerKit/Detail/Config.h> + +/// @file kdbg.cc +/// @brief NeKernel debugger. + +CK_IMPORT_C Int32 DebuggerNeKernel(Int32 argc, Char const* argv[]); + +/// @brief Debugger entrypoint. +/// @return Status code of debugger. +Int32 main(Int32 argc, Char const* argv[]) { + return DebuggerNeKernel(argc, argv); +} diff --git a/src/CommandLine/kdbg.json b/src/CommandLine/kdbg.json new file mode 100644 index 0000000..f661fc5 --- /dev/null +++ b/src/CommandLine/kdbg.json @@ -0,0 +1,12 @@ +{ + "compiler_path": "clang++", + "compiler_std": "c++20", + "headers_path": ["../CompilerKit", "../", "../CompilerKit/src/Detail"], + "sources_path": ["kdbg.cc"], + "output_name": "kdbg", + "compiler_flags": ["-L/usr/lib", "-lDebuggerKit"], + "cpp_macros": [ + "__DBG__=202401", + "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" + ] +} diff --git a/src/CommandLine/ld64.cc b/src/CommandLine/ld64.cc new file mode 100644 index 0000000..618bd32 --- /dev/null +++ b/src/CommandLine/ld64.cc @@ -0,0 +1,16 @@ +/* ======================================== + + Copyright (C) 2024-2025 Amlal El Mahrouss, licensed under the Apache 2.0 license + +======================================== */ + +#include <CompilerKit/Detail/Config.h> + +/// @file ld64.cc +/// @brief Nectar linker for AE objects. + +CK_IMPORT_C Int32 DynamicLinker64PEF(Int32 argc, Char const* argv[]); + +Int32 main(Int32 argc, Char const* argv[]) { + return DynamicLinker64PEF(argc, argv); +} diff --git a/src/CommandLine/ld64.json b/src/CommandLine/ld64.json new file mode 100644 index 0000000..2045550 --- /dev/null +++ b/src/CommandLine/ld64.json @@ -0,0 +1,12 @@ +{ + "compiler_path": "clang++", + "compiler_std": "c++20", + "headers_path": ["../CompilerKit", "../", "../CompilerKit/src/Detail"], + "sources_path": ["ld64.cc"], + "output_name": "ld64", + "compiler_flags": ["-L/usr/lib", "-lCompilerKit"], + "cpp_macros": [ + "__LD64__=202401", + "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" + ] +} diff --git a/src/CommandLine/pef-amd64-cxxdrv.cc b/src/CommandLine/pef-amd64-cxxdrv.cc new file mode 100644 index 0000000..1bd7c3c --- /dev/null +++ b/src/CommandLine/pef-amd64-cxxdrv.cc @@ -0,0 +1,38 @@ +/* ======================================== + + Copyright (C) 2024-2025 Amlal El Mahrouss, licensed under the Apache 2.0 license + +======================================== */ + +/// @file pef-amd64-cxxdrv.cc +/// @brief Nectar C++ frontend compiler for AMD64. + +#include <CompilerKit/Detail/Config.h> +#include <CompilerKit/ErrorID.h> +#include <CompilerKit/Utilities/Compiler.h> +#include <CompilerKit/Utilities/DLL.h> + +#ifdef __APPLE__ +static auto kPath = "/usr/local/lib/libCompilerKit.dylib"; +#else +static auto kPath = "/usr/lib/libCompilerKit.so"; +#endif + +static auto kSymbol = "CompilerCPlusPlusAMD64"; + +Int32 main(Int32 argc, Char const* argv[]) { + CompilerKit::DLLLoader dylib; + dylib(kPath, kSymbol); + + CompilerKit::DLLLoader::EntryT entrypoint_cxx = + reinterpret_cast<CompilerKit::DLLLoader::EntryT>(dylib.fEntrypoint); + + if (!entrypoint_cxx) { + kStdOut; + std::printf("error: Could not find entrypoint in %s: %s\n", kPath, dlerror()); + + return EXIT_FAILURE; + } + + return (entrypoint_cxx(argc, argv) == NECTI_SUCCESS) ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/src/CommandLine/pef-amd64-cxxdrv.json b/src/CommandLine/pef-amd64-cxxdrv.json new file mode 100644 index 0000000..62b5b4d --- /dev/null +++ b/src/CommandLine/pef-amd64-cxxdrv.json @@ -0,0 +1,19 @@ +{ + "compiler_path": "clang++", + "compiler_std": "c++20", + "headers_path": [ + "../CompilerKit", + "../", + "../CompilerKit/src/Detail" + ], + "sources_path": [ + "pef-amd64-cxxdrv.cc" + ], + "output_name": "pef-amd64-cxxdrv", + "compiler_flags": [ + ], + "cpp_macros": [ + "__CXXDRV__=202504", + "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" + ] +}
\ No newline at end of file diff --git a/src/CommandLine/pef-arm64-cdrv.cc b/src/CommandLine/pef-arm64-cdrv.cc new file mode 100644 index 0000000..f4be5d0 --- /dev/null +++ b/src/CommandLine/pef-arm64-cdrv.cc @@ -0,0 +1,38 @@ +/* ======================================== + + Copyright (C) 2024-2025 Amlal El Mahrouss, licensed under the Apache 2.0 license + +======================================== */ + +/// @file pef-arm-cdrv.cc +/// @brief Nectar ARm64 C frontend compiler. + +#include <CompilerKit/Detail/Config.h> +#include <CompilerKit/ErrorID.h> +#include <CompilerKit/Utilities/Compiler.h> +#include <CompilerKit/Utilities/DLL.h> + +#ifdef __APPLE__ +static auto kPath = "/usr/local/lib/libCompilerKit.dylib"; +#else +static auto kPath = "/usr/lib/libCompilerKit.so"; +#endif + +static auto kSymbol = "CompilerCLangARM64"; + +Int32 main(Int32 argc, Char const* argv[]) { + CompilerKit::DLLLoader dylib; + dylib(kPath, kSymbol); + + CompilerKit::DLLLoader::EntryT entrypoint_c = + reinterpret_cast<CompilerKit::DLLLoader::EntryT>(dylib.fEntrypoint); + + if (!entrypoint_c) { + kStdOut; + std::printf("error: Could not find entrypoint in %s: %s\n", kPath, dlerror()); + + return EXIT_FAILURE; + } + + return (entrypoint_c(argc, argv) == NECTI_SUCCESS) ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/src/CommandLine/pef-arm64-cdrv.json b/src/CommandLine/pef-arm64-cdrv.json new file mode 100644 index 0000000..be6a1be --- /dev/null +++ b/src/CommandLine/pef-arm64-cdrv.json @@ -0,0 +1,19 @@ +{ + "compiler_path": "clang++", + "compiler_std": "c++20", + "headers_path": [ + "../CompilerKit", + "../", + "../CompilerKit/src/Detail" + ], + "sources_path": [ + "pef-arm64-cdrv.cc" + ], + "output_name": "pef-arm64-cdrv", + "compiler_flags": [ + ], + "cpp_macros": [ + "__CXXDRV__=202504", + "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" + ] +}
\ No newline at end of file |
