Refactor code that handles when included files are missing

- Single unified routine for erroring out or handling missing dependencies
- Single three-state enum instead of two Booleans for missing dependencies
  (this causes `-MC` to imply `-MG` instead of needing `-MG -MC`)
- Functions than can miss included files return a Boolean for whether the
  parser should `YYACCEPT` and exit
This commit is contained in:
Rangi42
2025-07-18 14:03:23 -04:00
parent b80b30fba1
commit e7d63f5f6b
9 changed files with 72 additions and 76 deletions

View File

@@ -24,14 +24,14 @@
#include "asm/symbol.hpp"
#include "asm/warning.hpp"
FILE *dependFile = nullptr; // -M
bool continueAfterMissingIncludes = false; // -MC
bool generatedMissingIncludes = false; // -MG
bool generatePhonyDeps = false; // -MP
std::string targetFileName; // -MQ, -MT
bool failedOnMissingInclude = false;
bool verbose = false; // -v
FILE *dependFile = nullptr; // -M
MissingInclude missingIncludeState = INC_ERROR; // -MC, -MG
bool generatePhonyDeps = false; // -MP
std::string targetFileName; // -MQ, -MT
bool failedOnMissingInclude = false;
// Escapes Make-special chars from a string
static std::string make_escape(std::string &str) {
std::string escaped;
@@ -371,11 +371,11 @@ int main(int argc, char *argv[]) {
case 0:
switch (depType) {
case 'C':
continueAfterMissingIncludes = true;
missingIncludeState = GEN_CONTINUE;
break;
case 'G':
generatedMissingIncludes = true;
missingIncludeState = GEN_EXIT;
break;
case 'P':