Make build profile project detection also set build options
This commit is contained in:
parent
e45cc68092
commit
454e4f817c
28 changed files with 786 additions and 82 deletions
|
|
@ -36,6 +36,7 @@
|
|||
#include "core/io/missing_resource.h"
|
||||
#include "core/object/script_language.h"
|
||||
#include "core/version.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
|
||||
//#define print_bl(m_what) print_line(m_what)
|
||||
#define print_bl(m_what) (void)(m_what)
|
||||
|
|
@ -937,11 +938,10 @@ void ResourceLoaderBinary::get_classes_used(Ref<FileAccess> p_f, HashSet<StringN
|
|||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < internal_resources.size(); i++) {
|
||||
p_f->seek(internal_resources[i].offset);
|
||||
for (const IntResource &res : internal_resources) {
|
||||
p_f->seek(res.offset);
|
||||
String t = get_unicode_string();
|
||||
ERR_FAIL_COND(p_f->get_error() != OK);
|
||||
if (t != String()) {
|
||||
if (!p_f->get_error() && t != String() && ClassDB::class_exists(t)) {
|
||||
p_classes->insert(t);
|
||||
}
|
||||
}
|
||||
|
|
@ -1518,6 +1518,37 @@ void ResourceFormatLoaderBinary::get_classes_used(const String &p_path, HashSet<
|
|||
loader.local_path = ProjectSettings::get_singleton()->localize_path(p_path);
|
||||
loader.res_path = loader.local_path;
|
||||
loader.get_classes_used(f, r_classes);
|
||||
|
||||
// Fetch the nodes inside scene files.
|
||||
if (loader.type == "PackedScene") {
|
||||
ERR_FAIL_COND(loader.load() != OK);
|
||||
|
||||
Ref<SceneState> state = Ref<PackedScene>(loader.get_resource())->get_state();
|
||||
for (int i = 0; i < state->get_node_count(); i++) {
|
||||
const StringName node_name = state->get_node_type(i);
|
||||
if (ClassDB::class_exists(node_name)) {
|
||||
r_classes->insert(node_name);
|
||||
}
|
||||
|
||||
// Fetch the values of properties in the node.
|
||||
for (int j = 0; j < state->get_node_property_count(i); j++) {
|
||||
const Variant var = state->get_node_property_value(i, j);
|
||||
if (var.get_type() != Variant::OBJECT) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const Object *obj = var.get_validated_object();
|
||||
if (obj == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const StringName obj_name = obj->get_class_name();
|
||||
if (ClassDB::class_exists(obj_name)) {
|
||||
r_classes->insert(obj_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String ResourceFormatLoaderBinary::get_resource_type(const String &p_path) const {
|
||||
|
|
|
|||
|
|
@ -434,6 +434,7 @@ Variant ResourceFormatImporter::get_resource_metadata(const String &p_path) cons
|
|||
|
||||
return pat.metadata;
|
||||
}
|
||||
|
||||
void ResourceFormatImporter::get_classes_used(const String &p_path, HashSet<StringName> *r_classes) {
|
||||
PathAndType pat;
|
||||
Error err = _get_path_and_type(p_path, pat, false);
|
||||
|
|
@ -456,6 +457,18 @@ void ResourceFormatImporter::get_dependencies(const String &p_path, List<String>
|
|||
ResourceLoader::get_dependencies(pat.path, p_dependencies, p_add_types);
|
||||
}
|
||||
|
||||
void ResourceFormatImporter::get_build_dependencies(const String &p_path, HashSet<String> *r_dependencies) {
|
||||
if (!exists(p_path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Ref<ResourceImporter>> valid_importers;
|
||||
get_importers_for_file(p_path, &valid_importers);
|
||||
for (Ref<ResourceImporter> importer : valid_importers) {
|
||||
importer->get_build_dependencies(p_path, r_dependencies);
|
||||
}
|
||||
}
|
||||
|
||||
Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_name(const String &p_name) const {
|
||||
for (int i = 0; i < importers.size(); i++) {
|
||||
if (importers[i]->get_importer_name() == p_name) {
|
||||
|
|
@ -555,9 +568,21 @@ ResourceFormatImporter::ResourceFormatImporter() {
|
|||
|
||||
//////////////
|
||||
|
||||
void ResourceImporter::get_build_dependencies(const String &p_path, HashSet<String> *r_dependencies) {
|
||||
Vector<String> ret;
|
||||
if (GDVIRTUAL_CALL(_get_build_dependencies, p_path, ret)) {
|
||||
for (int i = 0; i < ret.size(); i++) {
|
||||
r_dependencies->insert(ret[i]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void ResourceImporter::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(IMPORT_ORDER_DEFAULT);
|
||||
BIND_ENUM_CONSTANT(IMPORT_ORDER_SCENE);
|
||||
|
||||
GDVIRTUAL_BIND(_get_build_dependencies, "path");
|
||||
}
|
||||
|
||||
/////
|
||||
|
|
|
|||
|
|
@ -78,6 +78,8 @@ public:
|
|||
virtual void get_classes_used(const String &p_path, HashSet<StringName> *r_classes) override;
|
||||
virtual bool exists(const String &p_path) const override;
|
||||
|
||||
void get_build_dependencies(const String &p_path, HashSet<String> *r_dependencies);
|
||||
|
||||
virtual int get_import_order(const String &p_path) const override;
|
||||
|
||||
Error get_import_order_threads_and_importer(const String &p_path, int &r_order, bool &r_can_threads, String &r_importer) const;
|
||||
|
|
@ -106,6 +108,8 @@ class ResourceImporter : public RefCounted {
|
|||
GDCLASS(ResourceImporter, RefCounted);
|
||||
|
||||
protected:
|
||||
GDVIRTUAL1RC(Vector<String>, _get_build_dependencies, String)
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
|
|
@ -155,6 +159,8 @@ public:
|
|||
virtual Error import_group_file(const String &p_group_file, const HashMap<String, HashMap<StringName, Variant>> &p_source_file_options, const HashMap<String, String> &p_base_paths) { return ERR_UNAVAILABLE; }
|
||||
virtual bool are_import_settings_valid(const String &p_path, const Dictionary &p_meta) const { return true; }
|
||||
virtual String get_import_settings_string() const { return String(); }
|
||||
|
||||
virtual void get_build_dependencies(const String &p_path, HashSet<String> *r_build_dependencies);
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(ResourceImporter::ImportOrder);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue