Skip to content

Commit

Permalink
feat(ci): build library.
Browse files Browse the repository at this point in the history
  • Loading branch information
bsmithcompsci committed Oct 29, 2024
1 parent f1dca08 commit cda5305
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 18 deletions.
33 changes: 26 additions & 7 deletions .github/workflows/addon-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,48 @@ on:
jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
godot-version:
- 4x
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Create example.txt
run: echo "This is an example file..." > example.txt
- name: Build CMake project
run: cmake -B build -S . && cmake --build build

- name: Archive build artifacts
env:
GODOT_VERSION: ${{ matrix.godot-version }}
VERSION: ${{ github.ref }}
run: |
mkdir -p dist/bin
if [[ "$GODOT_VERSION" == "4x" ]]; then
# Write GDExtension config file
cp templates/godot-4x/ dist/
fi
- name: Zip example.txt
run: zip example.zip example.txt
# Copy the built binaries to the dist directory
cp build/bin/ dist/bin/
zip -r godot-${GODOT_VERSION}-kafka-${VERSION}.zip dist
# Upload the asset to the releases page, if the tag is a version tag; otherwise, upload it as an artifact.
- name: Upload Release Asset
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: example.zip
files: godot-${{ matrix.godot-version }}-kafka-${{ github.ref }}.zip
- name: Upload Artifact Asset
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: actions/upload-artifact@v4
env:
GODOT_VERSION: ${{ matrix.godot-version }}
VERSION: ${{ github.ref }}
with:
name: build
path: example.zip
path: godot-${{ matrix.godot-version }}-kafka-${{ github.ref }}.zip
if-no-files-found: error
retention-days: 1
overwrite: true
14 changes: 4 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ project(

option(BUILD_TESTS "Build the tests" ON)

# Generate the project files
# execute_process(
# COMMAND scons
# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
# )

# Set the C++ standard to C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -40,7 +34,7 @@ file(GLOB_RECURSE LIB_SOURCES "src/kafkalib/*.cpp")
file(GLOB_RECURSE LIB_HEADERS "src/kafkalib/*.hpp" "src/kafkalib/*.h" "include/kafkalib/*.hpp" "include/kafkalib/*.h")

# Include OpenSSL
set(OPENSSL_USE_STATIC_LIBS TRUE)
set(OPENSSL_USE_STATIC_LIBS TRUE CACHE BOOL "Use static OpenSSL libraries" FORCE)
find_package(OpenSSL REQUIRED)
set(system_library_extension "lib")

Expand Down Expand Up @@ -85,9 +79,9 @@ target_link_libraries(GodotKafka PRIVATE KafkaLib)
set_target_properties(godot-cpp PROPERTIES FOLDER "External/Godot")

# Include librdkafka
set(RDKAFKA_BUILD_EXAMPLES OFF)
set(RDKAFKA_BUILD_TESTS OFF)
set(RDKAFKA_BUILD_STATIC ON)
set(RDKAFKA_BUILD_EXAMPLES OFF CACHE BOOL "Disable building examples" FORCE)
set(RDKAFKA_BUILD_TESTS OFF CACHE BOOL "Disable building examples" FORCE)
set(RDKAFKA_BUILD_STATIC ON CACHE BOOL "Disable building examples" FORCE)
add_subdirectory(extern/librdkafka)
target_link_libraries(KafkaLib PUBLIC rdkafka) # rdkafka is the C library and the core.
target_link_libraries(KafkaLib PUBLIC rdkafka++) # rdkafka++ is a C++ wrapper around librdkafka
Expand Down
1 change: 1 addition & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cmake -B build -S . && cmake --build build
2 changes: 1 addition & 1 deletion src/godotkafka/register_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void uninitialize_gdextension_types(godot::ModuleInitializationLevel p_level) {
extern "C"
{
// Initialization
GDExtensionBool GDE_EXPORT library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization)
GDExtensionBool GDE_EXPORT GDExtensionInit(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization)
{
godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);
init_obj.register_initializer(initialize_gdextension_types);
Expand Down
24 changes: 24 additions & 0 deletions templates/godot-4x/godot-kafka.gdextension
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[configuration]

entry_symbol = "GDExtensionInit"
compatibility_minimum = 4.1
reloadable = false

[libraries]

// Exist only for Dedicated Servers.

linux.debug.dedicated_server = "lib/Linux/libGodotKafka-d.so"
linux.release.dedicated_server = "lib/Linux/libGodotKafka.so"

windows.debug.dedicated_server = "lib/Windows/libGodotKafka-d.dll"
windows.release.dedicated_server = "lib/Windows/libGodotKafka.dll"

// Duplicate for Editor

linux.debug.editor = "lib/Linux/libGodotKafka-d.so"
linux.release.editor = "lib/Linux/libGodotKafka.so"

windows.debug.editor = "lib/Windows/libGodotKafka-d.dll"
windows.release.editor = "lib/Windows/libGodotKafka.dll"

0 comments on commit cda5305

Please sign in to comment.