It was Mat Sutcliffe who sent me a patch to compile node.js with mingw last weekend, if I recalled node.js used to be compilable with mingw via scons but apparently they switch to gyp entirely and mingw support became broken since then. I though it was a bit weird to sent it to me, but it turn out the process would involve msys python (needed by gyp to work properly).
The patch itself is a win-win solution as it will build native win32 binary but with support for posix path (MSYS and CYGWIN) via generic mount mechanism. He further explain why he choose mount over cygpath, that is because node.js operate asynchronously so by using mount path would settled once rather repeatedly as with cygpath.
This is binary of node.js 0.10.12 (built as ./configure --gdb --without-etw --without-perfctr)
nodejs-0.10.12.7z
original patch for mingw by Mat -> replace msysmnt with mount
modified patch for mingw-w64
python msys
The functionality is implemented in path.js which is bundled inside the executable. So actually you could modify (if you wish) that part (look for mingwToWindowsPath) with your favorite hex editor if you don't want to recompile. Just make sure you don't add and reduce the string block length. Or if you think mingw is such mundane task feel free to apply patch only to path.js and then compile it with M$VS as usual :-)
How to build with mingw:
1. extract the source file for node.js homepage
2. download python for msys and extract to msys installation
3. download one of appropriate patches (above) put in source tree
3. start mingw, navigate to source tree and apply patch
4. ./configure [your options] (make sure that python for msys is the active one)
5. python tools/gyp_node -f make
6. LINK=g++ make -C out BUILDTYPE=Release V=1
Notes:
- I'm not sure about etw and perfctr whether those compilable with mingw but both don't compile out of box.
- The download is contain official installation hierarchy with node.exe replaced. Since it's not installer (it make no sense anyway) I'll assume you know what to do next ;-)
Enjoy!
Thanks for the peer review and for providing a place to host this. It's worth pointing out that the changes I made to path.js are an ugly hack using synchronous I/O, albeit amortized, so if you want to use Node for serious network services work you might want to look to do this in a different way - maybe by adding the POSIX path support to libuv instead. My application was not speed critical, so for my use case it didn't matter, I just needed the easiest way to get it working. And you can still build Node without any path-related changes; it simply won't understand absolute POSIX paths.
ReplyDelete