refactor(srp): split universal managed pipeline assembly
This commit is contained in:
@@ -49,17 +49,34 @@ void Application::InitializeScriptingRuntime(const std::string& projectPath) {
|
||||
settings.assemblyDirectory = assemblyDirectory;
|
||||
settings.corlibDirectory = assemblyDirectory;
|
||||
settings.coreAssemblyPath = assemblyDirectory / L"XCEngine.ScriptCore.dll";
|
||||
settings.engineAssemblies.push_back(
|
||||
::XCEngine::Scripting::MonoScriptRuntime::ManagedAssemblyDescriptor{
|
||||
"XCEngine.RenderPipelines.Universal",
|
||||
assemblyDirectory / L"XCEngine.RenderPipelines.Universal.dll"});
|
||||
settings.appAssemblyPath = assemblyDirectory / L"GameScripts.dll";
|
||||
|
||||
std::error_code ec;
|
||||
const bool hasCoreAssembly = fs::exists(settings.coreAssemblyPath, ec);
|
||||
ec.clear();
|
||||
bool hasEngineAssemblies = true;
|
||||
for (const auto& assembly : settings.engineAssemblies) {
|
||||
const bool hasAssembly = fs::exists(assembly.path, ec);
|
||||
ec.clear();
|
||||
hasEngineAssemblies = hasEngineAssemblies && hasAssembly;
|
||||
}
|
||||
const bool hasAppAssembly = fs::exists(settings.appAssemblyPath, ec);
|
||||
ec.clear();
|
||||
const bool hasCorlibAssembly = fs::exists(assemblyDirectory / L"mscorlib.dll", ec);
|
||||
m_scriptRuntimeStatus.assembliesFound = hasCoreAssembly && hasAppAssembly && hasCorlibAssembly;
|
||||
m_scriptRuntimeStatus.assembliesFound =
|
||||
hasCoreAssembly &&
|
||||
hasEngineAssemblies &&
|
||||
hasAppAssembly &&
|
||||
hasCorlibAssembly;
|
||||
|
||||
if (!hasCoreAssembly || !hasAppAssembly || !hasCorlibAssembly) {
|
||||
if (!hasCoreAssembly ||
|
||||
!hasEngineAssemblies ||
|
||||
!hasAppAssembly ||
|
||||
!hasCorlibAssembly) {
|
||||
m_scriptRuntimeStatus.statusMessage =
|
||||
"Script assemblies were not found in " + Platform::WideToUtf8(assemblyDirectory.wstring()) +
|
||||
". Script class discovery is disabled until the managed assemblies are built.";
|
||||
|
||||
@@ -250,6 +250,8 @@ EditorScriptAssemblyBuildResult EditorScriptAssemblyBuilder::RebuildProjectAssem
|
||||
const fs::path outputDirectory = projectRoot / "Library" / "ScriptAssemblies";
|
||||
const fs::path generatedDirectory = outputDirectory / "Generated";
|
||||
const fs::path scriptCoreOutputPath = outputDirectory / "XCEngine.ScriptCore.dll";
|
||||
const fs::path renderPipelinesUniversalOutputPath =
|
||||
outputDirectory / "XCEngine.RenderPipelines.Universal.dll";
|
||||
const fs::path gameScriptsOutputPath = outputDirectory / "GameScripts.dll";
|
||||
const fs::path corlibOutputPath = outputDirectory / "mscorlib.dll";
|
||||
const fs::path monoCorlibSourcePath = monoRoot / "binary" / "mscorlib.dll";
|
||||
@@ -306,11 +308,33 @@ EditorScriptAssemblyBuildResult EditorScriptAssemblyBuilder::RebuildProjectAssem
|
||||
return BuildFailure("Mono corlib was not found: " + ScriptBuilderPathToUtf8(monoCorlibSourcePath));
|
||||
}
|
||||
|
||||
std::vector<fs::path> scriptCoreSources = CollectCSharpSourceFiles(scriptCoreSourceRoot);
|
||||
const std::vector<fs::path> allScriptCoreSources =
|
||||
CollectCSharpSourceFiles(scriptCoreSourceRoot);
|
||||
std::vector<fs::path> scriptCoreSources;
|
||||
std::vector<fs::path> renderPipelinesUniversalSources;
|
||||
scriptCoreSources.reserve(allScriptCoreSources.size());
|
||||
renderPipelinesUniversalSources.reserve(allScriptCoreSources.size());
|
||||
for (const fs::path& sourcePath : allScriptCoreSources) {
|
||||
const std::string relativePath =
|
||||
sourcePath.lexically_relative(scriptCoreSourceRoot)
|
||||
.generic_string();
|
||||
if (relativePath.rfind("Rendering/Renderer/", 0) == 0 ||
|
||||
relativePath.rfind("Rendering/FirstParty/", 0) == 0) {
|
||||
renderPipelinesUniversalSources.push_back(sourcePath);
|
||||
} else {
|
||||
scriptCoreSources.push_back(sourcePath);
|
||||
}
|
||||
}
|
||||
|
||||
if (scriptCoreSources.empty()) {
|
||||
return BuildFailure("No ScriptCore C# source files were found under: " +
|
||||
ScriptBuilderPathToUtf8(scriptCoreSourceRoot));
|
||||
}
|
||||
if (renderPipelinesUniversalSources.empty()) {
|
||||
return BuildFailure(
|
||||
"No RenderPipelines.Universal C# source files were found under: " +
|
||||
ScriptBuilderPathToUtf8(scriptCoreSourceRoot / "Rendering"));
|
||||
}
|
||||
|
||||
std::vector<fs::path> projectScriptSources = CollectCSharpSourceFiles(projectRoot / "Assets");
|
||||
std::string placeholderError;
|
||||
@@ -333,6 +357,22 @@ EditorScriptAssemblyBuildResult EditorScriptAssemblyBuilder::RebuildProjectAssem
|
||||
return BuildFailure("Failed to build XCEngine.ScriptCore.dll: " + compileError);
|
||||
}
|
||||
|
||||
std::vector<fs::path> renderPipelinesUniversalReferences =
|
||||
frameworkReferences;
|
||||
renderPipelinesUniversalReferences.push_back(scriptCoreOutputPath);
|
||||
if (!RunCSharpCompiler(
|
||||
dotnetExecutable,
|
||||
cscDllPath,
|
||||
projectRoot,
|
||||
renderPipelinesUniversalOutputPath,
|
||||
renderPipelinesUniversalReferences,
|
||||
renderPipelinesUniversalSources,
|
||||
compileError)) {
|
||||
return BuildFailure(
|
||||
"Failed to build XCEngine.RenderPipelines.Universal.dll: " +
|
||||
compileError);
|
||||
}
|
||||
|
||||
// Mono can keep the project-local corlib mapped for the lifetime of the process.
|
||||
// Once it exists in the output folder, reuse it across incremental rebuilds.
|
||||
ec.clear();
|
||||
@@ -350,6 +390,7 @@ EditorScriptAssemblyBuildResult EditorScriptAssemblyBuilder::RebuildProjectAssem
|
||||
|
||||
std::vector<fs::path> gameScriptReferences = frameworkReferences;
|
||||
gameScriptReferences.push_back(scriptCoreOutputPath);
|
||||
gameScriptReferences.push_back(renderPipelinesUniversalOutputPath);
|
||||
if (!RunCSharpCompiler(
|
||||
dotnetExecutable,
|
||||
cscDllPath,
|
||||
|
||||
Reference in New Issue
Block a user