pmed / v8pp

Bind C++ functions and classes into V8 JavaScript engine
http://pmed.github.io/v8pp/
Other
898 stars 120 forks source link

Fixed compilation error with V8 version 5.2.327+ #21

Closed isegal closed 8 years ago

isegal commented 8 years ago

As of https://github.com/v8/v8/commit/82dcb2beeeb85369902c76e48374caed4fac58fb V8 has removed a deprecated WeakCallbackData. This commit replaces the deprecated type with WeakCallbackInfo. This fixes the compilation error with newer versions of V8.

pmed commented 8 years ago

Hi Ivgeni,

Thanks for the PR. At this moment I can't build v8pp with V8 version 5.2+ to check your changes. It seems I have to update v8-build script.

Anyway, I think there should be support for older V8 versions in the project, at least for some time. Could you please add a compile time condition to switch between WeakCallbackData and WeakCallbackInfo depending on V8 version? I've seen defines for V8 version parts in v8-version.h header.

isegal commented 8 years ago

No problem. Interesting find: It appears they have introduced the renamed type a year ago in https://github.com/v8/v8/commit/60c1ad026d084b62fc963330af0b4802346eab7d and supported both for a while. You might not need a conditional check with your current version. Let me know if that is not the case and I'll re submit.

In case for when you want to move to a newer v8, I found there were a couple of minor changes in their build system. Below are examples that work on my machines with latest v8.

  1. They moved gyp_v8 from build/gyp_v8 to gypfiles/gyp_v8
  2. The generated output projects also moved.

(Assuming you execute script from one level above v8 that has depot_tools in the same directory)

For Mac:

export PATH=pwd/depot_tools:"$PATH" gclient sync --with_branch_heads cd v8 gypfiles/gyp_v8 -Dtarget_arch=x64 -Dsnapshot=on xcodebuild -project gypfiles/all.xcodeproj -configuration Release

For Windows: set DEPOT_TOOLS_WIN_TOOLCHAIN=0 set GYP_MSVS_VERSION=2015 call gclient sync call python v8\gypfiles\gyp_v8 -Dtarget_arch=x64 cd v8 "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.com" /build Release src\v8.sln

The sln file appears to have moved to src\ devenv.com" /build Release src\v8.sln

pmed commented 8 years ago

@isegal, thanks! You were absolutely right - WeakCallbackInfo had been declared in V8 a time ago. I changed v8pp to use it instead of WeakCallbackData.

I also fixed a couple of bugs there and tested it on Windows the project with V8 5.2 and 4.8 versions.

pmed commented 8 years ago

I had to add compile time selection for the weak callback, because v8::WeakCallbackInfo was added in V8 4.3.28.

pmed commented 8 years ago

Resolved with prerpocessor defines