diff --git a/.github/workflows/build-builder.yaml b/.github/workflows/build-builder.yaml index 35a60bf..b918f75 100644 --- a/.github/workflows/build-builder.yaml +++ b/.github/workflows/build-builder.yaml @@ -7,7 +7,7 @@ on: workflow_dispatch: # Allow this workflow to be triggered manually env: - IMAGE_NAME_BUILDER: chatterbox-builder + IMAGE_NAME_BUILDER: chatterbox-ubuntu-builder jobs: build-and-push-builder: @@ -30,7 +30,7 @@ jobs: - name: Build and push builder-image uses: docker/build-push-action@v3 with: - file: 'scripts/Dockerfile.builder' + file: 'scripts/Dockerfile-ubuntu.builder' context: scripts push: true tags: ghcr.io/${{ github.actor }}/${{ env.IMAGE_NAME_BUILDER }}:latest diff --git a/contrib/depot_tools b/contrib/depot_tools index 9c44fe5..a5c46d2 160000 --- a/contrib/depot_tools +++ b/contrib/depot_tools @@ -1 +1 @@ -Subproject commit 9c44fe5fca957f65f36b5a5f2b375c2ad95b83dc +Subproject commit a5c46d20477c1a66dba04f4f6abe99be5e890ca3 diff --git a/docs/build.md b/docs/build.md index 254ac78..4f7fe41 100644 --- a/docs/build.md +++ b/docs/build.md @@ -3,7 +3,7 @@ - [Build](#build) - [Build requirements](#build-requirements) - [How to build](#how-to-build) - - [Build using the OpenSuse Leap Docker builder image](#build-using-the-opensuse-leap-docker-builder-image) + - [Build using a Docker builder image](#build-using-a-docker-builder-image) ## Build requirements @@ -12,15 +12,14 @@ Currently, `chatterbox` can be solely built under Linux. If you wish to build the `chatterbox` binary directly on your Linux distribution, ensure your system provides all the required dependencies. You can figure out what are the needed packages for your system by inspecting the -[builder Dockerfile](../scripts/Dockerfile.builder) for OpenSuse Tumbleweed. +[builder Dockerfile](../scripts/Dockerfile-leap.builder) for OpenSuse Tumbleweed. ## How to build After you have checked out all the `chatterbox`'s submodules with: ```shell -git submodule init -git submodule update +git submodule update --init --recursive ``` Build the `chatterbox` binary, alongside with all its dependencies, with: @@ -30,15 +29,16 @@ cd scripts ./build.sh build-all ``` -### Build using the OpenSuse Leap Docker builder image +### Build using a Docker builder image It is possible to use a Docker builder image to compile the binary of `chatterbox`. -- `scripts/Dockerfile.builder` +- `scripts/Dockerfile-leap.builder` +- `scripts/Dockerfile-ubuntu.builder` To build `chatterbox` with the Docker builder image, your system needs -to provide Podman or Docker. +to provide Docker. To create the `chatterbox` builder image: @@ -50,12 +50,12 @@ cd scripts ```shell $ docker images -REPOSITORY TAG -localhost/chatterbox-builder latest +REPOSITORY TAG +localhost/chatterbox-ubuntu-builder latest ``` -Using this image, it is possible to build the `chatterbox` binary -for OpenSuse Leap: +Using the image, it is possible to build the `chatterbox` binary +for the target system: ```shell cd scripts diff --git a/scripts/Dockerfile.builder b/scripts/Dockerfile-leap.builder similarity index 85% rename from scripts/Dockerfile.builder rename to scripts/Dockerfile-leap.builder index 0b61adf..2d5589c 100644 --- a/scripts/Dockerfile.builder +++ b/scripts/Dockerfile-leap.builder @@ -24,15 +24,17 @@ RUN zypper -n install --no-recommends \ RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12 \ && update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-12 12 \ && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 12 \ -&& update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-12 12 +&& update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-12 12 \ +&& update-alternatives --install /usr/bin/python3 python /usr/bin/python3.11 311 + +RUN mkdir -p /project/contrib +ENV CONTRIB_PATH /project/contrib +ENV TAR_OPTIONS --no-same-owner COPY contrib_init.sh /usr/bin/contrib_init.sh -COPY rapidyaml-build /contrib/rapidyaml-build +COPY rapidyaml-build /project/contrib/rapidyaml-build COPY build.sh /usr/bin/build.sh -ENV CONTRIB_PATH /contrib -ENV TAR_OPTIONS --no-same-owner - RUN contrib_init.sh && build.sh build-deps \ && find /contrib -name "*.o" -type f -delete \ && find /contrib -name "*.so" -type f -delete \ @@ -47,7 +49,7 @@ RUN contrib_init.sh && build.sh build-deps \ && cp -R --parents /contrib/v8/include /tmp \ && cp -R --parents /contrib/googletest/googletest/include /tmp \ && cp -R --parents /contrib/restclient-cpp/.libs /tmp \ -&& cp -R --parents /contrib/v8/out/x86.release/obj /tmp \ +&& cp -R --parents /contrib/v8/out/x64.release/obj /tmp \ && cp -R --parents /contrib/googletest/build/lib /tmp \ && rm -rf /contrib \ && mv /tmp/contrib /contrib diff --git a/scripts/Dockerfile-ubuntu.builder b/scripts/Dockerfile-ubuntu.builder new file mode 100644 index 0000000..bd5afd7 --- /dev/null +++ b/scripts/Dockerfile-ubuntu.builder @@ -0,0 +1,48 @@ +FROM ubuntu:22.04 +LABEL Name=chatterbox-builder + +RUN apt-get update && apt-get -y install \ + build-essential \ + ninja-build \ + wget \ + make \ + cmake \ + git \ + python3 \ + python3-venv \ + libglib2.0-dev \ + automake \ + autogen \ + libssl-dev \ + libcurl4-openssl-dev \ + && apt-get autoremove + +RUN mkdir -p /project/contrib +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 /contrib -name "*.o" -type f -delete \ +&& find /contrib -name "*.so" -type f -delete \ +&& find /contrib -name "*.exe" -type f -delete \ +&& cp -R --parents /contrib/rapidyaml-build /tmp \ +&& cp -R --parents /contrib/pistache/include /tmp \ +&& cp -R --parents /contrib/pistache/build/src /tmp \ +&& cp -R --parents /contrib/restclient-cpp/include /tmp \ +&& cp -R --parents /contrib/cryptopp /tmp \ +&& cp -R --parents /contrib/spdlog/include /tmp \ +&& cp -R --parents /contrib/clipp/include /tmp \ +&& cp -R --parents /contrib/v8/include /tmp \ +&& cp -R --parents /contrib/googletest/googletest/include /tmp \ +&& cp -R --parents /contrib/restclient-cpp/.libs /tmp \ +&& cp -R --parents /contrib/v8/out/x64.release/obj /tmp \ +&& cp -R --parents /contrib/googletest/build/lib /tmp \ +&& rm -rf /contrib \ +&& mv /tmp/contrib /contrib + +ENTRYPOINT ["build.sh"] +CMD ["build"] diff --git a/scripts/build.sh b/scripts/build.sh index a82e542..106d535 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -3,9 +3,10 @@ container_mng=${CNT_MNG:-"docker"} basedir=$(realpath ${BASE_DIR:-"../"}) ninja_jobs=${NINJA_JOBS:-"6"} -builder_image=${BUILDER_IMAGE:-"chatterbox-builder"} +builder_image=${BUILDER_IMAGE:-"chatterbox-ubuntu-builder"} +builder_dockerfile=${BUILDER_DOCKERFILE:-"Dockerfile-ubuntu.builder"} contrib_path=$(realpath ${CONTRIB_PATH:-"../contrib"}) -python_bin=${PYTHON_BIN:-"python3.11"} +python_bin=${PYTHON_BIN:-"python3"} usage() { cat << EOF @@ -35,6 +36,7 @@ env variables BASE_DIR Specify the directory containing src and test directories (default: ../). NINJA_JOBS Specify the number of parallel ninja jobs. BUILDER_IMAGE Specify the builder's image to use. + BUILDER_DOCKERFILE Specify the builder's dockerfile to use. CONTRIB_PATH Specify the path where contrib resources are placed. EOF } @@ -45,8 +47,8 @@ error() { create_builder() { echo "Creating the chatterbox builder image ..." - $container_mng build -t chatterbox-builder \ - -f Dockerfile.builder . || exit 1 + $container_mng build -t ${builder_image} \ + -f $builder_dockerfile . || exit 1 } builder_build() { @@ -155,8 +157,8 @@ clean_googletest() { # see this issue: https://bugs.chromium.org/p/v8/issues/detail?id=13455 patch_v8_code() { - sed -i 's/std::is_pod/std::is_standard_layout/g' $basedir/contrib/v8/src/base/vector.h - sed -i 's/std::back_insert_iterator(snapshots)/std::back_insert_iterator>(snapshots)/g' $basedir/contrib/v8/src/compiler/turboshaft/wasm-gc-type-reducer.cc + sed -i 's/std::is_pod/std::is_standard_layout/g' $contrib_path/v8/src/base/vector.h + sed -i 's/std::back_insert_iterator(snapshots)/std::back_insert_iterator>(snapshots)/g' $contrib_path/v8/src/compiler/turboshaft/wasm-gc-type-reducer.cc } build_v8() { @@ -181,8 +183,8 @@ EOF ) patch_v8_code - gn gen out/x86.release --args="${args}" - ninja -j$ninja_jobs -C out/x86.release v8_monolith || exit 1 + gn gen out/x64.release --args="${args}" + ninja -j$ninja_jobs -C out/x64.release v8_monolith || exit 1 } clean_v8() { diff --git a/scripts/contrib_init.sh b/scripts/contrib_init.sh index 038ec36..0beb308 100755 --- a/scripts/contrib_init.sh +++ b/scripts/contrib_init.sh @@ -1,6 +1,6 @@ #!/bin/bash -contrib_path=$(realpath ${CONTRIB_PATH:-"/contrib"}) +contrib_path=$(realpath ${CONTRIB_PATH:-"../contrib"}) mkdir -p $contrib_path diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cfd7a1b..8ef6535 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,7 +24,7 @@ link_directories(${CONTRIB_PATH}/restclient-cpp/.libs ${CONTRIB_PATH}/rapidyaml-build/lib ${CONTRIB_PATH}/pistache/build/src ${CONTRIB_PATH}/cryptopp - ${CONTRIB_PATH}/v8/out/x86.release/obj) + ${CONTRIB_PATH}/v8/out/x64.release/obj) add_executable(cbx main.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9bfd928..279eac4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -26,7 +26,7 @@ link_directories(${CONTRIB_PATH}/restclient-cpp/.libs ${CONTRIB_PATH}/rapidyaml-build/lib ${CONTRIB_PATH}/pistache/build/src ${CONTRIB_PATH}/cryptopp - ${CONTRIB_PATH}/v8/out/x86.release/obj + ${CONTRIB_PATH}/v8/out/x64.release/obj ${CONTRIB_PATH}/googletest/build/lib) add_executable(cbx_test