diff options
| author | EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> | 2021-11-27 20:06:29 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-27 15:06:29 -0500 |
| commit | 0966109a1402ac4a070345f9e151b93064d09fc9 (patch) | |
| tree | 58043fa7bd894bb57a61d843bca9e99492387df4 /ZAPD/Main.cpp | |
| parent | 6948306d97a8d87c5ecae23c409894383badfe67 (diff) | |
Warning system (#189)
* first draft
* take vt.h from mm repo
* Colors
* Fix argument types
* Add argument parser to errorhandler
* Rename ErrorHandler to WarningHandler
* Add -Wno- and more warning types
* header and body in warnings
* Small cleanup
* Replace a bunch of warnings with the new system
Co-authored-by: EllipticEllipsis <EllipticEllipsis@users.noreply.github.com>
* Move stuff around
* Move stuff to header
* Make some more VT macros, new Warning_Build function + macro, ZBackground
* Add remaining warnings
* Add ZResource* param to Warning_Resource
* Add warning help message
* Simplify help message a bit
* Refactor warnings into lots of helper functions
* Fix HANG_INDT in the wild
* Builds now
* Update macros to use bold
* Fix body printing and error colour
* Add -Werror=
* Add warningType to HANDLE_ERROR
* Change some throws into HANDLE_ERROR
* Create init and main maps and write new help printer
* Changed ZTextureAnimation to new w/e
* Typo
* Delete build warnings list file
* Use ERROR in ZResource and ZPath
* Remove extra structs
* Move ifdef into the InitMap, add descriptions
* Actually move into initMap and add descriptions...
* Remove Everything from the WarningType enum
* Make more of the handler arguments const for compatibility
* Fix warning
* Document macros a bit
* Add ImageBackend ERRRORs
* Note on Weverything, rename InvalidData to InvalidExtractedData
* add texture and mesh warnings/errors
* InvalidExtractedData
* Add description for InvalidPNG
* print which warnings are enabled by using debug verbosity
* Fix everything
* Fix some newlines
* Move help to the end, start some documentation
* Remove unnecessary `WarningHandler::`s
* Remove commented code
* Some more documentation
* Make first letters consistenty lowercase, more docs
* Consistently use lowercase, more docs
* Format consistently, more detail in documentation
* Simplify enabled warnings checks
* Rename HANDLE_WARNING_BUILD and add HANDLE_ERROR_PROCESS
* Delete BuildInfo.cpp
* Use PROCESS where possible, bit more documentation
* Add documenation to README, sort when printing help
* Add an example, escalate the rest of the invalids by default
* Format warning names in table
* format readme
* Remove old flags info
* Remove obsolete variables
* Format
* assert.h -> cassert
* Replace some asserts in ZTexture
* Remove test file
* Minor cleanup
* Bit more in the help
* Fix header includes
* Format
* One character in readme
* Update README.md
Co-authored-by: Anghelo Carvajal <angheloalf95@gmail.com>
* Some Morita inspiration
* Convert new errors
* Static warnings/errors
* Merge remote-tracking branch 'upstream/master' into errorlib
* Add explanation for switch control flow
* format
* whooops
* Fix segment warning that doesn't apply now we assume no segment means use VRAM
* Comment out MM in Jenkinsfile
Co-authored-by: Angie <angheloalf95@gmail.com>
Co-authored-by: EllipticEllipsis <EllipticEllipsis@users.noreply.github.com>
Diffstat (limited to 'ZAPD/Main.cpp')
| -rw-r--r-- | ZAPD/Main.cpp | 55 |
1 files changed, 29 insertions, 26 deletions
diff --git a/ZAPD/Main.cpp b/ZAPD/Main.cpp index 298ca02..7f2854a 100644 --- a/ZAPD/Main.cpp +++ b/ZAPD/Main.cpp @@ -1,8 +1,9 @@ -#include <Utils/Directory.h> -#include <Utils/File.h> -#include <Utils/Path.h> #include "Globals.h" #include "Overlays/ZOverlay.h" +#include "Utils/Directory.h" +#include "Utils/File.h" +#include "Utils/Path.h" +#include "WarningHandler.h" #include "ZAnimation.h" #include "ZBackground.h" #include "ZBlob.h" @@ -12,10 +13,10 @@ #if !defined(_MSC_VER) && !defined(__CYGWIN__) #include <csignal> #include <cstdlib> +#include <ctime> #include <cxxabi.h> // for __cxa_demangle #include <dlfcn.h> // for dladdr #include <execinfo.h> -#include <time.h> #include <unistd.h> #endif @@ -97,6 +98,9 @@ int main(int argc, char* argv[]) return 1; } + Globals* g = new Globals(); + WarningHandler::Init(argc, argv); + for (int i = 1; i < argc; i++) { if (!strcmp(argv[i], "--version")) @@ -109,12 +113,12 @@ int main(int argc, char* argv[]) printf("Congratulations!\n"); printf("You just found the (unimplemented and undocumented) ZAPD's help message.\n"); printf("Feel free to implement it if you want :D\n"); + + WarningHandler::PrintHelp(); return 0; } } - Globals* g = new Globals; - // Parse other "commands" for (int32_t i = 2; i < argc; i++) { @@ -186,26 +190,15 @@ int main(int argc, char* argv[]) signal(SIGSEGV, ErrorHandler); signal(SIGABRT, ErrorHandler); #else - fprintf(stderr, - "Warning: Tried to set error handler, but this build lacks support for one.\n"); + HANDLE_WARNING(WarningType::Always, + "tried to set error handler, but this ZAPD build lacks support for one", + ""); #endif } else if (arg == "-v") // Verbose { Globals::Instance->verbosity = static_cast<VerbosityLevel>(strtol(argv[++i], NULL, 16)); } - else if (arg == "-wu" || arg == "--warn-unaccounted") // Warn unaccounted - { - Globals::Instance->warnUnaccounted = true; - } - else if (arg == "-wno" || arg == "--warn-no-offset") - { - Globals::Instance->warnNoOffset = true; - } - else if (arg == "-eno" || arg == "--error-no-offset") - { - Globals::Instance->errorNoOffset = true; - } else if (arg == "-vu" || arg == "--verbose-unaccounted") // Verbose unaccounted { Globals::Instance->verboseUnaccounted = true; @@ -262,6 +255,11 @@ int main(int argc, char* argv[]) if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) printf("ZAPD: Zelda Asset Processor For Decomp: %s\n", gBuildHash); + if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) + { + WarningHandler::PrintWarningsDebugInfo(); + } + // TODO: switch if (fileMode == ZFileMode::Extract || fileMode == ZFileMode::BuildSourceFile) { @@ -334,7 +332,9 @@ bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path if (eResult != tinyxml2::XML_SUCCESS) { - fprintf(stderr, "Invalid xml file: '%s'\n", xmlFilePath.c_str()); + // TODO: use XMLDocument::ErrorIDToName to get more specific error messages here + HANDLE_ERROR(WarningType::InvalidXML, + StringHelper::Sprintf("invalid XML file: '%s'", xmlFilePath.c_str()), ""); return false; } @@ -342,7 +342,9 @@ bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path if (root == nullptr) { - fprintf(stderr, "Missing Root tag in xml file: '%s'\n", xmlFilePath.c_str()); + HANDLE_WARNING( + WarningType::InvalidXML, + StringHelper::Sprintf("missing Root tag in xml file: '%s'", xmlFilePath.c_str()), ""); return false; } @@ -392,10 +394,11 @@ bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path } else { - throw std::runtime_error(StringHelper::Sprintf( - "Parse: Fatal error in '%s'.\n\t A resource was found outside of " - "a File element: '%s'\n", - xmlFilePath.c_str(), child->Name())); + std::string errorHeader = + StringHelper::Sprintf("when parsing file '%s'", xmlFilePath.c_str()); + std::string errorBody = StringHelper::Sprintf( + "Found a resource outside a File element: '%s'", child->Name()); + HANDLE_ERROR(WarningType::InvalidXML, errorHeader, errorBody); } } |
