plantuml / plantuml

Generate diagrams from textual description
https://plantuml.com
Other
9.73k stars 881 forks source link

GraphViz Windows distribution #405

Open boessu opened 3 years ago

boessu commented 3 years ago

I have here a stripped version of graphviz dot (Windows). Yes, it is possible to make a stripped down version as GraphViz has a modular nature. A specific GraphViz distribution, only for plantuml, would have 982 kBytes (compared to ~26 mBytes including all parts, which aren't used by plantuml at all). Plantuml itself looks up on several places where the dot command is; including the env var GRAPHVIZ_DOT (pointing to dot.exe). I mainly had this need as I have to distribute an application including everything, which can be just unzipped somewhere (without admin rights) and works. That's possible that way and I think the future is more in that direction (see jdk 11+ modularity and JRE's out of jlink). So that doesn't work out of the box (yet) but is helpful if you try to make something like an "all inclusive" package with plantuml.jar.

Would it make sense to have something like "plantuml specific graphviz-distribuitions" somewhere or is it easier to just install graphviz on the system? Any interests? Where should that be placed?

arnaudroques commented 3 years ago

Sure, that's a good news ! If needed, we could create a new repository "graphviz-distribution" in https://github.com/plantuml and let you commit/push there. What do you think about it ?

boessu commented 3 years ago

Yes, that would be possible. Basically it is a zip archive. I guess the win32 version is enough? Is there a way to test the distribution through a set of (GraphViz dependent) plant graphics just to be sure it works (I guess a simple ant script would do that)?

arnaudroques commented 3 years ago

Yes, win32 is enough. About testing, I am not sure how to do. Usually, users are testing for us :-) Feel free to do whatever you want with https://github.com/plantuml/graphviz-distributions

boessu commented 3 years ago

Initial distribution uploaded. Feel free to test. ;-)

arnaudroques commented 3 years ago

Thanks for your file. We've just test it some Windows 10 and we have an error when launching "dot.exe" from command line. (0xc0000007b). Any idea ?

boessu commented 3 years ago

Thanks for the test. The reason for this was the missing library VCRUNTIME140.dll. This is not included in the msbuild but it's included in the cbuild of graphviz. That's a bit odd... but it seems as one of the weak spots of graphviz is it's installation process (see https://forum.graphviz.org/t/new-simplified-installation-procedure-on-windows/).
I didn't note that because this is a dll which is part of the visual studio developer package. There are programs which install that into their programming folder (as we should do), others do install them as separate package "Microsoft Visual C++ 20xx Redistributable (x86)", which places this file into the system folder. That's the reason why sometimes you have that file already (even a game sometimes installs this redistribution as part of its own installation) and especially a MS developer itself won't get that error, except he would test it on a plain vanilla Windows 10 BESIDE of his developer machine which has included such files anyway in the path (due to the VS installation).

The developers of graphviz make no secret of the fact that they are not very familiar with this area (apart from that I'm not that well versed in it either and I can't blame them; especially as the test to find this kind of errors is rather hard to do if you only have one Windows installation at home). Anyway... the new distribution has this DLL in it and should work. Please do me the courtesy to retest it ;-)

arnaudroques commented 3 years ago

Please do me the courtesy to retest it ;-)

We did, and it works fine ! This is really great.

Now I must say that the idea of integrating your .zip file inside plantuml.jar so that, on Windows, if no GraphViz installation is detected, PlantUML would unzip this archive to c:\windows\temp and launch dot.exe from there is very temptating. Very easy to implement for us. This way, people under Windows won't have to install GraphViz by themself (which is not that easy)

Would it be possible to reduce the footprint of this archive ?

The GraphViz build process is really a magic process to me, but maybe with some C compiler option ? Not also that many features of dot are unused by PlantUML. So you can remove png, ps, jpg, gif, vml... We really only need svg generation. Doing a dot -c on your build give me the impression that there is some possible improvement.

boessu commented 3 years ago

I'm not sure if that's possible. I think that's a question we should ask them directly. ;-)

I've uploaded a dependency overview: https://github.com/plantuml/graphviz-distributions/blob/main/GraphViz_Dependencies.puml As far as I understood that, the main program is gvc.dll (dot.exe is just a small wrapper to start that). The dll dependencies from there are all mandatory to run graphviz. The biggest is expat.dll for XML parsing. The plugins are the optional part, as they will be loaded with config6. I guess the plugins itself can't be substantially smaller. The most interesting plugin (which is obviously the dot layout engine) is the 2nd largest file.

By the way it seems as it is possible to load gvc.dll directly: https://graphviz.org/pdf/gv.3java.pdf. I guess their reason is their integration with SWIG:, which not only integrates Windows. Quite frankly I'm not a big fan of native integration, as this can kill your java process too if the native library crashes for whatever reason. That's also the reason why J2EE forbids that. But that depends on the case of course. There is the chance that a desktop application or microservice deployment would profit more than loosing. Of course this decision is up to you. :-)

arnaudroques commented 3 years ago

About using GraphViz as a library, we are doing something even creaziest : we are porting GraphViz sources to Java. It's a long term action (started 7 years ago !) but we are still working on it and we are confident that in some future (meaning few years...) we will get a full implementation of dot in Java.

In the meantime, we are asking users what they think about integrating your distribution in the main PlantUML.jar file.

We'll be what people will say...