Updated all CompilationSteps to use the new ACompiler

This commit is contained in:
erri120 2019-11-03 17:45:49 +01:00 committed by Timothy Baldridge
parent 917a9e296c
commit 8eb2f34faa
24 changed files with 72 additions and 72 deletions

View File

@ -14,9 +14,9 @@ namespace Wabbajack.Lib.CompilationSteps
private readonly List<ICompilationStep> _microstack;
private readonly List<ICompilationStep> _microstackWithInclude;
public DeconstructBSAs(Compiler compiler) : base(compiler)
public DeconstructBSAs(ACompiler compiler) : base(compiler)
{
_include_directly = _compiler.ModInis.Where(kv =>
_include_directly = compiler._mo2Compiler.ModInis.Where(kv =>
{
var general = kv.Value.General;
if (general.notes != null && general.notes.Contains(Consts.WABBAJACK_INCLUDE)) return true;
@ -28,16 +28,16 @@ namespace Wabbajack.Lib.CompilationSteps
_microstack = new List<ICompilationStep>
{
new DirectMatch(_compiler),
new IncludePatches(_compiler),
new DropAll(_compiler)
new DirectMatch(compiler),
new IncludePatches(compiler._mo2Compiler),
new DropAll(compiler)
};
_microstackWithInclude = new List<ICompilationStep>
{
new DirectMatch(_compiler),
new IncludePatches(_compiler),
new IncludeAll(_compiler)
new DirectMatch(compiler),
new IncludePatches(compiler._mo2Compiler),
new IncludeAll(compiler._mo2Compiler)
};
}
@ -61,7 +61,7 @@ namespace Wabbajack.Lib.CompilationSteps
var id = Guid.NewGuid().ToString();
var matches = source_files.PMap(e => Compiler.RunStack(stack, new RawSourceFile(e)
var matches = source_files.PMap(e => _compiler.RunStack(stack, new RawSourceFile(e)
{
Path = Path.Combine(Consts.BSACreationDir, id, e.Paths.Last())
}));
@ -71,7 +71,7 @@ namespace Wabbajack.Lib.CompilationSteps
{
if (match is IgnoredDirectly)
Utils.Error($"File required for BSA {source.Path} creation doesn't exist: {match.To}");
_compiler.ExtraFiles.Add(match);
_compiler._mo2Compiler.ExtraFiles.Add(match);
}
CreateBSA directive;
@ -92,7 +92,7 @@ namespace Wabbajack.Lib.CompilationSteps
[JsonObject("DeconstructBSAs")]
public class State : IState
{
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new DeconstructBSAs(compiler);
}

View File

@ -6,7 +6,7 @@ namespace Wabbajack.Lib.CompilationSteps
{
public class DirectMatch : ACompilationStep
{
public DirectMatch(Compiler compiler) : base(compiler)
public DirectMatch(ACompiler compiler) : base(compiler)
{
}
@ -34,7 +34,7 @@ namespace Wabbajack.Lib.CompilationSteps
[JsonObject("DirectMatch")]
public class State : IState
{
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new DirectMatch(compiler);
}

View File

@ -5,7 +5,7 @@ namespace Wabbajack.Lib.CompilationSteps
{
public class DropAll : ACompilationStep
{
public DropAll(Compiler compiler) : base(compiler)
public DropAll(ACompiler compiler) : base(compiler)
{
}
@ -25,7 +25,7 @@ namespace Wabbajack.Lib.CompilationSteps
[JsonObject("DropAll")]
public class State : IState
{
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new DropAll(compiler);
}

View File

@ -10,12 +10,12 @@ namespace Wabbajack.Lib.CompilationSteps
{
private readonly IEnumerable<string> _allEnabledMods;
public IgnoreDisabledMods(Compiler compiler) : base(compiler)
public IgnoreDisabledMods(ACompiler compiler) : base(compiler)
{
var alwaysEnabled = _compiler.ModInis.Where(f => IsAlwaysEnabled(f.Value)).Select(f => f.Key).ToHashSet();
var alwaysEnabled = compiler._mo2Compiler.ModInis.Where(f => IsAlwaysEnabled(f.Value)).Select(f => f.Key).ToHashSet();
_allEnabledMods = _compiler.SelectedProfiles
.SelectMany(p => File.ReadAllLines(Path.Combine(_compiler.MO2Folder, "profiles", p, "modlist.txt")))
_allEnabledMods = compiler._mo2Compiler.SelectedProfiles
.SelectMany(p => File.ReadAllLines(Path.Combine(compiler._mo2Compiler.MO2Folder, "profiles", p, "modlist.txt")))
.Where(line => line.StartsWith("+") || line.EndsWith("_separator"))
.Select(line => line.Substring(1))
.Concat(alwaysEnabled)
@ -55,7 +55,7 @@ namespace Wabbajack.Lib.CompilationSteps
[JsonObject("IgnoreDisabledMods")]
public class State : IState
{
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new IgnoreDisabledMods(compiler);
}

View File

@ -7,7 +7,7 @@ namespace Wabbajack.Lib.CompilationSteps
private readonly string _postfix;
private readonly string _reason;
public IgnoreEndsWith(Compiler compiler, string postfix) : base(compiler)
public IgnoreEndsWith(ACompiler compiler, string postfix) : base(compiler)
{
_postfix = postfix;
_reason = $"Ignored because path ends with {postfix}";
@ -40,7 +40,7 @@ namespace Wabbajack.Lib.CompilationSteps
public string Postfix { get; set; }
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new IgnoreEndsWith(compiler, Postfix);
}

View File

@ -7,7 +7,7 @@ namespace Wabbajack.Lib.CompilationSteps
{
private readonly string _startDir;
public IgnoreGameFiles(Compiler compiler) : base(compiler)
public IgnoreGameFiles(ACompiler compiler) : base(compiler)
{
_startDir = Consts.GameFolderFilesDir + "\\";
}
@ -28,7 +28,7 @@ namespace Wabbajack.Lib.CompilationSteps
[JsonObject("IgnoreGameFiles")]
public class State : IState
{
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new IgnoreGameFiles(compiler);
}

View File

@ -7,7 +7,7 @@ namespace Wabbajack.Lib.CompilationSteps
private readonly string _pattern;
private readonly string _reason;
public IgnorePathContains(Compiler compiler, string pattern) : base(compiler)
public IgnorePathContains(ACompiler compiler, string pattern) : base(compiler)
{
_pattern = $"\\{pattern.Trim('\\')}\\";
_reason = $"Ignored because path contains {_pattern}";
@ -40,7 +40,7 @@ namespace Wabbajack.Lib.CompilationSteps
public string Pattern { get; set; }
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new IgnorePathContains(compiler, Pattern);
}

View File

@ -9,7 +9,7 @@ namespace Wabbajack.Lib.CompilationSteps
private readonly Regex _regex;
private readonly string _pattern;
public IgnoreRegex(Compiler compiler, string pattern) : base(compiler)
public IgnoreRegex(ACompiler compiler, string pattern) : base(compiler)
{
_pattern = pattern;
_reason = $"Ignored because path matches regex {pattern}";
@ -43,7 +43,7 @@ namespace Wabbajack.Lib.CompilationSteps
public string Pattern { get; set; }
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new IgnoreRegex(compiler, Pattern);
}

View File

@ -7,7 +7,7 @@ namespace Wabbajack.Lib.CompilationSteps
private readonly string _prefix;
private readonly string _reason;
public IgnoreStartsWith(Compiler compiler, string prefix) : base(compiler)
public IgnoreStartsWith(ACompiler compiler, string prefix) : base(compiler)
{
_prefix = prefix;
_reason = string.Format("Ignored because path starts with {0}", _prefix);
@ -44,7 +44,7 @@ namespace Wabbajack.Lib.CompilationSteps
public string Prefix { get; set; }
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new IgnoreStartsWith(compiler, Prefix);
}

View File

@ -9,7 +9,7 @@ namespace Wabbajack.Lib.CompilationSteps
{
private readonly HashSet<string> _cruftFiles;
public IgnoreWabbajackInstallCruft(Compiler compiler) : base(compiler)
public IgnoreWabbajackInstallCruft(ACompiler compiler) : base(compiler)
{
_cruftFiles = new HashSet<string>
{
@ -34,7 +34,7 @@ namespace Wabbajack.Lib.CompilationSteps
[JsonObject("IgnoreWabbajackInstallCruft")]
public class State : IState
{
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new IgnoreWabbajackInstallCruft(compiler);
}

View File

@ -5,7 +5,7 @@ namespace Wabbajack.Lib.CompilationSteps
{
public class IncludeAll : ACompilationStep
{
public IncludeAll(Compiler compiler) : base(compiler)
public IncludeAll(ACompiler compiler) : base(compiler)
{
}
@ -24,7 +24,7 @@ namespace Wabbajack.Lib.CompilationSteps
[JsonObject("IncludeAll")]
public class State : IState
{
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new IncludeAll(compiler);
}

View File

@ -6,7 +6,7 @@ namespace Wabbajack.Lib.CompilationSteps
{
public class IncludeAllConfigs : ACompilationStep
{
public IncludeAllConfigs(Compiler compiler) : base(compiler)
public IncludeAllConfigs(ACompiler compiler) : base(compiler)
{
}
@ -26,7 +26,7 @@ namespace Wabbajack.Lib.CompilationSteps
[JsonObject("IncludeAllConfigs")]
public class State : IState
{
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new IncludeAllConfigs(compiler);
}

View File

@ -5,7 +5,7 @@ namespace Wabbajack.Lib.CompilationSteps
{
public class IncludeDummyESPs : ACompilationStep
{
public IncludeDummyESPs(Compiler compiler) : base(compiler)
public IncludeDummyESPs(ACompiler compiler) : base(compiler)
{
}
@ -36,7 +36,7 @@ namespace Wabbajack.Lib.CompilationSteps
[JsonObject("IncludeDummyESPs")]
public class State : IState
{
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new IncludeDummyESPs(compiler);
}

View File

@ -8,7 +8,7 @@ namespace Wabbajack.Lib.CompilationSteps
{
private readonly string _prefix;
public IncludeLootFiles(Compiler compiler) : base(compiler)
public IncludeLootFiles(ACompiler compiler) : base(compiler)
{
_prefix = Consts.LOOTFolderFilesDir + "\\";
}
@ -29,7 +29,7 @@ namespace Wabbajack.Lib.CompilationSteps
[JsonObject("IncludeLootFiles")]
public class State : IState
{
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new IncludeLootFiles(compiler);
}

View File

@ -5,7 +5,7 @@ namespace Wabbajack.Lib.CompilationSteps
{
public class IncludeModIniData : ACompilationStep
{
public IncludeModIniData(Compiler compiler) : base(compiler)
public IncludeModIniData(ACompiler compiler) : base(compiler)
{
}
@ -25,7 +25,7 @@ namespace Wabbajack.Lib.CompilationSteps
[JsonObject("IncludeModIniData")]
public class State : IState
{
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new IncludeModIniData(compiler);
}

View File

@ -9,9 +9,9 @@ namespace Wabbajack.Lib.CompilationSteps
{
private readonly IEnumerable<string> _profiles;
public IgnoreOtherProfiles(Compiler compiler) : base(compiler)
public IgnoreOtherProfiles(ACompiler compiler) : base(compiler)
{
_profiles = _compiler.SelectedProfiles
_profiles = compiler._mo2Compiler.SelectedProfiles
.Select(p => Path.Combine("profiles", p) + "\\")
.ToList();
}
@ -33,7 +33,7 @@ namespace Wabbajack.Lib.CompilationSteps
[JsonObject("IgnoreOtherProfiles")]
public class State : IState
{
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new IgnoreOtherProfiles(compiler);
}

View File

@ -11,7 +11,7 @@ namespace Wabbajack.Lib.CompilationSteps
{
private readonly Dictionary<string, IGrouping<string, VirtualFile>> _indexed;
public IncludePatches(Compiler compiler) : base(compiler)
public IncludePatches(ACompiler compiler) : base(compiler)
{
_indexed = _compiler.IndexedFiles.Values
.SelectMany(f => f)
@ -47,7 +47,7 @@ namespace Wabbajack.Lib.CompilationSteps
[JsonObject("IncludePatches")]
public class State : IState
{
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new IncludePatches(compiler);
}

View File

@ -7,7 +7,7 @@ namespace Wabbajack.Lib.CompilationSteps
{
public class IncludePropertyFiles : ACompilationStep
{
public IncludePropertyFiles(Compiler compiler) : base(compiler)
public IncludePropertyFiles(ACompiler compiler) : base(compiler)
{
}
@ -15,23 +15,23 @@ namespace Wabbajack.Lib.CompilationSteps
{
var files = new HashSet<string>
{
_compiler.ModListImage, _compiler.ModListReadme
_compiler._mo2Compiler.ModListImage, _compiler._mo2Compiler.ModListReadme
};
if (!files.Any(f => source.AbsolutePath.Equals(f))) return null;
if (!File.Exists(source.AbsolutePath)) return null;
var isBanner = source.AbsolutePath == _compiler.ModListImage;
var isBanner = source.AbsolutePath == _compiler._mo2Compiler.ModListImage;
//var isReadme = source.AbsolutePath == ModListReadme;
var result = source.EvolveTo<PropertyFile>();
result.SourceDataID = _compiler.IncludeFile(File.ReadAllBytes(source.AbsolutePath));
if (isBanner)
{
result.Type = PropertyType.Banner;
_compiler.ModListImage = result.SourceDataID;
_compiler._mo2Compiler.ModListImage = result.SourceDataID;
}
else
{
result.Type = PropertyType.Readme;
_compiler.ModListReadme = result.SourceDataID;
_compiler._mo2Compiler.ModListReadme = result.SourceDataID;
}
return result;
@ -45,7 +45,7 @@ namespace Wabbajack.Lib.CompilationSteps
[JsonObject("IncludePropertyFiles")]
public class State : IState
{
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new IncludePropertyFiles(compiler);
}

View File

@ -9,7 +9,7 @@ namespace Wabbajack.Lib.CompilationSteps
private readonly string _pattern;
private readonly Regex _regex;
public IncludeRegex(Compiler compiler, string pattern) : base(compiler)
public IncludeRegex(ACompiler compiler, string pattern) : base(compiler)
{
_pattern = pattern;
_regex = new Regex(pattern);
@ -43,7 +43,7 @@ namespace Wabbajack.Lib.CompilationSteps
public string Pattern { get; set; }
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new IncludeRegex(compiler, Pattern);
}

View File

@ -7,7 +7,7 @@ namespace Wabbajack.Lib.CompilationSteps
{
public class IncludeStubbedConfigFiles : ACompilationStep
{
public IncludeStubbedConfigFiles(Compiler compiler) : base(compiler)
public IncludeStubbedConfigFiles(ACompiler compiler) : base(compiler)
{
}
@ -30,14 +30,14 @@ namespace Wabbajack.Lib.CompilationSteps
data = data.Replace(_compiler.GamePath.Replace("\\", "\\\\"), Consts.GAME_PATH_MAGIC_DOUBLE_BACK);
data = data.Replace(_compiler.GamePath.Replace("\\", "/"), Consts.GAME_PATH_MAGIC_FORWARD);
data = data.Replace(_compiler.MO2Folder, Consts.MO2_PATH_MAGIC_BACK);
data = data.Replace(_compiler.MO2Folder.Replace("\\", "\\\\"), Consts.MO2_PATH_MAGIC_DOUBLE_BACK);
data = data.Replace(_compiler.MO2Folder.Replace("\\", "/"), Consts.MO2_PATH_MAGIC_FORWARD);
data = data.Replace(_compiler._mo2Compiler.MO2Folder, Consts.MO2_PATH_MAGIC_BACK);
data = data.Replace(_compiler._mo2Compiler.MO2Folder.Replace("\\", "\\\\"), Consts.MO2_PATH_MAGIC_DOUBLE_BACK);
data = data.Replace(_compiler._mo2Compiler.MO2Folder.Replace("\\", "/"), Consts.MO2_PATH_MAGIC_FORWARD);
data = data.Replace(_compiler.MO2DownloadsFolder, Consts.DOWNLOAD_PATH_MAGIC_BACK);
data = data.Replace(_compiler.MO2DownloadsFolder.Replace("\\", "\\\\"),
data = data.Replace(_compiler._mo2Compiler.MO2DownloadsFolder, Consts.DOWNLOAD_PATH_MAGIC_BACK);
data = data.Replace(_compiler._mo2Compiler.MO2DownloadsFolder.Replace("\\", "\\\\"),
Consts.DOWNLOAD_PATH_MAGIC_DOUBLE_BACK);
data = data.Replace(_compiler.MO2DownloadsFolder.Replace("\\", "/"), Consts.DOWNLOAD_PATH_MAGIC_FORWARD);
data = data.Replace(_compiler._mo2Compiler.MO2DownloadsFolder.Replace("\\", "/"), Consts.DOWNLOAD_PATH_MAGIC_FORWARD);
if (data == originalData)
return null;
@ -49,7 +49,7 @@ namespace Wabbajack.Lib.CompilationSteps
[JsonObject("IncludeStubbedConfigFiles")]
public class State : IState
{
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new IncludeStubbedConfigFiles(compiler);
}

View File

@ -11,10 +11,10 @@ namespace Wabbajack.Lib.CompilationSteps
private readonly string _tag;
public IncludeTaggedMods(Compiler compiler, string tag) : base(compiler)
public IncludeTaggedMods(ACompiler compiler, string tag) : base(compiler)
{
_tag = tag;
_includeDirectly = _compiler.ModInis.Where(kv =>
_includeDirectly = compiler._mo2Compiler.ModInis.Where(kv =>
{
var general = kv.Value.General;
if (general.notes != null && general.notes.Contains(_tag))
@ -56,7 +56,7 @@ namespace Wabbajack.Lib.CompilationSteps
public string Tag { get; set; }
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new IncludeTaggedMods(compiler, Tag);
}

View File

@ -10,9 +10,9 @@ namespace Wabbajack.Lib.CompilationSteps
{
private readonly IEnumerable<string> _correctProfiles;
public IncludeThisProfile(Compiler compiler) : base(compiler)
public IncludeThisProfile(ACompiler compiler) : base(compiler)
{
_correctProfiles = _compiler.SelectedProfiles.Select(p => Path.Combine("profiles", p) + "\\").ToList();
_correctProfiles = compiler._mo2Compiler.SelectedProfiles.Select(p => Path.Combine("profiles", p) + "\\").ToList();
}
public override Directive Run(RawSourceFile source)
@ -48,7 +48,7 @@ namespace Wabbajack.Lib.CompilationSteps
[JsonObject("IncludeThisProfile")]
public class State : IState
{
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new IncludeThisProfile(compiler);
}

View File

@ -8,7 +8,7 @@ namespace Wabbajack.Lib.CompilationSteps
{
public class PatchStockESMs : ACompilationStep
{
public PatchStockESMs(Compiler compiler) : base(compiler)
public PatchStockESMs(ACompiler compiler) : base(compiler)
{
}
@ -44,7 +44,7 @@ namespace Wabbajack.Lib.CompilationSteps
[JsonObject("PatchStockESMs")]
public class State : IState
{
public ICompilationStep CreateStep(Compiler compiler)
public ICompilationStep CreateStep(ACompiler compiler)
{
return new PatchStockESMs(compiler);
}

View File

@ -13,7 +13,7 @@ namespace Wabbajack.Lib.CompilationSteps
.ToJSON(TypeNameHandling.Auto, TypeNameAssemblyFormatHandling.Simple);
}
public static List<ICompilationStep> Deserialize(string stack, Compiler compiler)
public static List<ICompilationStep> Deserialize(string stack, ACompiler compiler)
{
return stack.FromJSONString<List<IState>>(TypeNameHandling.Auto, TypeNameAssemblyFormatHandling.Simple)
.Select(s => s.CreateStep(compiler)).ToList();