Skip to content

Commit

Permalink
Merge pull request #864 from Spartan322/merge/6c05ec3
Browse files Browse the repository at this point in the history
  • Loading branch information
Spartan322 authored Nov 15, 2024
2 parents ac1a497 + 4a5836e commit 9767837
Show file tree
Hide file tree
Showing 143 changed files with 1,787 additions and 1,096 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 @@ -61,8 +61,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 @@ -132,8 +130,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 @@ -271,6 +271,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 @@ -321,6 +323,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 @@ -350,27 +355,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 Redot 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 Redot 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 Redot 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 Redot 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 Redot 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 @@ -667,40 +663,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 @@ -764,7 +752,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 @@ -1050,23 +1038,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 @@ -1148,5 +1120,3 @@ def purge_flaky_files():


atexit.register(purge_flaky_files)

methods.clean_cache(env)
2 changes: 1 addition & 1 deletion core/config/project_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,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
2 changes: 1 addition & 1 deletion core/input/input_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,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
4 changes: 2 additions & 2 deletions core/input/input_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ InputMap *InputMap::singleton = nullptr;
void InputMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("has_action", "action"), &InputMap::has_action);
ClassDB::bind_method(D_METHOD("get_actions"), &InputMap::_get_actions);
ClassDB::bind_method(D_METHOD("add_action", "action", "deadzone"), &InputMap::add_action, DEFVAL(0.2f));
ClassDB::bind_method(D_METHOD("add_action", "action", "deadzone"), &InputMap::add_action, DEFVAL(DEFAULT_DEADZONE));
ClassDB::bind_method(D_METHOD("erase_action", "action"), &InputMap::erase_action);

ClassDB::bind_method(D_METHOD("action_set_deadzone", "action", "deadzone"), &InputMap::action_set_deadzone);
Expand Down Expand Up @@ -307,7 +307,7 @@ void InputMap::load_from_project_settings() {
String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length());

Dictionary action = GLOBAL_GET(pi.name);
float deadzone = action.has("deadzone") ? (float)action["deadzone"] : 0.2f;
float deadzone = action.has("deadzone") ? (float)action["deadzone"] : DEFAULT_DEADZONE;
Array events = action["events"];

add_action(name, deadzone);
Expand Down
4 changes: 3 additions & 1 deletion core/input/input_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class InputMap : public Object {
List<Ref<InputEvent>> inputs;
};

static constexpr float DEFAULT_DEADZONE = 0.2f;

private:
static InputMap *singleton;

Expand All @@ -76,7 +78,7 @@ class InputMap : public Object {

bool has_action(const StringName &p_action) const;
List<StringName> get_actions() const;
void add_action(const StringName &p_action, float p_deadzone = 0.2);
void add_action(const StringName &p_action, float p_deadzone = DEFAULT_DEADZONE);
void erase_action(const StringName &p_action);

float action_get_deadzone(const StringName &p_action);
Expand Down
43 changes: 43 additions & 0 deletions core/io/file_access.compat.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**************************************************************************/
/* file_access.compat.inc */
/**************************************************************************/
/* This file is part of: */
/* REDOT ENGINE */
/* https://redotengine.org */
/**************************************************************************/
/* Copyright (c) 2024-present Redot Engine contributors */
/* (see REDOT_AUTHORS.md) */
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* 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 OR COPYRIGHT HOLDERS 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. */
/**************************************************************************/

#ifndef DISABLE_DEPRECATED

Ref<FileAccess> FileAccess::_open_encrypted_bind_compat_98918(const String &p_path, ModeFlags p_mode_flags, const Vector<uint8_t> &p_key) {
return open_encrypted(p_path, p_mode_flags, p_key, Vector<uint8_t>());
}

void FileAccess::_bind_compatibility_methods() {
ClassDB::bind_compatibility_static_method("FileAccess", D_METHOD("open_encrypted", "path", "mode_flags", "key"), &FileAccess::_open_encrypted_bind_compat_98918);
}

#endif // DISABLE_DEPRECATED
Loading

0 comments on commit 9767837

Please sign in to comment.