Skip to content

Commit

Permalink
core - add git to ffi
Browse files Browse the repository at this point in the history
  • Loading branch information
shdwmtr committed Jun 25, 2024
1 parent 5d4dc21 commit 0d2657e
Show file tree
Hide file tree
Showing 7 changed files with 392 additions and 214 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ set(SOURCE_FILES
"src/sys/io.cc"
"src/sys/settings.cc"
"src/api/executor.cc"
"src/deps/module.cc"
"src/git/git.cc"
"src/ftp/serv.cc"
)

Expand Down
61 changes: 59 additions & 2 deletions src/api/executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <sys/locals.h>
#include <core/hooks/web_load.h>
#include <core/co_initialize/co_stub.h>
#include <git/git.h>

PyObject* GetUserSettings(PyObject* self, PyObject* args)
{
Expand Down Expand Up @@ -248,23 +249,79 @@ PyObject* EmitReadyMessage(PyObject* self, PyObject* args)
return PyBool_FromLong(true);
}


PyObject* CloneRepository(PyObject* self, PyObject* args)
{
const char* repositoryUrl;
const char* destinationPath;

if (!PyArg_ParseTuple(args, "ss", &repositoryUrl, &destinationPath))
{
return NULL;
}

return PyLong_FromLong(DistributedGit::CloneRepository(destinationPath, repositoryUrl));
}

PyObject* PullRepoHead(PyObject* self, PyObject* args)
{
const char* localPath;

if (!PyArg_ParseTuple(args, "s", &localPath))
{
return NULL;
}

return PyLong_FromLong(DistributedGit::UpdateRepository(localPath));
}

PyObject* GetRepoCommit(PyObject* self, PyObject* args)
{
const char* localPath;

if (!PyArg_ParseTuple(args, "s", &localPath))
{
return NULL;
}

return PyUnicode_FromString(DistributedGit::GetLocalCommit(localPath).c_str());
}

PyObject* IsRepository(PyObject* self, PyObject* args)
{
const char* localPath;

if (!PyArg_ParseTuple(args, "s", &localPath))
{
return NULL;
}

return PyBool_FromLong(DistributedGit::IsRepository(localPath));
}

PyMethodDef* GetMillenniumModule()
{
static PyMethodDef moduleMethods[] =
{
{ "ready", EmitReadyMessage, METH_NOARGS, NULL },

{ "add_browser_css", AddBrowserCss, METH_VARARGS, NULL },
{ "add_browser_js", AddBrowserJs, METH_VARARGS, NULL },
{ "remove_browser_module", RemoveBrowserModule, METH_VARARGS, NULL },

{ "ready", EmitReadyMessage, METH_NOARGS, NULL },

{ "get_user_settings", GetUserSettings, METH_NOARGS, NULL },
{ "set_user_settings_key", SetUserSettings, METH_VARARGS, NULL },
{ "version", GetVersionInfo, METH_NOARGS, NULL },
{ "steam_path", GetSteamPath, METH_NOARGS, NULL },
{ "call_frontend_method", (PyCFunction)CallFrontendMethod, METH_VARARGS | METH_KEYWORDS, NULL },

// private function members
{ "change_plugin_status", TogglePluginStatus, METH_VARARGS, NULL },
{ "get_repo_commit", GetRepoCommit, METH_VARARGS, NULL },
{ "pull_repo_head", PullRepoHead, METH_VARARGS, NULL },
{ "clone_repo", CloneRepository, METH_VARARGS, NULL },
{ "is_repository", IsRepository, METH_VARARGS, NULL },

{NULL, NULL, 0, NULL} // Sentinel
};

Expand Down
2 changes: 2 additions & 0 deletions src/core/co_initialize/co_stub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ const void CoInitializer::InjectFrontendShims(uint16_t ftpPort, uint16_t ipcPort

backendHandler.Listen(BackendCallbacks::eEvents::CB_BACKENDS_READY, [ftpPort, ipcPort]()
{
Logger.Log("Backend listener fired.");

static uint16_t m_ftpPort = ftpPort;
static uint16_t m_ipcPort = ipcPort;

Expand Down
7 changes: 0 additions & 7 deletions src/deps/deps.h

This file was deleted.

Loading

0 comments on commit 0d2657e

Please sign in to comment.