Skip to content

Commit 219517f

Browse files
miheakien-mga
authored andcommitted
Add --import command-line flag
(cherry picked from commit 9d01793)
1 parent 0f6403f commit 219517f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

editor/editor_file_system.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ class EditorFileSystem : public Node {
304304
EditorFileSystemDirectory *get_filesystem();
305305
bool is_scanning() const;
306306
bool is_importing() const { return importing; }
307+
bool doing_first_scan() const { return first_scan; }
307308
float get_scanning_progress() const;
308309
void scan();
309310
void scan_changes();

main/main.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
#include "editor/debugger/editor_debugger_node.h"
9090
#include "editor/doc_data_class_path.gen.h"
9191
#include "editor/doc_tools.h"
92+
#include "editor/editor_file_system.h"
9293
#include "editor/editor_help.h"
9394
#include "editor/editor_node.h"
9495
#include "editor/editor_paths.h"
@@ -179,6 +180,7 @@ static OS::ProcessID editor_pid = 0;
179180
static bool found_project = false;
180181
static bool auto_build_solutions = false;
181182
static String debug_server_uri;
183+
static bool wait_for_import = false;
182184
#ifndef DISABLE_DEPRECATED
183185
static int converter_max_kb_file = 4 * 1024; // 4MB
184186
static int converter_max_line_length = 100000;
@@ -505,6 +507,7 @@ void Main::print_help(const char *p_binary) {
505507
OS::get_singleton()->print(" --main-loop <main_loop_name> Run a MainLoop specified by its global class name.\n");
506508
OS::get_singleton()->print(" --check-only Only parse for errors and quit (use with --script).\n");
507509
#ifdef TOOLS_ENABLED
510+
OS::get_singleton()->print(" --import Starts the editor, waits for any resources to be imported, and then quits.\n");
508511
OS::get_singleton()->print(" --export-release <preset> <path> Export the project in release mode using the given preset and output path. The preset name should match one defined in export_presets.cfg.\n");
509512
OS::get_singleton()->print(" <path> should be absolute or relative to the project directory, and include the filename for the binary (e.g. 'builds/game.exe').\n");
510513
OS::get_singleton()->print(" The target directory must exist.\n");
@@ -1288,12 +1291,17 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
12881291
OS::get_singleton()->print("Missing file to load argument after --validate-extension-api, aborting.");
12891292
goto error;
12901293
}
1291-
1294+
} else if (I->get() == "--import") {
1295+
editor = true;
1296+
cmdline_tool = true;
1297+
wait_for_import = true;
1298+
quit_after = 1;
12921299
} else if (I->get() == "--export-release" || I->get() == "--export-debug" ||
12931300
I->get() == "--export-pack") { // Export project
12941301
// Actually handling is done in start().
12951302
editor = true;
12961303
cmdline_tool = true;
1304+
wait_for_import = true;
12971305
main_args.push_back(I->get());
12981306
#ifndef DISABLE_DEPRECATED
12991307
} else if (I->get() == "--export") { // For users used to 3.x syntax.
@@ -3746,6 +3754,12 @@ bool Main::iteration() {
37463754
exit = true;
37473755
}
37483756

3757+
#ifdef TOOLS_ENABLED
3758+
if (wait_for_import && EditorFileSystem::get_singleton()->doing_first_scan()) {
3759+
exit = false;
3760+
}
3761+
#endif
3762+
37493763
if (fixed_fps != -1) {
37503764
return exit;
37513765
}

0 commit comments

Comments
 (0)