Skip to content

Commit 648e03c

Browse files
committed
Initial conversion
1 parent a1cfd4c commit 648e03c

20 files changed

+142
-131
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "godot-cpp"]
2+
path = godot-cpp
3+
url = https://github.com/godotengine/godot-cpp.git

CMakeLists.txt

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ set(CMAKE_CXX_STANDARD 17)
55
set(CMAKE_CXX_STANDARD_REQUIRED ON)
66
set(CMAKE_CXX_EXTENSIONS OFF)
77

8-
set(GODOT_ROOT_DIR ../../)
98

109
# Uncomment to pass auto completion in TOOLS mode
1110
#add_compile_definitions(MONO_GLUE_ENABLED)
@@ -20,17 +19,34 @@ add_compile_definitions(X11_ENABLED)
2019
#add_compile_definitions(IOS_ENABLED)
2120
#add_compile_definitions(__ANDROID__)
2221

22+
23+
24+
25+
#Godot-cpp
26+
file(GLOB_RECURSE GODOT-CPP godot-cpp/*.cpp)
27+
add_library(godot STATIC ${GODOT-CPP})
28+
29+
2330
# Get sources
2431
file(GLOB_RECURSE SOURCES src/*.c**)
2532
file(GLOB_RECURSE HEADERS src/*.h**)
33+
add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS})
34+
35+
# Includes
36+
target_include_directories(godot
37+
PUBLIC
38+
godot-cpp/include
39+
godot-cpp/include/godot_cpp
40+
godot-cpp/gen/include
41+
godot-cpp/gen/include/godot_cpp
42+
godot-cpp/gdextension
43+
)
2644

2745
# JNI
2846
find_package(JNI REQUIRED)
29-
30-
# Includes
31-
include_directories(./src)
32-
include_directories(${GODOT_ROOT_DIR})
3347
include_directories(${JNI_INCLUDE_DIRS})
3448

35-
# Target
36-
add_library(${PROJECT_NAME} SHARED register_types.h register_types.cpp ${SOURCES} ${HEADERS})
49+
target_link_libraries(${PROJECT_NAME}
50+
PRIVATE
51+
godot
52+
)

SConstruct

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import os
2+
import generate_templates
3+
4+
env = SConscript("godot-cpp/SConstruct")
5+
java_home = os.environ["JAVA_HOME"]
6+
7+
# Generate templates when building the engine.
8+
generate_templates.generate_header_from_files("kt/plugins/godot-intellij-plugin/src/main/resources/template", "src/editor/project/templates.h")
9+
10+
# Add those directory manually, so we can skip the godot_cpp directory when including headers in C++ files
11+
source_path = [
12+
os.path.join("godot-cpp", "include","godot_cpp"),
13+
os.path.join("godot-cpp", "gen", "include","godot_cpp")
14+
]
15+
env.Append(CPPPATH=[env.Dir(d) for d in source_path])
16+
17+
18+
# For the reference:
19+
# - CCFLAGS are compilation flags shared between C and C++
20+
# - CFLAGS are for C-specific compilation flags
21+
# - CXXFLAGS are for C++-specific compilation flags
22+
# - CPPFLAGS are for pre-processor flags
23+
# - CPPDEFINES are for pre-processor defines
24+
# - LINKFLAGS are for linking flags
25+
26+
# tweak this if you want to use different folders, or more folders, to store your source code in.
27+
env.Append(CPPPATH=["src/"])
28+
sources = [
29+
Glob("register_types.cpp"),
30+
Glob("src/*.cpp"),
31+
Glob("src/jni/*.cpp"),
32+
Glob("src/binding/*.cpp"),
33+
Glob("src/resource_format/*.cpp"),
34+
Glob("src/language/*.cpp"),
35+
Glob("src/script/*.cpp"),
36+
Glob("src/script/language/*.cpp"),
37+
Glob("src/jvm_wrapper/*.cpp"),
38+
Glob("src/jvm_wrapper/registration/*.cpp"),
39+
Glob("src/jvm_wrapper/bridge/*.cpp"),
40+
Glob("src/jvm_wrapper/memory/*.cpp"),
41+
Glob("src/lifecycle/*.cpp"),
42+
Glob("src/lifecycle/platforms/*.cpp"),
43+
]
44+
45+
if env["target"] in ["editor", "template_debug"]:
46+
sources.append(Glob("src/editor/*.cpp"))
47+
sources.append(Glob("src/editor/project/*.cpp"))
48+
sources.append(Glob("src/editor/build/*.cpp"))
49+
sources.append(Glob("src/editor/dialog/*.cpp"))
50+
sources.append(Glob("src/editor/panel/*.cpp"))
51+
52+
# Android
53+
if env["platform"] != "android":
54+
java_include_dirs = [
55+
java_home + "/include",
56+
java_home + "/include/linux",
57+
java_home + "/include/win32",
58+
java_home + "/include/darwin"
59+
]
60+
env.Append(CPPPATH=[java_include_dirs])
61+
62+
63+
if env["platform"] == "macos":
64+
library = env.SharedLibrary(
65+
"bin/godot.jvm.{}.{}.framework/godot.jvm.{}.{}".format(
66+
env["platform"], env["target"], env["platform"], env["target"]
67+
),
68+
source=sources,
69+
)
70+
elif env["platform"] == "ios":
71+
if env["ios_simulator"]:
72+
library = env.StaticLibrary(
73+
"bin/godot.jvm.{}.{}.simulator.a".format(env["platform"], env["target"]),
74+
source=sources,
75+
)
76+
else:
77+
library = env.StaticLibrary(
78+
"bin/godot.jvm.{}.{}.a".format(env["platform"], env["target"]),
79+
source=sources,
80+
)
81+
else:
82+
library = env.SharedLibrary(
83+
"bin/godot.jvm.{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),
84+
source=sources,
85+
)

SCsub

Lines changed: 0 additions & 45 deletions
This file was deleted.

generate_templates.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def generate_header_from_files(directory, header_file):
2323
file_is_binary = []
2424

2525
with open(header_file, 'w') as header:
26-
header.write(f'#ifdef TOOLS_ENABLED \n\n')
2726
header.write(f'// Auto-generated templates from {directory} directory \n\n')
2827
header.write("#ifndef FILE_CONTENTS_H\n")
2928
header.write("#define FILE_CONTENTS_H\n\n")
@@ -79,8 +78,6 @@ def generate_header_from_files(directory, header_file):
7978

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

82-
header.write("#endif// TOOLS_ENABLED\n")
83-
8481
print(f"{header_file} generated successfully.")
8582

8683
if __name__ == "__main__":

godot-cpp

Submodule godot-cpp added at e4b7c25

register_types.h

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/editor/dialog/about_dialog.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
2-
#ifdef TOOLS_ENABLED
3-
41
#include "about_dialog.h"
52

63
#include "editor/godot_kotlin_jvm_editor.h"
@@ -57,6 +54,4 @@ void AboutDialog::_notification(int notification) {
5754
popup_centered();
5855
set_exclusive(false);
5956
}
60-
}
61-
62-
#endif // TOOLS_ENABLED
57+
}

src/editor/dialog/about_dialog.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
2-
#ifdef TOOLS_ENABLED
3-
41
#ifndef GODOT_JVM_ABOUT_DIALOG_H
52
#define GODOT_JVM_ABOUT_DIALOG_H
63

@@ -19,6 +16,4 @@ class AboutDialog : public AcceptDialog {
1916
void _notification(int notification);
2017
};
2118

22-
#endif// GODOT_JVM_ABOUT_DIALOG_H
23-
24-
#endif// TOOLS_ENABLED
19+
#endif// GODOT_JVM_ABOUT_DIALOG_H

src/editor/dialog/build_dialog.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
2-
#ifdef TOOLS_ENABLED
3-
41
#include "build_dialog.h"
52

63
#include "editor/build/gradle_task_runner.h"
@@ -58,6 +55,4 @@ void TaskDialog::_notification(int notification) {
5855
vertical_container->add_child(progress_bar);
5956

6057
add_child(vertical_container);
61-
}
62-
63-
#endif // TOOLS_ENABLED
58+
}

0 commit comments

Comments
 (0)