5HT / fs

📁 FS: Windows, Linux, Mac Driver
https://fs.n2o.dev
Other
235 stars 69 forks source link

Include the precompiled Windows executable in priv #3

Closed josevalim closed 9 years ago

josevalim commented 9 years ago

First off, thanks for the great tool! @chrismccord has done some experiments to integrate fs with Phoenix live reload and now we have changes instantly propagating to the browser as soon as we save an asset or Elixir file to disk.

That said, we are planning to move ahead and make this project a Phoenix dependency. Our biggest pain point though has been Windows support. There are a couple issues:

  1. Mix (Elixir build tool) integrates with Rebar but it doesn't support hooks (so we can't effectively compile it on Windows)
  2. Even if we could somehow work around this limitation, the Windows process is prone to failures and depends on the environment you are running it (the current process seems to work for cygwin only).

However, I realized the Windows executable is not a port and it does not rely on the Erlang runtime. So I wondered, why not ship the precompiled windows executable inside priv? The .exe file is only 15Kb and this seems to be a fairly low price to pay to ensure compatibility across the board. :)

If you agree, I will gladly to send a PR.

Thanks!

5HT commented 9 years ago

Hi, Jose!

Having fs working without any additional packages or ports is a dream. The problem is that on linux you need to include dependency on inotifywait packages. Obviously you can't include binary for all architectures. That's why we don't promote binaries to repositories, because anyway on Linux you should compile first to be sure it runs on your platform. The good thing is that Linux provides the inotify-tools package. So the same thing should be on other platforms, like Windows.

All back-end drivers are implemented as erlang ports with erlang:open_port/2. We do have support of Windows in latest PR from https://github.com/sergej-klimenko/fs/commit/4bbd5021d8de1ee64d0dbaee0fa3a6e755aa2efa The only thing you need is to draft mix project file for fs which I could include in fs root directory.

Anyway you could draft your PR and I will comment on it further.

josevalim commented 9 years ago

Exactly. Linux already has fantastic support, most distributions have inotify-tools as a package and installing is easy. On Mac, rebar covers the compilation quite well.

On Windows though, we would need to provide at least two Makefiles, one for cygwin and another for Visual Studio, do environment checks to be sure which Makefile to invoke and so on. I have been down that road and it is not pretty, so it is easier to ship with the precompiled version. For that, I have opened a pull request here: #4.

I will open up another pull request for Mix later. I will try to get rid of the other c-dependency though. :)

5HT commented 9 years ago

I leaved pre hooks, cos we need it in production CI.

5HT commented 9 years ago

I have been down that road and it is not pretty

You can show me, I can apply this to fs. Anyway if users want to build themselves they should be able. binary will still be provided.

josevalim commented 9 years ago

Sure! If you are curious, for non-cygwin, you need to provide a Makefile.win and invoke it with nmake. Here is an example from the markdown project:

https://github.com/devinus/markdown/blob/master/Makefile.win

And here is how we invoke it:

https://github.com/devinus/markdown/blob/master/mix.exs#L6

5HT commented 9 years ago

Cool I will apply this to fs later, thanks.