| 74 | constexpr std::string_view output_folder_opt = "-o"; |
| 75 | |
| 76 | uint32_t executeCompilation( |
| 77 | int32_t argc, const char** argv, bool diffCompMode, bool fileUnit, |
| 78 | SURELOG::ErrorContainer::Stats* overallStats = nullptr) { |
| 79 | SURELOG::FileSystem* const fileSystem = SURELOG::FileSystem::getInstance(); |
| 80 | bool success = true; |
| 81 | bool noFatalErrors = true; |
| 82 | uint32_t codedReturn = 0; |
| 83 | SURELOG::SymbolTable* symbolTable = new SURELOG::SymbolTable(); |
| 84 | SURELOG::ErrorContainer* errors = new SURELOG::ErrorContainer(symbolTable); |
| 85 | SURELOG::CommandLineParser* clp = new SURELOG::CommandLineParser( |
| 86 | errors, symbolTable, diffCompMode, fileUnit); |
| 87 | success = clp->parseCommandLine(argc, argv); |
| 88 | bool parseOnly = clp->parseOnly(); |
| 89 | errors->printMessages(clp->muteStdout()); |
| 90 | if (success && (!clp->help())) { |
| 91 | // Load Python scripts in the interpreter |
| 92 | if (clp->pythonListener() || clp->pythonEvalScriptPerFile() || |
| 93 | clp->pythonEvalScript()) { |
| 94 | SURELOG::PythonAPI::loadScripts(); |
| 95 | |
| 96 | if (!SURELOG::PythonAPI::isListenerLoaded()) { |
| 97 | SURELOG::Location loc(SURELOG::BadSymbolId); |
| 98 | SURELOG::Error err( |
| 99 | SURELOG::ErrorDefinition::PY_NO_PYTHON_LISTENER_FOUND, loc); |
| 100 | errors->addError(err); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | SURELOG::scompiler* compiler = SURELOG::start_compiler(clp); |
| 105 | if (!compiler) codedReturn |= 1; |
| 106 | SURELOG::shutdown_compiler(compiler); |
| 107 | } |
| 108 | SURELOG::ErrorContainer::Stats stats; |
| 109 | if (!clp->help()) { |
| 110 | stats = errors->getErrorStats(); |
| 111 | if (overallStats) (*overallStats) += stats; |
| 112 | if (stats.nbFatal) codedReturn |= 1; |
| 113 | if (stats.nbSyntax) codedReturn |= 2; |
| 114 | if (stats.nbError) codedReturn |= 4; |
| 115 | } |
| 116 | bool noFErrors = true; |
| 117 | if (!clp->help()) noFErrors = errors->printStats(stats, clp->muteStdout()); |
| 118 | if (noFErrors == false) { |
| 119 | noFatalErrors = false; |
| 120 | } |
| 121 | |
| 122 | std::string ext_command = clp->getExeCommand(); |
| 123 | if (!ext_command.empty()) { |
| 124 | SURELOG::PathId fileId = fileSystem->getChild( |
| 125 | clp->getCompileDirId(), "file.lst", clp->getSymbolTable()); |
| 126 | fs::path fileList = fileSystem->toPath(fileId); |
| 127 | std::string command = ext_command + " " + fileList.string(); |
| 128 | int32_t result = system(command.c_str()); |
| 129 | codedReturn |= result; |
| 130 | std::cout << "Command result: " << result << std::endl; |
| 131 | } |
| 132 | clp->logFooter(); |
| 133 | if (diffCompMode && fileUnit) { |
no test coverage detected