summaryrefslogtreecommitdiffhomepage
path: root/Sources
diff options
context:
space:
mode:
authorAmlal El Mahrouss <113760121+Amlal-ElMahrouss@users.noreply.github.com>2024-03-27 08:31:41 +0100
committerAmlal El Mahrouss <113760121+Amlal-ElMahrouss@users.noreply.github.com>2024-03-27 08:31:41 +0100
commit3939adadfecc486173df35e1f54c606a9bb4bb94 (patch)
tree3b80ea14534e74e4bdb2c3db26a6270f66e49ce4 /Sources
parent69b78ac22d04b56a9882e845230a1df27d9af9a9 (diff)
Toolchain: Fix bpp and link, deprecate ccplus (C++ compiler)
repurpose all rule to compile everything. Signed-off-by: Amlal El Mahrouss <113760121+Amlal-ElMahrouss@users.noreply.github.com>
Diffstat (limited to 'Sources')
-rw-r--r--Sources/Deprecated/ccplus.cc (renamed from Sources/ccplus.cc)0
-rw-r--r--Sources/bpp.cc65
-rw-r--r--Sources/link.cc18
3 files changed, 14 insertions, 69 deletions
diff --git a/Sources/ccplus.cc b/Sources/Deprecated/ccplus.cc
index 00b6994..00b6994 100644
--- a/Sources/ccplus.cc
+++ b/Sources/Deprecated/ccplus.cc
diff --git a/Sources/bpp.cc b/Sources/bpp.cc
index fbe414f..acae226 100644
--- a/Sources/bpp.cc
+++ b/Sources/bpp.cc
@@ -279,64 +279,10 @@ void bpp_parse_file(std::ifstream &hdr_file, std::ofstream &pp_out) {
for (auto macro : kMacros) {
if (ParserKit::find_word(hdr_line, macro.fName) &&
hdr_line.find("%def") == std::string::npos) {
- auto substr = hdr_line.substr(hdr_line.find(macro.fName));
-
- std::vector<std::string> sym_vec;
- std::string sym_str;
-
- for (auto &subc : substr) {
- if (subc == ',' || subc == ')') {
- if (sym_str.empty()) continue;
-
- sym_vec.push_back(sym_str);
- sym_str.clear();
-
- continue;
- }
-
- if (isalnum(subc)) sym_str.push_back(subc);
- }
-
- if (macro.fArgs.size() > 0) {
- for (auto &item : sym_vec) {
- std::size_t cnt = 0;
-
- for (auto &arg : macro.fArgs) {
- if (item == arg) ++cnt;
- }
-
- if (cnt > 1) {
- auto it =
- std::find(macro.fArgs.begin(), macro.fArgs.end(), item);
-
- while (it != macro.fArgs.end()) {
- macro.fArgs.erase(it);
- it = std::find(macro.fArgs.begin(), macro.fArgs.end(), item);
- }
- }
- }
-
- if (sym_vec.size() != macro.fArgs.size()) {
- throw std::runtime_error(
- "bpp: arguments count mismatch, except " +
- std::to_string(sym_vec.size()) +
- ", got: " + std::to_string(macro.fArgs.size()));
- return;
- }
-
- substr = macro.fValue;
-
- std::size_t cnt = 0UL;
-
- for (auto &val : macro.fArgs) {
- substr.replace(substr.find(val), val.size(), sym_vec[cnt]);
- ++cnt;
- }
- }
-
+ auto value = macro.fValue;
+
hdr_line.replace(hdr_line.find(macro.fName), macro.fName.size(),
- substr);
- hdr_line.erase(hdr_line.find(substr) + substr.size());
+ value);
}
}
@@ -863,13 +809,12 @@ MPCC_MODULE(HCorePreprocessor) {
}
if (argv[index][0] == '-') {
- if (strcmp(argv[index], "-version") == 0) {
+ if (strcmp(argv[index], "-v") == 0) {
printf("%s\n", "bpp v1.11, (c) Mahrouss Logic");
return 0;
}
- if (strcmp(argv[index], "-h") == 0 ||
- strcmp(argv[index], "-help") == 0) {
+ if (strcmp(argv[index], "-h") == 0) {
printf("%s\n", "bpp v1.11, (c) Mahrouss Logic");
printf("%s\n", "-working-dir <path>: set directory to working path.");
printf("%s\n", "-include-dir <path>: add directory to include path.");
diff --git a/Sources/link.cc b/Sources/link.cc
index b771470..204b84d 100644
--- a/Sources/link.cc
+++ b/Sources/link.cc
@@ -96,7 +96,7 @@ MPCC_MODULE(HCoreLinker) {
kStdOut << "-output-file: Select output file name.\n";
return 0;
- } else if (StringCompare(argv[i], "-version") == 0) {
+ } else if (StringCompare(argv[i], "-v") == 0) {
kStdOut << kToolVersion << std::endl;
return 0;
@@ -144,7 +144,7 @@ MPCC_MODULE(HCoreLinker) {
continue;
} else {
if (argv[i][0] == '-') {
- kStdOut << "link: Unknown flag: " << argv[i] << "\n";
+ kStdOut << "link: unknown flag: " << argv[i] << "\n";
return -MPCC_EXEC_ERROR;
}
@@ -155,13 +155,13 @@ MPCC_MODULE(HCoreLinker) {
}
if (kOutput.empty()) {
- kStdOut << "link: no Output filename set." << std::endl;
+ kStdOut << "link: no output filename set." << std::endl;
return MPCC_EXEC_ERROR;
}
// sanity check.
if (kObjectList.empty()) {
- kStdOut << "link: No input files." << std::endl;
+ kStdOut << "link: no input files." << std::endl;
return MPCC_EXEC_ERROR;
} else {
// check for existing files, if they don't throw an error.
@@ -169,7 +169,7 @@ MPCC_MODULE(HCoreLinker) {
if (!std::filesystem::exists(obj)) {
// if filesystem doesn't find file
// -> throw error.
- kStdOut << "link: No such file: " << obj << std::endl;
+ kStdOut << "link: no such file: " << obj << std::endl;
return MPCC_EXEC_ERROR;
}
}
@@ -177,7 +177,7 @@ MPCC_MODULE(HCoreLinker) {
// PEF expects a valid architecture when outputing a binary.
if (kArch == 0) {
- kStdOut << "link: No target architecture set, can't continue." << std::endl;
+ kStdOut << "link: no target architecture set, can't continue." << std::endl;
return MPCC_EXEC_ERROR;
}
@@ -227,10 +227,10 @@ MPCC_MODULE(HCoreLinker) {
if (ae_header.fMagic[0] == kAEMag0 && ae_header.fMagic[1] == kAEMag1 &&
ae_header.fSize == sizeof(CompilerKit::AEHeader)) {
if (ae_header.fArch != kArch) {
- if (kVerbose) kStdOut << "link: info: is it a FAT binary? : ";
+ if (kVerbose) kStdOut << "link: info: is this a FAT binary? : ";
if (!kFatBinaryEnable) {
- if (kVerbose) kStdOut << "no.\n";
+ if (kVerbose) kStdOut << "No.\n";
kStdOut << "link: error: object " << i
<< " is a different kind of architecture and output isn't "
@@ -241,7 +241,7 @@ MPCC_MODULE(HCoreLinker) {
return -MPCC_FAT_ERROR;
} else {
if (kVerbose) {
- kStdOut << "yes.\n";
+ kStdOut << "Yes.\n";
}
}
}