mirror of
https://github.com/godotengine/godot-cpp.git
synced 2026-01-03 18:09:13 +03:00
Compare commits
1 Commits
3.x
...
godot-3.5.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
316b91c5f5 |
22
.github/actions/godot-cache/action.yml
vendored
22
.github/actions/godot-cache/action.yml
vendored
@@ -1,22 +0,0 @@
|
|||||||
name: Setup Godot build cache
|
|
||||||
description: Setup Godot build cache.
|
|
||||||
inputs:
|
|
||||||
cache-name:
|
|
||||||
description: The cache base name (job name by default).
|
|
||||||
default: "${{github.job}}"
|
|
||||||
scons-cache:
|
|
||||||
description: The scons cache path.
|
|
||||||
default: "${{github.workspace}}/.scons-cache/"
|
|
||||||
runs:
|
|
||||||
using: "composite"
|
|
||||||
steps:
|
|
||||||
# Upload cache on completion and check it out now
|
|
||||||
- name: Load .scons_cache directory
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: ${{inputs.scons-cache}}
|
|
||||||
key: ${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
|
|
||||||
restore-keys: |
|
|
||||||
${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
|
|
||||||
${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}
|
|
||||||
${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}
|
|
||||||
51
.github/workflows/ci.yml
vendored
51
.github/workflows/ci.yml
vendored
@@ -1,14 +1,6 @@
|
|||||||
name: Continuous integration
|
name: Continuous integration
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
|
||||||
env:
|
|
||||||
# Only used for the cache key. Increment version to force clean build.
|
|
||||||
GODOT_BASE_BRANCH: 3.x
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: ${{ matrix.name }}
|
name: ${{ matrix.name }}
|
||||||
@@ -18,69 +10,54 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- name: 🐧 Linux (GCC)
|
- name: 🐧 Linux (GCC)
|
||||||
os: ubuntu-20.04
|
os: ubuntu-18.04
|
||||||
platform: linux
|
platform: linux
|
||||||
artifact-name: godot-cpp-linux-glibc2.31-x86_64-release
|
artifact-name: godot-cpp-linux-glibc2.27-x86_64-release
|
||||||
artifact-path: bin/libgodot-cpp.linux.release.64.a
|
artifact-path: bin/libgodot-cpp.linux.release.64.a
|
||||||
godot_zip: Godot_v3.5-stable_linux_server.64.zip
|
godot_zip: Godot_v3.5-stable_linux_server.64.zip
|
||||||
executable: Godot_v3.5-stable_linux_server.64
|
executable: Godot_v3.5-stable_linux_server.64
|
||||||
cache-name: linux-x86_64
|
|
||||||
|
|
||||||
- name: 🏁 Windows (x86_64, MSVC)
|
- name: 🏁 Windows (x86_64, MSVC)
|
||||||
os: windows-2022
|
os: windows-2019
|
||||||
platform: windows
|
platform: windows
|
||||||
artifact-name: godot-cpp-windows-msvc2019-x86_64-release
|
artifact-name: godot-cpp-windows-msvc2019-x86_64-release
|
||||||
artifact-path: bin/libgodot-cpp.windows.release.64.lib
|
artifact-path: bin/libgodot-cpp.windows.release.64.lib
|
||||||
cache-name: windows-x86_64-msvc
|
|
||||||
|
|
||||||
- name: 🏁 Windows (x86_64, MinGW)
|
- name: 🏁 Windows (x86_64, MinGW)
|
||||||
os: windows-2022
|
os: windows-2019
|
||||||
platform: windows
|
platform: windows
|
||||||
artifact-name: godot-cpp-linux-mingw-x86_64-release
|
artifact-name: godot-cpp-linux-mingw-x86_64-release
|
||||||
artifact-path: bin/libgodot-cpp.windows.release.64.a
|
artifact-path: bin/libgodot-cpp.windows.release.64.a
|
||||||
flags: use_mingw=yes
|
flags: use_mingw=yes
|
||||||
cache-name: windows-x86_64-mingw
|
|
||||||
|
|
||||||
- name: 🍎 macOS (universal)
|
- name: 🍎 macOS (universal)
|
||||||
os: macos-13
|
os: macos-11
|
||||||
platform: osx
|
platform: osx
|
||||||
artifact-name: godot-cpp-macos-universal-release
|
artifact-name: godot-cpp-macos-universal-release
|
||||||
artifact-path: bin/libgodot-cpp.osx.release.64.a
|
artifact-path: bin/libgodot-cpp.osx.release.64.a
|
||||||
flags: macos_arch=universal
|
flags: macos_arch=universal
|
||||||
godot_zip: Godot_v3.5-stable_osx.universal.zip
|
godot_zip: Godot_v3.5-stable_osx.universal.zip
|
||||||
executable: Godot.app/Contents/MacOS/Godot
|
executable: Godot.app/Contents/MacOS/Godot
|
||||||
cache-name: macos-unversal
|
|
||||||
|
|
||||||
- name: 🤖 Android (arm64)
|
- name: 🤖 Android (arm64)
|
||||||
os: ubuntu-20.04
|
os: ubuntu-18.04
|
||||||
platform: android
|
platform: android
|
||||||
artifact-name: godot-cpp-android-arm64-release
|
artifact-name: godot-cpp-android-arm64-release
|
||||||
artifact-path: bin/libgodot-cpp.android.release.arm64v8.a
|
artifact-path: bin/libgodot-cpp.android.release.arm64v8.a
|
||||||
flags: ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME android_arch=arm64v8
|
flags: ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME android_arch=arm64v8
|
||||||
cache-name: android-arm64
|
|
||||||
|
|
||||||
- name: 🍏 iOS (arm64)
|
- name: 🍏 iOS (arm64)
|
||||||
os: macos-13
|
os: macos-11
|
||||||
platform: ios
|
platform: ios
|
||||||
artifact-name: godot-cpp-ios-arm64-release
|
artifact-name: godot-cpp-ios-arm64-release
|
||||||
artifact-path: bin/libgodot-cpp.ios.release.arm64.a
|
artifact-path: bin/libgodot-cpp.ios.release.arm64.a
|
||||||
cache-name: ios-arm64
|
|
||||||
|
|
||||||
env:
|
|
||||||
SCONS_CACHE: ${{ github.workspace }}/.scons-cache/
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: Setup Godot build cache
|
|
||||||
uses: ./.github/actions/godot-cache
|
|
||||||
with:
|
|
||||||
cache-name: ${{ matrix.cache-name }}
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
- name: Set up Python (for SCons)
|
- name: Set up Python (for SCons)
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
@@ -99,12 +76,10 @@ jobs:
|
|||||||
- name: Windows dependency (MinGW)
|
- name: Windows dependency (MinGW)
|
||||||
if: ${{ matrix.platform == 'windows' }}
|
if: ${{ matrix.platform == 'windows' }}
|
||||||
uses: egor-tensin/setup-mingw@v2
|
uses: egor-tensin/setup-mingw@v2
|
||||||
with:
|
|
||||||
version: 12.2.0
|
|
||||||
|
|
||||||
- name: Build godot-cpp (debug)
|
- name: Build godot-cpp (debug)
|
||||||
run: |
|
run: |
|
||||||
scons platform=${{ matrix.platform }} target=debug ${{ matrix.flags }}
|
scons platform=${{ matrix.platform }} target=debug generate_bindings=yes ${{ matrix.flags }}
|
||||||
|
|
||||||
- name: Build test without rebuilding godot-cpp (debug)
|
- name: Build test without rebuilding godot-cpp (debug)
|
||||||
run: |
|
run: |
|
||||||
@@ -135,9 +110,7 @@ jobs:
|
|||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v2
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
|
|
||||||
- name: Make apt sources.list use the default Ubuntu repositories
|
- name: Make apt sources.list use the default Ubuntu repositories
|
||||||
run: |
|
run: |
|
||||||
@@ -154,7 +127,3 @@ jobs:
|
|||||||
- name: Style checks via clang-format
|
- name: Style checks via clang-format
|
||||||
run: |
|
run: |
|
||||||
bash ./misc/scripts/clang_format.sh
|
bash ./misc/scripts/clang_format.sh
|
||||||
|
|
||||||
- name: Bindings generation checks (ensures get_file_list returns all generated files)
|
|
||||||
run: |
|
|
||||||
python ./misc/scripts/check_get_file_list.py
|
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -3,9 +3,6 @@ gen/*
|
|||||||
logs/*
|
logs/*
|
||||||
*.log
|
*.log
|
||||||
|
|
||||||
# The default cache directory
|
|
||||||
.scons_cache/
|
|
||||||
|
|
||||||
# Binaries
|
# Binaries
|
||||||
*.o
|
*.o
|
||||||
*.os
|
*.os
|
||||||
|
|||||||
63
SConstruct
63
SConstruct
@@ -1,10 +1,19 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import codecs
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
from binding_generator import scons_generate_bindings, scons_emit_files
|
|
||||||
|
if sys.version_info < (3,):
|
||||||
|
|
||||||
|
def decode_utf8(x):
|
||||||
|
return x
|
||||||
|
|
||||||
|
else:
|
||||||
|
import codecs
|
||||||
|
|
||||||
|
def decode_utf8(x):
|
||||||
|
return codecs.utf_8_decode(x)[0]
|
||||||
|
|
||||||
|
|
||||||
# Workaround for MinGW. See:
|
# Workaround for MinGW. See:
|
||||||
@@ -124,7 +133,15 @@ opts.Add(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
opts.Add(PathVariable("custom_api_file", "Path to a custom JSON API file", None, PathVariable.PathIsFile))
|
opts.Add(PathVariable("custom_api_file", "Path to a custom JSON API file", None, PathVariable.PathIsFile))
|
||||||
opts.Add(BoolVariable("generate_bindings", "Force GDNative API bindings generation.", False))
|
opts.Add(
|
||||||
|
EnumVariable(
|
||||||
|
"generate_bindings",
|
||||||
|
"Generate GDNative API bindings",
|
||||||
|
"auto",
|
||||||
|
allowed_values=["yes", "no", "auto", "true"],
|
||||||
|
ignorecase=2,
|
||||||
|
)
|
||||||
|
)
|
||||||
opts.Add(
|
opts.Add(
|
||||||
EnumVariable(
|
EnumVariable(
|
||||||
"android_arch",
|
"android_arch",
|
||||||
@@ -248,7 +265,7 @@ elif env["platform"] == "ios":
|
|||||||
env.Append(CCFLAGS=["-miphoneos-version-min=10.0"])
|
env.Append(CCFLAGS=["-miphoneos-version-min=10.0"])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sdk_path = codecs.utf_8_decode(subprocess.check_output(["xcrun", "--sdk", sdk_name, "--show-sdk-path"]).strip())[0]
|
sdk_path = decode_utf8(subprocess.check_output(["xcrun", "--sdk", sdk_name, "--show-sdk-path"]).strip())
|
||||||
except (subprocess.CalledProcessError, OSError):
|
except (subprocess.CalledProcessError, OSError):
|
||||||
raise ValueError("Failed to find SDK path while running xcrun --sdk {} --show-sdk-path.".format(sdk_name))
|
raise ValueError("Failed to find SDK path while running xcrun --sdk {} --show-sdk-path.".format(sdk_name))
|
||||||
|
|
||||||
@@ -455,14 +472,17 @@ elif env["platform"] == "javascript":
|
|||||||
elif env["target"] == "release":
|
elif env["target"] == "release":
|
||||||
env.Append(CCFLAGS=["-O3"])
|
env.Append(CCFLAGS=["-O3"])
|
||||||
|
|
||||||
# Cache
|
env.Append(
|
||||||
scons_cache_path = os.environ.get("SCONS_CACHE")
|
CPPPATH=[
|
||||||
if scons_cache_path is not None:
|
".",
|
||||||
CacheDir(scons_cache_path)
|
env["headers_dir"],
|
||||||
Decider("MD5")
|
"include",
|
||||||
|
"include/gen",
|
||||||
|
"include/core",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
# Generate bindings
|
# Generate bindings?
|
||||||
env.Append(BUILDERS={"GenerateBindings": Builder(action=scons_generate_bindings, emitter=scons_emit_files)})
|
|
||||||
json_api_file = ""
|
json_api_file = ""
|
||||||
|
|
||||||
if "custom_api_file" in env:
|
if "custom_api_file" in env:
|
||||||
@@ -470,22 +490,22 @@ if "custom_api_file" in env:
|
|||||||
else:
|
else:
|
||||||
json_api_file = os.path.join(os.getcwd(), env["headers_dir"], "api.json")
|
json_api_file = os.path.join(os.getcwd(), env["headers_dir"], "api.json")
|
||||||
|
|
||||||
bindings = env.GenerateBindings(
|
if env["generate_bindings"] == "auto":
|
||||||
env.Dir("."), [json_api_file, "binding_generator.py"]
|
# Check if generated files exist
|
||||||
)
|
should_generate_bindings = not os.path.isfile(os.path.join(os.getcwd(), "src", "gen", "Object.cpp"))
|
||||||
|
else:
|
||||||
|
should_generate_bindings = env["generate_bindings"] in ["yes", "true"]
|
||||||
|
|
||||||
# Forces bindings regeneration.
|
if should_generate_bindings:
|
||||||
if env["generate_bindings"]:
|
# Actually create the bindings here
|
||||||
AlwaysBuild(bindings)
|
import binding_generator
|
||||||
NoCache(bindings)
|
|
||||||
|
|
||||||
# Includes
|
binding_generator.generate_bindings(json_api_file, env["generate_template_get_node"])
|
||||||
env.Append(CPPPATH=[[env.Dir(d) for d in [".", env["headers_dir"], "include", "include/gen", "include/core"]]])
|
|
||||||
|
|
||||||
# Sources to compile
|
# Sources to compile
|
||||||
sources = []
|
sources = []
|
||||||
add_sources(sources, "src/core", "cpp")
|
add_sources(sources, "src/core", "cpp")
|
||||||
sources.extend(f for f in bindings if str(f).endswith(".cpp"))
|
add_sources(sources, "src/gen", "cpp")
|
||||||
|
|
||||||
arch_suffix = env["bits"]
|
arch_suffix = env["bits"]
|
||||||
if env["platform"] == "android":
|
if env["platform"] == "android":
|
||||||
@@ -510,6 +530,7 @@ if env["build_library"]:
|
|||||||
library = env.StaticLibrary(target=env.File("bin/%s" % library_name), source=sources)
|
library = env.StaticLibrary(target=env.File("bin/%s" % library_name), source=sources)
|
||||||
Default(library)
|
Default(library)
|
||||||
|
|
||||||
|
env.Append(CPPPATH=[env.Dir(f) for f in [env["headers_dir"], "include", "include/gen", "include/core"]])
|
||||||
env.Append(LIBPATH=[env.Dir("bin")])
|
env.Append(LIBPATH=[env.Dir("bin")])
|
||||||
env.Append(LIBS=library_name)
|
env.Append(LIBS=library_name)
|
||||||
Return("env")
|
Return("env")
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ def correct_method_name(method_list):
|
|||||||
classes = []
|
classes = []
|
||||||
|
|
||||||
|
|
||||||
def get_file_list(api_filepath, output_dir, headers=False, sources=False):
|
def print_file_list(api_filepath, output_dir, headers=False, sources=False):
|
||||||
global classes
|
global classes
|
||||||
files = []
|
end = ";"
|
||||||
with open(api_filepath) as api_file:
|
with open(api_filepath) as api_file:
|
||||||
classes = json.load(api_file)
|
classes = json.load(api_file)
|
||||||
include_gen_folder = Path(output_dir) / "include" / "gen"
|
include_gen_folder = Path(output_dir) / "include" / "gen"
|
||||||
@@ -26,35 +26,17 @@ def get_file_list(api_filepath, output_dir, headers=False, sources=False):
|
|||||||
header_filename = include_gen_folder / (strip_name(_class["name"]) + ".hpp")
|
header_filename = include_gen_folder / (strip_name(_class["name"]) + ".hpp")
|
||||||
source_filename = source_gen_folder / (strip_name(_class["name"]) + ".cpp")
|
source_filename = source_gen_folder / (strip_name(_class["name"]) + ".cpp")
|
||||||
if headers:
|
if headers:
|
||||||
files.append(str(header_filename.as_posix()))
|
print(str(header_filename.as_posix()), end=end)
|
||||||
if sources:
|
if sources:
|
||||||
files.append(str(source_filename.as_posix()))
|
print(str(source_filename.as_posix()), end=end)
|
||||||
icall_header_filename = include_gen_folder / "__icalls.hpp"
|
icall_header_filename = include_gen_folder / "__icalls.hpp"
|
||||||
register_types_filename = source_gen_folder / "__register_types.cpp"
|
register_types_filename = source_gen_folder / "__register_types.cpp"
|
||||||
init_method_bindings_filename = source_gen_folder / "__init_method_bindings.cpp"
|
init_method_bindings_filename = source_gen_folder / "__init_method_bindings.cpp"
|
||||||
if headers:
|
if headers:
|
||||||
files.append(str(icall_header_filename.as_posix()))
|
print(str(icall_header_filename.as_posix()), end=end)
|
||||||
if sources:
|
if sources:
|
||||||
files.append(str(register_types_filename.as_posix()))
|
print(str(register_types_filename.as_posix()), end=end)
|
||||||
files.append(str(init_method_bindings_filename.as_posix()))
|
print(str(init_method_bindings_filename.as_posix()), end=end)
|
||||||
return files
|
|
||||||
|
|
||||||
|
|
||||||
def print_file_list(api_filepath, output_dir, headers=False, sources=False):
|
|
||||||
for f in get_file_list(api_filepath, output_dir, headers, sources):
|
|
||||||
print(f, end=";")
|
|
||||||
|
|
||||||
|
|
||||||
def scons_emit_files(target, source, env):
|
|
||||||
files = [env.File(f) for f in get_file_list(str(source[0]), target[0].abspath, True, True)]
|
|
||||||
env.Clean(target, files)
|
|
||||||
env["godot_cpp_gen_dir"] = target[0].abspath
|
|
||||||
return files, source
|
|
||||||
|
|
||||||
|
|
||||||
def scons_generate_bindings(target, source, env):
|
|
||||||
generate_bindings(str(source[0]), env["generate_template_get_node"], env["godot_cpp_gen_dir"])
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def generate_bindings(api_filepath, use_template_get_node, output_dir="."):
|
def generate_bindings(api_filepath, use_template_get_node, output_dir="."):
|
||||||
@@ -66,12 +48,25 @@ def generate_bindings(api_filepath, use_template_get_node, output_dir="."):
|
|||||||
include_gen_folder = Path(output_dir) / "include" / "gen"
|
include_gen_folder = Path(output_dir) / "include" / "gen"
|
||||||
source_gen_folder = Path(output_dir) / "src" / "gen"
|
source_gen_folder = Path(output_dir) / "src" / "gen"
|
||||||
|
|
||||||
include_gen_folder.mkdir(parents=True, exist_ok=True)
|
try:
|
||||||
source_gen_folder.mkdir(parents=True, exist_ok=True)
|
include_gen_folder.mkdir(parents=True)
|
||||||
|
except os.error as e:
|
||||||
|
if e.errno == errno.EEXIST:
|
||||||
|
print(str(source_gen_folder) + ": " + os.strerror(e.errno))
|
||||||
|
else:
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
try:
|
||||||
|
source_gen_folder.mkdir(parents=True)
|
||||||
|
except os.error as e:
|
||||||
|
if e.errno == errno.EEXIST:
|
||||||
|
print(str(source_gen_folder) + ": " + os.strerror(e.errno))
|
||||||
|
else:
|
||||||
|
exit(1)
|
||||||
|
|
||||||
for c in classes:
|
for c in classes:
|
||||||
# print(c['name'])
|
# print(c['name'])
|
||||||
used_classes = sorted(get_used_classes(c))
|
used_classes = get_used_classes(c)
|
||||||
if use_template_get_node and c["name"] == "Node":
|
if use_template_get_node and c["name"] == "Node":
|
||||||
correct_method_name(c["methods"])
|
correct_method_name(c["methods"])
|
||||||
|
|
||||||
|
|||||||
Submodule godot-headers updated: 1049927a59...63d04316d3
@@ -1,31 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import os, sys
|
|
||||||
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", ".."))
|
|
||||||
|
|
||||||
from binding_generator import get_file_list, generate_bindings
|
|
||||||
|
|
||||||
api_filepath = "godot-headers/api.json"
|
|
||||||
bits = "64"
|
|
||||||
double = "float"
|
|
||||||
output_dir = "self_test"
|
|
||||||
|
|
||||||
generate_bindings(api_filepath, use_template_get_node=False, output_dir=output_dir)
|
|
||||||
flist = get_file_list(api_filepath, output_dir, headers=True, sources=True)
|
|
||||||
|
|
||||||
p = Path(output_dir)
|
|
||||||
allfiles = [str(f.as_posix()) for f in p.glob("**/*.*")]
|
|
||||||
missing = list(filter((lambda f: f not in flist), allfiles))
|
|
||||||
extras = list(filter((lambda f: f not in allfiles), flist))
|
|
||||||
if len(missing) > 0 or len(extras) > 0:
|
|
||||||
print("Error!")
|
|
||||||
for f in missing:
|
|
||||||
print("MISSING: " + str(f))
|
|
||||||
for f in extras:
|
|
||||||
print("EXTRA: " + str(f))
|
|
||||||
sys.exit(1)
|
|
||||||
else:
|
|
||||||
print("OK!")
|
|
||||||
Reference in New Issue
Block a user