Jelajahi Sumber

[Web] Fix Web Editor plugin being added to SCons multiple times

Move the Web Editor plugin files to an editor sub-folder inside the
platform folder.
Fabio Alessandrelli 9 bulan lalu
induk
melakukan
b4f8135d46

+ 3 - 1
platform/web/SCsub

@@ -27,9 +27,11 @@ web_files = [
     "javascript_bridge_singleton.cpp",
     "web_main.cpp",
     "os_web.cpp",
-    "api/web_tools_editor_plugin.cpp",
 ]
 
+if env["target"] == "editor":
+    env.add_source_files(web_files, "editor/*.cpp")
+
 sys_env = env.Clone()
 sys_env.AddJSLibraries(
     [

+ 0 - 2
platform/web/api/api.cpp

@@ -31,14 +31,12 @@
 #include "api.h"
 
 #include "javascript_bridge_singleton.h"
-#include "web_tools_editor_plugin.h"
 
 #include "core/config/engine.h"
 
 static JavaScriptBridge *javascript_bridge_singleton;
 
 void register_web_api() {
-	WebToolsEditorPlugin::initialize();
 	GDREGISTER_ABSTRACT_CLASS(JavaScriptObject);
 	GDREGISTER_ABSTRACT_CLASS(JavaScriptBridge);
 	javascript_bridge_singleton = memnew(JavaScriptBridge);

+ 0 - 4
platform/web/api/web_tools_editor_plugin.cpp → platform/web/editor/web_tools_editor_plugin.cpp

@@ -30,8 +30,6 @@
 
 #include "web_tools_editor_plugin.h"
 
-#if defined(TOOLS_ENABLED) && defined(WEB_ENABLED)
-
 #include "core/config/engine.h"
 #include "core/config/project_settings.h"
 #include "core/io/dir_access.h"
@@ -155,5 +153,3 @@ void WebToolsEditorPlugin::_zip_recursive(String p_path, String p_base_path, zip
 		cur = dir->get_next();
 	}
 }
-
-#endif // TOOLS_ENABLED && WEB_ENABLED

+ 0 - 4
platform/web/api/web_tools_editor_plugin.h → platform/web/editor/web_tools_editor_plugin.h

@@ -31,8 +31,6 @@
 #ifndef WEB_TOOLS_EDITOR_PLUGIN_H
 #define WEB_TOOLS_EDITOR_PLUGIN_H
 
-#if defined(TOOLS_ENABLED) && defined(WEB_ENABLED)
-
 #include "core/io/zip_io.h"
 #include "editor/plugins/editor_plugin.h"
 
@@ -57,6 +55,4 @@ public:
 	static void initialize() {}
 };
 
-#endif // TOOLS_ENABLED && WEB_ENABLED
-
 #endif // WEB_TOOLS_EDITOR_PLUGIN_H

+ 8 - 0
platform/web/web_main.cpp

@@ -38,6 +38,10 @@
 #include "scene/main/scene_tree.h"
 #include "scene/main/window.h" // SceneTree only forward declares it.
 
+#ifdef TOOLS_ENABLED
+#include "editor/web_tools_editor_plugin.h"
+#endif
+
 #include <emscripten/emscripten.h>
 #include <stdlib.h>
 
@@ -104,6 +108,10 @@ void main_loop_callback() {
 extern EMSCRIPTEN_KEEPALIVE int godot_web_main(int argc, char *argv[]) {
 	os = new OS_Web();
 
+#ifdef TOOLS_ENABLED
+	WebToolsEditorPlugin::initialize();
+#endif
+
 	// We must override main when testing is enabled
 	TEST_MAIN_OVERRIDE