Skip to content

Commit

Permalink
chore: add protobuf compilation to build
Browse files Browse the repository at this point in the history
  • Loading branch information
roflmuffin committed Oct 12, 2023
1 parent 305fe82 commit ea2cfb9
Show file tree
Hide file tree
Showing 5 changed files with 948 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
cmake-build-debug/
.kdev4/
.vscode/
generated/

libraries/mono/

Expand Down
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ SET(SOURCE_FILES
src/core/memory.h
)

# Generate protobuf source & headers
add_custom_command(
OUTPUT protobuf_output_stamp
COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf/compile.sh
COMMENT "Generating protobuf files using compile.sh script"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf/compile.sh
VERBATIM
)

SET(SOURCE_FILES ${SOURCE_FILES} protobuf_output_stamp)

# Sources
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${NATIVES_SOURCES} ${CONVERSIONS_SOURCES} ${CONVERSIONS_HEADERS})
Expand Down
15 changes: 15 additions & 0 deletions src/protobuf/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

rm -rf temp/ generated/
mkdir -p temp generated
mkdir -p generated

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

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

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

rm -r temp
Loading

0 comments on commit ea2cfb9

Please sign in to comment.