Skip to content
Open

V8 #11

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
20eff95
Merge remote-tracking branch 'upstream/master'
jmgasper May 16, 2018
09921f2
Merge remote-tracking branch 'upstream/master'
jmgasper Jun 14, 2018
d61bc7f
added stub v8 script implementation
Jun 15, 2018
d189aa2
Merge pull request #185 from krunt/origin/_v8
jmgasper Jun 18, 2018
6756bd3
v8 driver and binding test code
krunt Jun 20, 2018
2f64275
Merge pull request #187 from krunt/origin/_v8
jmgasper Jun 21, 2018
5e6571e
v8 promises unit test
krunt Jun 23, 2018
8db8ec0
v8 module loading support
krunt Jun 24, 2018
fcd8507
Merge pull request #188 from krunt/origin/_v8
jmgasper Jun 24, 2018
5f12b53
fixed compilation issues
Jun 26, 2018
feea043
fix build on mac/linux
Jun 27, 2018
6819b6c
Merge pull request #189 from krunt/origin/_v8
jmgasper Jun 27, 2018
894dbdf
porting core modules, working about.js
krunt Jun 28, 2018
0887489
fixes for linux
Jun 28, 2018
5b69596
fixes on mac
Jun 28, 2018
37ace84
Merge pull request #193 from krunt/origin/_v8
jmgasper Jun 28, 2018
d30d7a6
support nested scene scripts
krunt Jun 30, 2018
1bcda63
Merge pull request #195 from krunt/origin/_v8
jmgasper Jun 30, 2018
6f32d12
fixed some issues, refactor code, added http module support
krunt Jul 7, 2018
baabb7d
Merge pull request #200 from krunt/origin/_v8
jmgasper Jul 7, 2018
e89dab4
porting polaroid example
krunt Jul 8, 2018
1a5eb21
Merge pull request #201 from krunt/origin/_v8
jmgasper Jul 9, 2018
c412444
Updates for V8 specific instructions
jmgasper Jul 10, 2018
336f9de
set contextid in in context
krunt Jul 10, 2018
c60fd8c
Merge pull request #202 from krunt/origin/_v8
jmgasper Jul 10, 2018
9e9241b
v8 separate external windows part
krunt Jul 15, 2018
71b47dd
v8 external linux part
Jul 15, 2018
fa135a5
macos v8 external
Jul 15, 2018
afaa8d1
macos added docs
Jul 15, 2018
8868d74
Update build.sh
krunt Jul 15, 2018
d04a13e
Merge pull request #208 from krunt/origin/_v8
jmgasper Jul 15, 2018
cbee0ab
unify v8 and node code
krunt Jul 16, 2018
37e9aa0
Merge pull request #210 from krunt/origin/_v8
jmgasper Jul 16, 2018
d6ac6fa
added v8-build check
krunt Jul 17, 2018
6ed6257
Merge pull request #211 from krunt/origin/_v8
jmgasper Jul 17, 2018
d359b18
fixes to v8 build to pass tests
krunt Jul 20, 2018
6c99a78
Merge pull request #214 from krunt/origin/_v8
jmgasper Jul 20, 2018
67d62b9
v8 bin files into executable
krunt Jul 28, 2018
11f393d
revert pxscene.sh
krunt Jul 28, 2018
94bb457
moved rtScriptV8Node to rtScriptV8
krunt Jul 29, 2018
f51db4d
Merge pull request #218 from krunt/origin/_v8
jmgasper Jul 30, 2018
257e979
README about the project to this point
jmgasper Aug 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ option(PREFER_SYSTEM_LIBRARIES "Prefer to use system libraries over bundled." "O

option(DISABLE_DEBUG_MODE "Disable debugging mode." "OFF") # OFF for backward compatibility

option(SUPPORT_DUKTAPE "SUPPORT_DUKTAPE" ON)
option(SUPPORT_NODE "SUPPORT_NODE" ON)
option(SUPPORT_DUKTAPE "SUPPORT_DUKTAPE" OFF)
option(SUPPORT_NODE "SUPPORT_NODE" OFF)
option(SUPPORT_V8 "SUPPORT_V8" ON)

option(ENABLE_THREAD_SANITIZER "ENABLE_THREAD_SANITIZER" OFF)
option(ENABLE_ADDRESS_SANITIZER "ENABLE_ADDRESS_SANITIZER" OFF)
Expand Down
2 changes: 2 additions & 0 deletions cmake/NodeDeps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,6 @@ if (SUPPORT_NODE)
add_definitions(-DRTSCRIPT_SUPPORT_NODE)
else (SUPPORT_NODE)
unset(NODE_LIBRARIES)
unset(NODE_INCLUDE_DIRS)
unset(NODE_LIBRARY_DIRS)
endif (SUPPORT_NODE)
78 changes: 78 additions & 0 deletions cmake/V8Deps.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
set(NODEDIR "${EXTDIR}/libnode-v6.9.0/")
set(V8DIR "${EXTDIR}/v8/")
set(V8_INCLUDE_DIRS ${V8DIR}/include
${NODEDIR}/deps/uv/include
${NODEDIR}/deps/cares/include
${NODEDIR}/deps/openssl/openssl/include
${NODEDIR}/deps/icu-small/source/common/unicode
${NODEDIR}/deps/icu-small/source/common)

if (WIN32)
set(V8_LIBDIR ${V8DIR}/out.gn/ia32.release)
set(V8_LIBRARY_DIRS ${V8_LIBDIR} ${NODEDIR}build/Release/lib ${NODEDIR}Release/lib ${NODEDIR}Release)
set(V8_LIBRARIES
v8.dll.lib v8_libbase.dll.lib v8_libplatform.dll.lib
icutools.lib icustubdata.lib icudata.lib icuucx.lib icui18n.lib
winmm.lib dbghelp.lib shlwapi.lib
libuv.lib openssl.lib)
set(V8_BUILD_PATH_CHECK ${V8_LIBDIR}/v8.dll.lib)
set(V8_SOURCES ${V8_LIBDIR}/v8_binfile.cpp)
elseif (APPLE)
set(V8_LIBDIR ${V8DIR}/out.gn/x64.release/obj)
set (V8_INCLUDE_DIRS ${V8_INCLUDE_DIRS} ${NODEDIR}/deps/icu-small/source/common/)
set(V8_LIBRARY_DIRS
${V8_LIBDIR}
${NODEDIR})
set(V8_LIBRARIES
v8_base
v8_external_snapshot
v8_libplatform
v8_libsampler
v8_libbase
node)
set(V8_BUILD_PATH_CHECK ${V8_LIBDIR}/libv8_base.a)
set(V8_SOURCES ${V8_LIBDIR}/../v8_binfile.cpp)
else ()
set(V8_LIBDIR ${V8DIR}/out.gn/x64.release/obj)
set (V8_INCLUDE_DIRS ${V8_INCLUDE_DIRS} ${NODEDIR}/deps/icu-small/source/common/)
set(V8_LIBRARY_DIRS
${V8_LIBDIR}
${NODEDIR}/out/Release/obj.target
${NODEDIR}/out/Release/obj.target/deps/uv
${NODEDIR}/out/Release/obj.target/deps/v8/tools/gyp
${NODEDIR}/out/Release/obj.target/deps/cares
${NODEDIR}/out/Release/obj.target/deps/zlib
${NODEDIR}/out/Release/obj.target/deps/http_parser
${NODEDIR}out/Release/obj.target/tools/icu
)
set(V8_LIBRARIES
v8_base
v8_external_snapshot
v8_libplatform
v8_libsampler
v8_libbase
uv
cares
zlib
http_parser
icustubdata
icudata
icuucx
icui18n
)
set(V8_BUILD_PATH_CHECK ${V8_LIBDIR}/libv8_base.a)
set(V8_SOURCES ${V8_LIBDIR}/../v8_binfile.cpp)
endif ()

if (SUPPORT_V8)
if(EXISTS ${V8_BUILD_PATH_CHECK})
message("external/v8 library is built successfully")
else ()
message(FATAL_ERROR "external/v8 library is not built, please build it first")
endif ()
else (SUPPORT_V8)
unset(V8_INCLUDE_DIRS)
unset(V8_LIBRARY_DIRS)
unset(V8_LIBRARIES)
unset(V8_SOURCES)
endif (SUPPORT_V8)
6 changes: 3 additions & 3 deletions examples/pxScene2d/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## Minimum requirements
>macOS
> * OS : Macbook Pro (macOS Sierra)
> * OS : Macbook Pro (macOS Sierra >=10.12)
> * RAM Size : 256 MB
> * Disk space : 24 MB
> * Processor speed : 1 GHz
Expand All @@ -32,7 +32,7 @@
## macOS Setup

>Install Xcode, CMake and quilt
> * Download the latest version of Xcode from https://developer.apple.com/xcode/download/
> * Download the latest version of Xcode (>=9.2) from https://developer.apple.com/xcode/download/
> * Download and install the latest version of brew from https://brew.sh/
> * From terminal install dependencies: cmake, pkg-config, quilt, java.

Expand All @@ -44,7 +44,7 @@
>Setup Windows 10
> * Windows 10
> * Visual Studio 2017 community with `Desktop development with C++` workload
> * [windows sdk 10.0.16299.0](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk),it is included in VS2017 with above workload and only necessary if you have issue to install with VS2017)
> * [windows sdk 10.0.16299 and windows sdk 10.0.17134(aka 1803)] (https://developer.microsoft.com/en-us/windows/downloads/sdk-archive)
> * python 2.7.x , make sure python can work in cmd (setup environment variables depending on install location)
> * git for windows , make sure git can work in cmd (setup environment variables depending on install location)
> * patch utility for windows (this comes with git. setup environment variables depending on install location of patch.exe)
Expand Down
49 changes: 49 additions & 0 deletions examples/pxScene2d/V8_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Description

pxScene / Spark is a wrapper around the pxCore libraries that can run as a stand-along application on OS X, Windows, and Linux. The wrapper provides Javascript bindings to allow for easy consumption of the low-level pxCore functionality.

Initially, and in the production builds, pxScene / spark supports Node as the Javascript engine for the application. Node provides lots of nice features that are useful for pxScene development, but it has quite a bit of overhead, so we've been asked to investigate replacing the Node Javascript engine in pxScene with other Javascript engines.

The first implementation we did involved stripping out Node and replacing it with Duktape (http://duktape.org/). Duktape worked well and the memory overhead was reduced significantly. The problem with duktape is that it is a little *too* small. It lacks a lot of nice features that Node currently supports and that are used in the existing pxScene examples, including some ES6 features like:

* `let`
* `const`
* `arrow functions`
* promises
* proxy object support

We investigated adding support for these via a couple of different paths. Our members had trouble with modifying the duktape parsing path because it's complex, making it hard to add new functionality. I also got in touch with the main duktape developer and suggested to the client that maybe we contract with him directly to prioritise features, but that didn't really go too far.

# V8

More recently, the client has asked us to investigate supporting the Chrome JS engine called V8 (https://developers.google.com/v8/) as a replacement for Node. I've worked primarily with Alexey Kuts (kruntuid) to implement the V8 build, since he did a lot of work on the duktape build. He presented a stepped plan that we approved and worked on directly.

To date, we've been able to build the V8 integration pretty much completely, to the point where it runs the pxScene test suite the same as the Node version, with memory reduction. The memory reduction isn't as much as we'd probably like so we've been looking at turning off specific features in the V8 build to see if that will help. We've identified some items of reduction, but nothing overly significant.

# Challenges

One challenge we've had is supporting both Node and V8 in the same executable. This was possible in the duktape integration - the executable could use either interpreter and would default to one or the other based on files in the user's home directory.

This is not currently possible with the V8 build because Node includes an old version of V8 and the linking of both the old version and the current version causes linker errors.

# Build

Here's instructions for building pxScene with V8 instead of Node. The biggest change is the `-DSUPPORT_V8=ON` flag in the first call to `cmake`

### Setup for V8 specific build on Linux

* `sudo apt-get install git libglew-dev freeglut3 freeglut3-dev libgcrypt11-dev zlib1g-dev g++ libssl-dev nasm autoconf libtool cmake gnutls-bin libgnutls-dev autoconf libtool nasm`
* `git clone [email protected]:topcoderinc/pxCore.git`
* `cd pxCore`
* `git checkout duktape_proof_of_concept`
* `cd examples/pxScene2d/external`
* `./build.sh`
* `cd ../../../`
* `mkdir temp`
* `cd temp`
* `cmake -DSUPPORT_V8=ON ..`
* `cmake --build . --config Release -- -j1`
* `cd ../examples/pxScene2d/src`
* `./pxscene about.js`

At this point the `engine` field in about.js should say V8.
31 changes: 31 additions & 0 deletions examples/pxScene2d/external/binfile2cpp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/python

import sys
import os

(src, dst_h, dst_cpp) = sys.argv[1:4]

out_fd_h = open(dst_h, "a+")
out_fd_cpp = open(dst_cpp, "a+")

with open(src, "r") as fd:
name = os.path.basename(src).replace(".", "_")
symbol_name_header_data = "extern unsigned char %s_data[];\n" % (name)
symbol_name_header_sz_data = "extern int %s_size;\n" % (name)

out_fd_h.write(symbol_name_header_data)
out_fd_h.write(symbol_name_header_sz_data)

sz = os.stat(src).st_size

symbol_name_cpp_data = "unsigned char %s_data[] = {\n" % (name)
contents = fd.read()
for i in xrange(len(contents)):
symbol_name_cpp_data += ("0x%x" % ord(contents[i])) + ", "
if i > 0 and i % 16 == 0:
symbol_name_cpp_data += "\n"
symbol_name_cpp_data += "};\n"

symbol_name_cpp_data += "int %s_size = %d;\n" % (name, sz)

out_fd_cpp.write(symbol_name_cpp_data)
3 changes: 3 additions & 0 deletions examples/pxScene2d/external/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ then

fi

# v8
bash buildV8.sh

#-------- BREAKPAD (Non -macOS)

if [ "$(uname)" != "Darwin" ]; then
Expand Down
27 changes: 27 additions & 0 deletions examples/pxScene2d/external/buildV8.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@where msbuild 2> nul
@if %errorlevel% neq 0 (
@echo.
@echo Please execute this file from inside Visual Studio's Developer Command Prompt
@echo.
pause
goto :eof
)

cmd /c git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git depot_tools
set PATH=%cd%\depot_tools;%PATH%

cmd.exe /c gclient

cmd /c fetch v8
cd v8

cmd /c gclient sync --no-history --with_tags -r 6.9.351
cmd /c python tools/dev/v8gen.py ia32.release -- is_debug=false v8_enable_i18n_support=false target_cpu=\"x86\" is_component_build=true v8_static_library=true

cmd /c ninja -C out.gn/ia32.release

cmd /c python ..\binfile2cpp.py out.gn\ia32.release\natives_blob.bin out.gn\ia32.release\v8_binfile.h out.gn\ia32.release\v8_binfile.cpp
cmd /c python ..\binfile2cpp.py out.gn\ia32.release\snapshot_blob.bin out.gn\ia32.release\v8_binfile.h out.gn\ia32.release\v8_binfile.cpp

cd ..

19 changes: 19 additions & 0 deletions examples/pxScene2d/external/buildV8.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git depot_tools
export PATH=$PWD/depot_tools/:$PATH

gclient

fetch v8
cd v8

gclient sync --no-history --with_tags -r 6.9.351
python tools/dev/v8gen.py x64.release -- is_debug=false v8_enable_i18n_support=false target_cpu=\"x64\" is_component_build=false v8_static_library=true use_custom_libcxx = false use_custom_libcxx_for_host = false

ninja -C out.gn/x64.release v8

python ../binfile2cpp.py out.gn/x64.release/natives_blob.bin out.gn/x64.release/v8_binfile.h out.gn/x64.release/v8_binfile.cpp
python ../binfile2cpp.py out.gn/x64.release/snapshot_blob.bin out.gn/x64.release/v8_binfile.h out.gn/x64.release/v8_binfile.cpp

cd ..
2 changes: 2 additions & 0 deletions examples/pxScene2d/external/buildWindows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ cd vc.build\
msbuild external.sln /p:Configuration=Release /p:Platform=Win32 /m
cd ..

CALL buildV8.bat

cd breakpad-chrome_55
CALL gyp\gyp.bat src\client\windows\breakpad_client.gyp --no-circular-check
cd src\client\windows
Expand Down
2 changes: 1 addition & 1 deletion examples/pxScene2d/external/libnode-v6.9.0/buildNode.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
./configure --shared
make
make -j
ln -sf libnode.so.48 out/Release/obj.target/libnode.so
ln -sf libnode.48.dylib out/Release/libnode.dylib
22 changes: 15 additions & 7 deletions examples/pxScene2d/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ include(${PXCOREDIR}/cmake/CommDeps.cmake)
include(${PXCOREDIR}/cmake/NodeDeps.cmake)
include(${PXCOREDIR}/cmake/DukeDeps.cmake)
include(${PXCOREDIR}/cmake/SManDeps.cmake)
include(${PXCOREDIR}/cmake/V8Deps.cmake)

set(WESTEROSINC ${EXTDIR}/westeros/external/install/include)
set(WESTEROSSTUBINC ${EXTDIR}/westeros-stub)
Expand Down Expand Up @@ -91,8 +92,8 @@ if (APPLE)
set(PXSCENE_LINKER_OPTIONS "${PXSCENE_LINKER_OPTIONS} -fsanitize=address")
endif (ENABLE_ADDRESS_SANITIZER)
set(PXSCENE_LINK_LIBRARIES)
set(PXSCENE_LINK_DIRECTORIES ${PXSCENE_LINK_DIRECTORIES} ${NODE_LIBRARY_DIRS} ${DUKE_LIBRARY_DIRS} ${COMM_DEPS_LIBRARY_DIRS})
set(PLATFORM_LIBRARIES pxCore rtCore_s pthread ${NODE_LIBRARIES} ${DUKE_LIBRARIES} ${COMM_DEPS_LIBRARIES})
set(PXSCENE_LINK_DIRECTORIES ${PXSCENE_LINK_DIRECTORIES} ${NODE_LIBRARY_DIRS} ${V8_LIBRARY_DIRS} ${DUKE_LIBRARY_DIRS} ${COMM_DEPS_LIBRARY_DIRS})
set(PLATFORM_LIBRARIES pxCore rtCore_s pthread ${NODE_LIBRARIES} ${V8_LIBRARIES} ${DUKE_LIBRARIES} ${COMM_DEPS_LIBRARIES})
include_directories(AFTER ${NODE_INCLUDE_DIRS} ${DUKE_INCLUDE_DIRS} ${COMM_DEPS_INCLUDE_DIRS})
if (DEFINED ENV{CODE_COVERAGE})
message("enabling code coverage support")
Expand All @@ -115,18 +116,21 @@ elseif (CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
add_definitions(${COMM_DEPS_DEFINITIONS})

include_directories(AFTER
${V8_INCLUDE_DIRS}
${NODE_INCLUDE_DIRS}
${DUKE_INCLUDE_DIRS}
${COMM_DEPS_INCLUDE_DIRS}
)

set(PXSCENE_LINK_DIRECTORIES ${PXSCENE_LINK_DIRECTORIES}
${NODE_LIBRARY_DIRS}
${V8_LIBRARY_DIRS}
${DUKE_LIBRARY_DIRS}
${COMM_DEPS_LIBRARY_DIRS}
)
set(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES}
${NODE_LIBRARIES}
${V8_LIBRARIES}
${DUKE_LIBRARIES}
${COMM_DEPS_LIBRARIES}
pthread rt dl m)
Expand Down Expand Up @@ -272,13 +276,14 @@ elseif (WIN32)
-DU_HAVE_STD_STRING=0 -DUCONFIG_NO_BREAK_ITERATION=0 -DUCONFIG_NO_LEGACY_CONVERSION=1 -DUCONFIG_NO_CONVERSION=1
-DHTTP_PARSER_STRICT=0 -DUSE_RENDER_STATS -D_HAS_EXCEPTIONS=0)
add_definitions(${COMM_DEPS_DEFINITIONS})
include_directories(AFTER ${COMM_DEPS_INCLUDE_DIRS} ${NODE_INCLUDE_DIRS} ${DUKE_INCLUDE_DIRS})
include_directories(AFTER ${COMM_DEPS_INCLUDE_DIRS} ${NODE_INCLUDE_DIRS} ${V8_INCLUDE_DIRS} ${DUKE_INCLUDE_DIRS})
include_directories(AFTER "${EXTDIR}/pthread-2.9" ${WINSPARKLEINC} ${EXTDIR}/breakpad-chrome_55/src/)

set(PXSCENE_LINK_DIRECTORIES ${PXSCENE_LINK_DIRECTORIES} ${COMM_DEPS_LIBRARY_DIRS} ${NODE_LIBRARY_DIRS} ${DUKE_LIBRARY_DIRS})
set(PXSCENE_LINK_DIRECTORIES ${PXSCENE_LINK_DIRECTORIES} ${COMM_DEPS_LIBRARY_DIRS} ${NODE_LIBRARY_DIRS}
${V8_LIBRARY_DIRS} ${DUKE_LIBRARY_DIRS})

set(PLATFORM_LIBRARIES pxCore.lib)
set(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES} ${COMM_DEPS_LIBRARIES} ${NODE_LIBRARIES} ${DUKE_LIBRARIES})
set(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES} ${COMM_DEPS_LIBRARIES} ${NODE_LIBRARIES} ${V8_LIBRARIES} ${DUKE_LIBRARIES})
set(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES}
pthreadVC2.lib opengl32.lib Winmm.lib
Ws2_32.lib Wldap32.lib msvcrt.lib psapi.lib
Expand Down Expand Up @@ -319,7 +324,7 @@ set(PXSCENE_DEFINITIONS ${PXSCENE_DEFINITIONS} -D${PX_PLATFORM} -DENABLE_RT_NODE
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
#set(PXSCENE_LINKER_OPTIONS "${PXSCENE_LINKER_OPTIONS} -lgcov")

include_directories(AFTER ${NODE_INCLUDE_DIRS} ${DUKE_INCLUDE_DIRS})
include_directories(AFTER ${NODE_INCLUDE_DIRS} ${V8_INCLUDE_DIRS} ${DUKE_INCLUDE_DIRS})
include_directories(AFTER ${WESTEROSINC} ${WESTEROSSTUBINC} ${TURBO_JPEG_INCLUDE_DIRS} ${BREAKPADINC} ${RTREMOTEINC} ${PXCOREDIR}/src)
include_directories(AFTER ${CMAKE_CURRENT_SOURCE_DIR})
include_directories(AFTER ${CMAKE_CURRENT_SOURCE_DIR}/rasterizer)
Expand Down Expand Up @@ -457,6 +462,7 @@ if (BUILD_PXSCENE_APP)
install(TARGETS pxscene_app RUNTIME DESTINATION . COMPONENT pxscene)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/browser DESTINATION . COMPONENT pxscene)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/node_modules DESTINATION . COMPONENT pxscene)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/v8_modules DESTINATION . COMPONENT pxscene)
if (SUPPORT_DUKTAPE)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/rcvrcore/" DESTINATION rcvrcore COMPONENT pxscene)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/duk_modules/" DESTINATION duk_modules COMPONENT pxscene)
Expand All @@ -469,7 +475,9 @@ if (BUILD_PXSCENE_APP)

file(GLOB PXSCENE_INSTALL_FILES "${CMAKE_CURRENT_SOURCE_DIR}/FreeSans.ttf"
"${CMAKE_CURRENT_SOURCE_DIR}/*.json" "${CMAKE_CURRENT_SOURCE_DIR}/*.conf"
"${CMAKE_CURRENT_SOURCE_DIR}/../external/vc.build/builds/*.dll" "${CMAKE_CURRENT_SOURCE_DIR}/Release/")
"${CMAKE_CURRENT_SOURCE_DIR}/../external/vc.build/builds/*.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/../external/v8/out.gn/ia32.release/v8*.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/Release/")
if (SUPPORT_DUKTAPE)
message("installing additional duktape files")
install(FILES ${PXSCENE_INSTALL_FILES_JS2} DESTINATION . COMPONENT pxscene)
Expand Down
10 changes: 10 additions & 0 deletions examples/pxScene2d/src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
*/

var isDuk = (typeof Duktape != "undefined")?true:false;
var isV8 = (typeof _isV8 != "undefined")?true:false;

if (isDuk) {
global.console = require('console');
Expand All @@ -41,6 +42,15 @@ global.constructPromise = function (obj) {
});
}
}
else if (isV8) {
console = require('console');
timers = require('timers');

setTimeout = timers.setTimeout;
clearTimeout = timers.clearTimeout;
setInterval = timers.setInterval;
clearInterval = timers.clearInterval;
}

var AppSceneContext = require('rcvrcore/AppSceneContext');
var RPCController = require('rcvrcore/rpcController');
Expand Down
Loading