| 99 | } |
| 100 | |
| 101 | void* SCookContextImpl::_Import() |
| 102 | { |
| 103 | SkrZoneScoped; |
| 104 | //-----load importer |
| 105 | simdjson::ondemand::parser parser; |
| 106 | auto doc = parser.iterate(record->meta); |
| 107 | auto importerJson = doc["importer"]; // import from asset |
| 108 | if (importerJson.error() == simdjson::SUCCESS) |
| 109 | { |
| 110 | skr_guid_t importerTypeGuid = {}; |
| 111 | importer = GetImporterRegistry()->LoadImporter(record, std::move(importerJson).value_unsafe(), &importerTypeGuid); |
| 112 | if(!importer) |
| 113 | { |
| 114 | SKR_LOG_ERROR(u8"[SCookContext::Cook] importer failed to load, asset: %s", record->path.u8string().c_str()); |
| 115 | return nullptr; |
| 116 | } |
| 117 | importerVersion = importer->Version(); |
| 118 | importerType = importerTypeGuid; |
| 119 | //-----import raw data |
| 120 | SkrZoneScopedN("Importer.Import"); |
| 121 | skr::String name_holder = u8"unknown"; |
| 122 | if (auto type = skr::rttr::get_type_from_guid(importerType)) |
| 123 | { |
| 124 | name_holder = type->name().u8_str(); |
| 125 | } |
| 126 | else |
| 127 | { |
| 128 | name_holder = skr::format(u8"{}", importerType); |
| 129 | SKR_LOG_WARN(u8"[SCookContext::Cook] importer without RTTI INFO detected: %s", name_holder.c_str()); |
| 130 | } |
| 131 | [[maybe_unused]] const char* type_name = name_holder.c_str(); |
| 132 | ZoneName(type_name, strlen(type_name)); |
| 133 | auto rawData = importer->Import(ioService, this); |
| 134 | SKR_LOG_INFO(u8"[SCookContext::Cook] asset imported for asset: %s", record->path.u8string().c_str()); |
| 135 | return rawData; |
| 136 | } |
| 137 | // auto parentJson = doc["parent"]; // derived from resource |
| 138 | // if (parentJson.error() == simdjson::SUCCESS) |
| 139 | // { |
| 140 | // skr_guid_t parentGuid; |
| 141 | // skr::json::Read(std::move(parentJson).value_unsafe(), parentGuid); |
| 142 | // return AddStaticDependency(parentGuid); |
| 143 | // } |
| 144 | return nullptr; |
| 145 | } |
| 146 | |
| 147 | skr::filesystem::path SCookContextImpl::GetOutputPath() const |
| 148 | { |
nothing calls this directly
no test coverage detected