editor: prefer bundled mono runtime discovery

This commit is contained in:
2026-04-13 00:27:11 +08:00
parent 2326857a43
commit 6f876678f5
2 changed files with 13 additions and 4 deletions

View File

@@ -32,11 +32,15 @@ if(NOT TARGET XCEngine)
option(XCENGINE_ENABLE_MONO_SCRIPTING "Build the Mono-based C# scripting runtime" ON) option(XCENGINE_ENABLE_MONO_SCRIPTING "Build the Mono-based C# scripting runtime" ON)
if(NOT DEFINED XCENGINE_MONO_ROOT_DIR OR XCENGINE_MONO_ROOT_DIR STREQUAL "") if(NOT DEFINED XCENGINE_MONO_ROOT_DIR OR XCENGINE_MONO_ROOT_DIR STREQUAL "")
file(GLOB XCENGINE_MONO_ROOT_DIR_CANDIDATES "${XCENGINE_ROOT_DIR}/*/Fermion/Fermion/external/mono") if(EXISTS "${XCENGINE_ROOT_DIR}/engine/third_party/mono/binary/mscorlib.dll")
if(XCENGINE_MONO_ROOT_DIR_CANDIDATES) set(XCENGINE_MONO_ROOT_DIR_DEFAULT "${XCENGINE_ROOT_DIR}/engine/third_party/mono")
list(GET XCENGINE_MONO_ROOT_DIR_CANDIDATES 0 XCENGINE_MONO_ROOT_DIR_DEFAULT)
else() else()
set(XCENGINE_MONO_ROOT_DIR_DEFAULT "${XCENGINE_ROOT_DIR}/managed/mono") file(GLOB XCENGINE_MONO_ROOT_DIR_CANDIDATES "${XCENGINE_ROOT_DIR}/*/Fermion/Fermion/external/mono")
if(XCENGINE_MONO_ROOT_DIR_CANDIDATES)
list(GET XCENGINE_MONO_ROOT_DIR_CANDIDATES 0 XCENGINE_MONO_ROOT_DIR_DEFAULT)
else()
set(XCENGINE_MONO_ROOT_DIR_DEFAULT "${XCENGINE_ROOT_DIR}/managed/mono")
endif()
endif() endif()
set( set(

View File

@@ -48,6 +48,11 @@ std::filesystem::path FindBundledMonoRootDirectory(const std::filesystem::path&
return {}; return {};
} }
const std::filesystem::path projectBundledMonoRoot = repositoryRoot / "engine" / "third_party" / "mono";
if (std::filesystem::exists(projectBundledMonoRoot / "binary" / "mscorlib.dll", ec)) {
return projectBundledMonoRoot.lexically_normal();
}
for (std::filesystem::directory_iterator it(repositoryRoot, ec), end; it != end && !ec; it.increment(ec)) { for (std::filesystem::directory_iterator it(repositoryRoot, ec), end; it != end && !ec; it.increment(ec)) {
if (ec || !it->is_directory(ec)) { if (ec || !it->is_directory(ec)) {
continue; continue;