internal void BuildAll() { var modList = new List <LocalMod>(); foreach (var modFolder in FindModSources()) { modList.Add(ReadBuildInfo(modFolder)); } //figure out which of the installed mods are required for building var installedMods = ModOrganizer.FindMods().Where(mod => !modList.Exists(m => m.Name == mod.Name)).ToList(); var requiredFromInstall = new HashSet <LocalMod>(); void Require(LocalMod mod, bool includeWeak) { foreach (var dep in mod.properties.RefNames(includeWeak)) { var depMod = installedMods.SingleOrDefault(m => m.Name == dep); if (depMod != null && requiredFromInstall.Add(depMod)) { Require(depMod, false); } } } foreach (var mod in modList) { Require(mod, true); } modList.AddRange(requiredFromInstall); //sort and version check List <BuildingMod> modsToBuild; try { ModOrganizer.EnsureDependenciesExist(modList, true); ModOrganizer.EnsureTargetVersionsMet(modList); var sortedModList = ModOrganizer.Sort(modList); modsToBuild = sortedModList.OfType <BuildingMod>().ToList(); } catch (ModSortingException e) { throw new BuildException(e.Message); } //build int num = 0; foreach (var mod in modsToBuild) { status.SetProgress(num++, modsToBuild.Count); Build(mod); } }
internal static bool BuildAll(string[] modFolders, IBuildStatus status) { var modList = new List <LoadingMod>(); foreach (var modFolder in modFolders) { var mod = ReadProperties(modFolder, status); if (mod == null) { return(false); } modList.Add(mod); } foreach (var modFile in FindMods()) { if (modList.Exists(m => m.Name == modFile.name)) { continue; } modList.Add(new LoadingMod(modFile, BuildProperties.ReadModFile(modFile))); } List <BuildingMod> modsToBuild; try { EnsureDependenciesExist(modList, true); EnsureTargetVersionsMet(modList); var sortedModList = Sort(modList); modsToBuild = sortedModList.OfType <BuildingMod>().ToList(); } catch (ModSortingException e) { ErrorLogger.LogDependencyError(e.Message); return(false); } int num = 0; foreach (var mod in modsToBuild) { status.SetProgress(num++, modsToBuild.Count); if (!Build(mod, status)) { return(false); } } return(true); }
internal static bool BuildAll(string[] modFolders, IBuildStatus status) { var modList = new List<LoadingMod>(); foreach (var modFolder in modFolders) { var mod = ReadProperties(modFolder, status); if (mod == null) return false; modList.Add(mod); } foreach (var modFile in FindMods()) { if (modList.Exists(m => m.Name == modFile.name)) continue; modList.Add(new LoadingMod(modFile, BuildProperties.ReadModFile(modFile))); } List<BuildingMod> modsToBuild; try { var sortedModList = TopoSort(modList, true); modsToBuild = sortedModList.OfType<BuildingMod>().ToList(); } catch (ModSortingException e) { ErrorLogger.LogDependencyError(e.Message); return false; } int num = 0; foreach (var mod in modsToBuild) { status.SetProgress(num++, modsToBuild.Count); if (!Build(mod, status)) return false; } return true; }
internal static bool BuildAll(string[] modFolders, IBuildStatus status) { var modList = new List <LoadingMod>(); //read mod sources folder foreach (var modFolder in modFolders) { var mod = ReadProperties(modFolder, status); if (mod == null) { return(false); } modList.Add(mod); } //figure out which of the installed mods are required for building var installedMods = FindMods() .Where(mod => !modList.Exists(m => m.Name == mod.name)) .Select(mod => new LoadingMod(mod, BuildProperties.ReadModFile(mod))) .ToList(); var requiredFromInstall = new HashSet <LoadingMod>(); Action <LoadingMod> require = null; require = (mod) => { foreach (var dep in mod.properties.RefNames(true)) { var depMod = installedMods.SingleOrDefault(m => m.Name == dep); if (depMod != null && requiredFromInstall.Add(depMod)) { require(depMod); } } }; foreach (var mod in modList) { require(mod); } modList.AddRange(requiredFromInstall); //sort and version check List <BuildingMod> modsToBuild; try { EnsureDependenciesExist(modList, true); EnsureTargetVersionsMet(modList); var sortedModList = Sort(modList); modsToBuild = sortedModList.OfType <BuildingMod>().ToList(); } catch (ModSortingException e) { ErrorLogger.LogDependencyError(e.Message); return(false); } //build int num = 0; foreach (var mod in modsToBuild) { status.SetProgress(num++, modsToBuild.Count); if (!Build(mod, status)) { return(false); } } return(true); }
private static bool Build(BuildingMod mod, IBuildStatus status) { byte[] winDLL = null; byte[] monoDLL = null; byte[] winPDB = null; if (mod.properties.noCompile) { winDLL = monoDLL = ReadIfExists(Path.Combine(mod.path, "All.dll")); winPDB = ReadIfExists(Path.Combine(mod.path, "All.pdb")); if (winDLL == null) { winDLL = ReadIfExists(Path.Combine(mod.path, "Windows.dll")); monoDLL = ReadIfExists(Path.Combine(mod.path, "Mono.dll")); winPDB = ReadIfExists(Path.Combine(mod.path, "Windows.pdb")); } if (winDLL == null || monoDLL == null) { ErrorLogger.LogDllBuildError(mod.path); return(false); } } else { var refMods = FindReferencedMods(mod.properties); if (refMods == null) { return(false); } if (Program.LaunchParameters.ContainsKey("-eac")) { if (!windows) { ErrorLogger.LogBuildError("Edit and continue is only supported on windows"); return(false); } try { status.SetStatus("Loading pre-compiled Windows.dll with edit and continue support"); var winPath = Program.LaunchParameters["-eac"]; var pdbPath = Path.ChangeExtension(winPath, "pdb"); winDLL = File.ReadAllBytes(winPath); winPDB = File.ReadAllBytes(pdbPath); mod.properties.editAndContinue = true; } catch (Exception e) { ErrorLogger.LogBuildError("Failed to load pre-compiled edit and continue dll " + e); return(false); } } else { status.SetStatus(Language.GetTextValue("tModLoader.MSCompilingWindows", mod)); status.SetProgress(0, 2); CompileMod(mod, refMods, true, ref winDLL, ref winPDB); } if (winDLL == null) { return(false); } status.SetStatus(Language.GetTextValue("tModLoader.MSCompilingMono", mod)); status.SetProgress(1, 2); CompileMod(mod, refMods, false, ref monoDLL, ref winPDB); //the pdb reference won't actually be written to if (monoDLL == null) { return(false); } } if (!VerifyName(mod.Name, winDLL) || !VerifyName(mod.Name, monoDLL)) { return(false); } status.SetStatus(Language.GetTextValue("tModLoader.MSBuilding") + mod + "..."); status.SetProgress(0, 1); mod.modFile.AddFile("Info", mod.properties.ToBytes()); if (Equal(winDLL, monoDLL)) { mod.modFile.AddFile("All.dll", winDLL); if (winPDB != null) { mod.modFile.AddFile("All.pdb", winPDB); } } else { mod.modFile.AddFile("Windows.dll", winDLL); mod.modFile.AddFile("Mono.dll", monoDLL); if (winPDB != null) { mod.modFile.AddFile("Windows.pdb", winPDB); } } foreach (var resource in Directory.GetFiles(mod.path, "*", SearchOption.AllDirectories)) { var relPath = resource.Substring(mod.path.Length + 1); if (mod.properties.ignoreFile(relPath) || relPath == "build.txt" || relPath == ".gitattributes" || relPath == ".gitignore" || relPath.StartsWith(".git" + Path.DirectorySeparatorChar) || relPath.StartsWith(".vs" + Path.DirectorySeparatorChar) || relPath.StartsWith("bin" + Path.DirectorySeparatorChar) || relPath.StartsWith("obj" + Path.DirectorySeparatorChar) || !mod.properties.includeSource && sourceExtensions.Contains(Path.GetExtension(resource)) || Path.GetFileName(resource) == "Thumbs.db") { continue; } mod.modFile.AddFile(relPath, File.ReadAllBytes(resource)); } WAVCacheIO.ClearCache(mod.Name); mod.modFile.Save(); EnableMod(mod.modFile); ActivateExceptionReporting(); ModLoader.isModder = true; return(true); }
private static bool Build(BuildingMod mod, IBuildStatus status) { byte[] winDLL = null; byte[] monoDLL = null; byte[] winPDB = null; if (mod.properties.noCompile) { winDLL = monoDLL = ReadIfExists(Path.Combine(mod.path, "All.dll")); winPDB = ReadIfExists(Path.Combine(mod.path, "All.pdb")); if (winDLL == null) { winDLL = ReadIfExists(Path.Combine(mod.path, "Windows.dll")); monoDLL = ReadIfExists(Path.Combine(mod.path, "Mono.dll")); winPDB = ReadIfExists(Path.Combine(mod.path, "Windows.pdb")); } if (winDLL == null || monoDLL == null) { ErrorLogger.LogDllBuildError(mod.path); return false; } } else { var refMods = FindReferencedMods(mod.properties); if (refMods == null) return false; if (Program.LaunchParameters.ContainsKey("-eac")) { if (!windows) { ErrorLogger.LogBuildError("Edit and continue is only supported on windows"); return false; } try { status.SetStatus("Loading pre-compiled Windows.dll with edit and continue support"); var winPath = Program.LaunchParameters["-eac"]; var pdbPath = Path.ChangeExtension(winPath, "pdb"); winDLL = File.ReadAllBytes(winPath); winPDB = File.ReadAllBytes(pdbPath); mod.properties.editAndContinue = true; } catch (Exception e) { ErrorLogger.LogBuildError("Failed to load pre-compiled edit and continue dll "+e); return false; } } else { status.SetStatus("Compiling " + mod.Name + " for Windows..."); status.SetProgress(0, 2); CompileMod(mod, refMods, true, ref winDLL, ref winPDB); } status.SetStatus("Compiling " + mod.Name + " for Mono..."); status.SetProgress(1, 2); CompileMod(mod, refMods, false, ref monoDLL, ref winPDB);//the pdb reference won't actually be written to if (winDLL == null || monoDLL == null) return false; } if (!VerifyName(mod.Name, winDLL) || !VerifyName(mod.Name, monoDLL)) return false; status.SetStatus("Building "+mod.Name+"..."); status.SetProgress(0, 1); mod.modFile.AddFile("Info", mod.properties.ToBytes()); if (Equal(winDLL, monoDLL)) { mod.modFile.AddFile("All.dll", winDLL); if (winPDB != null) mod.modFile.AddFile("All.pdb", winPDB); } else { mod.modFile.AddFile("Windows.dll", winDLL); mod.modFile.AddFile("Mono.dll", monoDLL); if (winPDB != null) mod.modFile.AddFile("Windows.pdb", winPDB); } foreach (var resource in Directory.GetFiles(mod.path, "*", SearchOption.AllDirectories)) { var relPath = resource.Substring(mod.path.Length + 1); if (mod.properties.ignoreFile(relPath) || relPath == "build.txt" || !mod.properties.includeSource && Path.GetExtension(resource) == ".cs" || Path.GetFileName(resource) == "Thumbs.db") continue; mod.modFile.AddFile(relPath, File.ReadAllBytes(resource)); } WAVCacheIO.ClearCache(mod.Name); mod.modFile.Save(); EnableMod(mod.modFile); return true; }
internal bool BuildAll(string[] modFolders) { var modList = new List <LocalMod>(); //read mod sources folder foreach (var modFolder in modFolders) { var mod = ReadProperties(modFolder); if (mod == null) { return(false); } modList.Add(mod); } //figure out which of the installed mods are required for building var installedMods = ModOrganizer.FindMods().Where(mod => !modList.Exists(m => m.Name == mod.Name)).ToList(); var requiredFromInstall = new HashSet <LocalMod>(); void Require(LocalMod mod) { foreach (var dep in mod.properties.RefNames(true)) { var depMod = installedMods.SingleOrDefault(m => m.Name == dep); if (depMod != null && requiredFromInstall.Add(depMod)) { Require(depMod); } } } foreach (var mod in modList) { Require(mod); } modList.AddRange(requiredFromInstall); //sort and version check List <BuildingMod> modsToBuild; try { ModOrganizer.EnsureDependenciesExist(modList, true); ModOrganizer.EnsureTargetVersionsMet(modList); var sortedModList = ModOrganizer.Sort(modList); modsToBuild = sortedModList.OfType <BuildingMod>().ToList(); } catch (ModSortingException e) { status.LogError(null, e.Message); return(false); } //build int num = 0; foreach (var mod in modsToBuild) { status.SetProgress(num++, modsToBuild.Count); if (!Build(mod)) { return(false); } } return(true); }