Skip to content

Commit

Permalink
Merge pull request #9 from Norrox/from-master
Browse files Browse the repository at this point in the history
Updates from godot
  • Loading branch information
Norrox authored Nov 16, 2024
2 parents a816a78 + 0d34486 commit 70a859f
Show file tree
Hide file tree
Showing 184 changed files with 3,398 additions and 1,225 deletions.
10 changes: 4 additions & 6 deletions .github/actions/godot-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ inputs:
required: false
scons-cache:
description: The SCons cache path.
default: ${{ github.workspace }}/.scons-cache/
default: ${{ github.workspace }}/.scons_cache/
scons-cache-limit:
description: The SCons cache size limit.
# actions/cache has 10 GiB limit, and GitHub runners have a 14 GiB disk.
# Limit to 7 GiB to avoid having the extracted cache fill the disk.
default: 7168
default: 7

runs:
using: composite
Expand All @@ -32,10 +32,8 @@ runs:
shell: sh
env:
SCONSFLAGS: ${{ inputs.sconsflags }}
SCONS_CACHE: ${{ inputs.scons-cache }}
SCONS_CACHE_LIMIT: ${{ inputs.scons-cache-limit }}
run: |
echo "Building with flags:" platform=${{ inputs.platform }} target=${{ inputs.target }} tests=${{ inputs.tests }} ${{ env.SCONSFLAGS }}
echo "Building with flags:" platform=${{ inputs.platform }} target=${{ inputs.target }} tests=${{ inputs.tests }} ${{ env.SCONSFLAGS }} "cache_path=${{ inputs.scons-cache }}" cache_limit=${{ inputs.scons-cache-limit }}
if [ "${{ inputs.target }}" != "editor" ]; then
# Ensure we don't include editor code in export template builds.
Expand All @@ -49,5 +47,5 @@ runs:
export BUILD_NAME="gh"
fi
scons platform=${{ inputs.platform }} target=${{ inputs.target }} tests=${{ inputs.tests }} ${{ env.SCONSFLAGS }}
scons platform=${{ inputs.platform }} target=${{ inputs.target }} tests=${{ inputs.tests }} ${{ env.SCONSFLAGS }} "cache_path=${{ inputs.scons-cache }}" cache_limit=${{ inputs.scons-cache-limit }}
ls -l bin/
3 changes: 1 addition & 2 deletions .github/actions/godot-cache-restore/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ inputs:
default: ${{ github.job }}
scons-cache:
description: The SCons cache path.
default: ${{ github.workspace }}/.scons-cache/
default: ${{ github.workspace }}/.scons_cache/

runs:
using: composite
Expand All @@ -29,7 +29,6 @@ runs:
# 4. A partial match for the same base branch only (not ideal, matches any PR with the same base branch).

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 }}-refs/heads/${{ env.GODOT_BASE_BRANCH }}
${{ inputs.cache-name }}-${{ env.GODOT_BASE_BRANCH }}
2 changes: 1 addition & 1 deletion .github/actions/godot-cache-save/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ inputs:
default: ${{ github.job }}
scons-cache:
description: The SCons cache path.
default: ${{ github.workspace }}/.scons-cache/
default: ${{ github.workspace }}/.scons_cache/

runs:
using: composite
Expand Down
1 change: 0 additions & 1 deletion .github/actions/godot-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ runs:
shell: bash
run: |
python -c "import sys; print(sys.version)"
python -m pip install wheel
python -m pip install scons==${{ inputs.scons-version }}
scons --version
3 changes: 0 additions & 3 deletions .github/workflows/godot_cpp_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ jobs:
# continue-on-error: true

- name: Build godot-cpp test extension
env: # Keep synced with godot-build.
SCONS_CACHE: ${{ github.workspace }}/.scons-cache/
SCONS_CACHE_LIMIT: 7168
run: scons --directory=./godot-cpp/test target=template_debug dev_build=yes verbose=yes

# - name: Save Godot build cache
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/linux_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ concurrency:

jobs:
build-linux:
# If unspecified, stay one LTS before latest to increase portability of Linux artifacts.
runs-on: ${{ matrix.os || 'ubuntu-22.04' }}
# Stay one LTS before latest to increase portability of Linux artifacts.
runs-on: ubuntu-22.04
name: ${{ matrix.name }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -72,8 +72,6 @@ jobs:
artifact: false
# Test our oldest supported SCons/Python versions on one arbitrary editor build.
legacy-scons: true
# Python 3.6 unavailable on 22.04.
os: ubuntu-20.04

- name: Editor with ThreadSanitizer (target=editor, tests=yes, dev_build=yes, use_tsan=yes, use_llvm=yes, linker=lld)
cache-name: linux-editor-thread-sanitizer
Expand Down Expand Up @@ -143,8 +141,8 @@ jobs:
uses: ./.github/actions/godot-deps
with:
# Sync with Ensure*Version in SConstruct.
python-version: 3.6
scons-version: 3.1.2
python-version: 3.8
scons-version: 4.0

- name: Setup GCC problem matcher
uses: ammaraskar/gcc-problem-matcher@master
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ venv
__pycache__/
*.pyc

# Python modules
.*_cache/

# Documentation
doc/_build/

Expand Down Expand Up @@ -164,9 +167,6 @@ gmon.out
# Kdevelop
*.kdev4

# Mypy
.mypy_cache

# Qt Creator
*.config
*.creator
Expand Down
98 changes: 34 additions & 64 deletions SConstruct
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python
from misc.utility.scons_hints import *

EnsureSConsVersion(3, 1, 2)
EnsurePythonVersion(3, 6)
EnsureSConsVersion(4, 0)
EnsurePythonVersion(3, 8)

# System
import atexit
Expand Down Expand Up @@ -59,7 +59,7 @@ import glsl_builders
import methods
import scu_builders
from methods import print_error, print_warning
from platform_methods import architecture_aliases, architectures
from platform_methods import architecture_aliases, architectures, compatibility_platform_aliases

if ARGUMENTS.get("target", "editor") == "editor":
_helper_module("editor.editor_builders", "editor/editor_builders.py")
Expand Down Expand Up @@ -272,6 +272,8 @@ opts.Add(BoolVariable("scu_build", "Use single compilation unit build", False))
opts.Add("scu_limit", "Max includes per SCU file when using scu_build (determines RAM use)", "0")
opts.Add(BoolVariable("engine_update_check", "Enable engine update checks in the Project Manager", True))
opts.Add(BoolVariable("steamapi", "Enable minimal SteamAPI integration for usage time tracking (editor only)", False))
opts.Add("cache_path", "Path to a directory where SCons cache files will be stored. No value disables the cache.", "")
opts.Add("cache_limit", "Max size (in GiB) for the SCons cache. 0 means no limit.", "0")

# Thirdparty libraries
opts.Add(BoolVariable("builtin_brotli", "Use the built-in Brotli library", True))
Expand Down Expand Up @@ -322,6 +324,9 @@ opts.Add("rcflags", "Custom flags for Windows resource compiler")
# in following code (especially platform and custom_modules).
opts.Update(env)

# Setup caching logic early to catch everything.
methods.prepare_cache(env)

# Copy custom environment variables if set.
if env["import_env_vars"]:
for env_var in str(env["import_env_vars"]).split(","):
Expand Down Expand Up @@ -351,27 +356,18 @@ if env["platform"] == "":
if env["platform"] != "":
print(f'Automatically detected platform: {env["platform"]}')

if env["platform"] == "osx":
# Deprecated alias kept for compatibility.
print_warning('Platform "osx" has been renamed to "macos" in Godot 4. Building for platform "macos".')
env["platform"] = "macos"

if env["platform"] == "iphone":
# Deprecated alias kept for compatibility.
print_warning('Platform "iphone" has been renamed to "ios" in Godot 4. Building for platform "ios".')
env["platform"] = "ios"

if env["platform"] in ["linux", "bsd", "x11"]:
if env["platform"] == "x11":
# Deprecated alias kept for compatibility.
print_warning('Platform "x11" has been renamed to "linuxbsd" in Godot 4. Building for platform "linuxbsd".')
# Alias for convenience.
env["platform"] = "linuxbsd"
# Deprecated aliases kept for compatibility.
if env["platform"] in compatibility_platform_aliases:
alias = env["platform"]
platform = compatibility_platform_aliases[alias]
print_warning(
f'Platform "{alias}" has been renamed to "{platform}" in Godot 4. Building for platform "{platform}".'
)
env["platform"] = platform

if env["platform"] == "javascript":
# Deprecated alias kept for compatibility.
print_warning('Platform "javascript" has been renamed to "web" in Godot 4. Building for platform "web".')
env["platform"] = "web"
# Alias for convenience.
if env["platform"] in ["linux", "bsd"]:
env["platform"] = "linuxbsd"

if env["platform"] not in platform_list:
text = "The following platforms are available:\n\t{}\n".format("\n\t".join(platform_list))
Expand Down Expand Up @@ -668,40 +664,32 @@ elif methods.using_gcc(env):
"to switch to posix threads."
)
Exit(255)
if env["debug_paths_relative"] and cc_version_major < 8:
print_warning("GCC < 8 doesn't support -ffile-prefix-map, disabling `debug_paths_relative` option.")
env["debug_paths_relative"] = False
elif methods.using_clang(env):
# Apple LLVM versions differ from upstream LLVM version \o/, compare
# in https://en.wikipedia.org/wiki/Xcode#Toolchain_versions
if env["platform"] == "macos" or env["platform"] == "ios":
vanilla = methods.is_vanilla_clang(env)
if vanilla and cc_version_major < 6:
print_error(
"Detected Clang version older than 6, which does not fully support "
"C++17. Supported versions are Clang 6 and later."
)
Exit(255)
elif not vanilla and cc_version_major < 10:
if methods.is_apple_clang(env):
if cc_version_major < 10:
print_error(
"Detected Apple Clang version older than 10, which does not fully "
"support C++17. Supported versions are Apple Clang 10 and later."
)
Exit(255)
if env["debug_paths_relative"] and not vanilla and cc_version_major < 12:
elif env["debug_paths_relative"] and cc_version_major < 12:
print_warning(
"Apple Clang < 12 doesn't support -ffile-prefix-map, disabling `debug_paths_relative` option."
)
env["debug_paths_relative"] = False
elif cc_version_major < 6:
print_error(
"Detected Clang version older than 6, which does not fully support "
"C++17. Supported versions are Clang 6 and later."
)
Exit(255)
if env["debug_paths_relative"] and cc_version_major < 10:
print_warning("Clang < 10 doesn't support -ffile-prefix-map, disabling `debug_paths_relative` option.")
env["debug_paths_relative"] = False
else:
if cc_version_major < 6:
print_error(
"Detected Clang version older than 6, which does not fully support "
"C++17. Supported versions are Clang 6 and later."
)
Exit(255)
elif env["debug_paths_relative"] and cc_version_major < 10:
print_warning("Clang < 10 doesn't support -ffile-prefix-map, disabling `debug_paths_relative` option.")
env["debug_paths_relative"] = False

elif env.msvc:
# Ensure latest minor builds of Visual Studio 2017/2019.
# https://github.com/godotengine/godot/pull/94995#issuecomment-2336464574
Expand Down Expand Up @@ -765,7 +753,7 @@ else:
project_path = Dir("#").abspath
env.Append(CCFLAGS=[f"-ffile-prefix-map={project_path}=."])
else:
if methods.using_clang(env) and not methods.is_vanilla_clang(env):
if methods.is_apple_clang(env):
# Apple Clang, its linker doesn't like -s.
env.Append(LINKFLAGS=["-Wl,-S", "-Wl,-x", "-Wl,-dead_strip"])
else:
Expand Down Expand Up @@ -1053,23 +1041,7 @@ GLSL_BUILDERS = {
}
env.Append(BUILDERS=GLSL_BUILDERS)

scons_cache_path = os.environ.get("SCONS_CACHE")
if scons_cache_path is not None:
CacheDir(scons_cache_path)
print("Scons cache enabled... (path: '" + scons_cache_path + "')")

if env["vsproj"]:
env.vs_incs = []
env.vs_srcs = []

if env["compiledb"]:
if env.scons_version < (4, 0, 0):
# Generating the compilation DB (`compile_commands.json`) requires SCons 4.0.0 or later.
print_error(
"The `compiledb=yes` option requires SCons 4.0 or later, but your version is %s." % scons_raw_version
)
Exit(255)

env.Tool("compilation_db")
env.Alias("compiledb", env.CompilationDatabase())

Expand Down Expand Up @@ -1151,5 +1123,3 @@ def purge_flaky_files():


atexit.register(purge_flaky_files)

methods.clean_cache(env)
8 changes: 8 additions & 0 deletions core/config/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,14 @@ void Engine::set_freeze_time_scale(bool p_frozen) {
freeze_time_scale = p_frozen;
}

void Engine::set_embedded(bool p_enabled) {
embedded = p_enabled;
}

bool Engine::is_embedded() const {
return embedded;
}

Engine::Engine() {
singleton = this;
}
Expand Down
3 changes: 3 additions & 0 deletions core/config/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class Engine {
bool editor_hint = false;
bool project_manager_hint = false;
bool extension_reloading = false;
bool embedded = false;

bool _print_header = true;

Expand Down Expand Up @@ -201,6 +202,8 @@ class Engine {
bool notify_frame_server_synced();

void set_freeze_time_scale(bool p_frozen);
void set_embedded(bool p_enabled);
bool is_embedded() const;

Engine();
virtual ~Engine();
Expand Down
2 changes: 1 addition & 1 deletion core/config/project_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ void ProjectSettings::_add_builtin_input_map() {
}

Dictionary action;
action["deadzone"] = Variant(0.2f);
action["deadzone"] = Variant(InputMap::DEFAULT_DEADZONE);
action["events"] = events;

String action_name = "input/" + E.key;
Expand Down
9 changes: 9 additions & 0 deletions core/core_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1897,6 +1897,14 @@ bool Engine::is_editor_hint() const {
return ::Engine::get_singleton()->is_editor_hint();
}

void Engine::set_embedded(bool p_enabled) {
::Engine::get_singleton()->set_embedded(p_enabled);
}

bool Engine::is_embedded() const {
return ::Engine::get_singleton()->is_embedded();
}

String Engine::get_write_movie_path() const {
return ::Engine::get_singleton()->get_write_movie_path();
}
Expand Down Expand Up @@ -1974,6 +1982,7 @@ void Engine::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_script_language", "index"), &Engine::get_script_language);

ClassDB::bind_method(D_METHOD("is_editor_hint"), &Engine::is_editor_hint);
ClassDB::bind_method(D_METHOD("is_embedded"), &Engine::is_embedded);

ClassDB::bind_method(D_METHOD("get_write_movie_path"), &Engine::get_write_movie_path);

Expand Down
3 changes: 3 additions & 0 deletions core/core_bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,9 @@ class Engine : public Object {
void set_editor_hint(bool p_enabled);
bool is_editor_hint() const;

void set_embedded(bool p_enabled);
bool is_embedded() const;

// `set_write_movie_path()` is not exposed to the scripting API as changing it at run-time has no effect.
String get_write_movie_path() const;

Expand Down
2 changes: 1 addition & 1 deletion core/input/input_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ JoyAxis InputEventJoypadMotion::get_axis() const {

void InputEventJoypadMotion::set_axis_value(float p_value) {
axis_value = p_value;
pressed = Math::abs(axis_value) >= 0.5f;
pressed = Math::abs(axis_value) >= InputMap::DEFAULT_DEADZONE;
emit_changed();
}

Expand Down
Loading

0 comments on commit 70a859f

Please sign in to comment.