Skip to content

Commit edf4390

Browse files
committed
Update SConstruct and .gdextension file of the godot-cpp example with newest conventions.
1 parent f908cdc commit edf4390

File tree

2 files changed

+28
-48
lines changed

2 files changed

+28
-48
lines changed

tutorials/scripting/cpp/files/cpp_example/SConstruct

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,25 @@
22
import os
33
import sys
44

5-
env = SConscript("godot-cpp/SConstruct")
5+
# You can find documentation for SCons and SConstruct files at:
6+
# https://scons.org/documentation.html
67

7-
# For reference:
8-
# - CCFLAGS are compilation flags shared between C and C++
9-
# - CFLAGS are for C-specific compilation flags
10-
# - CXXFLAGS are for C++-specific compilation flags
11-
# - CPPFLAGS are for pre-processor flags
12-
# - CPPDEFINES are for pre-processor defines
13-
# - LINKFLAGS are for linking flags
8+
# This lets SCons know that we're using godot-cpp, from the godot-cpp folder.
9+
env = SConscript("godot-cpp/SConstruct")
1410

15-
# tweak this if you want to use different folders, or more folders, to store your source code in.
11+
# Configures the 'src' directory as a source for header files.
1612
env.Append(CPPPATH=["src/"])
13+
14+
# Collects all .cpp files in the 'src' folder as compile targets.
1715
sources = Glob("src/*.cpp")
1816

19-
if env["platform"] == "macos":
20-
library = env.SharedLibrary(
21-
"demo/bin/libgdexample.{}.{}.framework/libgdexample.{}.{}".format(
22-
env["platform"], env["target"], env["platform"], env["target"]
23-
),
24-
source=sources,
25-
)
26-
elif env["platform"] == "ios":
27-
if env["ios_simulator"]:
28-
library = env.StaticLibrary(
29-
"demo/bin/libgdexample.{}.{}.simulator.a".format(env["platform"], env["target"]),
30-
source=sources,
31-
)
32-
else:
33-
library = env.StaticLibrary(
34-
"demo/bin/libgdexample.{}.{}.a".format(env["platform"], env["target"]),
35-
source=sources,
36-
)
37-
else:
38-
library = env.SharedLibrary(
39-
"demo/bin/libgdexample{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),
40-
source=sources,
41-
)
17+
lib_filename = "{}gdexample{}{}".format(env.subst('$SHLIBPREFIX'), env["suffix"], env.subst('$SHLIBSUFFIX'))
18+
19+
# Creates a SCons target for the path with our sources.
20+
library = env.SharedLibrary(
21+
"demo/bin/{}".format(lib_filename),
22+
source=sources,
23+
)
4224

25+
# Selects the shared library as the default target.
4326
Default(library)

tutorials/scripting/cpp/gdextension_cpp_example.rst

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -338,18 +338,18 @@ loaded for each platform and the entry function for the module. It is called ``g
338338
339339
[libraries]
340340
341-
macos.debug = "res://bin/libgdexample.macos.template_debug.framework"
342-
macos.release = "res://bin/libgdexample.macos.template_release.framework"
343-
windows.debug.x86_32 = "res://bin/libgdexample.windows.template_debug.x86_32.dll"
344-
windows.release.x86_32 = "res://bin/libgdexample.windows.template_release.x86_32.dll"
345-
windows.debug.x86_64 = "res://bin/libgdexample.windows.template_debug.x86_64.dll"
346-
windows.release.x86_64 = "res://bin/libgdexample.windows.template_release.x86_64.dll"
347-
linux.debug.x86_64 = "res://bin/libgdexample.linux.template_debug.x86_64.so"
348-
linux.release.x86_64 = "res://bin/libgdexample.linux.template_release.x86_64.so"
349-
linux.debug.arm64 = "res://bin/libgdexample.linux.template_debug.arm64.so"
350-
linux.release.arm64 = "res://bin/libgdexample.linux.template_release.arm64.so"
351-
linux.debug.rv64 = "res://bin/libgdexample.linux.template_debug.rv64.so"
352-
linux.release.rv64 = "res://bin/libgdexample.linux.template_release.rv64.so"
341+
macos.debug = "./libgdexample.macos.template_debug.dylib"
342+
macos.release = "./libgdexample.macos.template_release.dylib"
343+
windows.debug.x86_32 = "./gdexample.windows.template_debug.x86_32.dll"
344+
windows.release.x86_32 = "./gdexample.windows.template_release.x86_32.dll"
345+
windows.debug.x86_64 = "./gdexample.windows.template_debug.x86_64.dll"
346+
windows.release.x86_64 = "./gdexample.windows.template_release.x86_64.dll"
347+
linux.debug.x86_64 = "./libgdexample.linux.template_debug.x86_64.so"
348+
linux.release.x86_64 = "./libgdexample.linux.template_release.x86_64.so"
349+
linux.debug.arm64 = "./libgdexample.linux.template_debug.arm64.so"
350+
linux.release.arm64 = "./libgdexample.linux.template_release.arm64.so"
351+
linux.debug.rv64 = "./libgdexample.linux.template_debug.rv64.so"
352+
linux.release.rv64 = "./libgdexample.linux.template_release.rv64.so"
353353
354354
This file contains a ``configuration`` section that controls the entry function of the module.
355355
You should also set the minimum compatible Godot version with ``compatibility_minimum``,
@@ -363,10 +363,7 @@ also result in *just* that file being exported when you export the project,
363363
which means the data pack won't contain libraries that are incompatible with the
364364
target platform.
365365

366-
Finally, the ``dependencies`` section allows you to name additional dynamic
367-
libraries that should be included as well. This is important when your GDExtension
368-
plugin implements someone else's library and requires you to supply a
369-
third-party dynamic library with your project.
366+
You can learn more about ``.gdextension`` files at :ref:`doc_gdextension_file`.
370367

371368
Here is another overview to check the correct file structure:
372369

0 commit comments

Comments
 (0)