Giter Club home page Giter Club logo

Comments (2)

ardera avatar ardera commented on September 13, 2024

Looking at the gpiod plugin, it looks like a dart package (no native code) combined with a gpiod.c file in the plugins folder.

Exactly, a flutter-pi plugin is just:

  • a dart package for the dart-side implementation
  • typically, a my_plugin.c file inside src/plugins and a my_plugin.h file inside include/plugins (if you need more files, just create a my_plugin folder inside src/plugins and include/plugins which contains your plugin source files)
  • some code inside src/plugin_registry.c to make your plugin known to the plugin registry
  • of course, you also need to update the Makefile so it compiles your src/plugins/my_plugin.c file

It's also "convention" to implement a flag, like BUILD_MY_PLUGIN, so people can choose when compiling flutter-pi whether your plugin should be built and included in the finished binary. (To be more precise, the BUILD_MY_PLUGIN flag should do nothing more than enable/disable the registration of your plugin to the plugin_registry, see here and here)

What are the steps necessary to link and build the .c file and make flutter-pi aware of new plugins?

So, in practice, you'll have to add 6 lines to pluginregistry.c to make your plugin known to flutter-pi:

// my_plugin.h should contain the definitions of `my_plugin_init`
// and `my_plugin_deinit`
#ifdef BUILD_MY_PLUGIN
#    include <plugins/my_plugin.h>
#endif

// . . .

struct flutterpi_plugin hardcoded_plugins[] = {

// . . . the other plugins' registrations here

#ifdef BUILD_MY_PLUGIN
    {.name = "my_plugin", .init = my_plugin_init, .deinit = my_plugin_deinit},
#endif
};

Then you need to update the Makefile so your plugin gets built:

  1. Add src/plugins/my_plugin.c to the definition of the SOURCES variable
  2. Add the -DBUILD_MY_PLUGIN c-flag to the definition of the REAL_CFLAGS variable

from flutter-pi.

mortenboye avatar mortenboye commented on September 13, 2024

Perfect, works! Thanks, closing...

from flutter-pi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.