Skip to content

Commit 64d370b

Browse files
committed
[jnimarshalmethod-gen] Add -p|--profile option
The new option allows to specify which types are processed by a *profile* with the list of types (regex patterns) to process. It is similar to specify multiple `-t` options.
1 parent 4a2c9ea commit 64d370b

File tree

1 file changed

+21
-0
lines changed
  • tools/jnimarshalmethod-gen

1 file changed

+21
-0
lines changed

tools/jnimarshalmethod-gen/App.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ List<string> ProcessArguments (string [] args)
9393
{ "h|help|?",
9494
"Show this message and exit",
9595
v => help = v != null },
96+
{ "p|profile=",
97+
"Generate marshaling methods only for types whose names match regex patterns listed in the {PROFILE} file. One pattern per line. Empty lines and lines starting with '#' character are ignored (comments).",
98+
v => LoadProfile (v) },
9699
{ "t|type=",
97100
"Generate marshaling methods only for types whose names match {TYPE-REGEX}.",
98101
v => typeNameRegexes.Add (new Regex (v)) },
@@ -116,6 +119,24 @@ List<string> ProcessArguments (string [] args)
116119
return assemblies;
117120
}
118121

122+
void LoadProfile (string profilePath)
123+
{
124+
try {
125+
foreach (var line in File.ReadLines (profilePath)) {
126+
if (string.IsNullOrWhiteSpace (line))
127+
continue;
128+
129+
if (line [0] == '#')
130+
continue;
131+
132+
typeNameRegexes.Add (new Regex (line));
133+
}
134+
} catch (Exception e) {
135+
Error ($"Unable to read profile '{profilePath}'.\n{e}");
136+
Environment.Exit (4);
137+
}
138+
}
139+
119140
void ProcessAssemblies (List<string> assemblies)
120141
{
121142
CreateJavaVM (jvmDllPath);

0 commit comments

Comments
 (0)