Main project | Documentation | Usage example
Minimalistic template project to start with GDExtension development with godot-cppscript preinstalled.
- Install dependencies
- (Optional) use this template via GitHub
- Clone project
git clone https://github.com/IvanInventor/godot-cppscript-template --recurse-submodules godot-project
cd godot-project
git submodule update --remote external/cppscript- Latest godot-cpp beta
git submodule update --remote external/godot-cppOR
- For stable releases: checkout one of tags
cd external/godot-cpp/
git checkout <tag>OR
-
For custom builds (from guide): Switch to branch corresponding to godot version
Godot > 4.5.x -> 4.5 tag or master branch
cd external/godot-cpp/ git fetch origin 4.5 git switch 4.5- Generate custom bindings
./your_godot_executable --dump-extension-api
- Install bindings
- Replace included one
ORmv extension_api.json external/godot-cpp/gdextension/extension_api.json
- Add it to git and point to it with builder parameter
- Scons
scons custom_api_file=extension_api.json ...
- Cmake
cmake -DGODOTCPP_CUSTOM_API_FILE=extension_api.json ...
-
Build project
- Scons
scons api_version=4.7
- CMake
cmake -Bbuild -DGODOTCPP_API_VERSION=4.7 cmake --build build
-
Open
projectdirectory from Godot -
Run scene
You should see line of text in the center of screen and message in console
- Project name
- Rename with oneliner script (cppscript_example_name -> your_name)
- Bash (non-Windows)
NEWNAME="your_name"; mv "project/cppscript_example_name.gdextension" "project/$NEWNAME.gdextension" && find src project -type f -exec sed -i "s/cppscript_example_name/$NEWNAME/g" {} + && sed -i "s/cppscript_example_name/$NEWNAME/g" CMakeLists.txt SConstruct
- PowerShell (Windows)
$NEWNAME="your_name"; Move-Item "project/cppscript_example_name.gdextension" "project/$NEWNAME.gdextension"; Get-ChildItem project,src -File -Recurse | ForEach-Object { (Get-Content $_.FullName -Raw) -replace 'cppscript_example_name',[regex]::Escape($NEWNAME) | Set-Content $_.FullName }; Get-ChildItem CMakeLists.txt,SConstruct | ForEach-Object { (Get-Content $_.FullName -Raw) -replace 'cppscript_example_name',[regex]::Escape($NEWNAME) | Set-Content $_.FullName }
- Manually:
- Rename project/cppscript_example_name.gdextension -> project/your_name.gdextension
- Replace all occurences of
cppscript_example_nameinproject/,src/,CMakeLists.txt,SConstruct
- Rename with oneliner script (cppscript_example_name -> your_name)
- Header name (why?)
- SCons
--- a/SConstruct
+++ b/SConstruct
@@ -74,7 +74,7 @@ generated = create_cppscript_target(
{
# Name of header to be included to enable cppscript
# (Prefer name unique to your project)
- 'header_name' : 'cppscript.h',
+ 'header_name' : 'your_name.h',
# Path to C++ header files
'header_dir' : SRC_DIR,- Cmake
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -85,7 +85,7 @@ create_cppscript_target(
# Name of header to be included to enable cppscript
# (Prefer name unique to your project)
HEADER_NAME
- cppscript.h
+ your_name.h