1
Fork 0
mirror of https://github.com/Steffo99/better-tee.git synced 2024-11-27 00:54:20 +00:00
better-tee/Assets/Packages/Mirror/Editor/Weaver/Program.cs

63 lines
1.9 KiB
C#
Raw Normal View History

2019-09-15 22:28:36 +00:00
using System;
using System.Collections.Generic;
using System.IO;
namespace Mirror.Weaver
{
public static class Log
{
public static Action<string> WarningMethod;
public static Action<string> ErrorMethod;
public static void Warning(string msg)
{
WarningMethod("Mirror.Weaver warning: " + msg);
}
public static void Error(string msg)
{
ErrorMethod("Mirror.Weaver error: " + msg);
}
}
public static class Program
{
public static bool Process(string unityEngine, string netDLL, string outputDirectory, string[] assemblies, string[] extraAssemblyPaths, Action<string> printWarning, Action<string> printError)
{
CheckDLLPath(unityEngine);
CheckDLLPath(netDLL);
CheckOutputDirectory(outputDirectory);
CheckAssemblies(assemblies);
Log.WarningMethod = printWarning;
Log.ErrorMethod = printError;
return Weaver.WeaveAssemblies(assemblies, extraAssemblyPaths, outputDirectory, unityEngine, netDLL);
}
static void CheckDLLPath(string path)
{
if (!File.Exists(path))
throw new Exception("dll could not be located at " + path + "!");
}
static void CheckAssemblies(IEnumerable<string> assemblyPaths)
{
foreach (string assemblyPath in assemblyPaths)
CheckAssemblyPath(assemblyPath);
}
static void CheckAssemblyPath(string assemblyPath)
{
if (!File.Exists(assemblyPath))
throw new Exception("Assembly " + assemblyPath + " does not exist!");
}
static void CheckOutputDirectory(string outputDir)
{
if (outputDir != null && !Directory.Exists(outputDir))
{
Directory.CreateDirectory(outputDir);
}
}
}
}