From 21ce54e1f8330e09c2ed71a05c8e1071679684a7 Mon Sep 17 00:00:00 2001 From: Andrew Luchuk Date: Sat, 14 Mar 2026 18:49:29 -0400 Subject: [PATCH] Add readme and improve build script --- .gitignore | 1 + build.py | 2 +- readme.md | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 readme.md diff --git a/.gitignore b/.gitignore index 197b19d..a5d2983 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ demo/bin .idea + # Godot auto generated files *.gen.* .import/ diff --git a/build.py b/build.py index f17137a..ffdf7f4 100644 --- a/build.py +++ b/build.py @@ -42,7 +42,7 @@ ios.release = {{ }} """.format(PROJECT_NAME) - gdextension_file_path = "demo/template.gdextension" + gdextension_file_path = f"demo/{PROJECT_NAME}.gdextension" with open(gdextension_file_path, "w") as gdextension_file: gdextension_file.write(gdextension_file_content) \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..affac55 --- /dev/null +++ b/readme.md @@ -0,0 +1,58 @@ +# Redot GDExtension Template + +This repository provides a template for create GDExtensions. This template provides a basic layout including a demo +project which can be used to test your extension. It also provides a small file (`build.py`) which can generate a +`template.gdextension` file for you. This file should automatically enable your extension within the editor. + +This project uses Redot 26.1 as the basis for creating extensions. In the future, there will probably be branches +dedicated to future versions of Redot. This repository is based on the [official GDExtension tutorial][1]. + +## Using this template + +To set up a repository using this template, simply click the "Use this template" button in the top right of this +repository. You will then be presented with a new repository wizard that will guide you through the remaining setup +steps. + +## Building the extension. + +To build projects created with this template, you will need to run `scons`. If you have not already setup your system +for developing Redot extensions or extending the core editor, you can find instructions for doing so +[here](https://docs.redotengine.org/contributing/development/compiling/). These steps are designed to help you build +the entire Redot project, but you will need an understanding of how to do that in order to build extensions. + +I also strongly recommend that you read the [guide on C++ GDExtensions][2] +if you have not already done so to get the fullest picture of how GDExtensions are intended to work. + +Once you have setup your repository and cloned it to your local machine, you can build the extension by running: +```sh +scons +``` + +If you would like to build your extension with the help of an IDE, you may want to have `scons` generate a +`build_commands.json` file by building your project with the `compiledb=yes` option as below: + +```sh +scons compiledb=yes +``` + +## Customizing your build artifact name + +By default, this project is configured to output a shared library titled `libgdextension_template`, however you can +easily change this by modifying the `PROJECT_NAME` property in the `build.py` file. `scons` will automatically +incorporate this variable into your compilation artifact. + +## Generating a template.gdextension file + +This repository comes with a simple Python script that will generate a `*.gdextension` file and place it +in the `demo` directory. Redot requires this file to load your GDExtension, so using this script will get you started +quickly. + +```sh +python build.py +``` + +The script will also read the value of the `PROJECT_NAME` property so that the `*.gdextension` file will reflect the +name of your extension. + +[1]: https://docs.redotengine.org/tutorials/scripting/gdextension/ +[2]: https://docs.redotengine.org/tutorials/scripting/gdextension/ \ No newline at end of file