From c07e19519e1e08d62bb6d4870857b12a4ea01b3f Mon Sep 17 00:00:00 2001 From: Pavel Medvedev <1122386+pmed@users.noreply.github.com> Date: Mon, 16 Oct 2023 17:20:40 +0200 Subject: [PATCH] Run macos CI with `V8_ENABLE_SANDBOX` option (#199) * add `V8_ENABLE_SANDBOX=0` CMake option to use with v8 includes explicitly as a preprocessor define * macos CI run with `V8_ENABLE_SANDBOX=1` because v8 library in brew has this option turned on --- .github/workflows/cmake.yml | 16 +++++++++------- CMakeLists.txt | 1 + v8pp/CMakeLists.txt | 6 +++++- v8pp/version.ipp | 3 +++ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index c4ebe598..aa1d830e 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -8,18 +8,20 @@ jobs: build_type: [ Release ] shared_lib: [ false, true ] header_only: [ false, true ] - v8_compress_pointers: [ false, true ] - exclude: + include: - os: ubuntu-latest - v8_compress_pointers: true - - os: macos-latest v8_compress_pointers: false + v8_enable_sandbox: false + - os: macos-latest + v8_compress_pointers: true + v8_enable_sandbox: true - os: windows-latest - v8_compress_pointers: false + v8_compress_pointers: true + v8_enable_sandbox: false runs-on: ${{matrix.os}} - name: '${{matrix.os}} ${{matrix.build_type}} shared_lib=${{matrix.shared_lib}} header_only=${{matrix.header_only}} v8_compress_pointers=${{matrix.v8_compress_pointers}}' + name: '${{matrix.os}} ${{matrix.build_type}} shared_lib=${{matrix.shared_lib}} header_only=${{matrix.header_only}} v8_compress_pointers=${{matrix.v8_compress_pointers}} v8_enable_sandbox=${{matrix.v8_enable_sandbox}}' steps: - uses: actions/checkout@v2 @@ -47,7 +49,7 @@ jobs: uses: seanmiddleditch/gha-setup-ninja@v3 - name: Configure CMake - run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBUILD_TESTING=TRUE -DBUILD_SHARED_LIBS=${{matrix.shared_lib}} -DV8PP_HEADER_ONLY=${{matrix.header_only}} -DV8_COMPRESS_POINTERS=${{matrix.v8_compress_pointers}} + run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBUILD_TESTING=TRUE -DBUILD_SHARED_LIBS=${{matrix.shared_lib}} -DV8PP_HEADER_ONLY=${{matrix.header_only}} -DV8_COMPRESS_POINTERS=${{matrix.v8_compress_pointers}} -DV8_ENABLE_SANDBOX=${{matrix.v8_enable_sandbox}} - name: Build run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} diff --git a/CMakeLists.txt b/CMakeLists.txt index 989d93d4..98b0e701 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ set(V8PP_ISOLATE_DATA_SLOT 0 CACHE STRING "v8::Isolate data slot number, used in set(V8PP_PLUGIN_INIT_PROC_NAME "v8pp_module_init" CACHE STRING "v8pp plugin initialization procedure name") set(V8PP_PLUGIN_SUFFIX ${CMAKE_SHARED_MODULE_SUFFIX} CACHE STRING "v8pp plugin filename suffix") set(V8_COMPRESS_POINTERS 1 CACHE BOOL "Use new V8 ABI with V8_COMPRESS_POINTERS and V8_31BIT_SMIS_ON_64BIT_ARCH") +set(V8_ENABLE_SANDBOX 0 CACHE BOOL "Enable sandoxing in V8") if(BUILD_SHARED_LIBS AND WIN32) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS true) diff --git a/v8pp/CMakeLists.txt b/v8pp/CMakeLists.txt index 0f1e066f..074627bc 100644 --- a/v8pp/CMakeLists.txt +++ b/v8pp/CMakeLists.txt @@ -12,7 +12,11 @@ endif() configure_file(config.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/config.hpp) if(V8_COMPRESS_POINTERS) - set(V8PP_DEFINES V8_COMPRESS_POINTERS V8_31BIT_SMIS_ON_64BIT_ARCH) + list(APPEND V8PP_DEFINES V8_COMPRESS_POINTERS V8_31BIT_SMIS_ON_64BIT_ARCH) +endif() + +if (V8_ENABLE_SANDBOX) + list(APPEND V8PP_DEFINES V8_ENABLE_SANDBOX) endif() set(V8PP_HEADERS diff --git a/v8pp/version.ipp b/v8pp/version.ipp index 41943011..8d766612 100644 --- a/v8pp/version.ipp +++ b/v8pp/version.ipp @@ -41,6 +41,9 @@ V8PP_IMPL char const* build_options() #endif #ifdef V8_COMPRESS_POINTERS STR(V8_COMPRESS_POINTERS) +#endif +#ifdef V8_ENABLE_SANDBOX + STR(V8_ENABLE_SANDBOX) #endif ; #undef STR