Skip to content
Merged
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
27 changes: 25 additions & 2 deletions tools/jnimarshalmethod-gen/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ List<string> ProcessArguments (string [] args)
{ "h|help|?",
"Show this message and exit",
v => help = v != null },
{ "types=",
"Generate marshaling methods only for types whose names match regex patterns listed {FILE}.\n" +
"One regex pattern per line.\n" +
"Empty lines and lines starting with '#' character are ignored as comments.",
v => LoadTypes (v) },
{ "t|type=",
"Generate marshaling methods only for types whose names match {TYPE-REGEX}.",
v => typeNameRegexes.Add (new Regex (v)) },
Expand All @@ -116,6 +121,24 @@ List<string> ProcessArguments (string [] args)
return assemblies;
}

void LoadTypes (string typesPath)
{
try {
foreach (var line in File.ReadLines (typesPath)) {
if (string.IsNullOrWhiteSpace (line))
continue;

if (line [0] == '#')
continue;

typeNameRegexes.Add (new Regex (line));
}
} catch (Exception e) {
Error ($"Unable to read profile '{typesPath}'.{Environment.NewLine}{e}");
Environment.Exit (4);
}
}

void ProcessAssemblies (List<string> assemblies)
{
CreateJavaVM (jvmDllPath);
Expand Down Expand Up @@ -153,7 +176,7 @@ void ProcessAssemblies (List<string> assemblies)
try {
CreateMarshalMethodAssembly (assembly);
} catch (Exception e) {
Error ($"Unable to process assembly '{assembly}'\n{e.Message}\n{e}");
Error ($"Unable to process assembly '{assembly}'{Environment.NewLine}{e.Message}{Environment.NewLine}{e}");
Environment.Exit (1);
}
}
Expand All @@ -168,7 +191,7 @@ void CreateJavaVM (string jvmDllPath)
try {
builder.CreateJreVM ();
} catch (Exception e) {
Error ($"Unable to create Java VM\n{e}");
Error ($"Unable to create Java VM{Environment.NewLine}{e}");
Environment.Exit (3);
}
}
Expand Down