enwi / dartzmq

A simple dart zeromq implementation/wrapper around the libzmq C++ library
https://pub.dev/documentation/dartzmq/latest/
MIT License
26 stars 17 forks source link

Brain-free installation #5

Closed Eerey closed 2 years ago

Eerey commented 2 years ago

I know it's kind of a huge task, but would it be theoretically possible to use ZeroMQ in Flutter without thinking about Android/Windows/iOS/Linux?

What steps would be necessary?

Would it be possible to distribute precompiled zeromq-Versions (.dll, .so etc) within this plugin?

Is it theoretically possible to transpile the ZeroMQ Code to Dart only?

We think this is an amazing plugin but we're really uncertain about the fact that you need to make sure that e.g. a precompiled .dll (windows) works on every machine (it does not).

enwi commented 2 years ago

Would it be possible to distribute precompiled zeromq-Versions (.dll, .so etc) within this plugin?

I have already looked into this and it is possible to do. It would make using the library for mobile platforms and desktops a lot easier. Here is some reference on how it can be done, but I did not have the time to implement it: https://groups.google.com/a/dartlang.org/g/misc/c/fyh2W38AEVo

Scylla2020 commented 2 years ago

I been struggling for hours trying to understand how creating a shared dll on windows works. It sounded like something that should be straightforward seeing the steps were omitted from the docs. Would you be able to share what exact steps to follow to create the shared dll for Windows 10? Like what file do we need to download from where, what commands are used to create the dll etc. Looks like an awesome plugin would love to get it to work. Thank you

Eerey commented 2 years ago

In my case, I did not compile it myself. I downloaded it somewhere and renamed it to the expected file name. This can be optimized in many ways and I struggled to find that out myself aswell.

enwi commented 2 years ago

@Scylla2020 You can find some instructions here

Scylla2020 commented 2 years ago

Oh great thanks let me have a look at the instructions,

enwi commented 2 years ago

Ultimately it would be best to distribute precompiled versions with this package. Then anyone who still wants a specific version can go through the trouble.

kevinelliott commented 2 years ago

I don't use Flutter. I was disappointed that I couldn't use this library since I'm Dart-only.

enwi commented 2 years ago

@kevinelliott Technically this should be possible, since there aren't any dependencies to Flutter afaik.

kevinelliott commented 2 years ago

@kevinelliott Technically this should be possible, since there aren't any dependencies to Flutter afaik.

The fact that it currently requires flutter SDK prevents this at the moment. Is there any way to allow for dart only?

enwi commented 2 years ago

I think it should be possible to convert this into a dart only package, though how would the different compiled libraries for different platforms be handled?

kevinelliott commented 2 years ago

I have seen packages listed that support both SDKs. I wonder how they do it.

On May 17, 2022, at 5:27 AM, Moritz Wirger @.***> wrote:

 I think it should be possible to convert this into a dart only package, though how would the different compiled libraries for different platforms be handled?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

enwi commented 2 years ago

Me too

rbebb commented 2 years ago

Is there any news on this effort? It would be so cool to have this as a Dart only package!

One-Nub commented 2 years ago

I have seen packages listed that support both SDKs. I wonder how they do it.

Just from skimming pubspec.yaml(s), this is usually just accomplished automatically by the site when a file only uses the SDK constraint under the environment field (so thus not requiring flutter). In the case of this package, I'm not sure how that would affect the other dependencies (specifically the dev_dependencies). I would guess removing flutter specific stuff would work in this case, but would just have to try it and see what happens.

Edit: Looks like that's exactly what @ach-ee did in his fork mentioned in issue #4 (His pubspec: https://github.com/ach-ee/dartzmq/blob/main/pubspec.yaml)

kevinelliott commented 2 years ago

Any update here?

enwi commented 2 years ago

I haven't had time to take a deeper look into this, but this might change in the upcoming days. I would also like to check if the changes in #4 improve the overall performance.

kevinelliott commented 2 years ago

Is there an easy way for me to override this in my own project so that I can at least move forward with development?

enwi commented 2 years ago

You can change the source code locally. If you use VS-Code it will display a warning, but until you update the dependencies and there is a new release of this library you should be fine.

Eerey commented 2 years ago

Is there any news on this effort? It would be so cool to have this as a Dart only package!

According to stackoverflow answers, it would also be possible to do it in dart only (no c++ involved): https://stackoverflow.com/questions/71127181/mimic-zeromq-sub-socket-in-a-pub-sub-system-with-e-g-socket-websocket-in-flut

But i guess it is a huge challenge and I'm not sure if it should be done after thinking about it, because it will be detached from the original repository.

enwi commented 2 years ago

@kevinelliott I removed the flutter dependencies, if you want you can try the new version

enwi commented 2 years ago

@Eerey @Scylla2020 it should now work for Windows and Android out of the box

enwi commented 2 years ago

@kevinelliott @rbebb @One-Nub With the change now the issue is that I have to include the Flutter dependency otherwise it does not work. It won't let me publish the package without it, because the platforms key requires it. I wonder if there is a solution for this. Other than that if you provide the ZeroMQ binary yourself it should work with dart only with a298137968251477faa6ecd759db32a3ed518800

plugin:
    platforms:
enwi commented 2 years ago

So we either need to find a workaround for the platforms key or we could split the code into two repositories, one with all the dart only code and one for flutter where it automatically includes the binaries

kevinelliott commented 2 years ago

I wonder if someone at https://github.com/dart-lang or https://github.com/flutter could chime in with the best practice here.

Scylla2020 commented 2 years ago

@enwi Thanks for this! I'll give it a go