Page 2 of 2

Re: MicroPython package (module!) manager ideas

Posted: Thu May 01, 2014 6:49 pm
by stijn
Building outside the tree is possible though: it's a matter of including the necessary headers and then linking against the main executable, the linker's happy with that. That's still a couple of steps away from loading the lib built like that, but eg if you want simple plugin-style external functionality without having to recompile uPy you could have all your external libs export a function init() or so, then add sunctionality in main() or in the core lib to dlopen/LoadLibrary, followed by dlsym/GetProcAddress to get the init() function and run it. Just tried this and it works.

Re: MicroPython package (module!) manager ideas

Posted: Thu May 01, 2014 7:02 pm
by pfalcon
That works, and trivial to do on Linux (or more exactly, with ELF binaries format), even using "ffi" module. I doubt that would work on Windows due to funky DLL import handling. So, one would need to define "API dispatch table" to get around binary file format differences. But hard problem is not that table, but what to put into it - more specifically, what constitutes uPy "public API". There's no such, or more exactly, all uPy API is currently public and unstable - so bin modules are not going to work unless freshly complied by yourself. And then, not to forget that uPy is bare-metal project first of all, so whoever wants to add dynamic module support to *uPy* (and not random port-specific hack), should think about bare-metal ports. Not too hard to deal with either - "just" learn how to build completely PIC code for all possible and impossible platforms and write converter from ELF to much more simple bin format. But as I told, nobody volunteered to work on all these "exciting" tasks.