forked from godotengine/godot-cpp-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 882ffb2
Showing
15 changed files
with
382 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Normalize EOL for all files that Git considers text files. | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Bug report | ||
description: Report a bug with the godot-cpp template | ||
body: | ||
|
||
- type: markdown | ||
attributes: | ||
value: | | ||
- Write a descriptive issue title above. | ||
- Search [open]() and [closed]() issues to ensure it has not already been reported. | ||
- type: input | ||
attributes: | ||
label: Godot version | ||
description: > | ||
Specify the Git commit hash of your Godot build. | ||
placeholder: v4.0.stable.official [92bee43ad] | ||
validations: | ||
required: true | ||
|
||
- type: input | ||
attributes: | ||
label: godot-cpp version | ||
description: > | ||
Specify the Git commit hash of the godot-cpp submodule in your project. You can run `git status` inside the folder to check it. | ||
placeholder: v4.0.stable.official [9d1c396c5] | ||
validations: | ||
required: true | ||
|
||
- type: input | ||
attributes: | ||
label: System information | ||
description: | | ||
Specify the OS version. | ||
placeholder: Windows 10 | ||
validations: | ||
required: true | ||
|
||
- type: textarea | ||
attributes: | ||
label: Issue description | ||
description: | | ||
Describe your issue briefly. What doesn't work, and how do you expect it to work instead? | ||
You can include images or videos with drag and drop, and format code blocks or logs with <code>```</code> tags. | ||
validations: | ||
required: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
name: Builds | ||
|
||
on: push | ||
|
||
env: | ||
LIBNAME: example | ||
|
||
concurrency: | ||
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-macos | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{matrix.os}} | ||
name: ${{matrix.name}} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- identifier: windows-debug | ||
os: windows-latest | ||
name: 🏁 Windows Debug | ||
target: template_debug | ||
platform: windows | ||
arch: x86_64 | ||
- identifier: windows-release | ||
os: windows-latest | ||
name: 🏁 Windows Release | ||
target: template_release | ||
platform: windows | ||
arch: x86_64 | ||
- identifier: macos-debug | ||
os: macos-latest | ||
name: 🍎 macOS (universal) Debug | ||
target: template_debug | ||
platform: macos | ||
arch: universal | ||
- identifier: macos-release | ||
os: macos-latest | ||
name: 🍎 macOS (universal) Release | ||
target: template_release | ||
platform: macos | ||
arch: universal | ||
- identifier: linux-debug | ||
os: ubuntu-latest | ||
name: 🐧 Linux Debug | ||
runner: ubuntu-20.04 | ||
target: template_debug | ||
platform: linux | ||
arch: x86_64 | ||
- identifier: linux-release | ||
os: ubuntu-latest | ||
name: 🐧 Linux Release | ||
runner: ubuntu-20.04 | ||
target: template_release | ||
platform: linux | ||
arch: x86_64 | ||
|
||
steps: | ||
- name: Checkout project | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Set up SCons | ||
shell: bash | ||
run: | | ||
python -c "import sys; print(sys.version)" | ||
python -m pip install scons | ||
scons --version | ||
- name: Linux dependencies | ||
if: ${{ matrix.platform == 'linux' }} | ||
run: | | ||
sudo apt-get update -qq | ||
sudo apt-get install -qqq build-essential pkg-config | ||
- name: Setup MinGW for Windows/MinGW build | ||
if: ${{ matrix.platform == 'windows' }} | ||
uses: egor-tensin/setup-mingw@v2 | ||
|
||
- name: Compile godot-cpp | ||
shell: sh | ||
run: | | ||
scons target='${{ matrix.target }}' platform='${{ matrix.platform }}' arch='${{ matrix.arch }}' | ||
working-directory: godot-cpp | ||
|
||
- name: Compile Extension | ||
shell: sh | ||
run: | | ||
scons target='${{ matrix.target }}' platform='${{ matrix.platform }}' arch='${{ matrix.arch }}' | ||
- name: Delete compilation files | ||
if: ${{ matrix.platform == 'windows' }} | ||
run: | | ||
Remove-Item bin/* -Include *.exp,*.lib,*.pdb -Force | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ github.event.repository.name }} | ||
path: | | ||
${{ github.workspace }}/bin/* | ||
- name: Archive Release | ||
uses: thedoctor0/[email protected] | ||
with: | ||
type: 'zip' | ||
filename: '${{ env.LIBNAME }}.${{ matrix.platform }}.${{ matrix.arch }}.zip' | ||
path: '${{ github.workspace }}/bin/' | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | ||
|
||
- name: Create and upload asset | ||
if: success() && github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
allowUpdates: true | ||
artifacts: "${{ env.LIBNAME }}.${{ matrix.platform }}.${{ matrix.arch }}.zip" | ||
omitNameDuringUpdate: true | ||
omitBodyDuringUpdate: true | ||
token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Godot 4+ specific ignores | ||
.godot/ | ||
|
||
# Ignore library files but not the gdextension file | ||
demo/bin/* | ||
!demo/bin/*.gdextension | ||
.sconsign*.dblite | ||
|
||
# Binaries | ||
*.o | ||
*.os | ||
*.so | ||
*.obj | ||
*.bc | ||
*.pyc | ||
*.dblite | ||
*.pdb | ||
*.lib | ||
*.config | ||
*.creator | ||
*.creator.user | ||
*.files | ||
*.includes | ||
*.idb | ||
*.exp | ||
|
||
# Other stuff | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[submodule "godot-cpp"] | ||
path = godot-cpp | ||
url = https://github.com/godotengine/godot-cpp.git | ||
branch = 4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
This is free and unencumbered software released into the public domain. | ||
|
||
Anyone is free to copy, modify, publish, use, compile, sell, or | ||
distribute this software, either in source code form or as a compiled | ||
binary, for any purpose, commercial or non-commercial, and by any | ||
means. | ||
|
||
In jurisdictions that recognize copyright laws, the author or authors | ||
of this software dedicate any and all copyright interest in the | ||
software to the public domain. We make this dedication for the benefit | ||
of the public at large and to the detriment of our heirs and | ||
successors. We intend this dedication to be an overt act of | ||
relinquishment in perpetuity of all present and future rights to this | ||
software under copyright law. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
For more information, please refer to <https://unlicense.org> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# godot-cpp template | ||
This repository serves as a quickstart template for GDExtension development with Godot 4.0+. | ||
|
||
## Contents | ||
* An empty Godot project (`demo/`) | ||
* godot-cpp as a submodule (`godot-cpp/`) | ||
* GitHub Issues template (`.github/ISSUE_TEMPLATE.yml`) | ||
* GitHub CI/CD to publish your library packages when creating a release (`.github/workflows/builds.yml`) | ||
* preconfigured source files for C++ development of the GDExtension (`src/`) | ||
|
||
## Usage | ||
To use this template, click the green "Use this template" button at the top of the repository page. | ||
This will let you create a copy of this repository with a clean git history. Make sure you clone the correct branch as these are configured for development of their respective Godot development branches and differ from each other. Refer to the docs to see what changed between the versions. | ||
|
||
For getting started after cloning your own copy to your local machine, you should | ||
* change the name of the compiled library file inside the `SConstruct` file by modifying the `libname` string. | ||
* change the name of the to be loaded library name inside the `.gdextension` file. This should be the same name as in your `SConstruct` file. | ||
* change the `entry_symbol` string inside your `.gdextension` file to be configured for your GDExtension name. This should be the same as the `GDExtensionBool GDE_EXPORT` external C function. As the name suggests, this sets the entry function for your GDExtension to be loaded by the Godot editors C API. | ||
* register the classes you want Godot to interact with inside the `register_types.cpp` file in the initialization method (here `initialize_gdextension_types`) in the syntax `ClassDB::register_class<CLASS-NAME>();`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python | ||
|
||
libname = "EXTENSION-NAME" | ||
|
||
env = SConscript("godot-cpp/SConstruct") | ||
|
||
env.Append(CPPPATH=["src/"]) | ||
sources = Glob("src/*.cpp") | ||
|
||
if env["platform"] == "macos": | ||
platlibname = "{}.{}.{}".format(libname, env["platform"], env["target"]) | ||
library = env.SharedLibrary( | ||
"bin/{}.framework/{}".format(platlibname, platlibname), | ||
source=sources, | ||
) | ||
else: | ||
library = env.SharedLibrary( | ||
"bin/{}{}{}".format(libname, env["suffix"], env["SHLIBSUFFIX"]), | ||
source=sources, | ||
) | ||
|
||
Default(library) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[configuration] | ||
|
||
entry_symbol = "example_library_init" | ||
compatibility_minimum = 4.1 | ||
|
||
[libraries] | ||
|
||
macos.debug = "res://bin/libgdexample.macos.template_debug.framework" | ||
macos.release = "res://bin/libgdexample.macos.template_release.framework" | ||
windows.debug.x86_32 = "res://bin/libgdexample.windows.template_debug.x86_32.dll" | ||
windows.release.x86_32 = "res://bin/libgdexample.windows.template_release.x86_32.dll" | ||
windows.debug.x86_64 = "res://bin/libgdexample.windows.template_debug.x86_64.dll" | ||
windows.release.x86_64 = "res://bin/libgdexample.windows.template_release.x86_64.dll" | ||
linux.debug.x86_64 = "res://bin/libgdexample.linux.template_debug.x86_64.so" | ||
linux.release.x86_64 = "res://bin/libgdexample.linux.template_release.x86_64.so" | ||
linux.debug.arm64 = "res://bin/libgdexample.linux.template_debug.arm64.so" | ||
linux.release.arm64 = "res://bin/libgdexample.linux.template_release.arm64.so" | ||
linux.debug.rv64 = "res://bin/libgdexample.linux.template_debug.rv64.so" | ||
linux.release.rv64 = "res://bin/libgdexample.linux.template_release.rv64.so" | ||
android.debug.x86_64 = "res://bin/libgdexample.android.template_debug.x86_64.so" | ||
android.release.x86_64 = "res://bin/libgdexample.android.template_release.x86_64.so" | ||
android.debug.arm64 = "res://bin/libgdexample.android.template_debug.arm64.so" | ||
android.release.arm64 = "res://bin/libgdexample.android.template_release.arm64.so" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="CompressedTexture2D" | ||
uid="uid://dbx66sovxd1" | ||
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://icon.svg" | ||
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/high_quality=false | ||
compress/lossy_quality=0.7 | ||
compress/hdr_compression=1 | ||
compress/normal_map=0 | ||
compress/channel_pack=0 | ||
mipmaps/generate=false | ||
mipmaps/limit=-1 | ||
roughness/mode=0 | ||
roughness/src_normal="" | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/normal_map_invert_y=false | ||
process/hdr_as_srgb=false | ||
process/hdr_clamp_exposure=false | ||
process/size_limit=0 | ||
detect_3d/compress_to=1 | ||
svg/scale=1.0 | ||
editor/scale_with_editor_scale=false | ||
editor/convert_colors_with_editor_theme=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
; Engine configuration file. | ||
; It's best edited using the editor UI and not directly, | ||
; since the parameters that go here are not all obvious. | ||
; | ||
; Format: | ||
; [section] ; section goes between [] | ||
; param=value ; assign values to parameters | ||
|
||
config_version=5 | ||
|
||
[application] | ||
|
||
config/name="godot cpp template" | ||
config/features=PackedStringArray("4.0", "Forward Plus") | ||
config/icon="res://icon.svg" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "register_types.h" | ||
#include <gdextension_interface.h> | ||
#include <godot_cpp/core/class_db.hpp> | ||
#include <godot_cpp/core/defs.hpp> | ||
#include <godot_cpp/godot.hpp> | ||
|
||
using namespace godot; | ||
|
||
void initialize_gdextension_types(ModuleInitializationLevel p_level) | ||
{ | ||
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { | ||
return; | ||
} | ||
} | ||
|
||
void uninitialize_gdextension_types(ModuleInitializationLevel p_level) { | ||
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { | ||
return; | ||
} | ||
} | ||
|
||
extern "C" | ||
{ | ||
// Initialization | ||
GDExtensionBool GDE_EXPORT example_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) | ||
{ | ||
GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization); | ||
init_obj.register_initializer(initialize_gdextension_types); | ||
init_obj.register_terminator(uninitialize_gdextension_types); | ||
init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE); | ||
|
||
return init_obj.init(); | ||
} | ||
} |
Oops, something went wrong.