forked from TokisanGames/Terrain3D
-
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 2e62ab0
Showing
21 changed files
with
495 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,122 @@ | ||
name: 🛠️ Builds | ||
on: | ||
push: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.runner }} | ||
name: ${{ matrix.name }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- identifier: linux-debug | ||
name: Linux Debug | ||
runner: ubuntu-20.04 | ||
target: template_debug | ||
platform: linux | ||
arch: x86_64 | ||
- identifier: linux-release | ||
name: Linux Release | ||
runner: ubuntu-20.04 | ||
target: template_release | ||
platform: linux | ||
arch: x86_64 | ||
- identifier: windows-debug | ||
name: Windows Debug | ||
runner: ubuntu-20.04 | ||
target: template_debug | ||
platform: windows | ||
arch: x86_64 | ||
- identifier: windows-release | ||
name: Windows Release | ||
runner: ubuntu-20.04 | ||
target: template_release | ||
platform: windows | ||
arch: x86_64 | ||
- identifier: android-release | ||
name: Android Release | ||
runner: ubuntu-20.04 | ||
target: template_release | ||
platform: android | ||
arch: arm64 | ||
|
||
steps: | ||
- name: (Windows) Install mingw64 | ||
if: ${{ startsWith(matrix.identifier, 'windows-') }} | ||
shell: sh | ||
run: | | ||
sudo apt-get install mingw-w64 | ||
sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix | ||
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix | ||
- name: (Android) Set up Java 11 | ||
if: ${{ startsWith(matrix.identifier, 'android-') }} | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
|
||
- name: (Android) Set up Android SDK | ||
if: ${{ startsWith(matrix.identifier, 'android-') }} | ||
uses: android-actions/setup-android@v2 | ||
|
||
- name: (Android) Install Android Tools | ||
if: ${{ startsWith(matrix.identifier, 'android-') }} | ||
shell: sh | ||
run: | | ||
"$ANDROID_SDK_ROOT"/cmdline-tools/latest/bin/sdkmanager --sdk_root="$ANDROID_SDK_ROOT" "platform-tools" "build-tools;30.0.3" "platforms;android-29" "cmdline-tools;latest" "cmake;3.10.2.4988404" "ndk;21.4.7075529" | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
|
||
- name: Set up SCons | ||
shell: bash | ||
run: | | ||
python -c "import sys; print(sys.version)" | ||
python -m pip install scons | ||
scons --version | ||
- name: Checkout project | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
|
||
# TODO: Cache doesn't work yet. SCons rebuilds the objects even if they already exist. Could be caused by modification dates or extension_api.json. | ||
# fetch-depth: 0 May be needed for cache. See: <https://github.com/actions/checkout/issues/468>. | ||
# - name: Set up SCons cache | ||
# uses: actions/cache@v3 | ||
# with: | ||
# path: | | ||
# ${{ github.workspace }}/.scons-cache/ | ||
# ${{ github.workspace }}/**/.sconsign.dblite | ||
# ${{ github.workspace }}/godot-cpp/gen/ | ||
# key: ${{ matrix.identifier }}-${{ github.ref }}-${{ github.sha }} | ||
# restore-keys: | | ||
# ${{ matrix.identifier }}-${{ github.ref }}-${{ github.sha }} | ||
# ${{ matrix.identifier }}-${{ github.ref }} | ||
# ${{ matrix.identifier }} | ||
|
||
- name: Compile extension | ||
shell: sh | ||
# env: | ||
# SCONS_CACHE: '${{ github.workspace }}/.scons-cache/' | ||
# SCONS_CACHE_LIMIT: 8192 | ||
run: | | ||
scons target='${{ matrix.target }}' platform='${{ matrix.platform }}' arch='${{ matrix.arch }}' -j2 | ||
ls -l project/addons/*/bin/ | ||
- name: Copy extra files to addon | ||
shell: sh | ||
run: | | ||
for addon in ${{ github.workspace }}/project/addons/*/; do | ||
cp --no-clobber '${{ github.workspace }}/README.md' '${{ github.workspace }}/LICENSE' "$addon" | ||
done | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ github.event.repository.name }} | ||
path: | | ||
${{ github.workspace }}/project/ |
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,14 @@ | ||
# Objects. | ||
.scons-cache/ | ||
*.os | ||
|
||
# SConstruct | ||
.sconf_temp | ||
.sconsign.dblite | ||
*.pyc | ||
|
||
# MacOS | ||
.DS_Store | ||
|
||
# Editors | ||
.vscode/ |
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 = master |
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,49 @@ | ||
# gdextension | ||
|
||
GDExtension template that automatically builds into a self-contained addon for the Godot Asset Library. | ||
|
||
<!-- TODO: Change `master` to `4.x` on release (or `4.0`). | ||
TODO: Change `godot4` to `godot` on release --> | ||
|
||
# Compatibility warning: | ||
|
||
This template is only intended to work with the latest `master` on GitHub, _not the latest point release, such as `beta1`_. Before reporting an issue, make sure you are on the latest `master` and the submodule `godot-cpp` is up-to-date by running the command `git submodule update --remote`. | ||
|
||
### Getting started: | ||
1. Clone this repository (or a new repository with this template) with submodules. | ||
- `git clone --recurse-submodules https://github.com/nathanfranke/gdextension.git` \ | ||
- `cd gdextension` | ||
2. Build a debug binary for the current platform. | ||
- `scons` | ||
3. Import, edit, and play `project/` using Godot Engine 4+. | ||
- Alternatively, run the project using the terminal. | ||
- Either alias an existing executable to godot4: `alias godot4="~/workspace/godot/bin/godot.linuxbsd.tools.x86_64"` | ||
- Or, on Arch Linux, install `godot4-bin` from the AUR (`yay -S aur/godot4-bin`). | ||
- Finally, `godot4 --path project/` | ||
4. Check the output: | ||
``` | ||
Hello GDScript! | ||
Hello GDExtension Node! | ||
Hello GDExtension Singleton! | ||
``` | ||
|
||
### Repository structure: | ||
- `project/` - Godot project boilerplate. | ||
- `addons/example/` - Files to be distributed to other projects.¹ | ||
- `demo/` - Scenes and scripts for internal testing. Not strictly necessary. | ||
- `src/` - Source code of this extension. | ||
- `godot-cpp/` - Submodule needed for GDExtension compilation. | ||
|
||
¹ Before distributing as an addon, all binaries for all platforms must be built and copied to the `bin/` directory. This is done automatically by GitHub Actions. | ||
|
||
### Make it your own: | ||
1. Rename `project/addons/example/` and `project/addons/example/example.gdextension`. The library name is automatically changed to the gdextension file name. | ||
2. Replace `LICENSE`, `README.md`, and your code in `src/`. | ||
3. Not required, but consider leaving a note about this template if you found it helpful! | ||
|
||
### Distributing your extension on the Godot Asset Library: | ||
1. Go to Repository→Actions and download the latest artifact. | ||
2. Test the artifact by extracting the addon into a project. | ||
3. Create a new release on GitHub, uploading the artifact as an asset. | ||
4. On the asset, Right Click→Copy Link to get a direct file URL. Don't use the artifacts directly from GitHub Actions, as they expire. | ||
5. When submitting/updating on the Godot Asset Library, Change "Repository host" to `Custom` and "Download URL" to the one you copied. |
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,52 @@ | ||
#!/usr/bin/env python | ||
from glob import glob | ||
from pathlib import Path | ||
|
||
# TODO: Do not copy environment after godot-cpp/test is updated <https://github.com/godotengine/godot-cpp/blob/master/test/SConstruct>. | ||
env = SConscript("godot-cpp/SConstruct") | ||
|
||
# Add source files. | ||
env.Append(CPPPATH=["src/"]) | ||
sources = Glob("src/*.cpp") | ||
|
||
# Find gdextension path even if the directory or extension is renamed (e.g. project/addons/example/example.gdextension). | ||
(extension_path,) = glob("project/addons/*/*.gdextension") | ||
|
||
# Find the addon path (e.g. project/addons/example). | ||
addon_path = Path(extension_path).parent | ||
|
||
# Find the project name from the gdextension file (e.g. example). | ||
project_name = Path(extension_path).stem | ||
|
||
# TODO: Cache is disabled currently. | ||
# scons_cache_path = os.environ.get("SCONS_CACHE") | ||
# if scons_cache_path != None: | ||
# CacheDir(scons_cache_path) | ||
# print("Scons cache enabled... (path: '" + scons_cache_path + "')") | ||
|
||
# Create the library target (e.g. libexample.linux.debug.x86_64.so). | ||
debug_or_release = "release" if env["target"] == "template_release" else "debug" | ||
if env["platform"] == "macos": | ||
library = env.SharedLibrary( | ||
"{0}/bin/lib{1}.{2}.{3}.framework/{1}.{2}.{3}".format( | ||
addon_path, | ||
project_name, | ||
env["platform"], | ||
debug_or_release, | ||
), | ||
source=sources, | ||
) | ||
else: | ||
library = env.SharedLibrary( | ||
"{}/bin/lib{}.{}.{}.{}{}".format( | ||
addon_path, | ||
project_name, | ||
env["platform"], | ||
debug_or_release, | ||
env["arch"], | ||
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,4 @@ | ||
# Ignore everything outside of the addons folder when exporting. | ||
/** export-ignore | ||
/addons !export-ignore | ||
/addons/** !export-ignore |
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 @@ | ||
# Godot 4+ specific ignores | ||
.godot/ |
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 @@ | ||
* | ||
!.gitignore |
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,16 @@ | ||
[configuration] | ||
|
||
entry_symbol = "gdextension_init" | ||
|
||
[libraries] | ||
|
||
macos.debug = "bin/libexample.macos.debug.framework" | ||
macos.release = "bin/libexample.macos.release.framework" | ||
windows.debug.x86_64 = "bin/libexample.windows.debug.x86_64.dll" | ||
windows.release.x86_64 = "bin/libexample.windows.release.x86_64.dll" | ||
linux.debug.x86_64 = "bin/libexample.linux.debug.x86_64.so" | ||
linux.release.x86_64 = "bin/libexample.linux.release.x86_64.so" | ||
linux.debug.arm64 = "bin/libexample.linux.debug.arm64.so" | ||
linux.release.arm64 = "bin/libexample.linux.release.arm64.so" | ||
linux.debug.rv64 = "bin/libexample.linux.debug.rv64.so" | ||
linux.release.rv64 = "bin/libexample.linux.release.rv64.so" |
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,6 @@ | ||
extends Node | ||
|
||
func _ready() -> void: | ||
print("Hello GDScript!") | ||
$MyNode.hello_node() | ||
MySingleton.hello_singleton() |
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,8 @@ | ||
[gd_scene load_steps=2 format=3 uid="uid://p4prpbgep4um"] | ||
|
||
[ext_resource type="Script" path="res://demo/demo.gd" id="1_6gvlp"] | ||
|
||
[node name="Demo" type="Node"] | ||
script = ExtResource("1_6gvlp") | ||
|
||
[node name="MyNode" type="MyNode" parent="."] |
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="example" | ||
run/main_scene="res://demo/demo.tscn" | ||
config/features=PackedStringArray("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,34 @@ | ||
#include "my_node.hpp" | ||
|
||
#include <godot_cpp/core/class_db.hpp> | ||
#include <godot_cpp/variant/utility_functions.hpp> | ||
|
||
using namespace godot; | ||
|
||
void MyNode::_bind_methods() | ||
{ | ||
ClassDB::bind_method("hello_node", &MyNode::hello_node); | ||
} | ||
|
||
MyNode::MyNode() | ||
{ | ||
} | ||
|
||
MyNode::~MyNode() | ||
{ | ||
} | ||
|
||
// Override built-in methods with your own logic. Make sure to declare them in the header as well! | ||
|
||
void MyNode::_ready() | ||
{ | ||
} | ||
|
||
void MyNode::_process(double delta) | ||
{ | ||
} | ||
|
||
void MyNode::hello_node() | ||
{ | ||
UtilityFunctions::print("Hello GDExtension Node!"); | ||
} |
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 @@ | ||
#pragma once | ||
|
||
#include <godot_cpp/classes/node.hpp> | ||
#include <godot_cpp/core/class_db.hpp> | ||
|
||
using namespace godot; | ||
|
||
class MyNode : public Node | ||
{ | ||
GDCLASS(MyNode, Node); | ||
|
||
protected: | ||
static void _bind_methods(); | ||
|
||
public: | ||
MyNode(); | ||
~MyNode(); | ||
|
||
void _ready() override; | ||
void _process(double delta) override; | ||
|
||
void hello_node(); | ||
}; |
Oops, something went wrong.