Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a plugin system #4

Open
vgvassilev opened this issue Apr 5, 2023 · 3 comments
Open

Implement a plugin system #4

vgvassilev opened this issue Apr 5, 2023 · 3 comments

Comments

@vgvassilev
Copy link
Contributor

Xeus-cpp should be able to attach clang-repl and other plugins such as clad or cppyy. We should investigate and implement plugin-system which is friendly to package managers.

@SylvainCorlay, you had a concrete proposal for directory structure that we wanted to adopt. Could you spell it out here?

cc: @alexander-penev, @grimmmyshini

@SylvainCorlay
Copy link
Collaborator

The way I would go about it is the following:

Each clang-repl plugin provides a shared object (dynamic library) installed in the standard location ($PREFIX/lib most typically) providing a standardized API, for example a load(xcpp::interpreter&) free function to be invoked upon starting the plugin.

Each plugin gets installed with a "manifest" in $PREFIX/share/xeus-cpp/plugins.d in the form of a JSON file providing information about the plugin (the name of the dynamic library to be loaded, and metadata such as a description).

const char* name = plugins["clad"];      // get the library to be loaded for the clad plugins 
void* handle = dlopen(name);             // load the library
if (handle != NULL)
{
    func* setup = dlsym(handle, "load");
    if (load != NULL)
    {
        int ret = setup(interpreter);     // setup the plugin, passing e.g. the interpreter instance to the setup function.
        return 0;
    }
}
return 1;

This can obviously be a lot more advanced. Plugins can provide more functions, be listed by listing the items in the plugins.d directory. Installing a plugin is done by placing files in the installation prefix, so that it can easily be done via a package manager.

@vgvassilev
Copy link
Contributor Author

@SylvainCorlay, in our last meeting you said you already had implementation of that system for some other project. If it is open source could you point it to us as it seems that @mvassilev wants to look into this issue.

@SylvainCorlay
Copy link
Collaborator

Hey @vgvassilev. The timing is almost perfect. @DerThorsten just pushed out the first replease of xplugin.

@vgvassilev vgvassilev mentioned this issue Aug 1, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants