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

[pull] master from godotengine:master #121

Merged
merged 6 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
55 changes: 25 additions & 30 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,11 @@ for x in sorted(glob.glob("platform/*")):
sys.path.remove(tmppath)
sys.modules.pop("detect")

custom_tools = ["default"]

platform_arg = ARGUMENTS.get("platform", ARGUMENTS.get("p", False))

if platform_arg == "android":
custom_tools = ["clang", "clang++", "as", "ar", "link"]
elif platform_arg == "web":
# Use generic POSIX build toolchain for Emscripten.
custom_tools = ["cc", "c++", "ar", "link", "textfile", "zip"]
elif os.name == "nt" and methods.get_cmdline_bool("use_mingw", False):
custom_tools = ["mingw"]

# We let SCons build its default ENV as it includes OS-specific things which we don't
# want to have to pull in manually.
# want to have to pull in manually. However we enforce no "tools", which we register
# further down after parsing our platform-specific configuration.
# Then we prepend PATH to make it take precedence, while preserving SCons' own entries.
env = Environment(tools=custom_tools)
env = Environment(tools=[])
env.PrependENVPath("PATH", os.getenv("PATH"))
env.PrependENVPath("PKG_CONFIG_PATH", os.getenv("PKG_CONFIG_PATH"))
if "TERM" in os.environ: # Used for colored output.
Expand Down Expand Up @@ -168,11 +157,7 @@ if profile:
opts = Variables(customs, ARGUMENTS)

# Target build options
if env.scons_version >= (4, 3):
opts.Add(["platform", "p"], "Target platform (%s)" % "|".join(platform_list), "")
else:
opts.Add("platform", "Target platform (%s)" % "|".join(platform_list), "")
opts.Add("p", "Alias for 'platform'", "")
opts.Add((["platform", "p"], "Target platform (%s)" % "|".join(platform_list), ""))
opts.Add(EnumVariable("target", "Compilation target", "editor", ("editor", "template_release", "template_debug")))
opts.Add(EnumVariable("arch", "CPU architecture", "auto", ["auto"] + architectures, architecture_aliases))
opts.Add(BoolVariable("dev_build", "Developer build with dev-only debugging code (DEV_ENABLED)", False))
Expand Down Expand Up @@ -312,10 +297,7 @@ if env["import_env_vars"]:

# Platform selection: validate input, and add options.

if env.scons_version < (4, 3) and not env["platform"]:
env["platform"] = env["p"]

if env["platform"] == "":
if not env["platform"]:
# Missing `platform` argument, try to detect platform automatically
if (
sys.platform.startswith("linux")
Expand All @@ -330,7 +312,7 @@ if env["platform"] == "":
elif sys.platform == "win32":
env["platform"] = "windows"

if env["platform"] != "":
if env["platform"]:
print(f'Automatically detected platform: {env["platform"]}')

# Deprecated aliases kept for compatibility.
Expand All @@ -352,7 +334,7 @@ if env["platform"] not in platform_list:

if env["platform"] == "list":
print(text)
elif env["platform"] == "":
elif not env["platform"]:
print_error("Could not detect platform automatically.\n" + text)
else:
print_error(f'Invalid target platform "{env["platform"]}".\n' + text)
Expand Down Expand Up @@ -434,6 +416,23 @@ env.modules_detected = modules_detected
opts.Update(env, {**ARGUMENTS, **env.Dictionary()})
Help(opts.GenerateHelpText(env))


# FIXME: Tool assignment happening at this stage is a direct consequence of getting the platform logic AFTER the SCons
# environment was already been constructed. Fixing this would require a broader refactor where all options are setup
# ahead of time with native validator/converter functions.
tmppath = "./platform/" + env["platform"]
sys.path.insert(0, tmppath)
import detect

custom_tools = ["default"]
try: # Platform custom tools are optional
custom_tools = detect.get_tools(env)
except AttributeError:
pass
for tool in custom_tools:
env.Tool(tool)


# add default include paths

env.Prepend(CPPPATH=["#"])
Expand Down Expand Up @@ -515,10 +514,6 @@ if not env["deprecated"]:
if env["precision"] == "double":
env.Append(CPPDEFINES=["REAL_T_IS_DOUBLE"])

tmppath = "./platform/" + env["platform"]
sys.path.insert(0, tmppath)
import detect

# Default num_jobs to local cpu count if not user specified.
# SCons has a peculiarity where user-specified options won't be overridden
# by SetOption, so we can rely on this to know if we should use our default.
Expand Down Expand Up @@ -587,7 +582,7 @@ if env["dev_mode"]:
if env["production"]:
env["use_static_cpp"] = methods.get_cmdline_bool("use_static_cpp", True)
env["debug_symbols"] = methods.get_cmdline_bool("debug_symbols", False)
if platform_arg == "android":
if env["platform"] == "android":
env["swappy"] = methods.get_cmdline_bool("swappy", True)
# LTO "auto" means we handle the preferred option in each platform detect.py.
env["lto"] = ARGUMENTS.get("lto", "auto")
Expand Down
5 changes: 5 additions & 0 deletions editor/filesystem_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,11 @@ void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_
break;
}
}
} else {
Ref<Resource> res = ResourceCache::get_ref(old_path);
if (res.is_valid()) {
res->set_path_cache(new_path);
}
}
}

Expand Down
31 changes: 18 additions & 13 deletions editor/plugins/script_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1170,11 +1170,10 @@ void ScriptEditor::_live_auto_reload_running_scripts() {
bool ScriptEditor::_test_script_times_on_disk(Ref<Resource> p_for_script) {
disk_changed_list->clear();
TreeItem *r = disk_changed_list->create_item();
disk_changed_list->set_hide_root(true);

bool need_ask = false;
bool need_reload = false;
bool use_autoreload = bool(EDITOR_GET("text_editor/behavior/files/auto_reload_scripts_on_external_change"));
bool use_autoreload = EDITOR_GET("text_editor/behavior/files/auto_reload_scripts_on_external_change");

for (int i = 0; i < tab_container->get_tab_count(); i++) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
Expand All @@ -1188,12 +1187,12 @@ bool ScriptEditor::_test_script_times_on_disk(Ref<Resource> p_for_script) {
continue; //internal script, who cares
}

uint64_t last_date = edited_res->get_last_modified_time();
uint64_t date = FileAccess::get_modified_time(edited_res->get_path());
uint64_t last_date = se->edited_file_data.last_modified_time;
uint64_t date = FileAccess::get_modified_time(se->edited_file_data.path);

if (last_date != date) {
TreeItem *ti = disk_changed_list->create_item(r);
ti->set_text(0, edited_res->get_path().get_file());
ti->set_text(0, se->edited_file_data.path.get_file());

if (!use_autoreload || se->is_unsaved()) {
need_ask = true;
Expand Down Expand Up @@ -2231,11 +2230,6 @@ void ScriptEditor::_update_script_names() {
Ref<Texture2D> icon = se->get_theme_icon();
String path = se->get_edited_resource()->get_path();
bool saved = !path.is_empty();
if (saved) {
// The script might be deleted, moved, or renamed, so make sure
// to update original path to previously edited resource.
se->set_meta("_edit_res_path", path);
}
String name = se->get_name();
Ref<Script> scr = se->get_edited_resource();

Expand Down Expand Up @@ -2633,7 +2627,8 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col,

// If we delete a script within the filesystem, the original resource path
// is lost, so keep it as metadata to figure out the exact tab to delete.
se->set_meta("_edit_res_path", p_resource->get_path());
se->edited_file_data.path = p_resource->get_path();
se->edited_file_data.last_modified_time = FileAccess::get_modified_time(p_resource->get_path());
if (se->get_edit_menu()) {
se->get_edit_menu()->hide();
menu_hb->add_child(se->get_edit_menu());
Expand Down Expand Up @@ -3042,6 +3037,15 @@ void ScriptEditor::_files_moved(const String &p_old_file, const String &p_new_fi
if (!script_editor_cache->has_section(p_old_file)) {
return;
}

for (int i = 0; i < tab_container->get_tab_count(); i++) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
if (se && se->edited_file_data.path == p_old_file) {
se->edited_file_data.path = p_new_file;
break;
}
}

Variant state = script_editor_cache->get_value(p_old_file, "state");
script_editor_cache->erase_section(p_old_file);
script_editor_cache->set_value(p_new_file, "state", state);
Expand All @@ -3064,7 +3068,7 @@ void ScriptEditor::_file_removed(const String &p_removed_file) {
if (!se) {
continue;
}
if (se->get_meta("_edit_res_path") == p_removed_file) {
if (se->edited_file_data.path == p_removed_file) {
// The script is deleted with no undo, so just close the tab.
_close_tab(i, false, false);
}
Expand Down Expand Up @@ -4414,9 +4418,10 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
vbc->add_child(files_are_newer_label);

disk_changed_list = memnew(Tree);
vbc->add_child(disk_changed_list);
disk_changed_list->set_hide_root(true);
disk_changed_list->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
disk_changed_list->set_v_size_flags(SIZE_EXPAND_FILL);
vbc->add_child(disk_changed_list);

Label *what_action_label = memnew(Label);
what_action_label->set_text(TTR("What action should be taken?"));
Expand Down
5 changes: 5 additions & 0 deletions editor/plugins/script_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ class ScriptEditorBase : public VBoxContainer {
static void _bind_methods();

public:
struct EditedFileData {
String path;
uint64_t last_modified_time = -1;
} edited_file_data;

virtual void add_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlighter) = 0;
virtual void set_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlighter) = 0;

Expand Down
1 change: 1 addition & 0 deletions editor/plugins/script_text_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ void ScriptTextEditor::convert_indent() {

void ScriptTextEditor::tag_saved_version() {
code_editor->get_text_editor()->tag_saved_version();
edited_file_data.last_modified_time = FileAccess::get_modified_time(edited_file_data.path);
}

void ScriptTextEditor::goto_line(int p_line, int p_column) {
Expand Down
1 change: 1 addition & 0 deletions editor/plugins/text_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ void TextEditor::convert_indent() {

void TextEditor::tag_saved_version() {
code_editor->get_text_editor()->tag_saved_version();
edited_file_data.last_modified_time = FileAccess::get_modified_time(edited_file_data.path);
}

void TextEditor::goto_line(int p_line, int p_column) {
Expand Down
Loading
Loading