]> git.siccegge.de Git - frida/frida.git/blobdiff - src/main.cxx
Make commandline parser optional to build against cip qt 5.1
[frida/frida.git] / src / main.cxx
index e1a2d7cf503083debcad8da2da705711dc87f5d9..ebb85e87924d457a80c388a32a62f35a56b26fb6 100644 (file)
@@ -4,12 +4,18 @@
 #include <climits>
 
 #include <QApplication>
+#if QT_VERSION > QT_VERSION_CHECK(5, 2, 0)
+#define ARGPARSE
+#endif
+
+#ifdef ARGPARSE
+#include <QCommandLineParser>
+#endif
 #include <QTextEdit>
 
 #include "log4cxx/logger.h"
 #include "log4cxx/basicconfigurator.h"
 
-#include "Binary.hxx"
 #include "gui/Mainwindow.hxx"
 
 using std::cout;
@@ -18,18 +24,41 @@ using std::cerr;
 
 int main(int argc, char** argv)
 {
+       QApplication app(argc, argv);
+
     log4cxx::BasicConfigurator::configure();
     log4cxx::LoggerPtr _logger(log4cxx::Logger::getLogger("main"));
+
+#ifdef ARGPARSE
+       QCommandLineParser parser;
+#endif
+
+       QApplication::setApplicationName("frida");
+#ifdef ARGPARSE
+       parser.addHelpOption();
+       parser.addVersionOption();
+       parser.addPositionalArgument("filename", QCoreApplication::translate("main", "File to disassemble."));
+
+
+       parser.process(app);
+#endif
+
     LOG4CXX_DEBUG(_logger, "Initializing LLVM");
     llvm::InitializeAllTargetInfos();
     llvm::InitializeAllTargetMCs();
     llvm::InitializeAllAsmParsers();
     llvm::InitializeAllDisassemblers();
 
-    QApplication app(argc, argv);
+    LOG4CXX_DEBUG(_logger, "Initializing Qt");
 
-    Mainwindow m;
-    m.show();
+       std::string filename = "";
+#ifdef ARGPARSE
+       if (! parser.positionalArguments().isEmpty()) {
+               filename = parser.positionalArguments().at(0).toStdString();
+       }
+#endif
 
-    return app.exec();
+       Mainwindow m(filename);
+       m.show();
+       return app.exec();
 }