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

@@ -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': {