build: merge Coati app and Trial to single executable
* removed trial target * updated deploy scripts to exclude trial * cleanup CMakeLists * removed Eigen dependencies * split parser lib into lib_cxx and lib_java * added ProjectFactory and ProjectFactoryModules * removed old installer projects * updated wix installer * updated readme for wix setup * updated to use obfuscated exe * added qt.conf * added indexing dialog images * added jars * added coatidb files of sample projects * added source code of javaparser sample * removed auto-refresh image * intermediate files of windows installer are created in build folder * preselected desktop shortcut * build bat is executed from deploy_windows script
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
#include "data/graph/token_component/TokenComponentAccess.h"
|
||||
|
||||
#include "data/DefinitionType.h"
|
||||
#include "data/SqliteStorage.h"
|
||||
|
||||
class ParserClientImpl: public ParserClient
|
||||
{
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
#include "data/parser/TaskParseWrapper.h"
|
||||
|
||||
#include "component/view/DialogView.h"
|
||||
#include "data/PersistentStorage.h"
|
||||
#include "utility/file/FileRegister.h"
|
||||
#include "utility/messaging/type/MessageFinishedParsing.h"
|
||||
#include "utility/scheduling/Blackboard.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
TaskParseWrapper::TaskParseWrapper(
|
||||
PersistentStorage* storage,
|
||||
std::shared_ptr<FileRegister> fileRegister,
|
||||
DialogView* dialogView
|
||||
)
|
||||
: m_storage(storage)
|
||||
, m_fileRegister(fileRegister)
|
||||
, m_dialogView(dialogView)
|
||||
{
|
||||
}
|
||||
|
||||
TaskParseWrapper::~TaskParseWrapper()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskParseWrapper::setTask(std::shared_ptr<Task> task)
|
||||
{
|
||||
if (task)
|
||||
{
|
||||
m_taskRunner = std::make_shared<TaskRunner>(task);
|
||||
}
|
||||
}
|
||||
|
||||
void TaskParseWrapper::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
blackboard->set("indexer_count", 0);
|
||||
m_dialogView->updateIndexingDialog(0, m_fileRegister->getSourceFilesCount(), "");
|
||||
|
||||
m_start = utility::durationStart();
|
||||
m_storage->startParsing();
|
||||
}
|
||||
|
||||
Task::TaskState TaskParseWrapper::doUpdate(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
return m_taskRunner->update(blackboard);
|
||||
}
|
||||
|
||||
void TaskParseWrapper::doExit(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
blackboard->clear("indexer_count");
|
||||
|
||||
m_dialogView->showProgressDialog("Finish Indexing", "Optimizing database");
|
||||
|
||||
m_storage->optimizeMemory();
|
||||
|
||||
m_dialogView->showProgressDialog("Finish Indexing", "Building caches");
|
||||
|
||||
m_storage->finishParsing();
|
||||
|
||||
m_dialogView->hideProgressDialog();
|
||||
|
||||
MessageFinishedParsing().dispatch();
|
||||
|
||||
m_dialogView->finishedIndexingDialog(
|
||||
m_fileRegister->getParsedSourceFilesCount(),
|
||||
m_fileRegister->getSourceFilesCount(),
|
||||
utility::duration(m_start),
|
||||
m_storage->getErrorCount()
|
||||
);
|
||||
}
|
||||
|
||||
void TaskParseWrapper::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
m_taskRunner->reset();
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
#ifndef TASK_PARSE_CXX_H
|
||||
#define TASK_PARSE_CXX_H
|
||||
|
||||
#include <memory>
|
||||
#include <deque>
|
||||
|
||||
#include "data/parser/Parser.h"
|
||||
#include "data/parser/ParserClientImpl.h"
|
||||
#include "utility/scheduling/Task.h"
|
||||
#include "utility/TimePoint.h"
|
||||
#include "utility/messaging/type/MessageInterruptTasks.h"
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
|
||||
class CxxParser;
|
||||
class DialogView;
|
||||
class FileRegister;
|
||||
class StorageProvider;
|
||||
|
||||
namespace clang
|
||||
{
|
||||
namespace tooling
|
||||
{
|
||||
class JSONCompilationDatabase;
|
||||
}
|
||||
}
|
||||
|
||||
class TaskParseCxx
|
||||
: public Task
|
||||
, public MessageListener<MessageInterruptTasks>
|
||||
{
|
||||
public:
|
||||
static std::vector<FilePath> getSourceFilesFromCDB(const FilePath& compilationDatabasePath);
|
||||
|
||||
TaskParseCxx(
|
||||
std::shared_ptr<StorageProvider> storageProvider,
|
||||
std::shared_ptr<FileRegister> fileRegister,
|
||||
const Parser::Arguments& arguments,
|
||||
DialogView* dialogView
|
||||
);
|
||||
|
||||
private:
|
||||
virtual void doEnter(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual TaskState doUpdate(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doExit(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doReset(std::shared_ptr<Blackboard> blackboard);
|
||||
|
||||
virtual void handleMessage(MessageInterruptTasks* message);
|
||||
|
||||
std::shared_ptr<StorageProvider> m_storageProvider;
|
||||
|
||||
const Parser::Arguments m_arguments;
|
||||
DialogView* m_dialogView;
|
||||
|
||||
std::shared_ptr<CxxParser> m_parser;
|
||||
std::shared_ptr<ParserClientImpl> m_parserClient;
|
||||
|
||||
bool m_isCDB;
|
||||
std::shared_ptr<clang::tooling::JSONCompilationDatabase> m_cdb;
|
||||
|
||||
bool m_interrupted;
|
||||
};
|
||||
|
||||
#endif // TASK_PARSE_CXX_H
|
||||
@@ -1,92 +0,0 @@
|
||||
#include "data/parser/java/JavaEnvironment.h"
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
#include "data/parser/java/JavaEnvironmentFactory.h"
|
||||
|
||||
JavaEnvironment::~JavaEnvironment()
|
||||
{
|
||||
JavaEnvironmentFactory::getInstance()->unregisterEnvironment();
|
||||
}
|
||||
|
||||
bool JavaEnvironment::callStaticVoidMethod(std::string className, std::string methodName, int arg1, std::string arg2, std::string arg3, std::string arg4)
|
||||
{
|
||||
jclass javaClass = m_env->FindClass(className.c_str());
|
||||
if(javaClass == nullptr)
|
||||
{
|
||||
LOG_ERROR("class " + className + " not found in JVM environment");
|
||||
jthrowable exc = m_env->ExceptionOccurred();
|
||||
if(exc)
|
||||
{
|
||||
m_env->ExceptionDescribe();
|
||||
m_env->ExceptionClear();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
jmethodID javaMethodId = m_env->GetStaticMethodID(javaClass, methodName.c_str(), "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
|
||||
if(javaMethodId == nullptr)
|
||||
{
|
||||
LOG_ERROR("method void " + methodName + "(int, String, String, String) not found in JVM environment");
|
||||
}
|
||||
else
|
||||
{
|
||||
jint jarg1 = arg1;
|
||||
jstring jarg2 = m_env->NewStringUTF(arg2.c_str());
|
||||
jstring jarg3 = m_env->NewStringUTF(arg3.c_str());
|
||||
jstring jarg4 = m_env->NewStringUTF(arg4.c_str());
|
||||
m_env->CallStaticVoidMethod(javaClass, javaMethodId, jarg1, jarg2, jarg3, jarg4);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string JavaEnvironment::toStdString(jstring s)
|
||||
{
|
||||
const char *nativeString = m_env->GetStringUTFChars(s, 0);
|
||||
std::string ret = nativeString;
|
||||
m_env->ReleaseStringUTFChars(s, nativeString);
|
||||
return ret;
|
||||
}
|
||||
|
||||
jstring JavaEnvironment::toJString(std::string s)
|
||||
{
|
||||
return m_env->NewStringUTF(s.c_str());
|
||||
}
|
||||
|
||||
JavaEnvironment::JavaEnvironment(JavaVM* jvm, JNIEnv* env)
|
||||
: m_jvm(jvm)
|
||||
, m_env(env)
|
||||
{
|
||||
JavaEnvironmentFactory::getInstance()->registerEnvironment();
|
||||
}
|
||||
|
||||
void JavaEnvironment::registerNativeMethods(std::string className, std::vector<NativeMethod> methods)
|
||||
{
|
||||
JNINativeMethod* jniMethods = new JNINativeMethod[methods.size()];
|
||||
|
||||
for (size_t i = 0; i < methods.size(); i++)
|
||||
{
|
||||
jniMethods[i].name = const_cast<char*>(methods[i].name.c_str());
|
||||
jniMethods[i].signature = const_cast<char*>(methods[i].signature.c_str());
|
||||
jniMethods[i].fnPtr = methods[i].function;
|
||||
}
|
||||
|
||||
jclass javaClass = m_env->FindClass(className.c_str());
|
||||
if (javaClass)
|
||||
{
|
||||
if (m_env->RegisterNatives(javaClass, jniMethods, methods.size()) < 0)
|
||||
{
|
||||
LOG_ERROR("RegisterNatives failed");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("class \"" + className + "\" not found while registering native methods");
|
||||
}
|
||||
|
||||
delete [] jniMethods;
|
||||
}
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
#ifndef JAVA_ENVIRONMENT_H
|
||||
#define JAVA_ENVIRONMENT_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct JavaVM_;
|
||||
typedef JavaVM_ JavaVM;
|
||||
|
||||
struct JNIEnv_;
|
||||
typedef JNIEnv_ JNIEnv;
|
||||
|
||||
class _jstring;
|
||||
typedef _jstring *jstring;
|
||||
|
||||
class JavaEnvironmentFactory;
|
||||
|
||||
class JavaEnvironment
|
||||
{
|
||||
public:
|
||||
struct NativeMethod
|
||||
{
|
||||
std::string name;
|
||||
std::string signature;
|
||||
void *function;
|
||||
};
|
||||
|
||||
~JavaEnvironment();
|
||||
bool callStaticVoidMethod(std::string className, std::string methodName, int arg1, std::string arg2, std::string arg3, std::string arg4);
|
||||
|
||||
std::string toStdString(jstring s);
|
||||
jstring toJString(std::string s);
|
||||
|
||||
void registerNativeMethods(std::string className, std::vector<NativeMethod> methods);
|
||||
private:
|
||||
friend class JavaEnvironmentFactory;
|
||||
|
||||
JavaEnvironment(JavaVM* jvm, JNIEnv* env);
|
||||
|
||||
JavaVM* m_jvm;
|
||||
JNIEnv* m_env;
|
||||
};
|
||||
|
||||
#endif // JAVA_ENVIRONMENT_H
|
||||
@@ -1,177 +0,0 @@
|
||||
#include "data/parser/java/JavaEnvironmentFactory.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "data/parser/java/JavaEnvironment.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/utilityLibrary.h"
|
||||
|
||||
void JavaEnvironmentFactory::createInstance(std::string classPath, std::string& errorString)
|
||||
{
|
||||
if (s_instance)
|
||||
{
|
||||
if (classPath == s_classPath)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("java classpath cannot be changed!");
|
||||
// todo: implement destroying the old factory instance and create a new one.
|
||||
// may be not so easy... there can only be one java env per process (which can never be destroyed) -.-
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::function<jint (JavaVM**, void**, void*)> createInstanceFunction;
|
||||
|
||||
createInstanceFunction = utility::loadFunctionFromLibrary<jint, JavaVM**, void**, void*>(
|
||||
FilePath(ApplicationSettings::getInstance()->getJavaPath()),
|
||||
"JNI_CreateJavaVM",
|
||||
errorString
|
||||
);
|
||||
|
||||
if (!createInstanceFunction && errorString.size() > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
s_classPath = classPath;
|
||||
|
||||
JavaVM* jvm = nullptr; // Pointer to the JVM (Java Virtual Machine)
|
||||
JNIEnv* env = nullptr; // Pointer to native interface
|
||||
|
||||
JavaVMInitArgs vm_args; // Initialization arguments
|
||||
JavaVMOption* options = new JavaVMOption[3]; // JVM invocation options
|
||||
std::string classPathOption = "-Djava.class.path=" + classPath;
|
||||
options[0].optionString = const_cast<char*>(classPathOption.c_str());
|
||||
options[1].optionString = const_cast<char*>("-Xms64m");
|
||||
std::string maximumMemoryOprionString = "-Xmx" + std::to_string(ApplicationSettings::getInstance()->getJavaMaximumMemory()) + "m";
|
||||
options[2].optionString = const_cast<char*>(maximumMemoryOprionString.c_str());
|
||||
vm_args.version = JNI_VERSION_1_6;
|
||||
vm_args.nOptions = 3;
|
||||
vm_args.options = options;
|
||||
vm_args.ignoreUnrecognized = false; // invalid options make the JVM init fail
|
||||
|
||||
jint rc = createInstanceFunction(&jvm, (void**)&env, &vm_args);
|
||||
|
||||
delete [] options;
|
||||
|
||||
if (rc != JNI_OK)
|
||||
{
|
||||
if(rc == JNI_EVERSION)
|
||||
{
|
||||
errorString = "JVM is oudated and doesn't meet requirements";
|
||||
}
|
||||
else if(rc == JNI_ENOMEM)
|
||||
{
|
||||
errorString = "not enough memory for JVM";
|
||||
}
|
||||
else if(rc == JNI_EINVAL)
|
||||
{
|
||||
errorString = "invalid argument for launching JVM";
|
||||
}
|
||||
else if(rc == JNI_EEXIST)
|
||||
{
|
||||
errorString = "the process can only launch one JVM an not more";
|
||||
}
|
||||
else
|
||||
{
|
||||
errorString = "could not create the JVM instance (error code " + std::to_string(rc) + ")";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
jvm->DetachCurrentThread();
|
||||
s_instance = std::shared_ptr<JavaEnvironmentFactory>(new JavaEnvironmentFactory(jvm));
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<JavaEnvironmentFactory> JavaEnvironmentFactory::getInstance()
|
||||
{
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
JavaEnvironmentFactory::~JavaEnvironmentFactory()
|
||||
{
|
||||
// todo: what if there are threads running using the jvm?? log something!
|
||||
m_jvm->DestroyJavaVM();
|
||||
}
|
||||
|
||||
std::shared_ptr<JavaEnvironment> JavaEnvironmentFactory::createEnvironment()
|
||||
{
|
||||
std::thread::id currentThreadId = std::this_thread::get_id();
|
||||
|
||||
JNIEnv* env;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_threadIdToEnvAndUserCountMutex);
|
||||
|
||||
std::map<std::thread::id, std::pair<JNIEnv*, int>>::const_iterator it = m_threadIdToEnvAndUserCount.find(currentThreadId);
|
||||
if (it != m_threadIdToEnvAndUserCount.end())
|
||||
{
|
||||
env = it->second.first;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_jvm->AttachCurrentThread((void**)&env, NULL);
|
||||
m_threadIdToEnvAndUserCount.insert(std::make_pair(currentThreadId, std::make_pair(env, 0)));
|
||||
}
|
||||
}
|
||||
|
||||
return std::shared_ptr<JavaEnvironment>(new JavaEnvironment(m_jvm, env));
|
||||
}
|
||||
|
||||
std::shared_ptr<JavaEnvironmentFactory> JavaEnvironmentFactory::s_instance;
|
||||
|
||||
std::string JavaEnvironmentFactory::s_classPath;
|
||||
|
||||
JavaEnvironmentFactory::JavaEnvironmentFactory(JavaVM* jvm)
|
||||
: m_jvm(jvm)
|
||||
{
|
||||
}
|
||||
|
||||
void JavaEnvironmentFactory::registerEnvironment()
|
||||
{
|
||||
std::thread::id currentThreadId = std::this_thread::get_id();
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_threadIdToEnvAndUserCountMutex);
|
||||
std::map<std::thread::id, std::pair<JNIEnv*, int>>::iterator it = m_threadIdToEnvAndUserCount.find(currentThreadId);
|
||||
if (it != m_threadIdToEnvAndUserCount.end())
|
||||
{
|
||||
it->second.second++;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("something went horribly wrong while registering a java environment");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JavaEnvironmentFactory::unregisterEnvironment()
|
||||
{
|
||||
std::thread::id currentThreadId = std::this_thread::get_id();
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_threadIdToEnvAndUserCountMutex);
|
||||
std::map<std::thread::id, std::pair<JNIEnv*, int>>::iterator it = m_threadIdToEnvAndUserCount.find(currentThreadId);
|
||||
if (it != m_threadIdToEnvAndUserCount.end())
|
||||
{
|
||||
it->second.second--;
|
||||
if (it->second.second == 0)
|
||||
{ // TODO: currently this happens quite often. do something about that.
|
||||
m_jvm->DetachCurrentThread();
|
||||
m_threadIdToEnvAndUserCount.erase(it);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("something went horribly wrong while unregistering a java environment");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
#ifndef JAVA_ENVIRONMENT_FACTORY_H
|
||||
#define JAVA_ENVIRONMENT_FACTORY_H
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
struct JavaVM_;
|
||||
typedef JavaVM_ JavaVM;
|
||||
|
||||
struct JNIEnv_;
|
||||
typedef JNIEnv_ JNIEnv;
|
||||
|
||||
class JavaEnvironment;
|
||||
|
||||
class JavaEnvironmentFactory
|
||||
{
|
||||
public:
|
||||
static void createInstance(std::string classPath, std::string& errorString);
|
||||
static std::shared_ptr<JavaEnvironmentFactory> getInstance();
|
||||
|
||||
~JavaEnvironmentFactory();
|
||||
|
||||
std::shared_ptr<JavaEnvironment> createEnvironment();
|
||||
|
||||
private:
|
||||
friend class JavaEnvironment;
|
||||
|
||||
static std::shared_ptr<JavaEnvironmentFactory> s_instance;
|
||||
static std::string s_classPath;
|
||||
|
||||
JavaEnvironmentFactory(JavaVM* jvm);
|
||||
|
||||
void registerEnvironment();
|
||||
void unregisterEnvironment();
|
||||
|
||||
JavaVM* m_jvm;
|
||||
std::map<std::thread::id, std::pair<JNIEnv*, int>> m_threadIdToEnvAndUserCount;
|
||||
std::mutex m_threadIdToEnvAndUserCountMutex;
|
||||
};
|
||||
|
||||
#endif // JAVA_ENVIRONMENT_FACTORY_H
|
||||
@@ -1,43 +0,0 @@
|
||||
#ifndef TASK_PARSE_JAVA_H
|
||||
#define TASK_PARSE_JAVA_H
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "data/parser/Parser.h"
|
||||
#include "utility/scheduling/Task.h"
|
||||
#include "utility/messaging/type/MessageInterruptTasks.h"
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
|
||||
class DialogView;
|
||||
class FileRegister;
|
||||
class StorageProvider;
|
||||
|
||||
class TaskParseJava
|
||||
: public Task
|
||||
, public MessageListener<MessageInterruptTasks>
|
||||
{
|
||||
public:
|
||||
TaskParseJava(
|
||||
std::shared_ptr<StorageProvider> storageProvider,
|
||||
std::shared_ptr<FileRegister> fileRegister,
|
||||
const Parser::Arguments& arguments,
|
||||
DialogView* dialogView
|
||||
);
|
||||
|
||||
private:
|
||||
virtual void doEnter(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual TaskState doUpdate(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doExit(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doReset(std::shared_ptr<Blackboard> blackboard);
|
||||
|
||||
virtual void handleMessage(MessageInterruptTasks* message);
|
||||
|
||||
std::shared_ptr<StorageProvider> m_storageProvider;
|
||||
std::shared_ptr<FileRegister> m_fileRegister;
|
||||
Parser::Arguments m_arguments;
|
||||
DialogView* m_dialogView;
|
||||
|
||||
bool m_interrupted;
|
||||
};
|
||||
|
||||
#endif // TASK_PARSE_JAVA_H
|
||||
Reference in New Issue
Block a user