Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement GDExtension support #15

Merged
merged 42 commits into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2c4e343
Port the first core classes to get started
limbonaut Jan 6, 2024
8eed672
Port BBParam classes
limbonaut Jan 6, 2024
4f97c1b
Post the rest of the BT tasks (massive changes)
limbonaut Jan 6, 2024
0767c0e
Port BTPlayer and LimboDebugger (game-side part)
limbonaut Jan 7, 2024
f5b1b52
Port LimboHSM, LimboState and BTState
limbonaut Jan 7, 2024
3d86a76
Port BehaviorTreeView
limbonaut Jan 7, 2024
f9ad9cc
Port ActionBanner
limbonaut Jan 7, 2024
73497b1
Port ModSwitchButton
limbonaut Jan 7, 2024
97daa29
Port TaskPalette
limbonaut Jan 7, 2024
bb346ef
Port TaskTree
limbonaut Jan 7, 2024
9645bae
Port LimboAI plugin and editor
limbonaut Jan 9, 2024
59a8ab9
chore: Rename macro LSNAME to LW_NAME
limbonaut Jan 9, 2024
d1030b8
Project config file macro
limbonaut Jan 9, 2024
b07fb71
Fix documentation related crash
limbonaut Jan 9, 2024
a9a38bb
Port debugger
limbonaut Jan 9, 2024
c1d0353
Don't show "Open debugger" in GDExtension
limbonaut Jan 9, 2024
966199e
Fix: Weird name showing on the tasks
limbonaut Jan 9, 2024
5b475b3
Fix: BB params convert to "Wrapped..."
limbonaut Jan 9, 2024
1b031df
Fix CheckVar performs erroneous equality check
limbonaut Jan 9, 2024
cdd5159
Move binaries to addon folder
limbonaut Jan 9, 2024
960f04b
Fix Forward button icon and crash
limbonaut Jan 9, 2024
835d053
Add script to update icons in the extension config
limbonaut Jan 9, 2024
a8dc787
Restore icons
limbonaut Jan 10, 2024
68b2aaf
Fix IS_CLASS macro not working as expected
limbonaut Jan 10, 2024
5953713
Fix: Create script template not working as expected
limbonaut Jan 10, 2024
1dfa3e9
Fix: User tasks not showing in the Task Palette
limbonaut Jan 10, 2024
8e9cc74
Fix: User icons are not showing in the task palette
limbonaut Jan 10, 2024
ac3da5a
Handle resource reloading (or for GDExtension - don't)
limbonaut Jan 10, 2024
0e37d3d
Fix module compilation
limbonaut Jan 10, 2024
e6c87be
Fix various bugs and unit tests
limbonaut Jan 10, 2024
52f218e
Don't compile editor classes into template builds
limbonaut Jan 11, 2024
3af6995
Create a script to set up new GDExtension development environment
limbonaut Jan 11, 2024
21b5053
Rename window wrapper
limbonaut Jan 11, 2024
c55c655
GHA: Update setup script and make build workflow for GDExtension
limbonaut Jan 11, 2024
392a2ac
GHA: Add init_version action for GDExtension
limbonaut Jan 11, 2024
8cb8f65
GHA: Adjust versioning of GDExtension build
limbonaut Jan 11, 2024
1d3cea6
GHA: Add Windows & macOS builds to GDExtension workflow
limbonaut Jan 11, 2024
947e253
Fix infinite call recursion crash due to virtual function workaround
limbonaut Jan 12, 2024
eec0852
Fix name generation broken in module
limbonaut Jan 13, 2024
f546e28
Refactor and clean up the code
limbonaut Jan 13, 2024
c875f9d
Fix BTState virtuals not being called
limbonaut Jan 13, 2024
46cd946
GHA: Fix inputs in test_builds.yml
limbonaut Jan 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/actions/init-version-gdext/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Setup version

runs:
using: "composite"
steps:
- name: Set GDEXTENSION_VERSION & LIMBOAI_VERSION
shell: bash
run: |
cd godot-cpp
GDEXTENSION_VERSION=$( (git describe --tags --exact-match HEAD || git rev-parse --short HEAD) | sed 's/\(.*\)-\(.*\)/\1/g' )

if [[ ${GDEXTENSION_VERSION} == godot-* ]]; then
GDEXTENSION_VERSION=${GDEXTENSION_VERSION#"godot-"}
fi

echo "GDEXTENSION_VERSION=${GDEXTENSION_VERSION}" >> "$GITHUB_ENV"

cd ../limboai
echo "LIMBOAI_VERSION=$( (git describe --tags --exact-match HEAD || git rev-parse --short HEAD) | sed 's/\(.*\)-\(.*\)/\1/g' )" >> "$GITHUB_ENV"

- name: Set NAME_PREFIX
shell: bash
run: echo "NAME_PREFIX=gdextension-${GDEXTENSION_VERSION}.limboai+${LIMBOAI_VERSION}" >> "$GITHUB_ENV"

209 changes: 209 additions & 0 deletions .github/workflows/gdextension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
name: 🔌 GDExtension
on:
workflow_call:
inputs:
godot-cpp-treeish:
description: A tag, branch or commit hash in the godot-cpp repository.
type: string
default: 4.2
limboai-treeish:
description: A tag, branch or commit hash in the LimboAI repository.
type: string
default: master
test-build:
description: Should we perform only a limited number of test builds?
type: boolean
default: false

workflow_dispatch:
inputs:
godot-cpp-treeish:
description: A tag, branch or commit hash in the godot-cpp repository.
type: string
default: 4.2
limboai-treeish:
description: A tag, branch or commit hash in the LimboAI repository.
type: string
default: master
test-build:
description: Should we perform only a limited number of test builds?
type: boolean
default: false

# Global Settings
env:
SCONS_CACHE_LIMIT: 4096
SCONSFLAGS: dev_build=no debug_symbols=no

jobs:
gdextension:
runs-on: ${{ matrix.opts.runner }}
name: ${{ matrix.opts.name }}
strategy:
fail-fast: false
matrix:
opts:
- name: 🐧 Linux (x86_64, release)
runner: ubuntu-20.04
platform: linux
target: template_release
arch: x86_64
should-build: true

- name: 🐧 Linux (x86_64, debug)
runner: ubuntu-20.04
platform: linux
target: editor
arch: x86_64
should-build: true

- name: 🪟 Windows (x86_64, release)
runner: windows-latest
platform: windows
target: template_release
arch: x86_64
should-build: true

- name: 🪟 Windows (x86_64, debug)
runner: windows-latest
platform: windows
target: editor
arch: x86_64
should-build: true

- name: 🍎 macOS (universal, release)
runner: macos-latest
platform: macos
target: template_release
arch: universal
should-build: true

- name: 🍎 macOS (universal, debug)
runner: macos-latest
platform: macos
target: editor
arch: universal
should-build: true

exclude:
- { opts: {should-build: false }}

env:
BIN: liblimboai.${{matrix.opts.platform}}.${{matrix.opts.target}}.${{matrix.opts.arch}}

steps:
- name: Clone godot-cpp
uses: actions/checkout@v4
with:
repository: godotengine/godot-cpp
fetch-tags: true
path: godot-cpp
ref: ${{ inputs.godot-cpp-treeish }}

- name: Clone LimboAI module
uses: actions/checkout@v4
with:
path: limboai
fetch-tags: true
ref: ${{ inputs.limboai-treeish }}

# Inits GDEXTENSION_VERSION, LIMBOAI_VERSION and NAME_PREFIX environment variables.
- uses: ./limboai/.github/actions/init-version-gdext

- name: Set up Linux buildroot x86_64
if: matrix.opts.platform == 'linux' && matrix.opts.arch == 'x86_64'
run: |
wget https://download.tuxfamily.org/godotengine/toolchains/linux/x86_64-godot-linux-gnu_sdk-buildroot.tar.bz2
tar -xjf x86_64-godot-linux-gnu_sdk-buildroot.tar.bz2
mv x86_64-godot-linux-gnu_sdk-buildroot buildroot
cd buildroot
./relocate-sdk.sh
cd ..

- name: Set up Linux buildroot x86_32
if: matrix.opts.platform == 'linux' && matrix.opts.arch == 'x86_32'
run: |
wget https://download.tuxfamily.org/godotengine/toolchains/linux/i686-godot-linux-gnu_sdk-buildroot.tar.bz2
tar -xjf i686-godot-linux-gnu_sdk-buildroot.tar.bz2
mv i686-godot-linux-gnu_sdk-buildroot buildroot
cd buildroot
./relocate-sdk.sh
cd ..

- name: Set up Python 3.x
if: matrix.opts.platform == 'windows' || matrix.opts.platform == 'macos'
uses: actions/setup-python@v4
with:
python-version: '3.x'
architecture: 'x64'

- name: Set up scons
if: matrix.opts.platform == 'windows' || matrix.opts.platform == 'macos'
run: |
python -c "import sys; print(sys.version)"
python -m pip install scons==4.4.0
python --version
scons --version

- name: Set up MSVC problem matcher on Windows
if: matrix.opts.platform == 'windows'
uses: ammaraskar/msvc-problem-matcher@master

- name: Set up scons cache
uses: actions/cache@v3
with:
path: ${{github.workspace}}/.scons_cache/
key: ${{env.BIN}}-${{inputs.godot-cpp-treeish}}-${{inputs.limboai-treeish}}-${{env.LIMBOAI_VERSION}}
restore-keys: |
${{env.BIN}}-${{inputs.godot-cpp-treeish}}-${{inputs.limboai-treeish}}-${{env.LIMBOAI_VERSION}}
${{env.BIN}}-${{inputs.godot-cpp-treeish}}-${{inputs.limboai-treeish}}
${{env.BIN}}-${{inputs.godot-cpp-treeish}}

- name: Setup project structure for GDExtension
shell: bash
run: |
python ./limboai/gdextension/update_icons.py
mkdir -p demo/addons/limboai/bin
mv limboai/icons demo/addons/limboai/
cp limboai/gdextension/SConstruct SConstruct
cp limboai/gdextension/limboai.gdextension demo/addons/limboai/bin
echo "---"
ls -l
ls -l -R ./demo/

- name: Compilation
shell: bash
env:
SCONS_CACHE: ${{github.workspace}}/.scons_cache/
run: |
PATH=${GITHUB_WORKSPACE}/buildroot/bin:$PATH
scons platform=${{matrix.opts.platform}} target=${{matrix.opts.target}} arch=${{matrix.opts.arch}} ${{env.SCONSFLAGS}}

- name: Prepare artifact
shell: bash
run: |
mkdir out
mv demo/addons/ out/
rm -f out/addons/limboai/bin/*.{exp,lib,pdb}
ls -R out/

- name: Strip lib
if: matrix.opts.platform != 'windows'
run: |
ls -l -R out/addons/limboai/bin/
echo "---"
if [ "$RUNNER_OS" == "macOS" ]; then
strip -u out/addons/limboai/bin/liblimboai*/liblimboai*
else
strip out/addons/limboai/bin/liblimboai*
fi
echo "---"
ls -l -R out/addons/limboai/bin/

- name: Upload artifact
uses: actions/upload-artifact@v3
env:
NAME: ${{env.NAME_PREFIX}}
with:
name: ${{ env.NAME }}
path: out/*
62 changes: 41 additions & 21 deletions .github/workflows/test_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ on:
- "**/*.png"
- "demo/*"
- "doc/*"
inputs:
godot-treeish:
description: A tag, branch or commit hash in the Godot repository.
type: string
default: 4.2.1-stable

pull_request:
branches: [ master ]
Expand All @@ -23,11 +18,12 @@ on:
- "LICENSE"
- "**/*.png"
- "demo/*"
inputs:
godot-treeish:
description: A tag, branch or commit hash in the Godot repository.
type: string
default: 4.2.1-stable
- "doc/*"

# Global Settings.
env:
GODOT_REF: "4.2.1-stable"
GODOT_CPP_REF: "4.2"

jobs:
unit-tests:
Expand All @@ -45,7 +41,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: godotengine/godot
ref: ${{ inputs.godot-treeish }}
ref: ${{ env.GODOT_REF }}

- name: Clone LimboAI module
uses: actions/checkout@v4
Expand All @@ -67,11 +63,11 @@ jobs:
uses: actions/cache@v3
with:
path: ${{github.workspace}}/.scons_cache/
key: ${{env.BIN}}-${{inputs.godot-treeish}}-${{github.ref}}-${{github.sha}}
key: ${{env.BIN}}-${{env.GODOT_REF}}-${{github.ref}}-${{github.sha}}
restore-keys: |
${{env.BIN}}-${{inputs.godot-treeish}}-${{github.ref}}-${{github.sha}}
${{env.BIN}}-${{inputs.godot-treeish}}-${{github.ref}}
${{env.BIN}}-${{inputs.godot-treeish}}
${{env.BIN}}-${{env.GODOT_REF}}-${{github.ref}}-${{github.sha}}
${{env.BIN}}-${{env.GODOT_REF}}-${{github.ref}}
${{env.BIN}}-${{env.GODOT_REF}}
continue-on-error: true

- name: Set up Python 3.x
Expand Down Expand Up @@ -107,26 +103,50 @@ jobs:
run: |
bin/${{ env.BIN }} --test --headless

cache-env:
runs-on: ubuntu-latest
outputs:
godot-ref: ${{ steps.cache-env.outputs.godot-ref }}
godot-cpp-ref: ${{ steps.cache-env.outputs.godot-cpp-ref }}
steps:
- name: Cache env
id: cache-env
run: |
echo "godot-ref=${GODOT_REF}" >> "$GITHUB_OUTPUT"
echo "godot-cpp-ref=${GODOT_CPP_REF}" >> "$GITHUB_OUTPUT"

linux-test-build:
name: 🐧 Linux test build
name: 🐧 Linux
needs: cache-env
uses: ./.github/workflows/linux.yml
with:
godot-treeish: ${{ inputs.godot-treeish }}
godot-treeish: ${{ needs.cache-env.outputs.godot-ref }}
limboai-treeish: ${{ github.sha }}
test-build: true

windows-test-build:
name: 🪟 Windows test build
name: 🪟 Windows
needs: cache-env
uses: ./.github/workflows/windows.yml
with:
godot-treeish: ${{ inputs.godot-treeish }}
godot-treeish: ${{ needs.cache-env.outputs.godot-ref }}
limboai-treeish: ${{ github.sha }}
test-build: true

macos-test-build:
name: 🍎 macOS test build
name: 🍎 macOS
needs: cache-env
uses: ./.github/workflows/macos.yml
with:
godot-treeish: ${{ inputs.godot-treeish }}
godot-treeish: ${{ needs.cache-env.outputs.godot-ref }}
limboai-treeish: ${{ github.sha }}
test-build: true

gdextension:
name: 🔌 GDExtension
needs: cache-env
uses: ./.github/workflows/gdextension.yml
with:
godot-cpp-treeish: ${{ needs.cache-env.outputs.godot-cpp-ref }}
limboai-treeish: ${{ github.sha }}
test-build: true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# LimboAI-specific
demo/addons/
icons/*.import

# Godot auto generated files
*.gen.*
.import/
Expand Down
2 changes: 2 additions & 0 deletions SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Import("env_modules")

module_env = env.Clone()

module_env.Append(CPPDEFINES = ['LIMBOAI_MODULE'])

module_env.add_source_files(env.modules_sources, "*.cpp")
module_env.add_source_files(env.modules_sources, "blackboard/*.cpp")
module_env.add_source_files(env.modules_sources, "blackboard/bb_param/*.cpp")
Expand Down
1 change: 0 additions & 1 deletion blackboard/bb_param/bb_aabb.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#define BB_AABB_H

#include "bb_param.h"
#include "core/object/object.h"

class BBAabb : public BBParam {
GDCLASS(BBAabb, BBParam);
Expand Down
1 change: 0 additions & 1 deletion blackboard/bb_param/bb_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#define BB_ARRAY_H

#include "bb_param.h"
#include "core/object/object.h"

class BBArray : public BBParam {
GDCLASS(BBArray, BBParam);
Expand Down
1 change: 0 additions & 1 deletion blackboard/bb_param/bb_basis.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#define BB_BASIS_H

#include "bb_param.h"
#include "core/object/object.h"

class BBBasis : public BBParam {
GDCLASS(BBBasis, BBParam);
Expand Down
1 change: 0 additions & 1 deletion blackboard/bb_param/bb_bool.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#define BB_BOOL_H

#include "bb_param.h"
#include "core/object/object.h"

class BBBool : public BBParam {
GDCLASS(BBBool, BBParam);
Expand Down
Loading
Loading