Some refactoring and reformatting (#1431)

This commit is contained in:
Sylvie
2024-07-26 11:51:27 -04:00
committed by GitHub
parent 92abe24894
commit 6a65cbc9ed
6 changed files with 73 additions and 74 deletions

View File

@@ -13,7 +13,7 @@
// Variables related to CLI options
extern bool isDmgMode;
extern char *linkerScriptName;
extern char const *linkerScriptName;
extern char const *mapFileName;
extern bool noSymInMap;
extern char const *symFileName;

View File

@@ -21,14 +21,13 @@
#include "asm/symbol.hpp"
#include "asm/warning.hpp"
FILE *dependFile = nullptr;
bool generatedMissingIncludes = false;
FILE *dependFile = nullptr; // -M
bool generatedMissingIncludes = false; // -MG
bool generatePhonyDeps = false; // -MP
std::string targetFileName; // -MQ, -MT
bool failedOnMissingInclude = false;
bool generatePhonyDeps = false;
std::string targetFileName;
bool verbose;
bool warnings; // True to enable warnings, false to disable them.
bool verbose = false; // -v
bool warnings = true; // -w
// Escapes Make-special chars from a string
static std::string make_escape(std::string &str) {
@@ -124,8 +123,6 @@ int main(int argc, char *argv[]) {
opt_G("0123");
opt_P(0);
opt_Q(16);
verbose = false;
warnings = true;
sym_SetExportAll(false);
uint32_t maxDepth = DEFAULT_MAX_DEPTH;
char const *dependFileName = nullptr;
@@ -336,8 +333,7 @@ int main(int argc, char *argv[]) {
if (failedOnMissingInclude)
return 0;
// If no path specified, don't write file
if (!objectName.empty())
out_WriteObject();
return 0;
}

View File

@@ -304,6 +304,9 @@ static void writeFileStackNode(FileStackNode const &node, FILE *file) {
// Write an object file
void out_WriteObject() {
if (objectName.empty())
return;
FILE *file;
if (objectName != "-") {
file = fopen(objectName.c_str(), "wb");

View File

@@ -114,31 +114,31 @@ static char const *optstring = "-Aa:b:Cc:Dd:FfhL:mN:n:Oo:Pp:Qq:r:s:Tt:U:uVvx:Z";
* over short opt matching
*/
static option const longopts[] = {
{"auto-attr-map", no_argument, nullptr, 'A' },
{"attr-map", required_argument, nullptr, 'a' },
{"base-tiles", required_argument, nullptr, 'b' },
{"color-curve", no_argument, nullptr, 'C' },
{"colors", required_argument, nullptr, 'c' },
{"depth", required_argument, nullptr, 'd' },
{"slice", required_argument, nullptr, 'L' },
{"mirror-tiles", no_argument, nullptr, 'm' },
{"nb-tiles", required_argument, nullptr, 'N' },
{"nb-palettes", required_argument, nullptr, 'n' },
{"group-outputs", no_argument, nullptr, 'O' },
{"output", required_argument, nullptr, 'o' },
{"auto-palette", no_argument, nullptr, 'P' },
{"palette", required_argument, nullptr, 'p' },
{"auto-palette-map", no_argument, nullptr, 'Q' },
{"palette-map", required_argument, nullptr, 'q' },
{"reverse", required_argument, nullptr, 'r' },
{"auto-tilemap", no_argument, nullptr, 'T' },
{"tilemap", required_argument, nullptr, 't' },
{"unit-size", required_argument, nullptr, 'U' },
{"unique-tiles", no_argument, nullptr, 'u' },
{"version", no_argument, nullptr, 'V' },
{"verbose", no_argument, nullptr, 'v' },
{"trim-end", required_argument, nullptr, 'x' },
{"columns", no_argument, nullptr, 'Z' },
{"auto-attr-map", no_argument, nullptr, 'A'},
{"attr-map", required_argument, nullptr, 'a'},
{"base-tiles", required_argument, nullptr, 'b'},
{"color-curve", no_argument, nullptr, 'C'},
{"colors", required_argument, nullptr, 'c'},
{"depth", required_argument, nullptr, 'd'},
{"slice", required_argument, nullptr, 'L'},
{"mirror-tiles", no_argument, nullptr, 'm'},
{"nb-tiles", required_argument, nullptr, 'N'},
{"nb-palettes", required_argument, nullptr, 'n'},
{"group-outputs", no_argument, nullptr, 'O'},
{"output", required_argument, nullptr, 'o'},
{"auto-palette", no_argument, nullptr, 'P'},
{"palette", required_argument, nullptr, 'p'},
{"auto-palette-map", no_argument, nullptr, 'Q'},
{"palette-map", required_argument, nullptr, 'q'},
{"reverse", required_argument, nullptr, 'r'},
{"auto-tilemap", no_argument, nullptr, 'T'},
{"tilemap", required_argument, nullptr, 't'},
{"unit-size", required_argument, nullptr, 'U'},
{"unique-tiles", no_argument, nullptr, 'u'},
{"version", no_argument, nullptr, 'V'},
{"verbose", no_argument, nullptr, 'v'},
{"trim-end", required_argument, nullptr, 'x'},
{"columns", no_argument, nullptr, 'Z'},
{nullptr, no_argument, nullptr, 0 }
};

View File

@@ -25,7 +25,7 @@
#include "link/symbol.hpp"
bool isDmgMode; // -d
char *linkerScriptName; // -l
char const *linkerScriptName; // -l
char const *mapFileName; // -m
bool noSymInMap; // -M
char const *symFileName; // -n
@@ -349,7 +349,7 @@ int main(int argc, char *argv[]) {
break;
case 'l':
if (linkerScriptName)
warnx("Overriding linker script %s", musl_optarg);
warnx("Overriding linker script %s", linkerScriptName);
linkerScriptName = musl_optarg;
break;
case 'M':
@@ -357,22 +357,22 @@ int main(int argc, char *argv[]) {
break;
case 'm':
if (mapFileName)
warnx("Overriding map file %s", musl_optarg);
warnx("Overriding map file %s", mapFileName);
mapFileName = musl_optarg;
break;
case 'n':
if (symFileName)
warnx("Overriding sym file %s", musl_optarg);
warnx("Overriding sym file %s", symFileName);
symFileName = musl_optarg;
break;
case 'O':
if (overlayFileName)
warnx("Overriding overlay file %s", musl_optarg);
warnx("Overriding overlay file %s", overlayFileName);
overlayFileName = musl_optarg;
break;
case 'o':
if (outputFileName)
warnx("Overriding output file %s", musl_optarg);
warnx("Overriding output file %s", outputFileName);
outputFileName = musl_optarg;
break;
case 'p': {