refactor(srp): unify engine managed assembly discovery
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -58,26 +59,11 @@ std::filesystem::path ResolveProjectGameScriptsDllPath() {
|
||||
return ResolveProjectManagedOutputDirectory() / "GameScripts.dll";
|
||||
}
|
||||
|
||||
std::filesystem::path ResolveProjectRenderPipelinesUniversalDllPath() {
|
||||
constexpr const char* configuredPath =
|
||||
XCENGINE_TEST_PROJECT_RENDER_PIPELINES_UNIVERSAL_DLL;
|
||||
if (configuredPath[0] != '\0') {
|
||||
return std::filesystem::path(configuredPath);
|
||||
}
|
||||
|
||||
return ResolveProjectManagedOutputDirectory() /
|
||||
"XCEngine.RenderPipelines.Universal.dll";
|
||||
}
|
||||
|
||||
MonoScriptRuntime::Settings CreateProjectMonoSettings() {
|
||||
MonoScriptRuntime::Settings settings;
|
||||
settings.assemblyDirectory = ResolveProjectManagedOutputDirectory();
|
||||
settings.corlibDirectory = settings.assemblyDirectory;
|
||||
settings.coreAssemblyPath = ResolveProjectScriptCoreDllPath();
|
||||
settings.engineAssemblies.push_back(
|
||||
MonoScriptRuntime::ManagedAssemblyDescriptor{
|
||||
"XCEngine.RenderPipelines.Universal",
|
||||
ResolveProjectRenderPipelinesUniversalDllPath()});
|
||||
settings.appAssemblyPath = ResolveProjectGameScriptsDllPath();
|
||||
return settings;
|
||||
}
|
||||
@@ -86,12 +72,24 @@ class ProjectScriptAssemblyTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
ASSERT_TRUE(std::filesystem::exists(ResolveProjectScriptCoreDllPath()));
|
||||
ASSERT_TRUE(
|
||||
std::filesystem::exists(
|
||||
ResolveProjectRenderPipelinesUniversalDllPath()));
|
||||
ASSERT_TRUE(std::filesystem::exists(ResolveProjectGameScriptsDllPath()));
|
||||
|
||||
runtime = std::make_unique<MonoScriptRuntime>(CreateProjectMonoSettings());
|
||||
MonoScriptRuntime::Settings settings =
|
||||
CreateProjectMonoSettings();
|
||||
std::string engineAssemblyError;
|
||||
ASSERT_TRUE(
|
||||
MonoScriptRuntime::DiscoverEngineAssemblies(
|
||||
settings,
|
||||
&engineAssemblyError))
|
||||
<< engineAssemblyError;
|
||||
ASSERT_FALSE(settings.engineAssemblies.empty());
|
||||
for (const MonoScriptRuntime::ManagedAssemblyDescriptor& assembly :
|
||||
settings.engineAssemblies) {
|
||||
ASSERT_TRUE(std::filesystem::exists(assembly.path))
|
||||
<< assembly.path.string();
|
||||
}
|
||||
|
||||
runtime = std::make_unique<MonoScriptRuntime>(std::move(settings));
|
||||
ASSERT_TRUE(runtime->Initialize()) << runtime->GetLastError();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user