utility: headless parsing

* resolve merge conflict
   * rpath for dev
   * generate a coatidb with a coatiproject
   * build script change to cmake --build
This commit is contained in:
Andreas Stallinger
2016-02-23 18:59:17 +01:00
parent 5b7e958ea7
commit 76697d8b6e
9 changed files with 184 additions and 85 deletions
+1
View File
@@ -50,6 +50,7 @@ project(${PROJECT_NAME})
if(UNIX AND NOT APPLE)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib/:$$ORIGIN/lib/")
include(cmake/external.cmake)
endif()
+9 -9
View File
@@ -12,38 +12,38 @@ then
if [ "$2" = "test" ]
then
#echo "release test"
ninja -C build/Release Coati_test && cd bin/test && Release/Coati_test
cmake --build build/Release --target Coati_test && cd bin/test && Release/Coati_test
elif [ "$2" = "trial" ]
then
ninja -C build/Release Coati_trial && cd bin/app && Release/Coati_trial
cmake --build build/Release --target Coati_trial && cd bin/app && Release/Coati_trial
elif [ "$2" = "keygen" ]
then
#echo "release keygen"
ninja -C build/Release Coati_license_generator && cd bin/license_generator && Release/Coati_license_generator
cmake --build build/Release --target Coati_license_generator && cd bin/license_generator && Release/Coati_license_generator
else
#echo "release app"
ninja -C build/Release Coati && cd bin/app && Release/Coati
cmake --build build/Release --target Coati && cd bin/app && Release/Coati
fi
elif [ "$1" = "debug" ] || [ "$1" = "d" ]
then
if [ "$2" = "test" ]
then
#echo "debug test"
ninja -C build/Debug Coati_test && cd bin/test && Debug/Coati_test
cmake --build build/Debug --target Coati_test && cd bin/test && Debug/Coati_test
elif [ "$2" = "trial" ]
then
ninja -C build/Debug Coati_trial && cd bin/app && Debug/Coati_trial
cmake --build build/Debug --target Coati_trial && cd bin/app && Debug/Coati_trial
elif [ "$2" = "keygen" ]
then
#echo "debug keygen"
ninja -C build/Debug Coati_license_generator && cd bin/license_generator && Debug/Coati_license_generator_d
cmake --build build/Debug --target Coati_license_generator && cd bin/license_generator && Debug/Coati_license_generator_d
else
#echo "debug app"
ninja -C build/Debug Coati && cd bin/app && Debug/Coati
cmake --build build/Debug --target Coati && cd bin/app && Debug/Coati
fi
elif [ "$1" = "package" ] || [ "$1" = "p" ]
then
ninja package -C build/Release Coati
cmake --target package --build build/Release Coati
mkdir -p distr && cp build/Release/Coati*.tar.gz distr #&& cp build/Release/Coati*.deb distr
echo "Packages copied into the distr folder"
else
+53 -22
View File
@@ -18,7 +18,21 @@
#include "version.h"
#include "settings/ProjectSettings.h"
#include "utility/solution/SolutionParserCompilationDatabase.h"
#include "utility/messaging/MessageListener.h"
#include "utility/messaging/type/MessageFinishedParsing.h"
class Quitter : public MessageListener<MessageFinishedParsing>
{
public:
Quitter(QCoreApplication* app){};
virtual ~Quitter(){};
private:
virtual void handleMessage(MessageFinishedParsing* message)
{
QCoreApplication::exit(0);
}
};
void init()
{
@@ -30,8 +44,6 @@ void init()
fileLogger->setLogLevel(Logger::LOG_ALL);
FileLogger::setFilePath(UserPaths::getLogPath());
LogManager::getInstance()->addLogger(fileLogger);
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf");
}
int main(int argc, char *argv[])
@@ -40,33 +52,52 @@ int main(int argc, char *argv[])
Version version = Version::fromString(GIT_VERSION_NUMBER);
QApplication::setApplicationVersion(version.toDisplayString().c_str());
QCoreApplication* qtApp = new QCoreApplication(argc, argv);
setup(argc, argv);
QtApplication qtApp(argc, argv);
qtApp.setAttribute(Qt::AA_UseHighDpiPixmaps);
init();
QtCommandLineParser commandLineParser;
commandLineParser.setup();
commandLineParser.process(qtApp);
QtViewFactory viewFactory;
QtNetworkFactory networkFactory;
if(AppPath::getAppPath().empty())
if(AppPath::getAppPath().empty())
{
AppPath::setAppPath(QCoreApplication::applicationDirPath().toStdString());
}
LicenseChecker checker;
init();
std::shared_ptr<Application> app = Application::create(version, &viewFactory, &networkFactory);
QtCommandLineParser commandLineParser;
commandLineParser.setup();
commandLineParser.process(*qtApp);
commandLineParser.evaluateCommandline();
std::shared_ptr<Application> app;
checker.setApp(app.get());
if(commandLineParser.noGUI())
{
app = Application::create( version );
commandLineParser.projectLoad();
commandLineParser.parseCommandline();
Quitter quitter(qtApp);
return qtApp->exec();
}
else
{
// replace the qt app with a gui qt app
// FIXME qtApp to shared_ptr
qtApp->quit();
delete qtApp;
qtApp = new QtApplication(argc, argv);
qtApp->setAttribute(Qt::AA_UseHighDpiPixmaps);
return qtApp.exec();
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf");
QtViewFactory viewFactory;
QtNetworkFactory networkFactory;
LicenseChecker checker;
app = Application::create(version, &viewFactory, &networkFactory);
checker.setApp(app.get());
commandLineParser.projectLoad();
return qtApp->exec();
}
}
+44 -14
View File
@@ -50,6 +50,20 @@ std::shared_ptr<Application> Application::create(
return ptr;
}
std::shared_ptr<Application> Application::create(const Version& version)
{
Version::setApplicationVersion(version);
loadSettings();
std::shared_ptr<Application> ptr(new Application());
ptr->m_storageCache = std::make_shared<StorageCache>();
ptr->m_project = Project::create(ptr->m_storageCache.get());
ptr->startMessagingAndScheduling();
return ptr;
}
void Application::loadSettings()
{
ApplicationSettings::getInstance()->load(FilePath(UserPaths::getAppSettingsPath()));
@@ -66,7 +80,10 @@ Application::~Application()
{
MessageQueue::getInstance()->stopMessageLoop();
TaskScheduler::getInstance()->stopSchedulerLoop();
m_mainView->saveLayout();
if(m_mainView)
{
m_mainView->saveLayout();
}
}
void Application::loadProject(const FilePath& projectSettingsFilePath)
@@ -76,18 +93,20 @@ void Application::loadProject(const FilePath& projectSettingsFilePath)
loadSettings();
updateRecentProjects(projectSettingsFilePath);
m_mainView->setTitle(
"Coati - " +
projectSettingsFilePath.fileName());
m_storageCache->clear();
m_componentManager->refreshViews();
m_storageCache->clear();
m_project = Project::create(m_storageCache.get());
m_project->load(projectSettingsFilePath);
m_mainView->updateRecentProjectMenu();
m_mainView->hideStartScreen();
if(m_mainView)
{
m_componentManager->refreshViews();
m_mainView->setTitle(
"Coati - " +
projectSettingsFilePath.fileName());
m_mainView->updateRecentProjectMenu();
m_mainView->hideStartScreen();
}
}
void Application::refreshProject()
@@ -95,7 +114,10 @@ void Application::refreshProject()
MessageStatus("Refreshing Project").dispatch();
m_storageCache->clear();
m_componentManager->refreshViews();
if(m_componentManager)
{
m_componentManager->refreshViews();
}
m_project->reload();
}
@@ -110,19 +132,27 @@ void Application::saveProject(const FilePath& projectSettingsFilePath)
void Application::showLicenseScreen()
{
m_mainView->showLicenseScreen();
if(m_mainView)
{
m_mainView->showLicenseScreen();
}
}
void Application::handleMessage(MessageActivateWindow* message)
{
m_mainView->activateWindow();
if(m_mainView)
{
m_mainView->activateWindow();
}
}
void Application::handleMessage(MessageFinishedParsing* message)
{
m_project->logStats();
MessageRefresh().refreshUiOnly().dispatch();
if(m_mainView)
{
MessageRefresh().refreshUiOnly().dispatch();
}
}
void Application::handleMessage(MessageLoadProject* message)
+1
View File
@@ -28,6 +28,7 @@ class Application
{
public:
static std::shared_ptr<Application> create(const Version& version, ViewFactory* viewFactory, NetworkFactory* networkFactory);
static std::shared_ptr<Application> create(const Version& version);
static void loadSettings();
~Application();
@@ -7,6 +7,8 @@
QtCommandLineParser::QtCommandLineParser()
: m_projectFileString("")
, m_noGUI(false)
{
}
@@ -25,45 +27,72 @@ void QtCommandLineParser::setup()
QCoreApplication::translate("main", "Load Coati with the a Coatiprojectfile <CoatiProject>."),
QCoreApplication::translate("main", "CoatiProject"));
addOption(projectOption);
QCommandLineOption parseProjectWithoutGUIOption(QStringList() << "d" << "database",
QCoreApplication::translate("main", "Start coati to parse the Coatiprojectfile <CoatiProject>. Result *.coatidb"),
QCoreApplication::translate("main", "CoatiProject"));
addOption(parseProjectWithoutGUIOption);
}
void QtCommandLineParser::parseCommandline()
void QtCommandLineParser::evaluateCommandline()
{
if (isSet("database"))
{
m_noGUI = true;
processProjectfile(value("database").toStdString());
}
if(isSet("project"))
{
QString projectfilename = value("project") ;
FilePath projectfile(projectfilename.toStdString());
bool isValidProjectfile = true;
std::stringstream errorstring("Provided Projectfile is not valid: ");
errorstring << "Provided Projectfile('" << projectfile.fileName() << ") ";
if(!projectfile.exists())
{
errorstring << "does not exist";
isValidProjectfile = false;
}
if(projectfile.extension() != ".coatiproject")
{
errorstring << "has a wrong fileending";
isValidProjectfile = false;
}
std::shared_ptr<ConfigManager> configManager = ConfigManager::createEmpty();
if(!configManager->load(TextAccess::createFromFile(projectfile.str())))
{
errorstring << "could not be loaded";
isValidProjectfile = false;
}
if(isValidProjectfile)
{
MessageLoadProject(projectfile.str(), false).dispatch();
}
else
{
MessageStatus(errorstring.str(), true).dispatch();
LOG_ERROR(errorstring.str());
}
processProjectfile(value("project").toStdString());
}
}
}
void QtCommandLineParser::projectLoad()
{
if (!m_projectFileString.empty())
{
MessageLoadProject(m_projectFileString, false).dispatch();
}
}
void QtCommandLineParser::processProjectfile(const std::string& file)
{
FilePath projectfile(file);
bool isValidProjectfile = true;
std::stringstream errorstring("Provided Projectfile is not valid: ");
errorstring << "Provided Projectfile('" << projectfile.fileName() << ") ";
if(!projectfile.exists())
{
errorstring << "does not exist";
isValidProjectfile = false;
}
if(projectfile.extension() != ".coatiproject")
{
errorstring << "has a wrong fileending";
isValidProjectfile = false;
}
std::shared_ptr<ConfigManager> configManager = ConfigManager::createEmpty();
if(!configManager->load(TextAccess::createFromFile(projectfile.str())))
{
errorstring << "could not be loaded";
isValidProjectfile = false;
}
if(isValidProjectfile)
{
m_projectFileString = projectfile.str();
}
else
{
MessageStatus(errorstring.str(), true).dispatch();
LOG_ERROR(errorstring.str());
}
}
bool QtCommandLineParser::noGUI()
{
return m_noGUI;
}
@@ -1,6 +1,7 @@
#ifndef QTCOMMANDLINEPARSER_H
#define QTCOMMANDLINEPARSER_H
#include <string>
#include <QCommandLineParser>
#include "Application.h"
@@ -10,10 +11,16 @@ public:
QtCommandLineParser();
~QtCommandLineParser();
void setup();
void parseCommandline();
void evaluateCommandline();
void projectLoad();
bool noGUI();
private:
std::string m_projectFileString;
bool m_noGUI;
void processProjectfile(const std::string& file);
};
#endif //QTCOMMANDLINEPARSER_H
+2 -2
View File
@@ -1,6 +1,6 @@
#include "qt/window/QtSplashScreen.h"
#include <QApplication>
#include <QCoreApplication>
#include <QThread>
#include <QTimer>
@@ -38,7 +38,7 @@ QtSplashScreen::~QtSplashScreen()
{
}
void QtSplashScreen::exec(QApplication& app)
void QtSplashScreen::exec(QCoreApplication& app)
{
m_state = 0;
QTimer* timer = new QTimer(this);
+2 -2
View File
@@ -5,7 +5,7 @@
#include <QPainter>
#include <QWidget>
class QApplication;
class QCoreApplication;
class QPixmap;
class QtSplashScreen
@@ -17,7 +17,7 @@ public:
QtSplashScreen(const QPixmap& pixmap, Qt::WindowFlags f = 0);
virtual ~QtSplashScreen();
void exec(QApplication& app);
void exec(QCoreApplication& app);
void setMessage(const QString& str);
void setVersion(const QString& str);