Skip to content

Commit

Permalink
print most error info in a pink color.
Browse files Browse the repository at this point in the history
  • Loading branch information
JPeterMugaas committed May 21, 2024
1 parent f3d3c41 commit e3022dc
Show file tree
Hide file tree
Showing 18 changed files with 2,423 additions and 2,282 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

cmake_minimum_required (VERSION 3.21)

set(EFXC2_VERSION 0.0.10.228)
set(EFXC2_VERSION 0.0.10.229)
project (efxc2 VERSION ${EFXC2_VERSION}
DESCRIPTION "Enhanced fxc2"
HOMEPAGE_URL "https://github.com/JPeterMugaas/efxc2"
Expand Down Expand Up @@ -40,6 +40,7 @@ set(EXEC_SOURCES efxc2.cpp
efxc2CompilerAPIContainer.cpp
efxc2CompilerIncludes.h
efxc2CompilerIncludes.cpp
efxc2Console.h
efxc2CompilerParams.h
efxc2CompilerParams.cpp
efxc2CompilerTasks.h
Expand Down
187 changes: 86 additions & 101 deletions efxc2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "efxc2CompilerTasks.h"
#include "efxc2Files.h"


/*Cygwin and MSYS2 compilers amd linkers don't support
the wmain -Municode entry-point*/

Expand All @@ -23,107 +22,93 @@ int wmain(int argc, wchar_t* argv[]) {
#else /* _WIN32 */
int main(int argc, char* argv[]) {
#endif /* _WIN32 */
// ====================================================================================
// seetup console
#ifdef _WIN32
HANDLE console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
int result = 0;
try {
// ====================================================================================
// Process Command Line Arguments

DWORD orig_console_mode = 0;
(void)GetConsoleMode(console_handle, &orig_console_mode);
DWORD new_console_mode = 0;
new_console_mode = orig_console_mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING;
(void)SetConsoleMode(console_handle, new_console_mode);
#endif
int result = 0;
try {
// ====================================================================================
// Process Command Line Arguments
efxc2Utils::M_CMD_PARAMS args(&argv[1], &argv[argc]);
efxc2Utils::M_STRING temp = efxc2Utils::M_STRING_INIT;
efxc2CompilerAPIContainer::CompilerAPIContainer api;
efxc2CompilerParams::CompilerParams params;
efxc2Files::Files files;

efxc2Utils::M_CMD_PARAMS args(&argv[1], &argv[argc]);
efxc2Utils::M_STRING temp = efxc2Utils::M_STRING_INIT;
efxc2CompilerAPIContainer::CompilerAPIContainer api;
efxc2CompilerParams::CompilerParams params;
efxc2Files::Files files;
efxc2Cmds::FindNOLOGO(args, params);
efxc2Cmds::FindDebug(args, params);
int immediate_exit = 0;

efxc2Cmds::FindNOLOGO(args, params);
efxc2Cmds::FindDebug(args, params);
int immediate_exit = 0;

size_t index = 0;
/*now scan for all arguments and input file name*/
index = 0;
while (TRUE) {
/* Detect the end of the options. */
if ((index >= args.size()) || (immediate_exit > 0)) {
break;
}
else if ((efxc2Utils::parseOpt(efxc2Cmds::M_QUESTION_MARK, args, &index, nullptr)) ||
(efxc2Utils::parseOpt(efxc2Cmds::M_HELP, args, &index, nullptr))) {
efxc2Utils::print_help_screen();
immediate_exit = 1;
continue;
}
else if (efxc2Cmds::parseCompilerOnlyCall(args, &index, params)) {
continue;
}
else if (efxc2Cmds::parseIgnoredOptions(args, &index, params)) {
continue;
}
else if (efxc2Cmds::parseNotSupportedOptions(args, &index)) {
result = 1;
immediate_exit = 1;
continue;
}
else if (efxc2Utils::parseOpt(efxc2Cmds::M_D, args, &index, &temp)) {
efxc2Cmds::cmd_D(params, temp);
continue;
}
else if (efxc2Utils::parseOpt(efxc2Cmds::M_E_, args, &index, &temp)) {
efxc2Cmds::cmd_E(params, temp);
continue;
}
else if (efxc2Cmds::parseCompilerFileCall(args, &index, params, files)) {
continue;
}
else if (efxc2Utils::parseOpt(efxc2Cmds::M_I, args, &index, &temp)) {
efxc2Cmds::cmd_I(params, temp);
continue;
}
else if (efxc2Utils::parseOpt(efxc2Cmds::M_NOLOGO, args, &index, nullptr)) {
continue;
}
else if (efxc2Utils::parseOpt(efxc2Cmds::M_DEBUG, args, &index, nullptr)) {
continue;
}
else if (efxc2Utils::parseOpt(efxc2Cmds::M_T, args, &index, &temp)) {
efxc2Cmds::cmd_T(params, temp);
continue;
}
else if (efxc2Utils::parseOpt(efxc2Cmds::M_VERSION, args, &index, nullptr)) {
efxc2Utils::print_version();
immediate_exit = 1;
continue;
}
else if (efxc2Utils::parseOpt(efxc2Cmds::M_VN, args, &index, &temp)) {
efxc2Cmds::cmd_Vn(params, temp);
continue;
}
else {
efxc2Cmds::parseInputFile(args[index], params, files);
index += 1;
}
}
if (immediate_exit == 0) {
efxc2Compiler::Compiler compiler(api, params);
efxc2CompilerTasks::CompilerTasks(compiler, files, params);
}
}
catch (...) {
/*We already reported the error to the user. */
result = 1;
}
#ifdef _WIN32
(void)SetConsoleMode(console_handle, orig_console_mode);
#endif
return result;
size_t index = 0;
/*now scan for all arguments and input file name*/
index = 0;
while (TRUE) {
/* Detect the end of the options. */
if ((index >= args.size()) || (immediate_exit > 0)) {
break;
}
else if ((efxc2Utils::parseOpt(efxc2Cmds::M_QUESTION_MARK, args, &index, nullptr)) ||
(efxc2Utils::parseOpt(efxc2Cmds::M_HELP, args, &index, nullptr))) {
efxc2Utils::print_help_screen();
immediate_exit = 1;
continue;
}
else if (efxc2Cmds::parseCompilerOnlyCall(args, &index, params)) {
continue;
}
else if (efxc2Cmds::parseIgnoredOptions(args, &index, params)) {
continue;
}
else if (efxc2Cmds::parseNotSupportedOptions(args, &index)) {
result = 1;
immediate_exit = 1;
continue;
}
else if (efxc2Utils::parseOpt(efxc2Cmds::M_D, args, &index, &temp)) {
efxc2Cmds::cmd_D(params, temp);
continue;
}
else if (efxc2Utils::parseOpt(efxc2Cmds::M_E_, args, &index, &temp)) {
efxc2Cmds::cmd_E(params, temp);
continue;
}
else if (efxc2Cmds::parseCompilerFileCall(args, &index, params, files)) {
continue;
}
else if (efxc2Utils::parseOpt(efxc2Cmds::M_I, args, &index, &temp)) {
efxc2Cmds::cmd_I(params, temp);
continue;
}
else if (efxc2Utils::parseOpt(efxc2Cmds::M_NOLOGO, args, &index, nullptr)) {
continue;
}
else if (efxc2Utils::parseOpt(efxc2Cmds::M_DEBUG, args, &index, nullptr)) {
continue;
}
else if (efxc2Utils::parseOpt(efxc2Cmds::M_T, args, &index, &temp)) {
efxc2Cmds::cmd_T(params, temp);
continue;
}
else if (efxc2Utils::parseOpt(efxc2Cmds::M_VERSION, args, &index, nullptr)) {
efxc2Utils::print_version();
immediate_exit = 1;
continue;
}
else if (efxc2Utils::parseOpt(efxc2Cmds::M_VN, args, &index, &temp)) {
efxc2Cmds::cmd_Vn(params, temp);
continue;
}
else {
efxc2Cmds::parseInputFile(args[index], params, files);
index += 1;
}
}
if (immediate_exit == 0) {
efxc2Compiler::Compiler compiler(api, params);
efxc2CompilerTasks::CompilerTasks(compiler, files, params);
}
}
catch (...) {
/*We already reported the error to the user. */
result = 1;
}
return result;
}
Loading

0 comments on commit e3022dc

Please sign in to comment.