Skip to content

Move to GDExtension #825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 10 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "godot-cpp"]
path = godot-cpp
url = https://github.com/godotengine/godot-cpp.git
28 changes: 18 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(GODOT_ROOT_DIR ../../)

# Uncomment to pass auto completion in TOOLS mode
#add_compile_definitions(MONO_GLUE_ENABLED)
Expand All @@ -20,17 +19,26 @@ add_compile_definitions(X11_ENABLED)
#add_compile_definitions(IOS_ENABLED)
#add_compile_definitions(__ANDROID__)

# Get sources

# Project
file(GLOB_RECURSE SOURCES src/*.c**)
file(GLOB_RECURSE HEADERS src/*.h**)

# JNI
find_package(JNI REQUIRED)
add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS})

# Includes
include_directories(./src)
include_directories(${GODOT_ROOT_DIR})
include_directories(${JNI_INCLUDE_DIRS})
include_directories(src)
include_directories(
SYSTEM
godot-cpp/include
godot-cpp/include/godot_cpp
godot-cpp/gen/include
godot-cpp/gen/include/godot_cpp
godot-cpp/gdextension
)

find_package(JNI REQUIRED)
include_directories(
SYSTEM
${JNI_INCLUDE_DIRS}
)

# Target
add_library(${PROJECT_NAME} SHARED register_types.h register_types.cpp ${SOURCES} ${HEADERS})
85 changes: 85 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import os
import generate_templates

env = SConscript("godot-cpp/SConstruct")
java_home = os.environ["JAVA_HOME"]

# Generate templates when building the engine.
generate_templates.generate_header_from_files("kt/plugins/godot-intellij-plugin/src/main/resources/template", "src/editor/project/templates.h")

# Add those directory manually, so we can skip the godot_cpp directory when including headers in C++ files
source_path = [
os.path.join("godot-cpp", "include", "godot_cpp"),
os.path.join("godot-cpp", "gen", "include", "godot_cpp")
]
env.Append(CPPPATH=[env.Dir(d) for d in source_path])


# For the reference:
# - CCFLAGS are compilation flags shared between C and C++
# - CFLAGS are for C-specific compilation flags
# - CXXFLAGS are for C++-specific compilation flags
# - CPPFLAGS are for pre-processor flags
# - CPPDEFINES are for pre-processor defines
# - LINKFLAGS are for linking flags

# tweak this if you want to use different folders, or more folders, to store your source code in.
env.Append(CPPPATH=["src/"])
sources = [
Glob("register_types.cpp"),
Glob("src/*.cpp"),
Glob("src/jni/*.cpp"),
Glob("src/binding/*.cpp"),
Glob("src/resource_format/*.cpp"),
Glob("src/language/*.cpp"),
Glob("src/script/*.cpp"),
Glob("src/script/language/*.cpp"),
Glob("src/jvm_wrapper/*.cpp"),
Glob("src/jvm_wrapper/registration/*.cpp"),
Glob("src/jvm_wrapper/bridge/*.cpp"),
Glob("src/jvm_wrapper/memory/*.cpp"),
Glob("src/lifecycle/*.cpp"),
Glob("src/lifecycle/platforms/*.cpp"),
]

if env["target"] in ["editor", "template_debug"]:
sources.append(Glob("src/editor/*.cpp"))
sources.append(Glob("src/editor/project/*.cpp"))
sources.append(Glob("src/editor/build/*.cpp"))
sources.append(Glob("src/editor/ui/*.cpp"))
sources.append(Glob("src/editor/export/*.cpp"))

# Android
if env["platform"] != "android":
java_include_dirs = [
java_home + "/include",
java_home + "/include/linux",
java_home + "/include/win32",
java_home + "/include/darwin"
]
env.Append(CPPPATH=[java_include_dirs])


if env["platform"] == "macos":
library = env.SharedLibrary(
"bin/godot.jvm.{}.{}.framework/godot.jvm.{}.{}".format(
env["platform"], env["target"], env["platform"], env["target"]
),
source=sources,
)
elif env["platform"] == "ios":
if env["ios_simulator"]:
library = env.StaticLibrary(
"bin/godot.jvm.{}.{}.simulator.a".format(env["platform"], env["target"]),
source=sources,
)
else:
library = env.StaticLibrary(
"bin/godot.jvm.{}.{}.a".format(env["platform"], env["target"]),
source=sources,
)
else:
library = env.SharedLibrary(
"bin/godot.jvm.{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),
source=sources,
)
45 changes: 0 additions & 45 deletions SCsub

This file was deleted.

60 changes: 60 additions & 0 deletions build_profile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"enabled_classes": [
"Object",
"Mutex",
"RefCounted",
"Node",

"FileAccess",
"DirAccess",

"Resource",
"ResourceUID",
"ResourceLoader",
"ResourceFormatLoader",
"ResourceFormatSaver",

"Script",
"ScriptExtension",
"ScriptLanguage",
"ScriptLanguageExtension",

"Thread",

"MultiplayerAPI",
"MultiplayerPeer",

"OS",
"Json",
"Time",
"Engine",
"ProjectSetting",
"Marshalls",

"EditorNode",
"EditorInterface",
"EditorPlugin",
"EditorSettings",

"EditorExport",
"EditorExportPreset",
"EditorExportPlatform",
"EditorExportPlugin",

"Control",
"Button",
"VScrollBar",
"AcceptDialog",
"PopupMenu",
"CheckBox",
"Label",
"ProgressBar",
"ScrollContainer",
"VSeparator",
"OptionButton",
"VBoxContainer",
"RichTextLabel",
"TranslationServer",
"TranslationDomain"
]
}
3 changes: 0 additions & 3 deletions generate_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def generate_header_from_files(directory, header_file):
file_is_binary = []

with open(header_file, 'w') as header:
header.write(f'#ifdef TOOLS_ENABLED \n\n')
header.write(f'// Auto-generated templates from {directory} directory \n\n')
header.write("#ifndef FILE_CONTENTS_H\n")
header.write("#define FILE_CONTENTS_H\n\n")
Expand Down Expand Up @@ -77,8 +76,6 @@ def generate_header_from_files(directory, header_file):

header.write("#endif // FILE_CONTENTS_H\n\n")

header.write("#endif// TOOLS_ENABLED\n")

print(f"{header_file} generated successfully.")

if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions godot-cpp
Submodule godot-cpp added at e4b7c2
9 changes: 0 additions & 9 deletions register_types.h

This file was deleted.

Loading
Loading