Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shared_library support #2

Open
4 of 5 tasks
indutny opened this issue Jun 12, 2016 · 23 comments
Open
4 of 5 tasks

shared_library support #2

indutny opened this issue Jun 12, 2016 · 23 comments

Comments

@indutny
Copy link
Owner

indutny commented Jun 12, 2016

gyp.js currently supports static_library, executable, and none target_type, but shared_library is very important for Node.js addons! Therefore we need to support it in ninja.

Hints:

  • New ninja rule solink needs to be added here
  • This rule should be used there

Possible problems - many.

Support:

  • OS X
  • Windows
  • Linux
  • FreeBSD (needs verification, should work)
  • Others (needs verification, should work)
@indutny
Copy link
Owner Author

indutny commented Jun 12, 2016

Could be tested on https://github.com/indutny/llnode

@indutny
Copy link
Owner Author

indutny commented Jun 12, 2016

I'm going to take OS X support for this.

indutny added a commit that referenced this issue Jun 12, 2016
@indutny
Copy link
Owner Author

indutny commented Jun 12, 2016

OS X - done.

@indutny
Copy link
Owner Author

indutny commented Jun 13, 2016

Linux - appears to be working.

@indutny
Copy link
Owner Author

indutny commented Jun 13, 2016

I'm inclined to say that FreeBSD and other Unixes should work, but this needs a verification.

@indutny
Copy link
Owner Author

indutny commented Jun 17, 2016

Anyone wants to verify this?

@indutny indutny modified the milestone: stable Jun 17, 2016
@kapouer
Copy link

kapouer commented Jun 17, 2016

Hey i'd like to ! Could you tell me where i should start ? llnode seems to be something different.

@indutny
Copy link
Owner Author

indutny commented Jun 17, 2016

@kapouer thank you!

@pmed you said that you tested windows shared_library support on node.js addons, would you care to share some info on this with us? Thanks!

@indutny
Copy link
Owner Author

indutny commented Jun 17, 2016

@kapouer llnode may be a bit too complicated. However, if you want to give it a shot, the way to do it is:

  • Install node.js on the system
  • Install ninja from https://ninja-build.org/
  • npm install -g gyp.js
  • git clone git@github.com:indutny/llnode.git && cd llnode
  • Install lldb-3.8 or any lldb, and its headers (Honestly, I don't know how to do it on FreeBSD, or anywhere else except Mac and Linux)
  • run gyp -Icommon.gypi llnode.gyp
  • run ninja -C out/Release
  • ls -la out/Release
  • should have llnode.so

@indutny
Copy link
Owner Author

indutny commented Jun 17, 2016

Alright, I have pushed gyppies to the repo. So it should be possible to test this by just running npm test. Note that tests should be run from MSVS console on Windows, and the NINJA env variable should be set to the full path to ninja.exe.

@pmed
Copy link
Contributor

pmed commented Jun 18, 2016

@indutny, I've forked node-gyp to use gyp.js instead of gyp: https://github.com/pmed/node-gyp/tree/gyp.js

To build a native addon you just need a C++ compiler and Ninja installed. Visual C++ is used by default on Windows (my version of node-gyp tries to locate a VC++ version installed in the system).

And ninja executable should be in a PATH. Yoг can also set NINJA environment variable or set -ninja command line option for node-gyp to override the ninja location.

ps. I just saw you added platform.win.genEnvironment() that performs similar to findMSVS() function. Probably I would try to use your implementation.

@indutny
Copy link
Owner Author

indutny commented Jun 18, 2016

@pmed Fantastic!

@indutny
Copy link
Owner Author

indutny commented Jun 18, 2016

@pmed I have just pushed some fixes, and it appears that all npm tests pass on Windows, except the copy one.

@indutny
Copy link
Owner Author

indutny commented Jun 18, 2016

@pmed One more thought: what do you think about contributing your patch back to node-gyp, with gyp.js used under a command-line flag or env variable?

@indutny
Copy link
Owner Author

indutny commented Jun 18, 2016

See: nodejs/node-gyp#960

@pmed
Copy link
Contributor

pmed commented Jun 18, 2016

Yes, command-line flag to switch between gyp and gyp.js would be great. And I'd like to use gyp.js by default some time later 😄

The switch should be the same for the configure and build commands, so env.variable seems preferable.

@indutny
Copy link
Owner Author

indutny commented Jun 18, 2016

@pmed I would go with both, probably? Is it too hard to do it in an existing architecture?

Thanks for looking into it.

@pmed
Copy link
Contributor

pmed commented Jun 18, 2016

@indutny yes, both, with comman-line option and env var. It shouldn't be hard to keep branches both for gyp and gyp.js in configure and build commands.

I added the gyp.js dependency into node-gyp/package.json, and use gyp.main() on configure step. Build function spawns ninja -C build/Release (or build/Debug). On Windows build function in node-gyp invokes vcvarsall.bat $target_arch before ninja.

I can try to make a PR into node-gyp.

@indutny
Copy link
Owner Author

indutny commented Jun 18, 2016

Just run npm test on FreeBSD, everything appears to be working.

@refack
Copy link
Contributor

refack commented Feb 9, 2017

@indutny what would you consider "others"? sunos and aix-ppc?
I can try to compile on a raspberry-pi 2 running noobs, and on a MIPS32 OpenWRT machine

@refack
Copy link
Contributor

refack commented Feb 10, 2017

Well llnode was a wild goose chase, it doesn't compile cleanly on VS2015 with GYP... :(
But I was able to compile node.dll, anybody know who do you test it?

@indutny
Copy link
Owner Author

indutny commented Feb 12, 2017

@refack yeah solaris, aix, everywhere where node works.

@refack
Copy link
Contributor

refack commented Feb 13, 2017

Cracking up my emulator...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants