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
4 changes: 2 additions & 2 deletions MiniInstaller/BackUp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static void ApplyVanillaPatchLibs(string patchLibsDir, string targetDir) {

Logger.LogLine("Applying patch vanilla libraries");
ApplyVanillaPatchLibs(patchLibsDir, Globals.PathOrig);
Directory.Delete(patchLibsDir, true);
Directory.Delete(patchLibsDir, recursive: true);
}

//Create symlinks
Expand Down 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}");
}
}
}
4 changes: 2 additions & 2 deletions MiniInstaller/InGameUpdaterHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static void MoveFilesFromUpdate(string srcPath = null, string dstPath = n

// Check if we have a new runtime (=there is a piton-runtime folder both in the game and the update directory)
if (Directory.Exists(Path.Combine(Globals.PathGame, "piton-runtime")) && Directory.Exists(Path.Combine(Globals.PathUpdate, "piton-runtime")))
Directory.Delete(Path.Combine(Globals.PathGame, "piton-runtime"), true);
Directory.Delete(Path.Combine(Globals.PathGame, "piton-runtime"), recursive: true);
}

if (!Directory.Exists(dstPath))
Expand All @@ -29,7 +29,7 @@ public static void MoveFilesFromUpdate(string srcPath = null, string dstPath = n

if (File.Exists(entrySrc)) {
Logger.LogLine($"Copying {entrySrc} +> {entryDst}");
File.Copy(entrySrc, entryDst, true);
File.Copy(entrySrc, entryDst, overwrite: true);
} else
MoveFilesFromUpdate(entrySrc, entryDst);
}
Expand Down
13 changes: 7 additions & 6 deletions MiniInstaller/LibAndDepHandling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void CopyNativeLib(string src, string dst) {
dst = Path.Combine(Path.GetDirectoryName(dst), mappedName);
}

File.Copy(src, dst, true);
File.Copy(src, dst, overwrite: true);

if (symlinkPath != null && symlinkPath != dst) {
File.Delete(symlinkPath);
Expand All @@ -106,20 +106,19 @@ 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, overwrite: true);

// Delete old libraries
foreach (string libFile in Globals.WindowsNativeLibFileNames)
File.Delete(Path.Combine(Globals.PathGame, libFile));

foreach (string libDir in new string[] { "lib", "lib64", "everest-lib64", "runtimes" }) {
if (Directory.Exists(Path.Combine(Globals.PathGame, libDir)))
Directory.Delete(Path.Combine(Globals.PathGame, libDir), true);
Directory.Delete(Path.Combine(Globals.PathGame, libDir), recursive: true);
}

if (Globals.PathOSXExecDir != null && Path.Exists(Path.Combine(Globals.PathOSXExecDir, "osx")))
Directory.Delete(Path.Combine(Globals.PathOSXExecDir, "osx"), true);
Directory.Delete(Path.Combine(Globals.PathOSXExecDir, "osx"), recursive: true);

// Finally make EverestSplash executable
if (Globals.Platform is Globals.InstallPlatform.Linux or Globals.InstallPlatform.MacOS) {
Expand All @@ -138,7 +137,7 @@ void CopyNativeLib(string src, string dst) {
}

public static void CopyControllerDB() {
File.Copy(Path.Combine(Globals.PathEverestLib, "gamecontrollerdb.txt"), Path.Combine(Globals.PathGame, "gamecontrollerdb.txt"), true);
File.Copy(Path.Combine(Globals.PathEverestLib, "gamecontrollerdb.txt"), Path.Combine(Globals.PathGame, "gamecontrollerdb.txt"), overwrite: true);
Logger.LogLine("Copied gamecontrollerdb.txt");
}

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, overwrite: 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"), overwrite: 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"), overwrite: 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, recursive: 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"));

Comment thread
Wartori54 marked this conversation as resolved.
DepCalls.LoadModders();

DepCalls.ConvertToNETCore(Path.Combine(Globals.PathOrig, "Celeste.exe"), Globals.PathCelesteExe);
DepCalls.ConvertToNETCore(Path.Combine(Globals.PathOrig, "Celeste.exe"), coreifiedCeleste);
Comment thread
Wartori54 marked this conversation as resolved.

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);
Comment thread
Wartori54 marked this conversation as resolved.
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, recursive: 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