Skip to content

Commit 0f49e5c

Browse files
committed
chore: re-organized project.
1 parent 0536d63 commit 0f49e5c

30 files changed

+199
-96
lines changed

.gitignore

+20-15
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1+
# Visual Studio
2+
.sln/
3+
4+
*.sln.lnk
5+
16
# Godot 4+ specific ignores
27
.godot/
38

49
# Ignore library files but not the gdextension file
5-
demo/bin/*
6-
!demo/bin/android
7-
demo/bin/android/*
8-
!demo/bin/android/.gitkeep
9-
!demo/bin/linux
10-
demo/bin/linux/*
11-
!demo/bin/linux/.gitkeep
12-
!demo/bin/macos
13-
demo/bin/macos/*
14-
!demo/bin/macos/.gitkeep
15-
!demo/bin/windows
16-
demo/bin/windows/*
17-
!demo/bin/windows/.gitkeep
18-
!demo/bin/*.gdextension
10+
demo/client/bin/*
11+
!demo/client/bin/android
12+
demo/client/bin/android/*
13+
!demo/client/bin/android/.gitkeep
14+
!demo/client/bin/linux
15+
demo/client/bin/linux/*
16+
!demo/client/bin/linux/.gitkeep
17+
!demo/client/bin/macos
18+
demo/client/bin/macos/*
19+
!demo/client/bin/macos/.gitkeep
20+
!demo/client/bin/windows
21+
demo/client/bin/windows/*
22+
!demo/client/bin/windows/.gitkeep
23+
!demo/client/bin/*.gdextension
1924
.sconsign*.dblite
2025

2126
# Ignore custom.py
@@ -48,4 +53,4 @@ compile_commands.json
4853
# VSCode
4954
.vscode/*
5055
!.vscode/extensions.json
51-
.DS_Store
56+
.DS_Store

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
path = godot-cpp
33
url = https://github.com/godotengine/godot-cpp.git
44
branch = 4.0
5+
[submodule "extern/librdkafka"]
6+
path = extern/librdkafka
7+
url = https://github.com/confluentinc/librdkafka.git

CMakeLists.txt

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
cmake_minimum_required(VERSION 3.23)
2+
project(
3+
Godot-Kafka
4+
VERSION 0.1.0
5+
LANGUAGES CXX
6+
)
7+
8+
# Generate the project files
9+
# execute_process(
10+
# COMMAND scons
11+
# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
12+
# )
13+
14+
# Set the C++ standard to C++17
15+
set(CMAKE_CXX_STANDARD 17)
16+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
17+
set(CMAKE_CXX_EXTENSIONS OFF)
18+
19+
# Use folders
20+
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
21+
22+
# Set CMake Predefined Targets Folders
23+
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "External/CMake")
24+
25+
# Output the binaries to the bin folder
26+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "$<1:${PROJECT_SOURCE_DIR}/demo/client/bin/${CMAKE_SYSTEM_NAME}>")
27+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "$<1:${PROJECT_SOURCE_DIR}/demo/server/bin/${CMAKE_SYSTEM_NAME}>")
28+
29+
# Prefix all the binaries with "lib"
30+
set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
31+
32+
# Glob all sources files.
33+
file(GLOB_RECURSE SOURCES "src/*.cpp")
34+
file(GLOB_RECURSE HEADERS "src/*.hpp" "src/*.h")
35+
36+
add_library(GodotKafka SHARED
37+
${SOURCES}
38+
${HEADERS}
39+
)
40+
41+
# Include Godot::cpp
42+
add_subdirectory(godot-cpp)
43+
target_link_libraries(GodotKafka PRIVATE godot::cpp)
44+
set_target_properties(godot-cpp PROPERTIES FOLDER "External/Godot")
45+
46+
# Include librdkafka
47+
set(RDKAFKA_BUILD_EXAMPLES OFF)
48+
set(RDKAFKA_BUILD_TESTS OFF)
49+
add_subdirectory(extern/librdkafka)
50+
target_link_libraries(GodotKafka PRIVATE rdkafka)
51+
set_target_properties(rdkafka PROPERTIES FOLDER "External/rdkafka")
52+
set_target_properties(rdkafka++ PROPERTIES FOLDER "External/rdkafka")

README.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
# godot-cpp template
2-
This repository serves as a quickstart template for GDExtension development with Godot 4.0+.
1+
# Godot-Kafka
2+
[![Build GDExtension](https://github.com/bsmithcompsci/godot-kafka-multiplayer-peer/actions/workflows/builds.yml/badge.svg)](https://github.com/bsmithcompsci/godot-kafka-multiplayer-peer/actions/workflows/builds.yml)
3+
4+
Godot-Kafka is a GDExtension for Godot 4.x+.
5+
36

47
## Contents
5-
* An empty Godot project (`demo/`)
8+
* An empty Godot project (`demo/client`)
9+
* Multiple Edge Services in various languages (`demo/server`)
610
* godot-cpp as a submodule (`godot-cpp/`)
711
* GitHub Issues template (`.github/ISSUE_TEMPLATE.yml`)
812
* GitHub CI/CD workflows to publish your library packages when creating a release (`.github/workflows/builds.yml`)

SConstruct

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ def validate_parent_dir(key, val, env):
1111
raise UserError("'%s' is not a directory: %s" % (key, os.path.dirname(val)))
1212

1313

14-
libname = "EXTENSION-NAME"
15-
projectdir = "demo"
14+
libname = "godot-kafka"
15+
projectdir = "demo/client"
1616

1717
localEnv = Environment(tools=["default"], PLATFORM="")
1818

bin/ios/ios.framework/Info.plist

-32
This file was deleted.

bin/macos/macos.framework/Resources/Info.plist

-32
This file was deleted.

demo/bin/macos/.gitkeep

Whitespace-only changes.

demo/bin/windows/.gitkeep

Whitespace-only changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

demo/server/rust-example/Cargo.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "rust-example"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]

demo/server/rust-example/src/main.rs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
println!("Hello, world!");
3+
}

extern/librdkafka

Submodule librdkafka added at d72576a

src/gen/doc_data.gen.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* THIS FILE IS GENERATED DO NOT EDIT */
2+
3+
#include <godot_cpp/godot.hpp>
4+
5+
static const char *_doc_data_hash = "9135276270124498186";
6+
static const int _doc_data_uncompressed_size = 0;
7+
static const int _doc_data_compressed_size = 8;
8+
static const unsigned char _doc_data_compressed[] = {
9+
120,
10+
218,
11+
3,
12+
0,
13+
0,
14+
0,
15+
0,
16+
1,
17+
};
18+
19+
static godot::internal::DocDataRegistration _doc_data_registration(_doc_data_hash, _doc_data_uncompressed_size, _doc_data_compressed_size, _doc_data_compressed);
20+

src/kafka_multiplayer.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "kafka_multiplayer.h"

src/kafka_multiplayer.h

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
3+
#include <godot_cpp/classes/node.hpp>
4+
#include <rdkafka.h>
5+
6+
class KafkaMultiplayer : godot::Node {
7+
GDCLASS(KafkaMultiplayer, godot::Node)
8+
9+
private:
10+
11+
protected:
12+
static void _bind_methods();
13+
14+
public:
15+
KafkaMultiplayer();
16+
~KafkaMultiplayer();
17+
};

src/kafka_multiplayer_peer.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "kafka_multiplayer_peer.h"

src/kafka_multiplayer_peer.h

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#pragma once
2+
3+
class KafkaMultiplayerPeer {
4+
};

src/register_types.cpp

+7-9
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@
44
#include <godot_cpp/core/defs.hpp>
55
#include <godot_cpp/godot.hpp>
66

7-
using namespace godot;
8-
9-
void initialize_gdextension_types(ModuleInitializationLevel p_level)
7+
void initialize_gdextension_types(godot::ModuleInitializationLevel p_level)
108
{
11-
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
9+
if (p_level != godot::MODULE_INITIALIZATION_LEVEL_SCENE) {
1210
return;
1311
}
1412
//ClassDB::register_class<YourClass>();
1513
}
1614

17-
void uninitialize_gdextension_types(ModuleInitializationLevel p_level) {
18-
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
15+
void uninitialize_gdextension_types(godot::ModuleInitializationLevel p_level) {
16+
if (p_level != godot::MODULE_INITIALIZATION_LEVEL_SCENE) {
1917
return;
2018
}
2119
}
@@ -25,11 +23,11 @@ extern "C"
2523
// Initialization
2624
GDExtensionBool GDE_EXPORT example_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization)
2725
{
28-
GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);
26+
godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);
2927
init_obj.register_initializer(initialize_gdextension_types);
3028
init_obj.register_terminator(uninitialize_gdextension_types);
31-
init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);
29+
init_obj.set_minimum_library_initialization_level(godot::MODULE_INITIALIZATION_LEVEL_SCENE);
3230

3331
return init_obj.init();
3432
}
35-
}
33+
}

src/register_types.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef EXAMPLE_REGISTER_TYPES_H
22
#define EXAMPLE_REGISTER_TYPES_H
33

4-
void initialize_gdextension_types();
5-
void uninitialize_gdextension_types();
4+
void initialize_gdextension_types(godot::ModuleInitializationLevel p_level);
5+
void uninitialize_gdextension_types(godot::ModuleInitializationLevel p_level);
66

7-
#endif // EXAMPLE_REGISTER_TYPES_H
7+
#endif // EXAMPLE_REGISTER_TYPES_H

vs.bat

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
@echo off
2+
3+
setlocal
4+
5+
:: Check, if want release or debug
6+
choice /C RD /M "Do you want to generate a release or debug project?"
7+
if %ERRORLEVEL% equ 1 (
8+
set "buildType=Release"
9+
) else (
10+
set "buildType=Debug"
11+
)
12+
13+
14+
if exist .sln/%buildType% (
15+
@REM Delete the .sln folder
16+
rmdir /s /q .sln/%buildType%
17+
)
18+
19+
mkdir .sln
20+
mkdir ".sln\%buildType%"
21+
pushd ".sln\%buildType%"
22+
23+
cmake -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=%buildType% ../..
24+
if %ERRORLEVEL% neq 0 (
25+
echo CMake failed.
26+
pause
27+
exit /b %ERRORLEVEL%
28+
)
29+
30+
REM Create a shortcut to the .sln file
31+
set "shortcutName=Project.sln"
32+
set "targetPath=%~dp0.sln\%buildType%\Godot-Kafka.sln"
33+
set "shortcutPath=%~dp0%shortcutName%.lnk"
34+
35+
:: Delete the shortcut if it already exists
36+
if exist "%shortcutPath%" (
37+
del "%shortcutPath%"
38+
)
39+
40+
REM Check if the shortcut already exists
41+
if exist "%shortcutPath%" (
42+
echo Shortcut already exists.
43+
) else (
44+
echo Creating shortcut...
45+
powershell -Command "$WshShell = New-Object -ComObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut('%shortcutPath%'); $Shortcut.TargetPath = '%targetPath%'; $Shortcut.Save()"
46+
)
47+
48+
start %shortcutPath%
49+
50+
endlocal
51+
52+
exit /b

0 commit comments

Comments
 (0)