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

added GitHub workflow and other enhancements #8

Merged
merged 25 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
602417c
Revert "Merge pull request #6 from JekSun97/revert-5-github_workflows"
FibreFoX Aug 30, 2024
c8880da
reworked build-setup to use more modern Ubuntu system for generating …
FibreFoX Aug 25, 2024
82c6922
fixed SCons being missing on MacOS (woops, worked before)
FibreFoX Aug 25, 2024
b1b193e
install 32bit libs too, not only mingw
FibreFoX Aug 25, 2024
a1db143
build binaries for Windows and Linux using custom docker builder image
FibreFoX Aug 26, 2024
e7525c0
reworked build file to have separate jobs for Linux, Windows and MacO…
FibreFoX Aug 26, 2024
9ebbc28
build 32bit and 64bit on separate jobs, would result in corrupted DLL…
FibreFoX Aug 26, 2024
81d0a31
ignore some files from being committed
FibreFoX Aug 26, 2024
ec9b7e3
use a bit more easy way to generate output filenames
FibreFoX Aug 26, 2024
e2c4f9e
use easier filenames on MacOS
FibreFoX Aug 26, 2024
210467c
added compatibility to Godot 4.0.x
FibreFoX Aug 29, 2024
ee16b71
apply workaround for Godot 4.0.x when using MacOS builder
FibreFoX Aug 29, 2024
d486a06
install older 4.7.x version of scons instead of using patch
FibreFoX Aug 29, 2024
03cac82
mark the gdextension to be working with Godot 4.0.x
FibreFoX Aug 29, 2024
10a2dbb
create bundle with all binaries in it for each Godot version
FibreFoX Aug 30, 2024
6d84891
create releasable ZIP files and fixed weird "Tree3D"/"gdTree3D"/"libt…
FibreFoX Aug 30, 2024
7f89c17
fixed library binary being "libgdTree3D" prefixed
FibreFoX Aug 30, 2024
82b59fc
removed the need for file duplication of icon and .gdextension file
FibreFoX Aug 30, 2024
ebe45cf
create addons-subfolder for Github Actions workflow
FibreFoX Aug 30, 2024
0aa37fc
clone repository when building release ZIP files
FibreFoX Aug 30, 2024
8967cd7
add Github release action for git tags
FibreFoX Aug 30, 2024
325a43c
fixed referenced icon
FibreFoX Aug 30, 2024
2237303
renamed from "gdTree3D" to "Tree3D"
FibreFoX Sep 1, 2024
fb189a1
clean built files before building for different CPU arch
FibreFoX Sep 1, 2024
034eb48
removed "gd" prefix from new node type
FibreFoX Sep 1, 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
186 changes: 186 additions & 0 deletions .github/workflows/build-with-github.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
name: Build With Github

on:
push:
# build and bundle for every branch push
branches: ["*"]
# create github release when commit was marked via "git tag"
tags: ["v*"]

jobs:
Build-Linux:
runs-on: ubuntu-latest
strategy:
matrix:
godot_cpp_branch: ["4.0", "4.1", "4.2", "4.3"]
# do NOT compile CPU archs in one go, would result in corrupted DLL (probably due to file-resue of 32bit files in 64bit run)
target_arch: [x86_32, x86_64]
steps:
# clone current repo
- uses: actions/checkout@v4
# clone required Godot source code into subfolder
- uses: actions/checkout@v4
with:
repository: 'godotengine/godot-cpp'
ref: ${{ matrix.godot_cpp_branch }}
path: 'godot-cpp'
submodules: true
- name: create docker image for building our binaries
run: |
docker build -t tree3dbuilder:latest .
# compile binaries via our docker build image (linux)
# makes it easier to create Linux and Windows binaries on other systems more reliable
- name: build binaries
run: |
# linux 32 bit (x86)
docker run --rm -v "$(pwd):/source" tree3dbuilder:latest scons target=template_debug arch=${{ matrix.target_arch }}
docker run --rm -v "$(pwd):/source" tree3dbuilder:latest scons target=template_release arch=${{ matrix.target_arch }}
- name: archive built binaries (linux)
uses: actions/upload-artifact@v4
with:
name: ${{ format('binaries-linux-godot{0}-{1}', matrix.godot_cpp_branch, matrix.target_arch) }}
if-no-files-found: 'error'
path: |
demo/addons/*
Build-Windows:
runs-on: ubuntu-latest
strategy:
matrix:
godot_cpp_branch: ["4.0", "4.1", "4.2", "4.3"]
# do NOT compile CPU archs in one go, would result in corrupted DLL (probably due to file-resue of 32bit files in 64bit run)
target_arch: [x86_32, x86_64]
steps:
# clone current repo
- uses: actions/checkout@v4
# clone required Godot source code into subfolder
- uses: actions/checkout@v4
with:
repository: 'godotengine/godot-cpp'
ref: ${{ matrix.godot_cpp_branch }}
path: 'godot-cpp'
submodules: true
- name: create docker image for building our binaries
run: |
docker build -t tree3dbuilder:latest .
# compile binaries via our docker build image (windows)
# makes it easier to create Linux and Windows binaries on other systems more reliable
- name: build binaries
run: |
docker run --rm -v "$(pwd):/source" tree3dbuilder:latest scons target=template_debug arch=${{ matrix.target_arch }} platform=windows
docker run --rm -v "$(pwd):/source" tree3dbuilder:latest scons target=template_release arch=${{ matrix.target_arch }} platform=windows
- name: archive built binaries (windows)
uses: actions/upload-artifact@v4
with:
name: ${{ format('binaries-windows-godot{0}-{1}', matrix.godot_cpp_branch, matrix.target_arch) }}
if-no-files-found: 'error'
path: |
demo/addons/*
Build-MacOS:
runs-on: macos-latest
strategy:
matrix:
godot_cpp_branch: ["4.0", "4.1", "4.2", "4.3"]
steps:
# clone current repo
- uses: actions/checkout@v4
# clone required Godot source code into subfolder
- uses: actions/checkout@v4
with:
repository: 'godotengine/godot-cpp'
ref: ${{ matrix.godot_cpp_branch }}
path: 'godot-cpp'
submodules: true
- name: install scons on macos
if: ${{ matrix.godot_cpp_branch != '4.0' }}
run: python -m pip install scons
# Godot 4.0 needs a specific version
# see https://github.com/godotengine/godot-cpp/issues/1518
# see https://github.com/godotengine/godot-cpp/pull/1526
- name: install older version of scons on macos
if: ${{ matrix.godot_cpp_branch == '4.0' }}
run: python -m pip install scons==4.7.0
# TODO we need to check if these binaries actually do work, as we lack any Apple Silicon device right now to check this
# TODO do we need to split CPU arch for MacOS too?
- name: build MacOS binaries
run: |
# MacOS 64 bit (x86)
scons target=template_debug arch=x86_64
scons target=template_release arch=x86_64
# MacOS 64 bit (Apple Silicon/ARM)
scons -c
scons target=template_debug arch=arm64
scons target=template_release arch=arm64
# create "Universal 2" files
lipo -create demo/addons/Tree3D/libTree3D.macos.template_release.arm64 demo/addons/Tree3D/libTree3D.macos.template_release.x86_64 -output demo/addons/Tree3D/libTree3D.macos.template_release.universal
lipo -create demo/addons/Tree3D/libTree3D.macos.template_debug.arm64 demo/addons/Tree3D/libTree3D.macos.template_debug.x86_64 -output demo/addons/Tree3D/libTree3D.macos.template_debug.universal
- name: archive built binaries (macos)
uses: actions/upload-artifact@v4
with:
name: ${{ format('binaries-macos-godot{0}-universal', matrix.godot_cpp_branch) }}
if-no-files-found: 'error'
path: |
demo/addons/*
Bundle-All-In-One-ZIP:
# wait for all binaries being created
needs: [Build-Linux, Build-Windows, Build-MacOS]
runs-on: ubuntu-latest
strategy:
matrix:
godot_cpp_branch: ["4.0", "4.1", "4.2", "4.3"]
steps:
# clone current repo
- uses: actions/checkout@v4
- name: download all created binaries for Godot ${{ matrix.godot_cpp_branch }}
uses: actions/download-artifact@v4
with:
path: generated-binaries
pattern: ${{ format('binaries-*-godot{0}-*', matrix.godot_cpp_branch) }}
merge-multiple: true
- name: move artifacts to their proper place
run: |
mkdir -p demo/addons/
mv generated-binaries/* demo/addons/
- name: create gdExtension ZIP for Godot ${{ matrix.godot_cpp_branch }}
uses: actions/upload-artifact@v4
with:
name: ${{ format('Tree3D-addon-godot{0}', matrix.godot_cpp_branch) }}
if-no-files-found: 'error'
path: |
demo/addons/*
- name: create demo ZIP for Godot ${{ matrix.godot_cpp_branch }}
uses: actions/upload-artifact@v4
with:
name: ${{ format('Tree3D-demo-project-godot{0}', matrix.godot_cpp_branch) }}
if-no-files-found: 'error'
path: |
demo/*
Create-Github-Draft-Release:
# wait for all binaries being created
needs: [Bundle-All-In-One-ZIP]
runs-on: ubuntu-latest
# only create when tagged
if: ${{ startsWith(github.ref, 'refs/tags/') }}
steps:
- name: Download All-In-One ZIP (addon)
uses: dawidd6/action-download-artifact@v6
with:
skip_unpack: true
name: Tree3D-addon-godot*
name_is_regexp: true
- name: Download All-In-One ZIP (demo project)
uses: dawidd6/action-download-artifact@v6
with:
skip_unpack: true
name: Tree3D-demo-project-godot*
name_is_regexp: true
- run: |
ls
- name: create draft release
uses: softprops/action-gh-release@v2
with:
draft: true
files: |
*.zip

# TODO add "android" and other platforms (if possible)
# TODO add Windows ARM (when arm-mingw is usable from anywhere)
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# avoids checking something into this repo by accident from the godot-cpp repository
/godot-cpp/
# but keep the folder
!/godot-cpp/Place godot-cpp here.txt

# sometimes generated by scons
/.sconsign.dblite

# generated files
/src/*.os

# created when loading with Godot 4.3+
/demo/.godot
/demo/*.import
/demo/**/*.import

# ignore generated file
/demo/addons/
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM ubuntu:24.04

RUN apt-get update && apt-get install -y \
# linux build dependencies
gcc g++ gcc-multilib g++-multilib \
# windows build dependencies
mingw-w64 \
# build system
python3 scons

WORKDIR /source
30 changes: 20 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
<img src="image/tree3d.png">

# gdTree3D
# Tree3D
Plugin for procedural generation of 3D trees of varying complexity.

<img src="image/Tree3D.png">

## Supported Godot Engine Versions
- Godot 4.0
- Godot 4.1
- Godot 4.2
- Godot 4.3

## Note
<img src="image/preview.png">

## Notes
- To ensure the tree displays correctly, use Cull Mode: Front for the tree trunk material.
- To change the season, you can make one unique leaf material for all the trees and then change its color or texture to make them yellow.

## Building GDExtension
## Building the GDExtension

1. Place [godot-cpp](https://github.com/godotengine/godot-cpp) of the version you need in the godot-cpp folder
2. Use the SCons command:
```
scons platform=windows target= ...
2. Use the SCons command (depending on your platform and Godot build version):
```sh
scons target=template_release platform=windows
```
Or use [ready-made libraries](https://github.com/JekSun97/gdTree3D/releases)

<img src="image/preview.png">
## Using Docker to build this GDExtension

For easier reproducibility, there is a Dockerfile provided for building binaries for Linux and Windows.

```sh
docker build -t tree3dbuilder:latest .
docker run --rm -v "$(pwd):/source" tree3dbuilder:latest scons target=template_release arch=x86_64 platform=windows
```

## Donations
If you liked this plugin, you could send me a thank you via Ko-Fi using [Ko-Fi](https://ko-fi.com/jeksun), I would be very grateful!
Expand All @@ -31,4 +41,4 @@ Your name and your GitHub account (if you have one) will be listed below :)
**List:**
- Meier Lukas

Thank you for your support!
Thank you for your support!
45 changes: 34 additions & 11 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,40 @@ env = SConscript("godot-cpp/SConstruct")
env.Append(CPPPATH=["src/"])
sources = Glob("src/*.cpp")

# the filename "libTree3D" results from the prefix "lib*", which (somehow) gets defined from "godot-cpp"
targetLibraryFileOutput = "demo/addons/Tree3D/libTree3D{}{}".format(env["suffix"], env["SHLIBSUFFIX"])

# on MacOS we need use different filename parameters
if env["platform"] == "macos":
library = env.SharedLibrary(
"demo/addons/tree3d/libtree3d.{}.{}.framework/libtree3d.{}.{}".format(
env["platform"], env["target"], env["platform"], env["target"]
),
source=sources,
)
else:
library = env.SharedLibrary(
"demo/addons/tree3d/libtree3d{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),
source=sources,
targetLibraryFileOutput = "demo/addons/Tree3D/libTree3D.{}.{}.{}".format(
env["platform"], env["target"], env["arch"]
)

Default(library)
# copy addons template to demo project
# makes it usable even without Github Actions runner
# use "Install" instead of "Copy"
# https://stackoverflow.com/a/35442344/1961102
copy_static_files_to_demo_folder = env.Install("demo/", "addons")

version_replacement_dict = {}

# Godot 4.0 has a different type/interface for register_types
#
# there probably are better ways, but checking the existence of a certain file,
# which was not present "in the past", was the best clue I got.
if not os.path.isfile("godot-cpp/pyproject.toml"):
env.Append(CPPDEFINES=['GODOT_40'])
# the .gdextension file CAN NOT have "4.0" in it, because Godot 4.1+ would reject it
# so change it only for Godot 4.0.x to be "4.0" instead of "4.1"
version_replacement_dict = {'compatibility_minimum = "4.1"': 'compatibility_minimum = "4.0"'}

# always generate .gdextension file (as we need to replace stuff there)
generate_gdextension_file = env.Substfile(source = 'addons/Tree3D/Tree3D.gdextension', target = 'demo/addons/Tree3D/Tree3D.gdextension', SUBST_DICT = version_replacement_dict)

library = env.SharedLibrary(
targetLibraryFileOutput,
source=sources,
)

# will be executed in reverse order
Default(library, generate_gdextension_file, copy_static_files_to_demo_folder)
27 changes: 27 additions & 0 deletions addons/Tree3D/Tree3D.gdextension
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[infomation]
name = "Tree3D"
# TODO generate version via SCons using git-tag inside Github Actions workflow
version = "v0.71-dev"
decription = "Plugin for procedural generation of 3D trees of varying complexity."
author = "Artyom Bozhko (JekSun)"
email = "jeksun2022@gmail.com"
repo = "https://github.com/JekSun97/gdTree3D"

[icons]
Tree3D = "res://addons/Tree3D/ico/Tree3D.png"

[configuration]
entry_symbol = "tree3d_library_init"
compatibility_minimum = "4.1"

[libraries]
macos.debug = "res://addons/Tree3D/libTree3D.macos.template_debug.universal"
macos.release = "res://addons/Tree3D/libTree3D.macos.template_release.universal"
windows.debug.x86_32 = "res://addons/Tree3D/libTree3D.windows.template_debug.x86_32.dll"
windows.release.x86_32 = "res://addons/Tree3D/libTree3D.windows.template_release.x86_32.dll"
windows.debug.x86_64 = "res://addons/Tree3D/libTree3D.windows.template_debug.x86_64.dll"
windows.release.x86_64 = "res://addons/Tree3D/libTree3D.windows.template_release.x86_64.dll"
linux.debug.x86_32 = "res://addons/Tree3D/libTree3D.linux.template_debug.x86_32.so"
linux.release.x86_32 = "res://addons/Tree3D/libTree3D.linux.template_release.x86_32.so"
linux.debug.x86_64 = "res://addons/Tree3D/libTree3D.linux.template_debug.x86_64.so"
linux.release.x86_64 = "res://addons/Tree3D/libTree3D.linux.template_release.x86_64.so"
File renamed without changes
Binary file removed demo/addons/tree3d/ico/Tree3D.png
Binary file not shown.
35 changes: 0 additions & 35 deletions demo/addons/tree3d/libtree3d.gdextension

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion demo/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ config/description="Author: Artyom Bozhko"
config/version="0.5 beta"
run/main_scene="res://tree_3d.tscn"
config/features=PackedStringArray("4.2", "GL Compatibility")
config/icon="res://addons/tree3d/ico/Tree3D.png"
config/icon="res://addons/Tree3D/ico/Tree3D.png"
File renamed without changes
Loading