Skip to content

Implement a plugin system #4

Open
@vgvassilev

Description

@vgvassilev

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

Activity

SylvainCorlay

SylvainCorlay commented on Apr 5, 2023

@SylvainCorlay
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

vgvassilev commented on Aug 2, 2023

@vgvassilev
ContributorAuthor

@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

SylvainCorlay commented on Aug 2, 2023

@SylvainCorlay
Collaborator

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

linked a pull request that will close this issue on Apr 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Implement a plugin system · Issue #4 · compiler-research/xeus-cpp