Closed unsuitable001 closed 3 years ago
CC @mannprerak2 @dcharkes
See https://github.com/dart-lang/sdk/issues/36712. In general we don't have a solution for non-Dart source code or compiled binaries in packages yet. I'm working on it.
If you are in Dart standalone mode and running in JIT (dart
), and not AOT (dart compile exe
) you can find the folder of your source package with: https://api.dart.dev/stable/2.2.0/dart-isolate/Isolate/packageConfig.html
Stay tuned on the SDK issue for a proper solution.
What if we place the C wrapper source under lib/src/wrapper
for now? That's what we did with ffigen when it used a wrapper.
Files were on lib/src/wrapper
previously. Though I'll try again. Locally, the current solution I have works. But, not from git.
I'll also try that tflite
package's approach.
Overall, what I've planned is, if this package is added as a dependency, people can run a command (just like ffigen
) and that will build the wrapper and copy it to the actual project's root directory. (And, maybe we can also download cronet binaries in the same way)
Issue fixed :). Thank you @mannprerak2 and @dcharkes Before closing this issue, I'm going to link some resources for future references and others in need.
I got the idea from: https://github.com/dart-lang/ffigen/blob/ed21cf5392ab9980947d838d0432efa65582f67d/lib/src/find_resource.dart
Other critical resources: https://github.com/dart-archive/tflite_native/tree/master/lib/src https://github.com/dart-lang/sdk/issues/36712 https://github.com/am15h/tflite_flutter_plugin
When I was adding this library to another dart project from local file system, shell scripts and C/C++ source files from the
bin
folder were also accessible. The moment I switched togit
dependency, it stopped working.Current solution in my head: Use the dart file under bin to download necessary files from the repo and do it's job.
It will be great if there's a way to also include non-dart files in
bin
folder.