Exemple #1
0
    int StartHost()
    {
        string runtimePath(EnvironmentUtils::Get("KR_RUNTIME"));
        string dll(FileUtils::Join(runtimePath.c_str(), "khost.dll", 0));
        HMODULE khost = SafeLoadRuntimeDLL(dll);
        if (!khost)
            return __LINE__;

        Executor *executor = (Executor*) GetProcAddress(khost, "Execute");
        if (!executor)
        {
            ShowError(string("Invalid entry point 'Execute' in khost.dll"));
            return __LINE__;
        }

        return executor(::GetModuleHandle(NULL), argc, (const char**)argv);
    }
Exemple #2
0
void Host::SetupApplication(int argc, const char* argv[])
{
    AssertEnvironmentVariable(HOME_ENV);
    AssertEnvironmentVariable(RUNTIME_ENV);
    AssertEnvironmentVariable(MODULES_ENV);

    string applicationHome(Environment::get(HOME_ENV));
    string runtimePath(Environment::get(RUNTIME_ENV));
    string modulePaths(Environment::get(MODULES_ENV));

    if (this->debug)
    {
        // Logging isn't activated yet -- need to just print here
        printf(">>> %s=%s\n", HOME_ENV, applicationHome.c_str());
        printf(">>> %s=%s\n", RUNTIME_ENV, runtimePath.c_str());
        printf(">>> %s=%s\n", MODULES_ENV, modulePaths.c_str());
    }

    this->application = Application::NewApplication(applicationHome);
    if (this->application.isNull())
    {
        std::cerr << "Could not load the application at: " << applicationHome << std::endl;
        exit(__LINE__);
    }
    this->application->SetArguments(argc, argv);

    // Re-resolve module/runtime dependencies of the application so that the
    // API module can introspect into the loaded components.
    this->application->ResolveDependencies();
    if (!this->application->runtime.isNull())
    {
        this->application->runtime->version = PRODUCT_VERSION;
    }

    // Parse the module paths, we'll later use this to load all the shared-objects.
    FileUtils::Tokenize(modulePaths, this->modulePaths, KR_LIB_SEP, true);
}