mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Use verbosePrint in rgbasm as well as rgblink
This commit is contained in:
@@ -8,6 +8,13 @@
|
||||
|
||||
extern bool verbose;
|
||||
|
||||
#define verbosePrint(...) \
|
||||
do { \
|
||||
if (verbose) { \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
extern FILE *dependFile;
|
||||
extern std::string targetFileName;
|
||||
extern bool continueAfterMissingIncludes;
|
||||
|
||||
@@ -29,7 +29,6 @@ extern bool beVerbose;
|
||||
extern bool isWRAM0Mode;
|
||||
extern bool disablePadding;
|
||||
|
||||
// Helper macro for printing verbose-mode messages
|
||||
#define verbosePrint(...) \
|
||||
do { \
|
||||
if (beVerbose) { \
|
||||
|
||||
@@ -120,11 +120,7 @@ void fstk_SetPreIncludeFile(std::string const &path) {
|
||||
warnx("Overriding pre-included filename %s", preIncludeName.c_str());
|
||||
}
|
||||
preIncludeName = path;
|
||||
// LCOV_EXCL_START
|
||||
if (verbose) {
|
||||
printf("Pre-included filename %s\n", preIncludeName.c_str());
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
verbosePrint("Pre-included filename %s\n", preIncludeName.c_str()); // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
static bool isValidFilePath(std::string const &path) {
|
||||
@@ -312,8 +308,10 @@ void fstk_RunInclude(std::string const &path, bool preInclude) {
|
||||
if (!fullPath) {
|
||||
if (generatedMissingIncludes && !preInclude) {
|
||||
// LCOV_EXCL_START
|
||||
if (verbose && !continueAfterMissingIncludes) {
|
||||
printf("Aborting (-MG) on INCLUDE file '%s' (%s)\n", path.c_str(), strerror(errno));
|
||||
if (!continueAfterMissingIncludes) {
|
||||
verbosePrint(
|
||||
"Aborting (-MG) on INCLUDE file '%s' (%s)\n", path.c_str(), strerror(errno)
|
||||
);
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
failedOnMissingInclude = true;
|
||||
|
||||
@@ -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
|
||||
// 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.
|
||||
if (verbose) {
|
||||
printf("mmap(%s, MAP_PRIVATE) failed, retrying with MAP_SHARED\n", path.c_str());
|
||||
}
|
||||
verbosePrint("mmap(%s, MAP_PRIVATE) failed, retrying with MAP_SHARED\n", path.c_str());
|
||||
mappingAddr = mmap(nullptr, size, PROT_READ, MAP_SHARED, fd, 0);
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
@@ -415,11 +413,7 @@ void LexerState::setFileAsNextState(std::string const &filePath, bool updateStat
|
||||
if (filePath == "-") {
|
||||
path = "<stdin>";
|
||||
content.emplace<BufferedContent>(STDIN_FILENO);
|
||||
// LCOV_EXCL_START
|
||||
if (verbose) {
|
||||
printf("Opening stdin\n");
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
verbosePrint("Opening stdin\n"); // LCOV_EXCL_LINE
|
||||
} else {
|
||||
struct stat statBuf;
|
||||
if (stat(filePath.c_str(), &statBuf) != 0) {
|
||||
@@ -445,11 +439,7 @@ void LexerState::setFileAsNextState(std::string const &filePath, bool updateStat
|
||||
content.emplace<ViewedContent>(
|
||||
std::shared_ptr<char[]>(mappingAddr, FileUnmapDeleter(size)), size
|
||||
);
|
||||
// LCOV_EXCL_START
|
||||
if (verbose) {
|
||||
printf("File \"%s\" is mmap()ped\n", path.c_str());
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
verbosePrint("File \"%s\" is mmap()ped\n", path.c_str()); // LCOV_EXCL_LINE
|
||||
isMmapped = true;
|
||||
}
|
||||
}
|
||||
@@ -458,15 +448,13 @@ void LexerState::setFileAsNextState(std::string const &filePath, bool updateStat
|
||||
// Sometimes mmap() fails or isn't available, so have a fallback
|
||||
content.emplace<BufferedContent>(fd);
|
||||
// LCOV_EXCL_START
|
||||
if (verbose) {
|
||||
if (statBuf.st_size == 0) {
|
||||
printf("File \"%s\" is empty\n", path.c_str());
|
||||
verbosePrint("File \"%s\" is empty\n", path.c_str());
|
||||
} else {
|
||||
printf(
|
||||
verbosePrint(
|
||||
"File \"%s\" is opened; errno reports: %s\n", path.c_str(), strerror(errno)
|
||||
);
|
||||
}
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,11 +329,7 @@ int main(int argc, char *argv[]) {
|
||||
if (stateFileSpecs.find(name) != stateFileSpecs.end()) {
|
||||
warnx("Overriding state filename %s", name);
|
||||
}
|
||||
// LCOV_EXCL_START
|
||||
if (verbose) {
|
||||
printf("State filename %s\n", name);
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
verbosePrint("State filename %s\n", name); // LCOV_EXCL_LINE
|
||||
stateFileSpecs.emplace(name, std::move(features));
|
||||
break;
|
||||
}
|
||||
@@ -421,9 +417,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
std::string mainFileName = argv[musl_optind];
|
||||
|
||||
if (verbose) {
|
||||
printf("Assembling %s\n", mainFileName.c_str()); // LCOV_EXCL_LINE
|
||||
}
|
||||
verbosePrint("Assembling %s\n", mainFileName.c_str()); // LCOV_EXCL_LINE
|
||||
|
||||
if (dependFile) {
|
||||
if (targetFileName.empty()) {
|
||||
|
||||
@@ -374,11 +374,7 @@ void out_SetFileName(std::string const &name) {
|
||||
warnx("Overriding output filename %s", objectFileName.c_str());
|
||||
}
|
||||
objectFileName = name;
|
||||
// LCOV_EXCL_START
|
||||
if (verbose) {
|
||||
printf("Output filename %s\n", objectFileName.c_str());
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
verbosePrint("Output filename %s\n", objectFileName.c_str()); // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
static void dumpString(std::string const &escape, FILE *file) {
|
||||
|
||||
Reference in New Issue
Block a user