Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MiniInstaller/BackUp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@ private static void Backup(string from, string backupDst = null) {
}
}
}
}
}
6 changes: 3 additions & 3 deletions MiniInstaller/DepCalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static void RunMonoMod(string asmFrom, string asmTo = null, string[] dllP
string asmTmp = Path.Combine(Globals.PathTmp, Path.GetFileName(asmTo));
try {
// We're lazy.
Environment.SetEnvironmentVariable("MONOMOD_DEPDIRS", Globals.PathGame);
Environment.SetEnvironmentVariable("MONOMOD_DEPDIRS", $"{Globals.PathMiniInstallerWorkspace}{Path.PathSeparator}{Globals.PathGame}"); // Prioritize workspace
Environment.SetEnvironmentVariable("MONOMOD_DEPENDENCY_MISSING_THROW", "0");
int returnCode = (int) AsmMonoMod.EntryPoint.Invoke(null, new object[] { Enumerable.Repeat(asmFrom, 1).Concat(dllPaths).Append(asmTmp).ToArray() });

Expand All @@ -84,7 +84,7 @@ public static void RunMonoMod(string asmFrom, string asmTo = null, string[] dllP
public static void RunHookGen(string asm, string targetName) {
Logger.LogLine($"Running MonoMod.RuntimeDetour.HookGen for {asm}");
// We're lazy.
Environment.SetEnvironmentVariable("MONOMOD_DEPDIRS", Globals.PathGame);
Environment.SetEnvironmentVariable("MONOMOD_DEPDIRS", $"{Globals.PathMiniInstallerWorkspace}{Path.PathSeparator}{Globals.PathGame}"); // Prioritize workspace
Environment.SetEnvironmentVariable("MONOMOD_DEPENDENCY_MISSING_THROW", "0");
AsmHookGen.EntryPoint.Invoke(null, new object[] { new string[] { "--private", asm, Path.Combine(Path.GetDirectoryName(targetName), "MMHOOK_" + Path.ChangeExtension(Path.GetFileName(targetName), "dll")) } });
}
Expand Down Expand Up @@ -132,4 +132,4 @@ public static void ConvertToNETCoreSingle(string asmFrom, string asmTo) {
File.Delete(Path.ChangeExtension(asmTmp, "mdb"));
}
}
}
}
5 changes: 4 additions & 1 deletion MiniInstaller/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ public static class Globals {
public static string PathOrig;
public static string PathLog;
public static string PathTmp;
public static string PathMiniInstallerWorkspace;

public static bool SetupPaths() {
PathGame = Directory.GetCurrentDirectory();
Console.WriteLine(PathGame);
PathMiniInstallerWorkspace = Path.Combine(PathGame, "MiniInstallerWorkspace");

if (Path.GetFileName(PathGame) == "everest-update" && (
File.Exists(Path.Combine(Path.GetDirectoryName(PathGame), "Celeste.exe")) ||
Expand Down Expand Up @@ -87,4 +90,4 @@ public static void DetermineInstallPlatform() {

Logger.LogLine($"Determined install platform: {Platform}");
}
}
}
5 changes: 3 additions & 2 deletions MiniInstaller/LibAndDepHandling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ void CopyNativeLib(string src, string dst) {

// Copy our Steamworks.NET.dll
string steamworksLibDst = Path.Combine(Globals.PathGame, "Steamworks.NET.dll");
File.Delete(steamworksLibDst);
File.Copy(steamworksLibSrc, steamworksLibDst);
File.Copy(steamworksLibSrc, steamworksLibDst, true);

// Delete old libraries
foreach (string libFile in Globals.WindowsNativeLibFileNames)
Expand Down Expand Up @@ -268,6 +267,7 @@ public static void SetupAppHosts(string appExe, string appDll, string resDll = n
// Bind Linux apphost
Logger.LogLine($"Binding Linux apphost {Path.ChangeExtension(appExe, null)}");
HostWriter.CreateAppHost(Path.Combine(hostsDir, "linux"), Path.ChangeExtension(appExe, null), Path.GetRelativePath(Path.GetDirectoryName(appExe), appDll));
File.Delete(Globals.PathCelesteExe);
} break;
case Globals.InstallPlatform.MacOS: {
// Bind OS X apphost
Expand All @@ -277,6 +277,7 @@ public static void SetupAppHosts(string appExe, string appDll, string resDll = n
File.Delete(Path.Combine(Globals.PathOSXExecDir, Path.GetFileNameWithoutExtension(appExe)));
File.CreateSymbolicLink(Path.Combine(Globals.PathOSXExecDir, Path.GetFileNameWithoutExtension(appExe)),
Path.GetRelativePath(Globals.PathOSXExecDir, Path.ChangeExtension(appExe, null)));
File.Delete(Globals.PathCelesteExe);
} break;
}
}
Expand Down
9 changes: 3 additions & 6 deletions MiniInstaller/MiscUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,15 @@ public static bool IsSteamworksNet(string file) {
}
// This is not "pure" but I guess it also somewhat fits here
public static void MoveExecutable(string srcPath, string dstPath) {
File.Delete(dstPath);
File.Move(srcPath, dstPath);
File.Move(srcPath, dstPath, true);

if (Path.GetFullPath(Path.ChangeExtension(srcPath, null)) != Path.GetFullPath(Path.ChangeExtension(dstPath, null))) {
if (File.Exists(Path.ChangeExtension(srcPath, ".pdb"))) {
File.Delete(Path.ChangeExtension(dstPath, ".pdb"));
File.Move(Path.ChangeExtension(srcPath, ".pdb"), Path.ChangeExtension(dstPath, ".pdb"));
File.Move(Path.ChangeExtension(srcPath, ".pdb"), Path.ChangeExtension(dstPath, ".pdb"), true);
}

if (File.Exists(Path.ChangeExtension(srcPath, ".mdb"))) {
File.Delete(Path.ChangeExtension(dstPath, ".mdb"));
File.Move(Path.ChangeExtension(srcPath, ".mdb"), Path.ChangeExtension(dstPath, ".mdb"));
File.Move(Path.ChangeExtension(srcPath, ".mdb"), Path.ChangeExtension(dstPath, ".mdb"), true);
}
}
}
Expand Down
36 changes: 27 additions & 9 deletions MiniInstaller/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,43 @@ public static int StandardMode(string[] args) {
LibAndDepHandling.SetupNativeLibs();
LibAndDepHandling.CopyControllerDB();

if (Directory.Exists(Globals.PathMiniInstallerWorkspace)) {
Logger.LogLine("MiniInstaller workspace already exists, cleaning before continuing.");
Directory.Delete(Globals.PathMiniInstallerWorkspace, true);
}

Directory.CreateDirectory(Globals.PathMiniInstallerWorkspace);

string coreifiedCeleste = Path.Combine(Globals.PathMiniInstallerWorkspace, "Celeste.Core.dll");
string coreifiedModdedCeleste = Path.Combine(Globals.PathMiniInstallerWorkspace, "Celeste.dll");
string moddedFNA = Path.Combine(Globals.PathMiniInstallerWorkspace, "FNA.dll");
string hookGenTempOutput = Path.Combine(Globals.PathMiniInstallerWorkspace, "MMHOOK_" + Path.ChangeExtension(Path.GetFileName(Globals.PathCelesteExe), ".dll"));

DepCalls.LoadModders();

DepCalls.ConvertToNETCore(Path.Combine(Globals.PathOrig, "Celeste.exe"), Globals.PathCelesteExe);
DepCalls.ConvertToNETCore(Path.Combine(Globals.PathOrig, "Celeste.exe"), coreifiedCeleste);

string everestModDLL = Path.ChangeExtension(Globals.PathCelesteExe, ".Mod.mm.dll");
string[] mods = new string[] { Globals.PathEverestLib, everestModDLL };
DepCalls.RunMonoMod(Path.Combine(Globals.PathEverestLib, "FNA.dll"), Path.Combine(Globals.PathGame, "FNA.dll"), dllPaths: mods); // We need to patch some methods in FNA as well
DepCalls.RunMonoMod(Globals.PathCelesteExe, dllPaths: mods);
DepCalls.RunMonoMod(Path.Combine(Globals.PathEverestLib, "FNA.dll"), moddedFNA, dllPaths: mods); // We need to patch some methods in FNA as well
DepCalls.RunMonoMod(coreifiedCeleste, coreifiedModdedCeleste, dllPaths: mods);

string hookGenOutput = Path.Combine(Globals.PathGame, "MMHOOK_" + Path.ChangeExtension(Path.GetFileName(Globals.PathCelesteExe), ".dll"));
DepCalls.RunHookGen(Globals.PathCelesteExe, Globals.PathCelesteExe);
DepCalls.RunMonoMod(hookGenOutput, dllPaths: mods); // We need to fix some MonoMod crimes, so relink it against the legacy MonoMod layer
DepCalls.RunHookGen(coreifiedModdedCeleste, coreifiedModdedCeleste);
DepCalls.RunMonoMod(hookGenTempOutput, dllPaths: mods); // We need to fix some MonoMod crimes, so relink it against the legacy MonoMod layer

MiscUtil.MoveExecutable(coreifiedModdedCeleste, Globals.PathEverestDLL);
MiscUtil.MoveExecutable(moddedFNA, Path.Combine(Globals.PathGame, "FNA.dll"));
MiscUtil.MoveExecutable(hookGenTempOutput, hookGenOutput);

MiscUtil.MoveExecutable(Globals.PathCelesteExe, Globals.PathEverestDLL);
LibAndDepHandling.CreateRuntimeConfigFiles(Globals.PathEverestDLL, new string[] { everestModDLL, hookGenOutput });
LibAndDepHandling.SetupAppHosts(Globals.PathCelesteExe, Globals.PathEverestDLL, Globals.PathEverestDLL);

XmlDoc.CombineXMLDoc(Path.ChangeExtension(Globals.PathCelesteExe, ".Mod.mm.xml"), Path.ChangeExtension(Globals.PathCelesteExe, ".xml"));

// Everything went well, cleaning MiniInstaller workspace
Directory.Delete(Globals.PathMiniInstallerWorkspace, true);

// If we're updating, start the game. Otherwise, close the window.
if (Globals.PathUpdate != null) {
InGameUpdaterHelper.StartGame();
Expand Down Expand Up @@ -126,7 +144,7 @@ public static int StandardMode(string[] args) {

return 0;
}

/// <summary>
/// Fast mode serves as a way to speed up development environments,
/// allowing disabling most parts of the installation process to only focus on the ones
Expand Down Expand Up @@ -180,10 +198,10 @@ public static int FastMode(string[] args) {
string[] mods = new string[] { Globals.PathEverestLib, everestModDLL };

string coreGameCacheFile = Path.ChangeExtension(Globals.PathCelesteExe, ".CoreGameCache.dll");

if (doMainGame && !File.Exists(coreGameCacheFile))
coreGameCacheRegen = true;

if (coreGameCacheRegen && File.Exists(coreGameCacheFile))
File.Delete(coreGameCacheFile);

Expand Down