8000 Add Node 7.x aka V8 5.2+ support by p2k · Pull Request #968 · swig/swig · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add Node 7.x aka V8 5.2+ support #968

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

Merged
merged 2 commits into from
Aug 2, 2018
Merged

Add Node 7.x aka V8 5.2+ support #968

merged 2 commits into from
Aug 2, 2018

Conversation

p2k
Copy link
Contributor
@p2k p2k commented Apr 13, 2017
  • Use WeakCallbackInfo instead of WeakCallbackData
  • Use GetPrivate instead of GetHiddenValue
  • Adopted new signature for SetWeak to support destructor calling
  • SetAccessor deprecation fixed
  • Proper version checks where applicable

This pull request is similar to the one from @tomleavy (i.e. @arfoll) but with less "hack" (no offence). It also fixes more warnings and resolves the apparent memory leak from not calling destructors. Credits go to the mentioned users for their inspiration.

* Use WeakCallbackInfo instead of WeakCallbackData
* Use GetPrivate instead of GetHiddenValue
* Adopted new signature for SetWeak to support destructor calling
* SetAccessor deprecation fixed
* Proper version checks where applicable
@p2k
Copy link
Contributor Author
p2k commented Apr 13, 2017

Provides a more complete solution for #804

@arfoll
Copy link
arfoll commented Apr 13, 2017

@p2k no offence taken - my commit was labelled a hack ;-) This is really cool, I'll test it and see if it works for my usecase next week.

@tomleavy
Copy link
Contributor

@p2k thanks for taking over and getting this done right. No offense taken. I'm certainly not an expert with v8, I'm just excited to get my wrapper to work properly.

The proposed changes targetted at 5.2 (or 5.4 to be more precise, since there is no Node release with V8 5.2 or 5.3) work for lower versions as well and bust the deprecation warnings there.
@p2k
Copy link
Contributor Author
p2k commented Apr 13, 2017

I've had hours and days (added up) of fun with the oh so great V8 and I'm more than happy to have finally found SWIG which ends my glue code nightmares all at once. As soon as you have multiple projects that require Node wrappers (or any language) it gets obvious that it's easier to keep a code generator maintained than fixing everything over and over again.

@aberaud
Copy link
aberaud commented May 28, 2017

Thanks, we used this PR for our project and it builds and works fine.

It would be great it that was merged soon, because the SWIG Node.js generator, as it currently ships from many sources, is broken and can't be used to build Node.js modules with distributed Node.js / V8 versions.

I think this is a nice and proper fix, and even it there was some issue, it would still be better than not being able to build at all. Version checking macros ensure that the behavior remains the same with older V8 versions. Having this in master would also give it more visibility so it would be tested by more people before an eventual release.

@mislavn
Copy link
mislavn commented May 30, 2017

This PR also fixes our problem we had with node 7.x.

@tomleavy
Copy link
Contributor
tomleavy commented May 30, 2017 via email

@ojwb ojwb mentioned this pull request Jun 28, 2017
@SergeySeroshtan
Copy link

@ojwb, could you please tell when this PR will be merged to the master?

@ojwb
Copy link
Member
ojwb commented Jul 13, 2017

The patch looks sane to me, but I know next to nothing about nodejs, and ideally I'd like to see CI coverage for this so I have confidence that it works. That'd also help ensure it doesn't get accidentally broken by a future patch being applied.

As best I can make out, travis is currently testing a really old version:

Node.js: v0.10.36
node-gyp: v3.6.0

(At least I assume 0.10.36 < 7.x!)

That build appear to be on Ubuntu precise still - adding dist: trusty would probably give us a newer version, but not sure if it'd be new enough.

@halton
Copy link
halton commented Aug 25, 2017

You could use nvm to manage to install different node versions for CI.

@yegorich
Copy link
Contributor

Successfully tested in Buildroot (swig 3.0.12 and Node.js 8.5).

@wsfulton
Copy link
Member

Is there anyone with C/C++ and Javascript experience who would like to step forward and maintain the Javascript module? Without a maintainer, it is hard to know if the various Javascript improvements like this one can't be added.

buildroot-auto-update pushed a commit to buildroot/buildroot that referenced this pull request Oct 8, 2017
Recent Node.js versions have removed some depreciated API calls,
that swig still relies on. Patches taken from this PR [1] fix
this issue.

[1] swig/swig#968

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
@murillo128
Copy link
Contributor
murillo128 commented Oct 26, 2017

Hi! current support for node 7 & 8 is completely broken, so why not apply this patch and see what happens? I understand that it is far from ideal, but it won't work worse than now.

@kopiro
Copy link
kopiro commented Nov 15, 2017

+1

@ojwb
Copy link
Member
ojwb commented Dec 13, 2017

@murillo128 I think we really need CI coverage for the newer node versions. Otherwise "what happens" will be that someone will propose a patch that accidentally breaks support for them, and we'll merge it and not spot the breakage until some some time later when it's harder to deal with.

Ideally someone would step up to actually maintain the node backend, but without someone in that role CI coverage is particularly important.

@murillo128
Copy link
Contributor

@ojwb I agree, but in your worst case we will be at the same place as we are currently.. it can't get worse than now that it is broken.. ;)

@ojwb
Copy link
Member
ojwb commented Mar 7, 2018

@p2k Indeed, thanks.

Note that @nshmyrev has opened #1208 for sorting out travis, so you should probably coordinate to avoid duplicated work there.

We try to tag issues and PRs which are target language specific, so you can see all the open issues for a particular target language (or at least those that have been tagged):

Javascript

There's only a "Javascript" tag at present, but in practice these are almost all about node.

@p2k
Copy link
Contributor Author
p2k commented Mar 7, 2018

Can do. I also did see the PR and I'm going to put further conversation about the topic there.

"Javascript" basically covers the v8 engine which is used in Node.js, Electron and Safari plugins. I have worked with all three of these, so I see no problems there, should a specific issue arise. Also I'll simply be honest if I don't know something and can't do the research myself.

So I'll basically monitor the Javascript tag and any tasks that are assigned to me or where I get mentioned. Github sends me an email and depending on timezones/vacation/weekend I can probably react within 24h. That's what I can offer. Details follow on the mailing list tomorrow.

@ojwb
Copy link
Member
ojwb commented Mar 11, 2018

The SWIG manual says that SWIG's Javascript backend also supports "JavascriptCore, the Javascript engine used by Safari/Webkit" which seems to be an independent Javascript implementation to v8. It seems to be hooked up in the CI.

Do Safari plugins really use a different Javascript engine to Safari itself? That seems surprising (and I can't find evidence of it online).

@p2k
Copy link
Contributor Author
p2k commented Mar 12, 2018

I'm going to double check this asap. v8 is courtesy of Google, but open source; it might still not be a part of WebKit/Safari in the near future.

PS: A project in my company recently escalated, which forces me to delay my application on the SWIG mailing list. I should be ready in one or two days.

@ojwb
< 6D40 span class="Button-content"> Copy link
Member
ojwb commented Mar 12, 2018

AIUI, Safari's Javascript engine is also FOSS but derives from KDE's KJS not v8.

But really having someone actively maintaining only the v8-based Javascript targets in SWIG would be a big improvement, and the CI should at least ensure that JSC support doesn't get accidentally broken by v8-related changes.

@notedit
Copy link
notedit commented Apr 15, 2018

hello any process about this PR. NODE 9 can not build.

@jamesamcl
Copy link

Seems odd that the official reason this isn't being merged is the lack of tests ("it might not work") when the bindings swig currently generates are useless for recent node versions ("it definitely does not work"). Forgive me if I'm wrong, but this looks more like the maintainers don't use nodejs and therefore don't care if this gets merged or not.

Why not at least merge this as a separate "node7+" target so that people can use it without having to merge a patch and compile swig from source?


9E88
@p2k
Copy link
Contributor Author
p2k commented Apr 20, 2018

It's also stuck, because the guy that wants to become maintainer (and does use nodejs and does care) is still under arrest by high work load in his company.

@murillo128
Copy link
Contributor

This is simply a nonsense.

SWIG does not support neither current nodejs version (v9) nor LTS (v8). Claiming that this patch breaks compatibility with unsupported node version is the worst excuse ever.

If you have a node<v7 project it is expected that things stop working for you, swig or any other dependency.

@ojwb
Copy link
Member
ojwb commented Apr 21, 2018

All we're asking for is to have CI coverage for the new node versions that this patch aims to support in order to demonstrate that the patch works, and to ensure that this support isn't broken by future patches.

I'm frankly amazed at the amount of time and energy people seem prepared to put in to arguing for us to merge this patch without having any CI coverage - far more in total now than it would have taken for someone to just sort the necessary CI changes.

@murillo128
Copy link
Contributor

FWIW node 10.0.0 it's going or tomorrow..

nodejs/Release#328

So swig will not support node 7,8,9 and 10.

Regarding CI , is there any support for node right now? What CI tests do you expect to be added and what should they cover? How can the CI changes be tested easily?

@wsfulton
Copy link
Member

We use Travis and Appveyor for CI. The Linux Travis environment is preferred for testing, so if someone can provide the 'sudo apt-get install' command for installing node 7,8,9 and 10 on Ubuntu 14.04 (Trusty Tahr), this can be set up in the Travis environment easily as follows. An addition to the block of code at

env: SWIGLANG=javascript ENGINE=node
to add in something like:

      env: SWIGLANG=javascript ENGINE=node VER=7
      sudo: required
      dist: trusty

and then a change to install the package is required in

travis_retry sudo apt-get install -qq nodejs node-gyp
and modify to something like:

			"node")
				if [[ -z "$VER" ]]; then
					travis_retry sudo apt-get install -qq nodejs node-gyp
				else
					# sudo-apt-repository etc ... 
					# apt-get install etc...
					# or whatever is required to install nodejs version ${VER}
				fi
			;;

Testing on a local box ought to be done first to check... Run the node install commands on a 14.04 machine, grab SWIG and run the usual configure and build and test-suite like this:

./autogen.sh && ./configure && make -s && make check-javascript-examples ENGINE=node && make check-javascript-test-suite ENGINE=node

If you click on the "Show All Checks" link in this pull request, you can navigate your way to the nodejs test run by this pull request (currently https://travis-ci.org/swig/swig/jobs/221819686). You will see among the output the versions installed which is the default installed by the install commands mentioned in travis-linux-install.sh:

Node.js: v0.10.36
node-gyp: v3.6.0

@murillo128
Copy link
Contributor

Node 0.10.36 is from 2015...

The nodejs packaged in ubuntu is unusable. The best way of installing specific node versions is using nvm (which do not require root):

https://github.com/creationix/nvm

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.10/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

Then installing & using an specific node version is:

nvm install 6
nvm install 7
nvm install 8
nvm install 9
nvm install 10
nvm use 6

So the question is, is that enough?

@ojwb
Copy link
Member
ojwb commented Apr 25, 2018

So the question is, is that enough?

Ideally we're looking for an updated and tested .travis.yml as a pull request, and the remaining steps to get there are likely to be easier for someone who knows node than for someone who doesn't.

But the information you provide above is certainly a step forwards, so thanks for that.

@murillo128
Copy link
Contributor

I don't have enough knowledge of travis to make the modifications neither I know how to actually test the changes.

I can help you with the node setup info, but can't provide the full PR, sorry (I would already have provided it otherwise)

@RebelSyntax
Copy link

so, for someone who just looked at swig and node-gyp for the first time today and is wrapping a rather complex shared object, is there an easy way to fix this on my local box? I am fairly certain that I compiled the latest distribution. I'd love to jump in and see what I can do with travis and ci coverage, cause I planned on experimenting with that technology here as well. But, alas, I must find a way to consume this shared object in my electron app as a top priority. really don't want to go the FFI route based on what I have read and the time I spent making the choice between the two. Thanks!

@yatli
Copy link
yatli commented May 28, 2018

@RebelSyntax just copy the updated swg files to your swig installation.

Copy link
@colinxsmith colinxsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This worked great for me for nodes 7,8,9 and 10, but it messed up 6 and downwards... not backwards compatible.

Copy link
@colinxsmith colinxsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This worked great for me for nodes 7,8,9 and 10, but it messed up 6 and downwards... not backwards compatible.

@colinxsmith
Copy link

node 6 was messed up because there's a bug #elifif instead of #elif in the 4'th file to be patched.

@wsfulton
Copy link
Member

#1290 from @furylynx contains builds on this patch to add CI tests on Travis. Please take a look as I intend to merge it in soon.

@wsfulton wsfulton merged commit 9ce8d7e into swig:master Aug 2, 2018
@wsfulton
Copy link
Member
wsfulton commented Aug 2, 2018

Merged via #1290. Please check using SWIG master.

@wsfulton wsfulton mentioned this pull request Aug 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0