Skip to content

Commit

Permalink
feat: add protobuf generation to build pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
roflmuffin committed Oct 12, 2023
1 parent ea2cfb9 commit 849e815
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/cmake-single-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
shell: bash
run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV

- name: Setup protobuf
shell: bash
run: sudo apt-get update && sudo apt install -y protobuf-compiler

- uses: actions/checkout@v3
with:
submodules: 'recursive'
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ jobs:
- if: steps.changes.outputs.csharp == 'true'
run: dotnet build -c Release managed/CounterStrikeSharp.API

- name: Setup protobuf
shell: bash
if: steps.changes.outputs.cpp == 'true'
run: sudo apt-get update && sudo apt install -y protobuf-compiler

- name: Configure CMake
if: steps.changes.outputs.cpp == 'true'
run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
Expand Down
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ SET(SOURCE_FILES
src/core/memory.h
)

# Generate protobuf source & headers
set(PROTO_DIRS -I${CMAKE_CURRENT_SOURCE_DIR}/libraries/GameTracking-CS2/Protobufs)
file(GLOB PROTOS "${CMAKE_CURRENT_SOURCE_DIR}/libraries/GameTracking-CS2/Protobufs/*.proto")

## Generate protobuf source & headers
add_custom_command(
OUTPUT protobuf_output_stamp
COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf/compile.sh
Expand All @@ -62,7 +65,6 @@ add_custom_command(
)

SET(SOURCE_FILES ${SOURCE_FILES} protobuf_output_stamp)

# Sources
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${NATIVES_SOURCES} ${CONVERSIONS_SOURCES} ${CONVERSIONS_HEADERS})

Expand Down
6 changes: 3 additions & 3 deletions src/protobuf/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ mkdir -p temp generated
mkdir -p generated

cp ../../libraries/GameTracking-CS2/Protobufs/*.proto temp/
cp -r google/ temp/

for file in temp/*.proto; do
echo 'syntax = "proto2";' | cat - $file > temp/tempfile && mv temp/tempfile $file
echo 'syntax = "proto2";' | cat - $file > temp/tempfile && mv temp/tempfile $file;
protoc --cpp_out=generated -I temp $file
done

./protoc --cpp_out=../generated -I=temp -I=. temp/*.proto > /dev/null 2>&1

rm -r temp
Binary file removed src/protobuf/protoc
Binary file not shown.

0 comments on commit 849e815

Please sign in to comment.