Well, I asked people to help me build a puzzle - and they helped me place one or another piece. And when I was done, I wanted to show how I completed it…for me, that is part of the concept of Open Source; sharing experience. :) Glad you apriciate that move! Am Do. Jan. 16 2014 21:12:45 schrieb Charlie McConnell:
> I really like how you asked the mailing list how to do this, figured it out, > and then posted a detailed tutorial. > > THIS is how this list should be used! > > Good work. > > -- > Charlie McConnell > > > On Thu, Jan 16, 2014, at 11:22 AM, Kevin Ingwersen wrote: >> Hey hey! >> >> I just did some reeeeally cool find-out that I am really happy about - and >> since, I want to share that too! :3 >> >> Caution: Make sure you have your toolchai (Xcode, gcc, MSYS, …) ready to >> use and a copy of the latest nodejs source code. I myself am using v0.10.24. >> >> Okay, let’s go. >> >> >> 1. Your module or addon needs preparation. >> Usual JS modules will work nicely, but…you need to make sure that you dont >> use too many modules. The ultra-basic require you will be having does not >> have all the functions you may expect. The in-binary require function seems >> to only look up actual filenames. In example, using require(„myFile“) will >> result in an internal lookup for myFile.js . Therefore, make sure your JS >> module is not using path-wise lookups - and especially, no subfolders. >> Subfolders simply dont exist in memory ;) >> >> If you have a native addon, then you need to change your entry-code’s >> NODE_MODULE declaration. If it looked like this before: >> >> NODE_MODULE(ph7, InitAll) >> >> Then you now need to make it look like this: >> >> NODE_MODULE(node_ph7, InitAll) >> >> >> You’re best off by creating a copy of your module entirely, so you aren’t >> modifying your working copies. >> >> >> 2. Telling GYP about the new files >> Open node.gyp in a text editor, and locate the section named library_files. >> This is a long JSON array, and at the bottom, add your module files. I >> recommend creating a new folder called extra/ and placing your stuff inside >> there. And very importantly, you need to add a very special file to the list: >> >> 'lib/_third_party_main.js', >> >> This file will be called instead of nodejs’ main() function. As it does not >> exist, you may comment out this entry for now - but we’ll need it later. I >> have NOT tested this without this file - for now, I am just assuming you >> want your script to run always when the binary is launched, and want to pull >> the several moduels form within the binary itself. >> After you filled this array, it’s time you fill up the native addon array - >> that is, if you have one. In my case, I do. So, to do so, locate sources, >> and add your sources at the bottom. If your souces need a custom include >> path, then you also need to edit include_dirs. >> >> >> 3. Telling the node-code to use your native addon (Not required if you dont >> use one) >> If you use a native addon, you must edit just one single file: >> src/node_extensions.h . The way it needs to be done should be ultra-obvious. >> But maybe I should explain anyway: This file contains a list of all the >> „internal extensions“. You may recognize, that all of them are prefixed with >> node_. That is a prefix to mark it as internal - and which is why I told you >> to change your native addon’s NODE_MODULE call too. So in that list, add >> your addon just like any other - save, exit. >> >> 4. Building. >> Now, after you added your sources, library_files, include_dirs and the like, >> you should have a nice GYP file. So, return to the nodejs source tree’s >> root, and run ./configure >> Now you can use whatever you want to. In my case, i used —ninja, and then >> typed: ninja -C out/Release >> Once you finished building, locate the new binary. If building and running >> seems okay, then it’s time to do some really cool things! >> >> 5. Implentation time! >> Before, I was telling you about _third_party_main.js. Now, this doesnt >> really exist so far. So what we now do, is create it. You may have commented >> it out previously (by putting a hashtag infront of it, like all the cool >> twitter kids do :p), but you may now uncomment it in node.gyp. Then, type: >> touch lib/_third_party_main.js >> Now you can open that file - and edit it. >> Note: Please consider the following: >> - require() only looks up the filenames inside the binary - but no folders, >> or subfolders, or the like. This is a semi-low-level JS you are doing here. >> You can still interact with files and everything else like normal, but >> require acts a bit different than usual. >> - To link against your native addon, use process.binding(). I,e,: var ph7 = >> process.binding(„ph7“); >> The name you have to give in, is the same as the one in NODE_MODULE, just >> without the node_ prefix. >> Once you are done, rebuild and test. >> >> DONE :D >> >> Again, this is more an experiment and soemthing i JUST learned. But I saw >> projects such as nexe - and i just felt like sharing what I figured out - it >> could be useful to them. If we can programaticaly edit node.gyp and >> node_extensions.h, then we actually can patch a source tree in order to >> allow „native modules“. I am still testing this thing myself, but it surely >> is something quite interesting. I also haven’t seen process.binding within >> the API docs or the like. I had to read it off lib/os.js :p >> >> Have fun with that lil thing! :D >> >> Kind regards, Ingwie. >> >> >> -- >> -- >> Job Board: http://jobs.nodejs.org/ >> Posting guidelines: >> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines >> You received this message because you are subscribed to the Google >> Groups "nodejs" group. >> To post to this group, send email to nodejs@googlegroups.com >> To unsubscribe from this group, send email to >> nodejs+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/nodejs?hl=en?hl=en >> >> --- >> You received this message because you are subscribed to the Google Groups >> "nodejs" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to nodejs+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > > -- -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.