animetosho / Nyuu

Flexible usenet binary posting tool
224 stars 32 forks source link

Why don't use pkg instead of nexe for compiling Nyuu into a single binary? #68

Closed Uukrull closed 2 years ago

Uukrull commented 4 years ago

I couldn't use nexe to compile and .exe for Windows with node 12.14.00 (I wanted to use the --connection-threads option that requires NodeJS >= 11.7), so I tried pkg and it worked without problems as long as yencode.node is supplied with the .exe

As a bonus, a Mac OS version could be easily added if someone compiles yencode.node for it.

Regards

animetosho commented 4 years ago

Thanks for the suggestion!

To answer the question, I'm not sure it was around when I was looking for a build system (early 2017). I did also prefer building with older versions of Node for smaller executable sizes, though I don't care so much about it these days, as Nyuu does now use some functionality in newer Node (like threading, as you mentioned).

I'm looking to release a new version in the near future, so can certainly look into a different build system. nexe may still work, it's just that the current build script targets an old version of it.
I try to build a fully static executable with the native extension (.node file) compiled into the Node binary itself, so it may be a little trickier than what most build tools do out of the box.

Uukrull commented 4 years ago

I compiled versions for Windows, Linux and OS X with pkg and node 12.14 and all you need to do is add this to the package.json:

  "pkg": {
    "assets": [
      "help.txt",
      "help-full.txt"
    ]  
  }, 

and put the yencode.node besides the executable.

animetosho commented 4 years ago

Thanks for the suggestion and info.

I've spent a bit longer looking at this, but am not sure pkg is exactly what I want. It seems that pkg is primarily aimed at packaging the application (as the name would suggest), however I'm looking more for a compilation tool. If you look at the nexe script used here, it patches the source code in a few ways, before building (such as removing exported functions to reduce the size of the final binary).
I do also try to have a fully static binary which has no external .node files, so some patching is also required there.

It's probably possible to do some of this with pkg, but the general sense I get is that it's meant to be a simple tool to do basic things, as opposed to aiming to allow this kind of build customization.