Skip to content
Merged
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: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ run-android: $(ATESTS)
run-test-jnimarshal: bin/Test$(CONFIGURATION)/Java.Interop.Export-Tests.dll bin/Test$(CONFIGURATION)/$(JAVA_INTEROP_LIB)
MONO_TRACE_LISTENER=Console.Out \
$(RUNTIME) bin/$(CONFIGURATION)/jnimarshalmethod-gen.exe -v -L $(JI_MONO_LIB_PATH)mono/4.5 -L $(JI_MONO_LIB_PATH)mono/4.5/Facades "$<"
$(RM) "$<" "$(basename $<)-JniMarshalMethods.dll"
mv "$(basename $<)-new.dll" "$<"
mv "$(basename $<)-new.pdb" "$(basename $<).pdb"
$(RM) "$(basename $<)-JniMarshalMethods.dll"
$(call RUN_TEST,$<)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ public Dictionary<string, AssemblyDefinition> ToResolverCache ()
return new Dictionary<string, AssemblyDefinition>(cache);
}

public bool AddToCache (AssemblyDefinition assembly)
{
var name = Path.GetFileNameWithoutExtension (assembly.MainModule.FileName);

if (cache.ContainsKey (name))
return false;

cache [name] = assembly;

return true;
}

public virtual AssemblyDefinition Load (string fileName, bool forceLoad = false)
{
if (!File.Exists (fileName))
Expand Down
8 changes: 7 additions & 1 deletion tools/jnimarshalmethod-gen/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,20 @@ public static int Main (string [] args)
return 0;
}

var readWriteParameters = new ReaderParameters {
AssemblyResolver = resolver,
ReadSymbols = true,
ReadWrite = true,
};
foreach (var assembly in assemblies) {
if (!File.Exists (assembly)) {
Error ($"Path '{assembly}' does not exist.");
return 1;
}

resolver.SearchDirectories.Add (Path.GetDirectoryName (assembly));
resolver.Load (assembly);
var ad = AssemblyDefinition.ReadAssembly (assembly, readWriteParameters);
resolver.AddToCache (ad);

try {
CreateMarshalMethodAssembly (assembly);
Expand Down
5 changes: 2 additions & 3 deletions tools/jnimarshalmethod-gen/TypeMover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ public void Move ()
return;
}

var newName = $"{Path.Combine (Path.GetDirectoryName (Destination.MainModule.FileName), Path.GetFileNameWithoutExtension (Destination.MainModule.FileName))}-new{Path.GetExtension (Destination.MainModule.FileName)}";
Destination.Write (newName, new WriterParameters () { WriteSymbols = true });
Destination.Write (new WriterParameters () { WriteSymbols = true });

if (App.Verbose)
App.ColorWriteLine ($"Wrote {newName} assembly", ConsoleColor.Cyan);
App.ColorWriteLine ($"Wrote updated {Destination.MainModule.FileName} assembly", ConsoleColor.Cyan);
}

static readonly string nestedName = "__<$>_jni_marshal_methods";
Expand Down