mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Warn when a duplicate CLI argument overrides a previous one (#1053)
Fixes #1050
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
#include "asm/main.h"
|
#include "asm/main.h"
|
||||||
#include "asm/symbol.h"
|
#include "asm/symbol.h"
|
||||||
#include "asm/warning.h"
|
#include "asm/warning.h"
|
||||||
|
#include "error.h"
|
||||||
#include "platform.h" // S_ISDIR (stat macro)
|
#include "platform.h" // S_ISDIR (stat macro)
|
||||||
|
|
||||||
#define MAXINCPATHS 128
|
#define MAXINCPATHS 128
|
||||||
@@ -137,7 +138,11 @@ void fstk_AddIncludePath(char const *path)
|
|||||||
|
|
||||||
void fstk_SetPreIncludeFile(char const *path)
|
void fstk_SetPreIncludeFile(char const *path)
|
||||||
{
|
{
|
||||||
|
if (preIncludeName)
|
||||||
|
warnx("Overriding pre-included filename %s", preIncludeName);
|
||||||
preIncludeName = path;
|
preIncludeName = path;
|
||||||
|
if (verbose)
|
||||||
|
printf("Pre-included filename %s\n", preIncludeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printDep(char const *path)
|
static void printDep(char const *path)
|
||||||
|
|||||||
@@ -53,11 +53,11 @@ char const *__asan_default_options(void) { return "detect_leaks=0"; }
|
|||||||
// Unfortunately, macOS still ships 2.3, which is from 2008...
|
// Unfortunately, macOS still ships 2.3, which is from 2008...
|
||||||
int yyparse(void);
|
int yyparse(void);
|
||||||
|
|
||||||
FILE * dependfile;
|
FILE *dependfile = NULL;
|
||||||
bool generatedMissingIncludes;
|
bool generatedMissingIncludes = false;
|
||||||
bool failedOnMissingInclude;
|
bool failedOnMissingInclude = false;
|
||||||
bool generatePhonyDeps;
|
bool generatePhonyDeps = false;
|
||||||
char *targetFileName;
|
char *targetFileName = NULL;
|
||||||
|
|
||||||
bool haltnop;
|
bool haltnop;
|
||||||
bool warnOnHaltNop;
|
bool warnOnHaltNop;
|
||||||
@@ -148,9 +148,6 @@ static void print_usage(void)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int ch;
|
|
||||||
char *ep;
|
|
||||||
|
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
char const *sourceDateEpoch = getenv("SOURCE_DATE_EPOCH");
|
char const *sourceDateEpoch = getenv("SOURCE_DATE_EPOCH");
|
||||||
|
|
||||||
@@ -159,18 +156,11 @@ int main(int argc, char *argv[])
|
|||||||
if (sourceDateEpoch)
|
if (sourceDateEpoch)
|
||||||
now = (time_t)strtoul(sourceDateEpoch, NULL, 0);
|
now = (time_t)strtoul(sourceDateEpoch, NULL, 0);
|
||||||
|
|
||||||
dependfile = NULL;
|
|
||||||
|
|
||||||
// Perform some init for below
|
// Perform some init for below
|
||||||
sym_Init(now);
|
sym_Init(now);
|
||||||
|
|
||||||
// Set defaults
|
// Set defaults
|
||||||
|
|
||||||
generatePhonyDeps = false;
|
|
||||||
generatedMissingIncludes = false;
|
|
||||||
failedOnMissingInclude = false;
|
|
||||||
targetFileName = NULL;
|
|
||||||
|
|
||||||
opt_B("01");
|
opt_B("01");
|
||||||
opt_G("0123");
|
opt_G("0123");
|
||||||
opt_P(0);
|
opt_P(0);
|
||||||
@@ -183,8 +173,11 @@ int main(int argc, char *argv[])
|
|||||||
warnings = true;
|
warnings = true;
|
||||||
sym_SetExportAll(false);
|
sym_SetExportAll(false);
|
||||||
uint32_t maxDepth = DEFAULT_MAX_DEPTH;
|
uint32_t maxDepth = DEFAULT_MAX_DEPTH;
|
||||||
|
char *dependFileName = NULL;
|
||||||
size_t targetFileNameLen = 0;
|
size_t targetFileNameLen = 0;
|
||||||
|
|
||||||
|
int ch;
|
||||||
|
char *ep;
|
||||||
while ((ch = musl_getopt_long_only(argc, argv, optstring, longopts, NULL)) != -1) {
|
while ((ch = musl_getopt_long_only(argc, argv, optstring, longopts, NULL)) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'b':
|
case 'b':
|
||||||
@@ -243,12 +236,17 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'M':
|
case 'M':
|
||||||
if (!strcmp("-", musl_optarg))
|
if (dependfile)
|
||||||
|
warnx("Overriding dependfile %s", dependFileName);
|
||||||
|
if (!strcmp("-", musl_optarg)) {
|
||||||
dependfile = stdout;
|
dependfile = stdout;
|
||||||
else
|
dependFileName = "<stdout>";
|
||||||
|
} else {
|
||||||
dependfile = fopen(musl_optarg, "w");
|
dependfile = fopen(musl_optarg, "w");
|
||||||
|
dependFileName = musl_optarg;
|
||||||
|
}
|
||||||
if (dependfile == NULL)
|
if (dependfile == NULL)
|
||||||
err("Could not open dependfile %s", musl_optarg);
|
err("Could not open dependfile %s", dependFileName);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
|
|||||||
@@ -540,7 +540,9 @@ void out_WriteObject(void)
|
|||||||
// Set the objectfilename
|
// Set the objectfilename
|
||||||
void out_SetFileName(char *s)
|
void out_SetFileName(char *s)
|
||||||
{
|
{
|
||||||
|
if (objectName)
|
||||||
|
warnx("Overriding output filename %s", objectName);
|
||||||
objectName = s;
|
objectName = s;
|
||||||
if (verbose)
|
if (verbose)
|
||||||
printf("Output filename %s\n", s);
|
printf("Output filename %s\n", objectName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -337,6 +337,8 @@ static char *parseArgv(int argc, char **argv, bool &autoAttrmap, bool &autoTilem
|
|||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
autoAttrmap = false;
|
autoAttrmap = false;
|
||||||
|
if (!options.attrmap.empty())
|
||||||
|
warning("Overriding attrmap file %s", options.attrmap.c_str());
|
||||||
options.attrmap = musl_optarg;
|
options.attrmap = musl_optarg;
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
@@ -479,6 +481,8 @@ static char *parseArgv(int argc, char **argv, bool &autoAttrmap, bool &autoTilem
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
|
if (!options.output.empty())
|
||||||
|
warning("Overriding tile data file %s", options.output.c_str());
|
||||||
options.output = musl_optarg;
|
options.output = musl_optarg;
|
||||||
break;
|
break;
|
||||||
case 'P':
|
case 'P':
|
||||||
@@ -486,6 +490,8 @@ static char *parseArgv(int argc, char **argv, bool &autoAttrmap, bool &autoTilem
|
|||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
autoPalettes = false;
|
autoPalettes = false;
|
||||||
|
if (!options.palettes.empty())
|
||||||
|
warning("Overriding palettes file %s", options.palettes.c_str());
|
||||||
options.palettes = musl_optarg;
|
options.palettes = musl_optarg;
|
||||||
break;
|
break;
|
||||||
case 'Q':
|
case 'Q':
|
||||||
@@ -493,6 +499,8 @@ static char *parseArgv(int argc, char **argv, bool &autoAttrmap, bool &autoTilem
|
|||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
autoPalmap = false;
|
autoPalmap = false;
|
||||||
|
if (!options.palmap.empty())
|
||||||
|
warning("Overriding palette map file %s", options.palmap.c_str());
|
||||||
options.palmap = musl_optarg;
|
options.palmap = musl_optarg;
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
@@ -520,6 +528,8 @@ static char *parseArgv(int argc, char **argv, bool &autoAttrmap, bool &autoTilem
|
|||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
autoTilemap = false;
|
autoTilemap = false;
|
||||||
|
if (!options.tilemap.empty())
|
||||||
|
warning("Overriding tilemap file %s", options.tilemap.c_str());
|
||||||
options.tilemap = musl_optarg;
|
options.tilemap = musl_optarg;
|
||||||
break;
|
break;
|
||||||
case 'V':
|
case 'V':
|
||||||
|
|||||||
@@ -369,21 +369,31 @@ int main(int argc, char *argv[])
|
|||||||
isWRA0Mode = true;
|
isWRA0Mode = true;
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
|
if (linkerScriptName)
|
||||||
|
warnx("Overriding linkerscript %s", musl_optarg);
|
||||||
linkerScriptName = musl_optarg;
|
linkerScriptName = musl_optarg;
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
noSymInMap = true;
|
noSymInMap = true;
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
|
if (mapFileName)
|
||||||
|
warnx("Overriding mapfile %s", musl_optarg);
|
||||||
mapFileName = musl_optarg;
|
mapFileName = musl_optarg;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
|
if (symFileName)
|
||||||
|
warnx("Overriding symfile %s", musl_optarg);
|
||||||
symFileName = musl_optarg;
|
symFileName = musl_optarg;
|
||||||
break;
|
break;
|
||||||
case 'O':
|
case 'O':
|
||||||
|
if (overlayFileName)
|
||||||
|
warnx("Overriding overlay file %s", musl_optarg);
|
||||||
overlayFileName = musl_optarg;
|
overlayFileName = musl_optarg;
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
|
if (outputFileName)
|
||||||
|
warnx("Overriding output file %s", musl_optarg);
|
||||||
outputFileName = musl_optarg;
|
outputFileName = musl_optarg;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
|
|||||||
Reference in New Issue
Block a user