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

Main: Default --doctool path to '.' if none given #47647

Merged
merged 1 commit into from
Apr 8, 2021
Merged
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
24 changes: 14 additions & 10 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ void Main::print_help(const char *p_binary) {
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'). The target directory should exist.\n");
OS::get_singleton()->print(" --export-debug <preset> <path> Same as --export, but using the debug template.\n");
OS::get_singleton()->print(" --export-pack <preset> <path> Same as --export, but only export the game pack for the given preset. The <path> extension determines whether it will be in PCK or ZIP format.\n");
OS::get_singleton()->print(" --doctool <path> Dump the engine API reference to the given <path> in XML format, merging if existing files are found.\n");
OS::get_singleton()->print(" --doctool [<path>] Dump the engine API reference to the given <path> (defaults to current dir) in XML format, merging if existing files are found.\n");
OS::get_singleton()->print(" --no-docbase Disallow dumping the base types (used with --doctool).\n");
OS::get_singleton()->print(" --build-solutions Build the scripting solutions (e.g. for C# projects). Implies --editor and requires a valid project to edit.\n");
#ifdef DEBUG_METHODS_ENABLED
Expand Down Expand Up @@ -1826,8 +1826,7 @@ bool Main::start() {
ERR_FAIL_COND_V(!_start_success, false);

bool hasicon = false;
String doc_tool;
List<String> removal_docs;
String doc_tool_path;
String positional_arg;
String game_path;
String script;
Expand Down Expand Up @@ -1881,9 +1880,11 @@ bool Main::start() {
script = args[i + 1];
#ifdef TOOLS_ENABLED
} else if (args[i] == "--doctool") {
doc_tool = args[i + 1];
for (int j = i + 2; j < args.size(); j++) {
removal_docs.push_back(args[j]);
doc_tool_path = args[i + 1];
akien-mga marked this conversation as resolved.
Show resolved Hide resolved
if (doc_tool_path.begins_with("-")) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the reference, this is something that could be done further up after else if (i < (args.size() - 1)) { for all "paired" parameters, but it's more risky so I'm keeping it localized.

The proper fix anyway is to scrap all this and redo the argument parsing with a proper parser (#44594).

// Assuming other command line arg, so default to cwd.
doc_tool_path = ".";
parsed_pair = false;
}
} else if (args[i] == "--export") {
editor = true; //needs editor
Expand All @@ -1904,16 +1905,19 @@ bool Main::start() {
if (parsed_pair) {
i++;
}
} else if (args[i] == "--doctool") {
// Handle case where no path is given to --doctool.
doc_tool_path = ".";
}
}

#ifdef TOOLS_ENABLED
if (doc_tool != "") {
if (doc_tool_path != "") {
Engine::get_singleton()->set_editor_hint(
true); // Needed to instance editor-only classes for their default values

{
DirAccessRef da = DirAccess::open(doc_tool);
DirAccessRef da = DirAccess::open(doc_tool_path);
ERR_FAIL_COND_V_MSG(!da, false, "Argument supplied to --doctool must be a valid directory path.");
}

Expand Down Expand Up @@ -1943,7 +1947,7 @@ bool Main::start() {
// Custom modules are always located by absolute path.
String path = _doc_data_class_paths[i].path;
if (path.is_rel_path()) {
path = doc_tool.plus_file(path);
path = doc_tool_path.plus_file(path);
}
String name = _doc_data_class_paths[i].name;
doc_data_classes[name] = path;
Expand All @@ -1960,7 +1964,7 @@ bool Main::start() {
}
}

String index_path = doc_tool.plus_file("doc/classes");
String index_path = doc_tool_path.plus_file("doc/classes");
// Create the main documentation directory if it doesn't exist
DirAccess *da = DirAccess::create_for_path(index_path);
da->make_dir_recursive(index_path);
Expand Down