summaryrefslogtreecommitdiffhomepage
path: root/src/CommandLine
diff options
context:
space:
mode:
Diffstat (limited to 'src/CommandLine')
-rw-r--r--src/CommandLine/asm.cc94
-rw-r--r--src/CommandLine/pef-amd64-asm.cc37
-rw-r--r--src/CommandLine/pef-amd64-asm.json (renamed from src/CommandLine/asm.json)10
3 files changed, 42 insertions, 99 deletions
diff --git a/src/CommandLine/asm.cc b/src/CommandLine/asm.cc
deleted file mode 100644
index 12d179a..0000000
--- a/src/CommandLine/asm.cc
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org)
-// Licensed under the Apache License, Version 2.0 (See accompanying
-// file LICENSE or copy at http://www.apache.org/licenses/LICENSE-2.0)
-// Official repository: https://github.com/nekernel-org/nectar
-
-/// @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/pef-amd64-asm.cc b/src/CommandLine/pef-amd64-asm.cc
new file mode 100644
index 0000000..1316d93
--- /dev/null
+++ b/src/CommandLine/pef-amd64-asm.cc
@@ -0,0 +1,37 @@
+// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org)
+// Licensed under the Apache License, Version 2.0 (See accompanying
+// file LICENSE or copy at http://www.apache.org/licenses/LICENSE-2.0)
+// Official repository: https://github.com/nekernel-org/nectar
+
+/// @file pef-amd64-asm.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 = "AssemblerMainAMD64";
+
+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) == NECTAR_SUCCESS) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/src/CommandLine/asm.json b/src/CommandLine/pef-amd64-asm.json
index 7107c4b..060fbf3 100644
--- a/src/CommandLine/asm.json
+++ b/src/CommandLine/pef-amd64-asm.json
@@ -1,12 +1,12 @@
{
- "compiler_path": "clang++",
+ "compiler_path": "g++",
"compiler_std": "c++20",
"headers_path": ["../../include/CompilerKit", "../../include", "../../include/CompilerKit/src/Detail"],
- "sources_path": ["asm.cc"],
- "output_name": "asm",
- "compiler_flags": ["-L/usr/lib", "-lCompilerKit"],
+ "sources_path": ["pef-amd64-asm.cc"],
+ "output_name": "pef-amd64-asm",
+ "compiler_flags": ["-L/usr/lib"],
"cpp_macros": [
- "__ASM__=202401",
+ "__DRV_ASM__=202601",
"kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)"
]
}