about summary refs log tree commit diff
path: root/pkgs/games/build-support/monogame-patcher
Commit message (Collapse)AuthorAgeFilesLines
* monogame-patcher: Also patch late-bound methodsaszlig2020-02-101-1/+2
| | | | | | | | | | | | | | This is something I encountered in Invisigun Heroes, where there is a virtual FileManagerAdapter class, which then gets bound to either the Desktop variant or any of the other ones. Since we always use the full path of the corresponding type/object, just adding the Callvirt to the opcodes we patch shouldn't interfere with any other games we patch that way and using an extra subcommand just for the Callvirt case would only add additional boilerplate for no additional benefits. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Fix SHA256 hashes for depsaszlig2019-02-131-2/+2
| | | | | | | | | | | I checked the archives against the previous versions and the contents match, however the archives themselves had differences with the file order so the hashes are different now. In the long term, we probably should use fetchzip instead so we don't get a hash mismatch if none of the actual contents change. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Fix string antiquotationaszlig2018-07-221-1/+1
| | | | | | | Getting a message like "Type {thetype} not found." is not very helpful, so let's add the $ in front of the string. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Allow to define specific methodsaszlig2018-07-192-23/+49
| | | | | | | | | | | | | | So far we only matched a substring of a type, which isn't very exact of course. We also weren't able to specify the method to patch. Now the methods that are being patched can be specified by using Type::Method. If it's just Type without a method all the methods of the type and its subtypes are patched. I also added a small check to make sure that all of these methods were found, and if not an error is thrown. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Return exitcode 1 on CLI erroraszlig2018-07-192-2/+13
| | | | | | | | If there is a command line usage error, we really don't want the program to return exit status 0 (success), so let's actually set the return value on WithParsed(). Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Raise exception on no-opaszlig2018-07-191-1/+10
| | | | | | | We really want to make sure that things were actually patched, so just silently skipping everything is not an option. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Allow specifying extra assemblyaszlig2018-07-193-14/+58
| | | | | | | | If we want to replace a call with one that's not in a module which is currently referenced by the target file we now have another command line flag for replace-call (-a) where we can specify the additional DLL file. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Use cleanSource for the src attraszlig2018-07-191-2/+2
| | | | | | | | While there won't be any .git directories within ./src, I still create Vim swap files all the time when editing stuff. So let's make sure that those swap files are not included in the src input of the derivation. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Fix assembly search directoryaszlig2018-07-192-11/+16
| | | | | | | | | | | | | | By default the assemblies are searched in the current working directory, but when patching an assembly in some other directory than the current the patcher will fail to resolve assemblies residing beneath the target file. So we just add the directory of the target file to the search path. I also moved all of the assemblies in the test to be in a subdir so we can verify that this indeed works and we won't regress in the future. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Work around terminal width issueaszlig2018-07-192-1/+13
| | | | | | | | | | | | | | | | | | If the command is not executed inside a terminal the value of Console.WindowWidth is 0 and thus we will get an exception from CommandLineParser: Unhandled Exception: System.ArgumentOutOfRangeException: Length cannot be less than zero. Parameter name: length at System.String.Substring ... at CommandLine.Text.HelpText.AddOption ... ... So let's initialize the parser with settings and if WindowWidth is 0 we just add 80 as the width. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Improve values for replace-callaszlig2018-07-192-5/+7
| | | | | | | | | | | | Using an IEnumerable for the search and replace arguments isn't really a very good idea, because it makes command line usage very annoying and messes up the usage description. I originally made this an IEnumerable because I wanted to have a way to specify multiple replacements, but we can simply run the patcher twice or more times. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Refactor method ref findingaszlig2018-07-195-67/+113
| | | | | | | | | | | | | | | | | | | | | | | | | | | So far we have searched for methods in two steps: First get all the types and then find all of the constructors or method definitions. The match for the actual method definition was done first for the type and then again for the full definition of the method/constructor. For the replace-call subcommand this also means that we don't have a very good way to find the type, because if we wanted to keep doing this in two steps we would need to parse the type name out of the one given as the replacement string in replace-call. So now we recurse through *all* the constructors and methods and do a full match against the specified replacement string, both for replace-call and for fix-filestreams. Compared to the implementation so far we also do this just once instead of every time we find a call or FileStream constructor. I also overhauled the way we do testing, because in the end writing tests using NUnit would introduce a lot of code churn because we need to make a lot of external calls. The shell is especially useful for exactly that and our tests are now just a plain shell script. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Restructure and add stub testsaszlig2018-07-195-30/+65
| | | | | | | | | | | | | Mainly this is so we can prepare for running unit tests, so we get the latest version of NUnit and run the console test runner. Currently there is only a dummy test which always succeeds, but it's there so that we can fill out the boilerplate later. I also moved the option definitions into a separate file so they don't clutter up the main file. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Switch to MSBuildaszlig2018-07-194-27/+65
| | | | | | | | | | | | | | I really would have preferred a simple Makefile, but with that we can't use buildDotnetPackage and we also need to take care of butchering the dependencies manually. So I moved everything to src/ and added a csproj file to clean up most of the cruft and just use buildDotnetPackage with minimal attributes. In addition to that I also added assembly info, so that the command line help will show the proper author name, copyright, yaddayadda... Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Add a replace-call subcommandaszlig2018-07-191-2/+61
| | | | | | | | | | | | | | | | | | | | | It's a very early version which I did for a Unity3d game and it *desperately* needs a cleanup. An example command line: monogame-patcher replace-call -i Assembly-CSharp.dll \ 'System.String UnityEngine.Application::get_dataPath()' \ 'System.String UnityEngine.Application::get_persistentDataPath()' \ IniParser SaveMeta Right now the replace-call subcommand has UnityEngine.Application hardcoded, so this won't work for other types than UnityEngine.Application. However, I'm going to refactor the whole patcher very soon and add some tests, so this whole mess will be cleaned up. Signed-off-by: aszlig <aszlig@nix.build>
* towerfall-ascension: Move patcher into own pkgaszlig2018-07-192-0/+140
The patcher using Cecil is now in its own derivation and can thus be easily added via nativeBuildInputs. Patching FileStream types is so common that it comes in handy for other games using Mono. I also improved the patcher a little bit so it accepts command line arguments and it's easier to add the types that needed to be patched directly via command line arguments. Signed-off-by: aszlig <aszlig@nix.build>