Skip to content

Commit

Permalink
Bugs and Improvements for CPP SDK and Example (#3318)
Browse files Browse the repository at this point in the history
* Bugs and Improvements for CPP SDK and Example

This fixes a bug in the CPP SDK, that was highlighted in the CPP
example, but didn't end show up in the conformance tests, as well as
several quality of life improvements.

* Bring all the gRPC references to our current gRPC version in the
  project.
* Add `-j$(nproc)` for all `build` targets to utlise more cores when
compiling. Shaved some time off compilation.
* Make the setup and compilation of the example align with the unit
tests (where it makes sense) - so same base image, etc.
* Explicitly compile the Abseil dependency (this was the critical
issue!)

Not quite sure if there is a good way to force this kind of issue to
show up in the conformance tests, given that we rely on gRPC to be
installed on the base image all SDK images are derived from -- but at
least this gets us over the current hurdle.

Work on #3281
  • Loading branch information
markmandel committed Aug 11, 2023
1 parent 2b95491 commit b097ed0
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 28 deletions.
6 changes: 0 additions & 6 deletions build/build-sdk-images/cpp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ RUN apt-get --allow-releaseinfo-change update && \
apt-get install -y zip wget clang-format && \
apt-get clean

RUN wget -q https://cmake.org/files/v3.14/cmake-3.14.1-Linux-x86_64.sh -O /cmake-3.14.1-Linux-x86_64.sh
RUN mkdir /opt/cmake
RUN sh /cmake-3.14.1-Linux-x86_64.sh --prefix=/opt/cmake --skip-license
RUN ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake
RUN cmake --version

WORKDIR /go/src/agones.dev/agones

# code generation scripts
Expand Down
4 changes: 2 additions & 2 deletions build/build-sdk-images/cpp/build-sdk-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ has already built - using cached version. \
Use make clean-sdk-conformance-tests if you want to start from scratch"
fi
cd $DIR/sdk/.build
cmake --build . --target install
cmake --build . --target install -j$(nproc)
cd $DIR && mkdir -p .build && cd .build
cmake .. -G "Unix Makefiles" \
-DCMAKE_PREFIX_PATH=$DIR/sdk/.build \
-Dagones_DIR=$DIR/sdk/.build/agones/cmake \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=.bin
cmake --build . --target install
cmake --build . --target install -j$(nproc)
2 changes: 1 addition & 1 deletion build/build-sdk-images/tool/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


#
# Base images for SDKs Bump: 2
# Base images for SDKs Bump: 3
#

FROM debian:bullseye
Expand Down
32 changes: 18 additions & 14 deletions examples/cpp-simple/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,31 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM gcc:9 as builder
FROM debian:bullseye as builder

WORKDIR /project
RUN apt-get update && apt-get install -y \
build-essential autoconf libtool git pkg-config \
automake libtool curl make g++ unzip moreutils cmake \
&& apt-get clean

RUN wget -q https://cmake.org/files/v3.14/cmake-3.14.1-Linux-x86_64.sh -O /cmake-3.14.1-Linux-x86_64.sh
RUN mkdir /opt/cmake
RUN sh /cmake-3.14.1-Linux-x86_64.sh --prefix=/opt/cmake --skip-license
RUN ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake
RUN cmake --version
WORKDIR /project

COPY ./sdks/cpp sdk
RUN cd sdk && mkdir -p .build && \
RUN cd sdk && \
mkdir -p .build && \
cd .build && \
cmake .. -DCMAKE_BUILD_TYPE=Release -DAGONES_SILENT_OUTPUT=ON -G "Unix Makefiles" -Wno-dev && \
cmake --build . --target install
cmake .. -DCMAKE_BUILD_TYPE=Release -DAGONES_SILENT_OUTPUT=OFF -DCMAKE_INSTALL_PREFIX=/project/sdk/.build \
-DAGONES_THIRDPARTY_INSTALL_PATH=/project/sdk/.build -G "Unix Makefiles" -Wno-dev && \
cmake --build . --target install -j$(nproc)

COPY ./examples/cpp-simple cpp-simple
RUN cd cpp-simple && mkdir -p .build && \
cd .build && \
cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=.bin && \
cmake --build . --target install
RUN cd cpp-simple && mkdir -p .build && cd .build && \
cmake .. -G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=/project/sdk/.build \
-Dagones_DIR=/project/sdk/.build/agones/cmake \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=.bin && \
cmake --build . --target install -j$(nproc)

FROM debian:bullseye
RUN useradd -u 1000 -m server
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp-simple/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ REPOSITORY = us-docker.pkg.dev/agones-images/examples
# Directory that this Makefile is in.
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
project_path := $(dir $(mkfile_path))
server_tag = $(REPOSITORY)/cpp-simple-server:0.15
server_tag = $(REPOSITORY)/cpp-simple-server:0.16
root_path = $(realpath $(project_path)/../..)

# _____ _
Expand Down
2 changes: 1 addition & 1 deletion sdks/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
set(CMAKE_DEBUG_POSTFIX "d")
set(AGONES_GRPC_VERSION "1.50.1")
set(AGONES_GRPC_VERSION "1.53.0")

# Platform specific stuff
if (WIN32)
Expand Down
2 changes: 1 addition & 1 deletion sdks/cpp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ build:
-mkdir $(build_path)
-mkdir $(archive_path)
cd $(build_path) && cmake .. -DCMAKE_BUILD_TYPE=Release -DAGONES_SILENT_OUTPUT=ON -G "Unix Makefiles" -Wno-dev -DCMAKE_INSTALL_PREFIX=.install
cd $(build_path) && cmake --build . --target install -- -s
cd $(build_path) && cmake --build . --target install -j$$(nproc) -- -s

verify:
cd $(build_path)/clang-format && cmake . -DAGONES_SILENT_OUTPUT=ON
Expand Down
2 changes: 1 addition & 1 deletion sdks/cpp/build_scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ cd ..
mkdir -p .build
cd .build
cmake .. -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" -Wno-dev -DCMAKE_INSTALL_PREFIX=./install
cmake --build . --target install
cmake --build . --target install -j$(nproc)
6 changes: 5 additions & 1 deletion sdks/cpp/cmake/prerequisites.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ endif()

# gRPC repo and version
set(gRPC_GIT_REPO "https://github.com/gRPC/gRPC.git")
set(gRPC_GIT_TAG "v1.50.1")
set(gRPC_GIT_TAG "v1.53.0")

# OpenSSL required only for successful build gRPC
set(OPENSSL_GIT_REPO "https://github.com/openssl/openssl.git")
Expand Down Expand Up @@ -177,6 +177,9 @@ if (NOT ${gRPC_FOUND})
"-Dprotobuf_MSVC_STATIC_RUNTIME=OFF"
"-Dprotobuf_BUILD_TESTS=OFF"
)
invoke_cmake_build(absl ${gRPC_SOURCE_DIR}/third_party/abseil-cpp
"-DABSL_BUILD_TESTING=OFF"
)

# Build gRPC as cmake package
set(OPENSSL_PARAM "")
Expand Down Expand Up @@ -205,6 +208,7 @@ if (NOT ${gRPC_FOUND})
"-DgRPC_ZLIB_PROVIDER=package"
"-DgRPC_CARES_PROVIDER=package"
"-DgRPC_SSL_PROVIDER=package"
"-DgRPC_ABSL_PROVIDER=package"
${GRPC_EXTRA_FLAGS}
)
set(AGONES_OWN_GRPC TRUE CACHE BOOL "Third party is built by Agones" FORCE)
Expand Down

0 comments on commit b097ed0

Please sign in to comment.