Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Spartan322 committed Dec 4, 2024
2 parents 85d8711 + 1f47e4c commit fdccf6f
Show file tree
Hide file tree
Showing 798 changed files with 28,341 additions and 5,841 deletions.
4 changes: 4 additions & 0 deletions .github/actions/godot-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ runs:
python -c "import sys; print(sys.version)"
python -m pip install scons==${{ inputs.scons-version }}
scons --version
- name: Setup problem matchers
shell: bash
run: echo ::add-matcher::misc/utility/problem-matchers.json
7 changes: 3 additions & 4 deletions .github/workflows/godot_cpp_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: .github
sparse-checkout: |
.github
misc/utility/problem-matchers.json
- name: Checkout godot-cpp
uses: actions/checkout@v4
Expand All @@ -34,9 +36,6 @@ jobs:
- name: Setup Python and SCons
uses: ./.github/actions/godot-deps

- name: Setup GCC problem matcher
uses: ammaraskar/gcc-problem-matcher@master

- name: Download GDExtension interface and API dump
uses: ./.github/actions/download-artifact
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/linux_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ jobs:
python-version: 3.8
scons-version: 4.0

- name: Setup GCC problem matcher
uses: ammaraskar/gcc-problem-matcher@master

- name: Compilation
uses: ./.github/actions/godot-build
with:
Expand All @@ -158,6 +155,9 @@ jobs:
- name: Build .NET solutions
if: matrix.build-mono
run: |
# FIXME: C# warnings should be properly handled eventually, but we don't want to clutter
# the GitHub Actions annotations, so remove the associated problem matcher for now.
echo "::remove-matcher owner=msvc::"
./modules/mono/build_scripts/build_assemblies.py --godot-output-dir=./bin --godot-platform=linuxbsd
- name: Prepare artifact
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/windows_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,6 @@ jobs:
- name: Extract pre-built ANGLE static libraries
run: Expand-Archive -Force angle/angle.zip ${{ github.workspace }}/

- name: Setup MSVC problem matcher
if: matrix.compiler == 'msvc'
uses: ammaraskar/msvc-problem-matcher@master

- name: Setup GCC problem matcher
if: matrix.compiler != 'msvc'
uses: ammaraskar/gcc-problem-matcher@master

- name: Compilation
uses: ./.github/actions/godot-build
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ xcuserdata/
*.xcscmblueprint
*.xccheckout
*.xcodeproj/*
!misc/misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj

##############################
### Visual Studio specific ###
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ repos:
.*\.patch$|
.*\.out$|
modules/gdscript/tests/scripts/parser/features/mixed_indentation_on_blank_lines\.gd$|
modules/gdscript/tests/scripts/parser/warnings/empty_file_newline_comment\.notest\.gd$|
modules/gdscript/tests/scripts/parser/warnings/empty_file_newline\.notest\.gd$|
modules/gdscript/tests/scripts/parser/warnings/empty_file_newline_comment\.norun\.gd$|
modules/gdscript/tests/scripts/parser/warnings/empty_file_newline\.norun\.gd$|
platform/android/java/editor/src/main/java/com/android/.*|
platform/android/java/lib/src/com/google/.*|
tests/data/.*\.bin$
Expand Down
5 changes: 5 additions & 0 deletions COPYRIGHT.txt
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ Comment: WebP codec
Copyright: 2010, Google Inc.
License: BSD-3-clause

Files: ./thirdparty/manifold/
Comment: Manifold
Copyright: 2020-2024, The Manifold Authors
License: Apache-2.0

Files: ./thirdparty/mbedtls/
Comment: Mbed TLS
Copyright: The Mbed TLS Contributors
Expand Down
8 changes: 6 additions & 2 deletions core/config/project_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ Error ProjectSettings::_load_settings_binary(const String &p_path) {
cs[slen] = 0;
f->get_buffer((uint8_t *)cs.ptr(), slen);
String key;
key.parse_utf8(cs.ptr());
key.parse_utf8(cs.ptr(), slen);

uint32_t vlen = f->get_32();
Vector<uint8_t> d;
Expand Down Expand Up @@ -1518,7 +1518,11 @@ ProjectSettings::ProjectSettings() {
GLOBAL_DEF("display/window/frame_pacing/android/enable_frame_pacing", true);
GLOBAL_DEF(PropertyInfo(Variant::INT, "display/window/frame_pacing/android/swappy_mode", PROPERTY_HINT_ENUM, "pipeline_forced_on,auto_fps_pipeline_forced_on,auto_fps_auto_pipeline"), 2);

custom_prop_info["rendering/driver/threads/thread_model"] = PropertyInfo(Variant::INT, "rendering/driver/threads/thread_model", PROPERTY_HINT_ENUM, "Single-Unsafe,Single-Safe,Multi-Threaded");
#ifdef DISABLE_DEPRECATED
custom_prop_info["rendering/driver/threads/thread_model"] = PropertyInfo(Variant::INT, "rendering/driver/threads/thread_model", PROPERTY_HINT_ENUM, "Safe:1,Separate");
#else
custom_prop_info["rendering/driver/threads/thread_model"] = PropertyInfo(Variant::INT, "rendering/driver/threads/thread_model", PROPERTY_HINT_ENUM, "Unsafe (deprecated),Safe,Separate");
#endif
GLOBAL_DEF("physics/2d/run_on_separate_thread", false);
GLOBAL_DEF("physics/3d/run_on_separate_thread", false);

Expand Down
6 changes: 6 additions & 0 deletions core/core_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,11 @@ String OS::get_cache_dir() const {
return ::OS::get_singleton()->get_cache_path();
}

String OS::get_temp_dir() const {
// Exposed as `get_temp_dir()` instead of `get_temp_path()` for consistency with other exposed OS methods.
return ::OS::get_singleton()->get_temp_path();
}

bool OS::is_debug_build() const {
#ifdef DEBUG_ENABLED
return true;
Expand Down Expand Up @@ -707,6 +712,7 @@ void OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_config_dir"), &OS::get_config_dir);
ClassDB::bind_method(D_METHOD("get_data_dir"), &OS::get_data_dir);
ClassDB::bind_method(D_METHOD("get_cache_dir"), &OS::get_cache_dir);
ClassDB::bind_method(D_METHOD("get_temp_dir"), &OS::get_temp_dir);
ClassDB::bind_method(D_METHOD("get_unique_id"), &OS::get_unique_id);

ClassDB::bind_method(D_METHOD("get_keycode_string", "code"), &OS::get_keycode_string);
Expand Down
1 change: 1 addition & 0 deletions core/core_bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ class OS : public Object {
String get_config_dir() const;
String get_data_dir() const;
String get_cache_dir() const;
String get_temp_dir() const;

Error set_thread_name(const String &p_name);
::Thread::ID get_thread_caller_id() const;
Expand Down
4 changes: 4 additions & 0 deletions core/crypto/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ class ResourceFormatLoaderCrypto : public ResourceFormatLoader {
virtual void get_recognized_extensions(List<String> *p_extensions) const override;
virtual bool handles_type(const String &p_type) const override;
virtual String get_resource_type(const String &p_path) const override;

// Treat certificates as text files, do not generate a `*.{crt,key,pub}.uid` file.
virtual ResourceUID::ID get_resource_uid(const String &p_path) const override { return ResourceUID::INVALID_ID; }
virtual bool has_custom_uid_support() const override { return true; }
};

class ResourceFormatSaverCrypto : public ResourceFormatSaver {
Expand Down
12 changes: 6 additions & 6 deletions core/extension/gdextension_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ typedef void (*GDExtensionInterfaceMemFree)(void *p_ptr);
*
* Logs an error to Godot's built-in debugger and to the OS terminal.
*
* @param p_description The code trigging the error.
* @param p_description The code triggering the error.
* @param p_function The function name where the error occurred.
* @param p_file The file where the error occurred.
* @param p_line The line where the error occurred.
Expand All @@ -858,7 +858,7 @@ typedef void (*GDExtensionInterfacePrintError)(const char *p_description, const
*
* Logs an error with a message to Godot's built-in debugger and to the OS terminal.
*
* @param p_description The code trigging the error.
* @param p_description The code triggering the error.
* @param p_message The message to show along with the error.
* @param p_function The function name where the error occurred.
* @param p_file The file where the error occurred.
Expand All @@ -873,7 +873,7 @@ typedef void (*GDExtensionInterfacePrintErrorWithMessage)(const char *p_descript
*
* Logs a warning to Godot's built-in debugger and to the OS terminal.
*
* @param p_description The code trigging the warning.
* @param p_description The code triggering the warning.
* @param p_function The function name where the warning occurred.
* @param p_file The file where the warning occurred.
* @param p_line The line where the warning occurred.
Expand All @@ -887,7 +887,7 @@ typedef void (*GDExtensionInterfacePrintWarning)(const char *p_description, cons
*
* Logs a warning with a message to Godot's built-in debugger and to the OS terminal.
*
* @param p_description The code trigging the warning.
* @param p_description The code triggering the warning.
* @param p_message The message to show along with the warning.
* @param p_function The function name where the warning occurred.
* @param p_file The file where the warning occurred.
Expand All @@ -902,7 +902,7 @@ typedef void (*GDExtensionInterfacePrintWarningWithMessage)(const char *p_descri
*
* Logs a script error to Godot's built-in debugger and to the OS terminal.
*
* @param p_description The code trigging the error.
* @param p_description The code triggering the error.
* @param p_function The function name where the error occurred.
* @param p_file The file where the error occurred.
* @param p_line The line where the error occurred.
Expand All @@ -916,7 +916,7 @@ typedef void (*GDExtensionInterfacePrintScriptError)(const char *p_description,
*
* Logs a script error with a message to Godot's built-in debugger and to the OS terminal.
*
* @param p_description The code trigging the error.
* @param p_description The code triggering the error.
* @param p_message The message to show along with the error.
* @param p_function The function name where the error occurred.
* @param p_file The file where the error occurred.
Expand Down
83 changes: 82 additions & 1 deletion core/io/dir_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@

#include "core/config/project_settings.h"
#include "core/io/file_access.h"
#include "core/os/memory.h"
#include "core/os/os.h"
#include "core/os/time.h"
#include "core/templates/local_vector.h"

thread_local Error DirAccess::last_dir_open_error = OK;
Expand Down Expand Up @@ -325,6 +325,80 @@ Ref<DirAccess> DirAccess::create(AccessType p_access) {
return da;
}

Ref<DirAccess> DirAccess::create_temp(const String &p_prefix, bool p_keep, Error *r_error) {
const String ERROR_COMMON_PREFIX = "Error while creating temporary directory";

if (!p_prefix.is_valid_filename()) {
*r_error = ERR_FILE_BAD_PATH;
ERR_FAIL_V_MSG(Ref<FileAccess>(), vformat(R"(%s: "%s" is not a valid prefix.)", ERROR_COMMON_PREFIX, p_prefix));
}

Ref<DirAccess> dir_access = DirAccess::open(OS::get_singleton()->get_temp_path());

uint32_t suffix_i = 0;
String path;
while (true) {
String datetime = Time::get_singleton()->get_datetime_string_from_system().replace("-", "").replace("T", "").replace(":", "");
datetime += itos(Time::get_singleton()->get_ticks_usec());
String suffix = datetime + (suffix_i > 0 ? itos(suffix_i) : "");
path = (p_prefix.is_empty() ? "" : p_prefix + "-") + suffix;
if (!path.is_valid_filename()) {
*r_error = ERR_FILE_BAD_PATH;
return Ref<DirAccess>();
}
if (!DirAccess::exists(path)) {
break;
}
suffix_i += 1;
}

Error err = dir_access->make_dir(path);
if (err != OK) {
*r_error = err;
ERR_FAIL_V_MSG(Ref<FileAccess>(), vformat(R"(%s: "%s" couldn't create directory "%s".)", ERROR_COMMON_PREFIX, path));
}
err = dir_access->change_dir(path);
if (err != OK) {
*r_error = err;
return Ref<DirAccess>();
}

dir_access->_is_temp = true;
dir_access->_temp_keep_after_free = p_keep;
dir_access->_temp_path = dir_access->get_current_dir();

*r_error = OK;
return dir_access;
}

Ref<DirAccess> DirAccess::_create_temp(const String &p_prefix, bool p_keep) {
return create_temp(p_prefix, p_keep, &last_dir_open_error);
}

void DirAccess::_delete_temp() {
if (!_is_temp || _temp_keep_after_free) {
return;
}

if (!DirAccess::exists(_temp_path)) {
return;
}

Error err;
{
Ref<DirAccess> dir_access = DirAccess::open(_temp_path, &err);
if (err != OK) {
return;
}
err = dir_access->erase_contents_recursive();
if (err != OK) {
return;
}
}

DirAccess::remove_absolute(_temp_path);
}

Error DirAccess::get_open_error() {
return last_dir_open_error;
}
Expand Down Expand Up @@ -557,6 +631,7 @@ bool DirAccess::is_case_sensitive(const String &p_path) const {
void DirAccess::_bind_methods() {
ClassDB::bind_static_method("DirAccess", D_METHOD("open", "path"), &DirAccess::_open);
ClassDB::bind_static_method("DirAccess", D_METHOD("get_open_error"), &DirAccess::get_open_error);
ClassDB::bind_static_method("DirAccess", D_METHOD("create_temp", "prefix", "keep"), &DirAccess::_create_temp, DEFVAL(""), DEFVAL(false));

ClassDB::bind_method(D_METHOD("list_dir_begin"), &DirAccess::list_dir_begin, DEFVAL(false), DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_next"), &DirAccess::_get_next);
Expand Down Expand Up @@ -590,6 +665,8 @@ void DirAccess::_bind_methods() {
ClassDB::bind_method(D_METHOD("read_link", "path"), &DirAccess::read_link);
ClassDB::bind_method(D_METHOD("create_link", "source", "target"), &DirAccess::create_link);

ClassDB::bind_method(D_METHOD("is_bundle", "path"), &DirAccess::is_bundle);

ClassDB::bind_method(D_METHOD("set_include_navigational", "enable"), &DirAccess::set_include_navigational);
ClassDB::bind_method(D_METHOD("get_include_navigational"), &DirAccess::get_include_navigational);
ClassDB::bind_method(D_METHOD("set_include_hidden", "enable"), &DirAccess::set_include_hidden);
Expand All @@ -600,3 +677,7 @@ void DirAccess::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "include_navigational"), "set_include_navigational", "get_include_navigational");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "include_hidden"), "set_include_hidden", "get_include_hidden");
}

DirAccess::~DirAccess() {
_delete_temp();
}
12 changes: 11 additions & 1 deletion core/io/dir_access.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ class DirAccess : public RefCounted {
bool include_navigational = false;
bool include_hidden = false;

bool _is_temp = false;
bool _temp_keep_after_free = false;
String _temp_path;
void _delete_temp();

static Ref<DirAccess> _create_temp(const String &p_prefix = "", bool p_keep = false);

protected:
static void _bind_methods();

Expand Down Expand Up @@ -138,6 +145,7 @@ class DirAccess : public RefCounted {
}

static Ref<DirAccess> open(const String &p_path, Error *r_error = nullptr);
static Ref<DirAccess> create_temp(const String &p_prefix = "", bool p_keep = false, Error *r_error = nullptr);

static int _get_drive_count();
static String get_drive_name(int p_idx);
Expand All @@ -162,9 +170,11 @@ class DirAccess : public RefCounted {
bool get_include_hidden() const;

virtual bool is_case_sensitive(const String &p_path) const;
virtual bool is_bundle(const String &p_file) const { return false; }

public:
DirAccess() {}
virtual ~DirAccess() {}
virtual ~DirAccess();
};

#endif // DIR_ACCESS_H
Loading

0 comments on commit fdccf6f

Please sign in to comment.