Skip to content

naiteluo/maki-v8

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

maki

Makise Kurisu, a v8 embed opengl renderer.

Setups (first time step)

  1. Get gtest and opengl related module from submodule

    git submodule init
    git submodule updata --init --recursive
  2. Download glew and extra to lib

    GLEW 2.1.0

  3. Get v8

    cd lib
    
    fetch v8 # it may take a long time
    
    cd v8
    
    # start to configure and build
    # create build configuration with helper script
    tools/dev/v8gen.py x64.release.sample
    # inspect configuration
    gn args out.gn/x64.release.sample
    # build (take x64 platform for example)
    ninja -C out.gn/x64.release.sample v8_monolith
    
    # try to build v8 example helloworld
    g++ -I. -Iinclude samples/hello-world.cc -o hello_world -lv8_monolith -Lout.gn/x64.release.sample/obj/ -pthread -std=c++14 -DV8_COMPRESS_POINTERS
    # run
    ./hello_world
    

    Finished! Now you have a linkable static v8 library in ./lib/v8/out.gn/x64.release.sample/obj

    To use v8 in your cmake project, add this to the CMakeLists.txt

    # link build output of v8 by directories
    link_directories(${CMAKE_SOURCE_DIR}/lib/v8/out.gn/x64.release.sample/obj)
    # link your app to v8
    target_link_libraries(${BINARY}_run v8_monolith)

    If you already have your v8 project checked out in other directory, you can also change linkable path to your v8 build results path. But don't commit!!

    References:

  4. Get Boost

We use websocketpp which alias Boost::asio to handle ws connection between chrome inspector, and the runtime. Install boost as local library deps.

brew install boost

IDE setups

CLion (Recommended)

Open project and wait for initializing and file indexing. Get CLion.

notes for debug:

Create new CMake profile in Preferences panel, set build type to "Debug". Otherwise, your debugger will not be triggered.

vscode

vscode recommended extensions for c/c++:

Using clangd in cmake project, you'll need to generate compile_commands.json file. clangd will look for it to understanding your project build flags or other building context. Read for more informations.

cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1

Regenerate compile_commands.json after big changes of the project structure or add new library.

Build and run

js file, and some assets are in ./resouces, cd into this directory as you working directory.

build and run in Clion (Recommended)

open project, build and run.

build and run in cli

  1. Configure

    cmake --no-warn-unused-cli \
        -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE \
        -DCMAKE_BUILD_TYPE:STRING=Debug \
        -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang \
        -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++ \
        -H. \
        -B./build \
        -G Ninja

    helps:

    • CMAKE_BUILD_TYPE:STRING define build mode.
    • -G Ninja specify build system generator.
  2. Build

    cmake --build ./build --config Debug --target all -j 14 --
  3. Run

    run w8 app

    ./build-*/src/maki_w8_run

build and run in vscode

Or just use vscode extensions to configure, build and run in vscode.

Debug

Use vscode or clion for life-saving.

JavaScript debugging with inspector

With the integration of inspector client and websocket service, we now support js debugging in chrome inspector.

  1. Run maki_w8_run with --inspector_enabled flag. Javascript execution will wait until inspector connection opened.
  2. Run open -n -a /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --user-data-dir="/tmp/chrome_dev_test" --remote-debugging-port=9222 http://localhost:9222/devtools/inspector.html?ws=localhost:9229

About

A V8 embed OpenGL renderer.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published