Use verbosePrint in rgbasm as well as rgblink

This commit is contained in:
Rangi42
2025-07-12 01:38:19 -04:00
parent 82513e5255
commit d32b1912ed
6 changed files with 24 additions and 42 deletions

View File

@@ -8,6 +8,13 @@
extern bool verbose; extern bool verbose;
#define verbosePrint(...) \
do { \
if (verbose) { \
fprintf(stderr, __VA_ARGS__); \
} \
} while (0)
extern FILE *dependFile; extern FILE *dependFile;
extern std::string targetFileName; extern std::string targetFileName;
extern bool continueAfterMissingIncludes; extern bool continueAfterMissingIncludes;

View File

@@ -29,7 +29,6 @@ extern bool beVerbose;
extern bool isWRAM0Mode; extern bool isWRAM0Mode;
extern bool disablePadding; extern bool disablePadding;
// Helper macro for printing verbose-mode messages
#define verbosePrint(...) \ #define verbosePrint(...) \
do { \ do { \
if (beVerbose) { \ if (beVerbose) { \

View File

@@ -120,11 +120,7 @@ void fstk_SetPreIncludeFile(std::string const &path) {
warnx("Overriding pre-included filename %s", preIncludeName.c_str()); warnx("Overriding pre-included filename %s", preIncludeName.c_str());
} }
preIncludeName = path; preIncludeName = path;
// LCOV_EXCL_START verbosePrint("Pre-included filename %s\n", preIncludeName.c_str()); // LCOV_EXCL_LINE
if (verbose) {
printf("Pre-included filename %s\n", preIncludeName.c_str());
}
// LCOV_EXCL_STOP
} }
static bool isValidFilePath(std::string const &path) { static bool isValidFilePath(std::string const &path) {
@@ -312,8 +308,10 @@ void fstk_RunInclude(std::string const &path, bool preInclude) {
if (!fullPath) { if (!fullPath) {
if (generatedMissingIncludes && !preInclude) { if (generatedMissingIncludes && !preInclude) {
// LCOV_EXCL_START // LCOV_EXCL_START
if (verbose && !continueAfterMissingIncludes) { if (!continueAfterMissingIncludes) {
printf("Aborting (-MG) on INCLUDE file '%s' (%s)\n", path.c_str(), strerror(errno)); verbosePrint(
"Aborting (-MG) on INCLUDE file '%s' (%s)\n", path.c_str(), strerror(errno)
);
} }
// LCOV_EXCL_STOP // LCOV_EXCL_STOP
failedOnMissingInclude = true; failedOnMissingInclude = true;

View File

@@ -82,9 +82,7 @@ static char *mapFile(int fd, std::string const &path, size_t size) {
// The implementation may not support MAP_PRIVATE; try again with MAP_SHARED // The implementation may not support MAP_PRIVATE; try again with MAP_SHARED
// instead, offering, I believe, weaker guarantees about external modifications to // instead, offering, I believe, weaker guarantees about external modifications to
// the file while reading it. That's still better than not opening it at all, though. // the file while reading it. That's still better than not opening it at all, though.
if (verbose) { verbosePrint("mmap(%s, MAP_PRIVATE) failed, retrying with MAP_SHARED\n", path.c_str());
printf("mmap(%s, MAP_PRIVATE) failed, retrying with MAP_SHARED\n", path.c_str());
}
mappingAddr = mmap(nullptr, size, PROT_READ, MAP_SHARED, fd, 0); mappingAddr = mmap(nullptr, size, PROT_READ, MAP_SHARED, fd, 0);
} }
// LCOV_EXCL_STOP // LCOV_EXCL_STOP
@@ -415,11 +413,7 @@ void LexerState::setFileAsNextState(std::string const &filePath, bool updateStat
if (filePath == "-") { if (filePath == "-") {
path = "<stdin>"; path = "<stdin>";
content.emplace<BufferedContent>(STDIN_FILENO); content.emplace<BufferedContent>(STDIN_FILENO);
// LCOV_EXCL_START verbosePrint("Opening stdin\n"); // LCOV_EXCL_LINE
if (verbose) {
printf("Opening stdin\n");
}
// LCOV_EXCL_STOP
} else { } else {
struct stat statBuf; struct stat statBuf;
if (stat(filePath.c_str(), &statBuf) != 0) { if (stat(filePath.c_str(), &statBuf) != 0) {
@@ -445,11 +439,7 @@ void LexerState::setFileAsNextState(std::string const &filePath, bool updateStat
content.emplace<ViewedContent>( content.emplace<ViewedContent>(
std::shared_ptr<char[]>(mappingAddr, FileUnmapDeleter(size)), size std::shared_ptr<char[]>(mappingAddr, FileUnmapDeleter(size)), size
); );
// LCOV_EXCL_START verbosePrint("File \"%s\" is mmap()ped\n", path.c_str()); // LCOV_EXCL_LINE
if (verbose) {
printf("File \"%s\" is mmap()ped\n", path.c_str());
}
// LCOV_EXCL_STOP
isMmapped = true; isMmapped = true;
} }
} }
@@ -458,14 +448,12 @@ void LexerState::setFileAsNextState(std::string const &filePath, bool updateStat
// Sometimes mmap() fails or isn't available, so have a fallback // Sometimes mmap() fails or isn't available, so have a fallback
content.emplace<BufferedContent>(fd); content.emplace<BufferedContent>(fd);
// LCOV_EXCL_START // LCOV_EXCL_START
if (verbose) { if (statBuf.st_size == 0) {
if (statBuf.st_size == 0) { verbosePrint("File \"%s\" is empty\n", path.c_str());
printf("File \"%s\" is empty\n", path.c_str()); } else {
} else { verbosePrint(
printf( "File \"%s\" is opened; errno reports: %s\n", path.c_str(), strerror(errno)
"File \"%s\" is opened; errno reports: %s\n", path.c_str(), strerror(errno) );
);
}
} }
// LCOV_EXCL_STOP // LCOV_EXCL_STOP
} }

View File

@@ -329,11 +329,7 @@ int main(int argc, char *argv[]) {
if (stateFileSpecs.find(name) != stateFileSpecs.end()) { if (stateFileSpecs.find(name) != stateFileSpecs.end()) {
warnx("Overriding state filename %s", name); warnx("Overriding state filename %s", name);
} }
// LCOV_EXCL_START verbosePrint("State filename %s\n", name); // LCOV_EXCL_LINE
if (verbose) {
printf("State filename %s\n", name);
}
// LCOV_EXCL_STOP
stateFileSpecs.emplace(name, std::move(features)); stateFileSpecs.emplace(name, std::move(features));
break; break;
} }
@@ -421,9 +417,7 @@ int main(int argc, char *argv[]) {
std::string mainFileName = argv[musl_optind]; std::string mainFileName = argv[musl_optind];
if (verbose) { verbosePrint("Assembling %s\n", mainFileName.c_str()); // LCOV_EXCL_LINE
printf("Assembling %s\n", mainFileName.c_str()); // LCOV_EXCL_LINE
}
if (dependFile) { if (dependFile) {
if (targetFileName.empty()) { if (targetFileName.empty()) {

View File

@@ -374,11 +374,7 @@ void out_SetFileName(std::string const &name) {
warnx("Overriding output filename %s", objectFileName.c_str()); warnx("Overriding output filename %s", objectFileName.c_str());
} }
objectFileName = name; objectFileName = name;
// LCOV_EXCL_START verbosePrint("Output filename %s\n", objectFileName.c_str()); // LCOV_EXCL_LINE
if (verbose) {
printf("Output filename %s\n", objectFileName.c_str());
}
// LCOV_EXCL_STOP
} }
static void dumpString(std::string const &escape, FILE *file) { static void dumpString(std::string const &escape, FILE *file) {