ThisIsNotRocketScience / GerberTools

Tools to load/edit/create/panelizer sets of gerber files
MIT License
725 stars 144 forks source link

Fix build on linux #128

Open positron96 opened 3 years ago

positron96 commented 3 years ago

This patch

dromer commented 3 years ago

Is there a specific mono version needed? Running this branch fix-build-on-linux on Debian Buster I get (large paste incoming) Using Mono JIT compiler version 5.18.0.240

[edit: wrong mono version. trace removed]

dromer commented 3 years ago

Ok, installed latest mono from their official repositories and then the build is fine :)

Now to figure out how to run these binaries again ..

CRImier commented 3 years ago

once you figure out how to run them, I would be willing to help test this - try to compile it myself, make some panels and see if anything breaks

dromer commented 3 years ago

Hmmm, I'm trying to run the panelizer with mono GerberPanelizer/bin/Debug/GerberPanelizer.exe and it briefly opens a window and then closes again. After a number of times I see some output in the shell that is maybe useful for debugging:

dreamer@auditorium:~/Sources/_downloads/positron_GerberTools$ mono GerberPanelizer/bin/Debug/GerberPanelizer.exe
dreamer@auditorium:~/Sources/_downloads/positron_GerberTools$ mono GerberPanelizer/bin/Debug/GerberPanelizer.exe
dreamer@auditorium:~/Sources/_downloads/positron_GerberTools$ mono GerberPanelizer/bin/Debug/GerberPanelizer.exe
dreamer@auditorium:~/Sources/_downloads/positron_GerberTools$ mono GerberPanelizer/bin/Debug/GerberPanelizer.exe
dreamer@auditorium:~/Sources/_downloads/positron_GerberTools$ mono GerberPanelizer/bin/Debug/GerberPanelizer.exe
dreamer@auditorium:~/Sources/_downloads/positron_GerberTools$ mono GerberPanelizer/bin/Debug/GerberPanelizer.exe

Unhandled Exception:
System.Exception: Generic Error [GDI+ status: GenericError]
  at System.Drawing.GDIPlus.CheckStatus (System.Drawing.Status status) [0x00079] in <613602aa03b748a88cf528e491396273>:0 
  at System.Drawing.Graphics.DrawLine (System.Drawing.Pen pen, System.Int32 x1, System.Int32 y1, System.Int32 x2, System.Int32 y2) [0x00025] in <613602aa03b748a88cf528e491396273>:0 
  at (wrapper remoting-invoke-with-check) System.Drawing.Graphics.DrawLine(System.Drawing.Pen,int,int,int,int)
  at System.Windows.Forms.ThemeWin32Classic.CPDrawBorder3D (System.Drawing.Graphics graphics, System.Drawing.Rectangle rectangle, System.Windows.Forms.Border3DStyle style, System.Windows.Forms.Border3DSide sides, System.Drawing.Color control_color) [0x0036a] in <a0f8b82443494dec9b517126f4032efe>:0 
  at System.Windows.Forms.ThemeWin32Classic.CPDrawBorder3D (System.Drawing.Graphics graphics, System.Drawing.Rectangle rectangle, System.Windows.Forms.Border3DStyle style, System.Windows.Forms.Border3DSide sides) [0x0000c] in <a0f8b82443494dec9b517126f4032efe>:0 
  at System.Windows.Forms.ControlPaint.DrawBorder3D (System.Drawing.Graphics graphics, System.Drawing.Rectangle rectangle, System.Windows.Forms.Border3DStyle style, System.Windows.Forms.Border3DSide sides) [0x00005] in <a0f8b82443494dec9b517126f4032efe>:0 
  at System.Windows.Forms.ControlPaint.DrawBorder3D (System.Drawing.Graphics graphics, System.Drawing.Rectangle rectangle, System.Windows.Forms.Border3DStyle style) [0x00000] in <a0f8b82443494dec9b517126f4032efe>:0 
  at System.Windows.Forms.XplatUIX11.GetMessage (System.Object queue_id, System.Windows.Forms.MSG& msg, System.IntPtr handle, System.Int32 wFilterMin, System.Int32 wFilterMax) [0x015d5] in <a0f8b82443494dec9b517126f4032efe>:0 
  at System.Windows.Forms.XplatUI.GetMessage (System.Object queue_id, System.Windows.Forms.MSG& msg, System.IntPtr hWnd, System.Int32 wFilterMin, System.Int32 wFilterMax) [0x00000] in <a0f8b82443494dec9b517126f4032efe>:0 
  at System.Windows.Forms.Application.RunLoop (System.Boolean Modal, System.Windows.Forms.ApplicationContext context) [0x0034e] in <a0f8b82443494dec9b517126f4032efe>:0 
  at System.Windows.Forms.Application.Run (System.Windows.Forms.ApplicationContext context) [0x00011] in <a0f8b82443494dec9b517126f4032efe>:0 
  at System.Windows.Forms.Application.Run (System.Windows.Forms.Form mainForm) [0x00006] in <a0f8b82443494dec9b517126f4032efe>:0 
  at GerberCombinerBuilder.Program.Main () [0x00036] in <d371e122ebcb4583863a2b80c121c8d5>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.Exception: Generic Error [GDI+ status: GenericError]
  at System.Drawing.GDIPlus.CheckStatus (System.Drawing.Status status) [0x00079] in <613602aa03b748a88cf528e491396273>:0 
  at System.Drawing.Graphics.DrawLine (System.Drawing.Pen pen, System.Int32 x1, System.Int32 y1, System.Int32 x2, System.Int32 y2) [0x00025] in <613602aa03b748a88cf528e491396273>:0 
  at (wrapper remoting-invoke-with-check) System.Drawing.Graphics.DrawLine(System.Drawing.Pen,int,int,int,int)
  at System.Windows.Forms.ThemeWin32Classic.CPDrawBorder3D (System.Drawing.Graphics graphics, System.Drawing.Rectangle rectangle, System.Windows.Forms.Border3DStyle style, System.Windows.Forms.Border3DSide sides, System.Drawing.Color control_color) [0x0036a] in <a0f8b82443494dec9b517126f4032efe>:0 
  at System.Windows.Forms.ThemeWin32Classic.CPDrawBorder3D (System.Drawing.Graphics graphics, System.Drawing.Rectangle rectangle, System.Windows.Forms.Border3DStyle style, System.Windows.Forms.Border3DSide sides) [0x0000c] in <a0f8b82443494dec9b517126f4032efe>:0 
  at System.Windows.Forms.ControlPaint.DrawBorder3D (System.Drawing.Graphics graphics, System.Drawing.Rectangle rectangle, System.Windows.Forms.Border3DStyle style, System.Windows.Forms.Border3DSide sides) [0x00005] in <a0f8b82443494dec9b517126f4032efe>:0 
  at System.Windows.Forms.ControlPaint.DrawBorder3D (System.Drawing.Graphics graphics, System.Drawing.Rectangle rectangle, System.Windows.Forms.Border3DStyle style) [0x00000] in <a0f8b82443494dec9b517126f4032efe>:0 
  at System.Windows.Forms.XplatUIX11.GetMessage (System.Object queue_id, System.Windows.Forms.MSG& msg, System.IntPtr handle, System.Int32 wFilterMin, System.Int32 wFilterMax) [0x015d5] in <a0f8b82443494dec9b517126f4032efe>:0 
  at System.Windows.Forms.XplatUI.GetMessage (System.Object queue_id, System.Windows.Forms.MSG& msg, System.IntPtr hWnd, System.Int32 wFilterMin, System.Int32 wFilterMax) [0x00000] in <a0f8b82443494dec9b517126f4032efe>:0 
  at System.Windows.Forms.Application.RunLoop (System.Boolean Modal, System.Windows.Forms.ApplicationContext context) [0x0034e] in <a0f8b82443494dec9b517126f4032efe>:0 
  at System.Windows.Forms.Application.Run (System.Windows.Forms.ApplicationContext context) [0x00011] in <a0f8b82443494dec9b517126f4032efe>:0 
  at System.Windows.Forms.Application.Run (System.Windows.Forms.Form mainForm) [0x00006] in <a0f8b82443494dec9b517126f4032efe>:0 
  at GerberCombinerBuilder.Program.Main () [0x00036] in <d371e122ebcb4583863a2b80c121c8d5>:0 
positron96 commented 3 years ago

Strange, I do mono ./GerberPanelizer.exe and it launches fine. My OS is Ubuntu 18.04.5, mono installed via official mono's instrunctions.

positron96 commented 3 years ago

Upon closer inspection, while GerberPanelizer is running, something is still broken. Here are Windows and Ubuntu screenshots of exact same exe: image image

Surprisingly, it works fine with that side panel not showing. I can drag-and-drop ZIP archive from ubuntu's file manager (thunar, BTW) and move the outlines over work area. After that, I can export the panel succesfully.

positron96 commented 3 years ago

@dromer Also, I forgot to mention that I have Xubuntu, not prestine Ubuntu. Maybe xfce does not mess with mono's graphics like debian does. Anyway, looking at your logs, I am not sure if it's mono's problem or this project's problem. The exception is deeply inside mono. Maybe wine+dotnet or wine+mono can help in your case?

dromer commented 3 years ago

Mess with mono's graphics? o.O I am using the proprietary nvidia driver, which could give issues with graphics maybe.

mono --debug GerberPanelizer.exe doesn't give me anything btw.

Not sure why I'd need wine to run native code though. Anyway, hope we get these tools working on linux at some point :)

positron96 commented 3 years ago

And I'm running Ubuntu in VirtualBox, so, not nvidia drivers.

positron96 commented 3 years ago

So, I've also figured what's going on with resx files, "XOR data length expected" errors and stuff: base64 data inside resx files encodes ICO files that contain PNG files inside them. Mono apparently does not handle them (https://xamarin.github.io/bugzilla-archives/30/30715/bug.html), while MS's .Net does. The current "fix" is to replace mimetype of these entries from mimetype="application/x-microsoft.net.object.bytearray.base64" into mimetype="application/x-microsoft.net.object.binary.base64". However, this just disables compiling of these resources, so mono compiles the project, but the icons are not shown at all. (Hopefully, compilation under Windows would still decode this correctly, it needs to be checked). The correct fix is to extract the ICO files from resx, convert them into ICOs with ordinary bitmaps inside (I've tried https://redketchup.io/icon-editor ) and re-embed the files into resx. Mimetype should be left as bytearray.

All of this applies only to icons. There are Bitmaps in resx files that are also encoded as bytearray.base64, those work fine as-is since they are not ICOs.

Another major problem is that side dock panel of e,g, GerberPanelizer is not shown on linux. This is probably unsolvable, since the library is Win-only (https://github.com/ThisIsNotRocketScience/GerberTools/issues/71#issuecomment-455454543, https://sourceforge.net/p/dockpanelsuite/discussion/402316/thread/ea083210/).

taotieren commented 3 years ago

Hi, What should I do if I want to package GerberTools into an application under Linux?

positron96 commented 3 years ago

@taotieren it entirely depends on what you mean by "package" and what parts of GerberTools you need. As mentioned above, some components (e.g. Panelizer) are still not usable.

taotieren commented 3 years ago

@taotieren it entirely depends on what you mean by "package" and what parts of GerberTools you need. As mentioned above, some components (e.g. Panelizer) are still not usable.

When will it be merged into the main repo?