static void OnCompilationFinished(string assemblyPath, CompilerMessage[] messages) { // Do nothing if there were compile errors on the target if (CompilerMessagesContainError(messages)) { Debug.Log("Weaver: stop because compile errors on target"); return; } // Should not run on the editor only assemblies if (assemblyPath.Contains("-Editor") || assemblyPath.Contains(".Editor")) { return; } // don't weave mirror files string assemblyName = Path.GetFileNameWithoutExtension(assemblyPath); if (assemblyName == MirrorRuntimeAssemblyName || assemblyName == MirrorWeaverAssemblyName || assemblyName == "Zenject") { return; } UnityAssembly assembly = CompilationPipeline.GetAssemblies().FirstOrDefault(ass => ass.outputPath == assemblyPath); if (assembly == null) { // no assembly found, this can happen if you use the AssemblyBuilder // happens with our weaver tests. // create an assembly object manually assembly = CreateUnityAssembly(assemblyPath); } // don't weave if this does not depend on mirror if (!assembly.allReferences.Any(path => Path.GetFileNameWithoutExtension(path) == MirrorRuntimeAssemblyName)) { return; } Log.WarningMethod = HandleWarning; Log.ErrorMethod = HandleError; if (!Weaver.WeaveAssembly(assembly)) { // Set false...will be checked in \Editor\EnterPlayModeSettingsCheck.CheckSuccessfulWeave() SessionState.SetBool("MIRROR_WEAVE_SUCCESS", false); if (UnityLogEnabled) { Debug.LogError("Weaving failed for: " + assemblyPath); } } }
/* * static bool CompilerMessagesContainError(CompilerMessage[] messages) * { * return messages.Any(msg => msg.type == CompilerMessageType.Error); * } */ static void OnCompilationFinished(string assemblyPath) { // Do nothing if there were compile errors on the target /* * if (CompilerMessagesContainError(messages)) * { * Debug.Log("Weaver: stop because compile errors on target"); * return; * } */ // Should not run on the editor only assemblies if (assemblyPath.Contains("-Editor") || assemblyPath.Contains(".Editor")) { return; } // don't weave mirror files string assemblyName = Path.GetFileNameWithoutExtension(assemblyPath); if (assemblyName == MirrorRuntimeAssemblyName || assemblyName == MirrorWeaverAssemblyName) { return; } // find Mirror.dll string mirrorRuntimeDll = FindMirrorRuntime(); if (string.IsNullOrEmpty(mirrorRuntimeDll)) { Console.WriteLine("Failed to find Mirror runtime assembly"); return; } if (!File.Exists(mirrorRuntimeDll)) { // this is normal, it happens with any assembly that is built before mirror // such as unity packages or your own assemblies // those don't need to be weaved // if any assembly depends on mirror, then it will be built after return; } // find UnityEngine.CoreModule.dll string unityEngineCoreModuleDLL = UnityEditorInternal.InternalEditorUtility.GetEngineCoreModuleAssemblyPath(); if (string.IsNullOrEmpty(unityEngineCoreModuleDLL)) { Console.WriteLine("Failed to find UnityEngine assembly"); return; } HashSet <string> dependencyPaths = GetDependecyPaths(assemblyPath); dependencyPaths.Add(Path.GetDirectoryName(mirrorRuntimeDll)); dependencyPaths.Add(Path.GetDirectoryName(unityEngineCoreModuleDLL)); Log.WarningMethod = HandleWarning; Log.ErrorMethod = HandleError; if (!Weaver.WeaveAssembly(assemblyPath, dependencyPaths.ToArray())) { // Set false...will be checked in \Editor\EnterPlayModeSettingsCheck.CheckSuccessfulWeave() //SessionState.SetBool("MIRROR_WEAVE_SUCCESS", false); if (UnityLogEnabled) { Console.WriteLine("Weaving failed for: " + assemblyPath); } } }