Skip to content

Commit

Permalink
Merge pull request #41 from giubacc/v8-build-fix
Browse files Browse the repository at this point in the history
bump v8 to 12.7.131
  • Loading branch information
giubacc authored Jul 30, 2024
2 parents f2e1f2a + 8a4741c commit a4b3774
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 87 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ wd
contrib/v8
contrib/.cipd
contrib/.gclient*
contrib/.gcs_entries
contrib/rapidyaml-build
contrib/pistache-build
venv
2 changes: 1 addition & 1 deletion contrib/depot_tools
Submodule depot_tools updated from a5c46d to fca881
50 changes: 0 additions & 50 deletions examples/scenario-1.js

This file was deleted.

4 changes: 2 additions & 2 deletions scripts/Dockerfile.leap.builder
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12 \
&& update-alternatives --install /usr/bin/python3 python /usr/bin/python3.11 311

RUN mkdir -p /project/contrib && mkdir -p /project/chatterbox
ENV CONTRIB_PATH /project/contrib
ENV TAR_OPTIONS --no-same-owner
ENV CONTRIB_PATH=/project/contrib
ENV TAR_OPTIONS=--no-same-owner

COPY contrib_init.sh /usr/bin/contrib_init.sh
COPY rapidyaml-build /project/contrib/rapidyaml-build
Expand Down
45 changes: 23 additions & 22 deletions scripts/Dockerfile.ubuntu.builder
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:22.04
FROM ubuntu:22.04 AS builder
LABEL Name=chatterbox-ubuntu-builder

RUN apt-get update && apt-get -y install \
RUN apt-get update && apt-get -y install --no-install-recommends \
build-essential \
ninja-build \
wget \
Expand All @@ -16,34 +16,35 @@ RUN apt-get update && apt-get -y install \
libtool \
libssl-dev \
libcurl4-openssl-dev \
&& apt-get autoremove
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir -p /project/contrib && mkdir -p /project/chatterbox
ENV CONTRIB_PATH /project/contrib
ENV TAR_OPTIONS --no-same-owner
ENV CONTRIB_PATH=/project/contrib
ENV TAR_OPTIONS=--no-same-owner

COPY contrib_init.sh /usr/bin/contrib_init.sh
COPY rapidyaml-build /project/contrib/rapidyaml-build
COPY build.sh /usr/bin/build.sh

RUN contrib_init.sh && build.sh build-deps \
&& find /project/contrib -name "*.o" -type f -delete \
&& find /project/contrib -name "*.so" -type f -delete \
&& find /project/contrib -name "*.exe" -type f -delete \
&& cp -R --parents /project/contrib/rapidyaml-build /tmp \
&& cp -R --parents /project/contrib/pistache/include /tmp \
&& cp -R --parents /project/contrib/pistache/build/src /tmp \
&& cp -R --parents /project/contrib/restclient-cpp/include /tmp \
&& cp -R --parents /project/contrib/cryptopp /tmp \
&& cp -R --parents /project/contrib/spdlog/include /tmp \
&& cp -R --parents /project/contrib/clipp/include /tmp \
&& cp -R --parents /project/contrib/v8/include /tmp \
&& cp -R --parents /project/contrib/googletest/googletest/include /tmp \
&& cp -R --parents /project/contrib/restclient-cpp/.libs /tmp \
&& cp -R --parents /project/contrib/v8/out/x64.release/obj /tmp \
&& cp -R --parents /project/contrib/googletest/build/lib /tmp \
&& rm -rf /project/contrib \
&& mv /tmp/project/contrib /project/contrib
&& find /project/contrib -name "*.o" -type f -delete \
&& find /project/contrib -name "*.so" -type f -delete \
&& find /project/contrib -name "*.exe" -type f -delete \
&& cp -R --parents /project/contrib/rapidyaml-build /tmp \
&& cp -R --parents /project/contrib/pistache/include /tmp \
&& cp -R --parents /project/contrib/pistache/build/src /tmp \
&& cp -R --parents /project/contrib/restclient-cpp/include /tmp \
&& cp -R --parents /project/contrib/cryptopp /tmp \
&& cp -R --parents /project/contrib/spdlog/include /tmp \
&& cp -R --parents /project/contrib/clipp/include /tmp \
&& cp -R --parents /project/contrib/v8/include /tmp \
&& cp -R --parents /project/contrib/googletest/googletest/include /tmp \
&& cp -R --parents /project/contrib/restclient-cpp/.libs /tmp \
&& cp -R --parents /project/contrib/v8/out/x64.release/obj /tmp \
&& cp -R --parents /project/contrib/googletest/build/lib /tmp \
&& rm -rf /project/contrib \
&& mv /tmp/project/contrib /project/contrib

ENTRYPOINT ["build.sh"]
CMD ["build"]
5 changes: 3 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ build_v8() {
cd $contrib_path
fetch v8
cd v8
git checkout branch-heads/11.9
git checkout 12.7.226
args=$(cat <<EOF
dcheck_always_on = false
is_component_build = false
Expand All @@ -176,7 +176,8 @@ v8_monolithic = true
v8_use_external_startup_data = false
EOF
)
patch_v8_code
#no more needed
#patch_v8_code

gn gen out/x64.release --args="${args}"
ninja -j$ninja_jobs -C out/x64.release v8_monolith || exit 1
Expand Down
4 changes: 2 additions & 2 deletions scripts/contrib_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ git clone https://github.com/google/googletest.git
echo "Bumping contrib resources ..."

cd $contrib_path/clipp && git checkout v1.2.3
cd $contrib_path/rapidyaml && git checkout master
cd $contrib_path/pistache && git checkout master
cd $contrib_path/rapidyaml && git checkout 7c0036e7c41318ec75368f9a2b2148c31b3121db
cd $contrib_path/pistache && git checkout fe5639a81a4392a7b8ab22c29a3d5c761e8e98d6
cd $contrib_path/restclient-cpp && git checkout set-verify-host
cd $contrib_path/spdlog && git checkout v1.9.2
cd $contrib_path/cryptopp && git checkout CRYPTOPP_8_7_0
Expand Down
8 changes: 6 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
cmake_minimum_required(VERSION 3.12)
project(chatterbox_binary VERSION 0.0.0)

option(ADD_DEBUG_SYMBOLS "Add debug symbols" OFF)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Wall -std=c++17)
# add_compile_options(-g -Wall -std=c++17)
add_compile_options(-Wall -std=c++20)
if(ADD_DEBUG_SYMBOLS)
add_compile_options(-g)
endif()
endif()

add_definitions(-DV8_COMPRESS_POINTERS
Expand Down
22 changes: 17 additions & 5 deletions src/jsenv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ int js_env::init(std::shared_ptr<spdlog::logger> &event_log)

int js_env::reset()
{
// Create a handle scope to hold the temporary references.
v8::HandleScope renew_scenario_context_scope(isolate_);
v8::Isolate::Scope isolate_scope(isolate_);
v8::HandleScope handle_scope(isolate_);

// Create a template for the global object where we set the
// built-in global functions.
Expand Down Expand Up @@ -124,6 +124,7 @@ v8::Local<v8::ObjectTemplate> js_env::make_ryml_noderef_template()

bool js_env::install_scenario_objects()
{
v8::Isolate::Scope isolate_scope(isolate_);
v8::HandleScope handle_scope(isolate_);

auto &holder = nodes_holder_[&parent_.scenario_out_] = std::unordered_map<size_t, ryml::NodeRef>();
Expand All @@ -145,6 +146,7 @@ bool js_env::install_scenario_objects()

v8::Local<v8::Object> js_env::wrap_ryml_noderef(ryml::NodeRef &obj)
{
v8::Isolate::Scope isolate_scope(isolate_);
v8::EscapableHandleScope handle_scope(isolate_);

// Fetch the template for creating ryml::NodeRef wrappers.
Expand Down Expand Up @@ -221,7 +223,9 @@ bool js_env::ryml_noderef_from_js_value(ryml::NodeRef &obj_val,
v8::Local<v8::Value> &js_obj_val,
js_env &self)
{
v8::Isolate::Scope isolate_scope(self.isolate_);
v8::HandleScope scope(self.isolate_);

v8::Local<v8::Context> ctx = self.scenario_context_.Get(self.isolate_);

if(js_obj_val->IsNull()) {
Expand Down Expand Up @@ -276,6 +280,7 @@ void js_env::ryml_noderef_get_by_name(v8::Local<v8::Name> key,
return;
}

v8::Isolate::Scope isolate_scope(pci.GetIsolate());
v8::HandleScope scope(pci.GetIsolate());

v8::Local<v8::Context> context = pci.GetIsolate()->GetCurrentContext();
Expand Down Expand Up @@ -317,6 +322,7 @@ void js_env::ryml_noderef_set_by_name(v8::Local<v8::Name> key,
return;
}

v8::Isolate::Scope isolate_scope(pci.GetIsolate());
v8::HandleScope scope(pci.GetIsolate());

v8::Local<v8::Context> context = pci.GetIsolate()->GetCurrentContext();
Expand Down Expand Up @@ -355,6 +361,7 @@ void js_env::ryml_noderef_set_by_name(v8::Local<v8::Name> key,
void js_env::ryml_noderef_get_by_idx(uint32_t index,
const v8::PropertyCallbackInfo<v8::Value> &pci)
{
v8::Isolate::Scope isolate_scope(pci.GetIsolate());
v8::HandleScope scope(pci.GetIsolate());

v8::Local<v8::Context> context = pci.GetIsolate()->GetCurrentContext();
Expand Down Expand Up @@ -388,6 +395,7 @@ void js_env::ryml_noderef_set_by_idx(uint32_t index,
v8::Local<v8::Value> value,
const v8::PropertyCallbackInfo<v8::Value> &pci)
{
v8::Isolate::Scope isolate_scope(pci.GetIsolate());
v8::HandleScope scope(pci.GetIsolate());

v8::Local<v8::Context> context = pci.GetIsolate()->GetCurrentContext();
Expand Down Expand Up @@ -434,6 +442,7 @@ bool js_env::invoke_js_function(ryml::NodeRef *ctx,
return false;
}

v8::Isolate::Scope isolate_scope(isolate_);
v8::HandleScope scope(isolate_);
v8::Local<v8::Context> context = scenario_context_.Get(isolate_);
v8::Context::Scope context_scope(context);
Expand Down Expand Up @@ -492,7 +501,8 @@ void js_env::cbk_log(const v8::FunctionCallbackInfo<v8::Value> &args)
}

v8::Isolate *isolate = args.GetIsolate();
v8::HandleScope scope(isolate);
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);

v8::Local<v8::Context> context = isolate->GetCurrentContext();

Expand Down Expand Up @@ -520,7 +530,8 @@ void js_env::cbk_load(const v8::FunctionCallbackInfo<v8::Value> &args)
}

v8::Isolate *isolate = args.GetIsolate();
v8::HandleScope scope(isolate);
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);

v8::Local<v8::Value> script_path_arg = args[0];
v8::String::Utf8Value script_path(isolate, script_path_arg);
Expand Down Expand Up @@ -568,7 +579,8 @@ void js_env::cbk_assert(const v8::FunctionCallbackInfo<v8::Value> &args)
}

v8::Isolate *isolate = args.GetIsolate();
v8::HandleScope scope(isolate);
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);

v8::Local<v8::Context> context = isolate->GetCurrentContext();
js_env *self = static_cast<js_env *>(context->GetAlignedPointerFromEmbedderData(1));
Expand Down
7 changes: 6 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
cmake_minimum_required(VERSION 3.12)
project(chatterbox_test VERSION 0.0.0)

option(ADD_DEBUG_SYMBOLS "Add debug symbols" OFF)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-g -Wall -std=c++17)
add_compile_options(-Wall -std=c++20)
if(ADD_DEBUG_SYMBOLS)
add_compile_options(-g)
endif()
endif()

add_definitions(-DV8_COMPRESS_POINTERS
Expand Down

0 comments on commit a4b3774

Please sign in to comment.