4using System.Collections.Generic;
5using System.CommandLine;
6using System.CommandLine.Parsing;
17 readonly
static char[] LIST_SEPARATOR = [
';',
','];
27 description:
"Path or name of class or JAR file to import.")
28 .LegalFilePathsOnly());
31 aliases: [
"-out",
"-o"],
32 description:
"Specify the output filename.")
33 .LegalFilePathsOnly());
37 description:
"Specify assembly name."));
41 description:
"Specifies the format of the output file.",
42 getDefaultValue: () => root ?
"library" :
null)
43 .FromAmong(
"exe",
"winexe",
"library",
"module"));
47 description:
"Limit which platforms this code can run on: x86, x64, arm, anycpu32bitpreferred, or anycpu.\nThe default is anycpu.",
48 getDefaultValue: () => root ?
"anycpu" :
null)
49 .FromAmong(
"x86",
"x64",
"arm",
"arm64",
"anycpu32bitpreferred",
"anycpu"));
53 description:
"Apply STAThreadAttribute to main.",
54 getDefaultValue: () => root ?
"none" :
null)
55 .FromAmong(
"sta",
"mta",
"none"));
59 description:
"Don't glob the arguments passed to main."));
63 description:
"Set system property (at runtime)."));
66 aliases: [
"-enableassertions",
"-ea"],
67 parseArgument: ParseOptionalString,
69 description:
"Set system property to enable assertions.")
71 Arity = ArgumentArity.ZeroOrMore,
76 aliases: [
"-disableassertions",
"-da"],
77 parseArgument: ParseOptionalString,
79 description:
"Set system property to disable assertions.")
81 Arity = ArgumentArity.ZeroOrMore,
86 name:
"-removeassertions",
87 description:
"Remove all assert statements."));
91 description:
"Specify the class containing the main method."));
94 aliases: [
"-reference",
"-r"],
95 description:
"Reference an assembly."));
99 description:
"Recurse directory and include matching file."));
103 description:
"Include file as Java resource.")
105 Arity = ArgumentArity.OneOrMore
109 aliases: [
"-externalresource"],
110 description:
"Reference file as Java resource.")
112 Arity = ArgumentArity.OneOrMore
117 description:
"Do not generate JNI stub for native methods."));
121 description:
"A file containing a list of classes to exclude.")
122 .LegalFilePathsOnly());
126 description:
"Specify assembly version."));
129 name:
"-fileversion",
130 description:
"File version."));
134 description:
"Embed specified icon in output.")
135 .LegalFilePathsOnly());
138 name:
"-win32manifest",
139 description:
"Specify a Win32 manifest file (.xml).")
140 .LegalFilePathsOnly());
143 aliases: [
"-keyfile"],
144 description:
"Use keyfile to sign the assembly.")
145 .LegalFilePathsOnly());
149 description:
"Use keycontainer to sign the assembly."));
152 aliases: [
"-delaysign"],
153 description:
"Delay-sign the assembly."));
157 description:
"Specify debugging type ('portable' is default)\n'portable' is a cross-platform format,\n'embedded' is a cross-platform format embedded into the target dll or exe.",
158 getDefaultValue: () => root ?
"portable" :
null)
159 .FromAmong(
"none",
"portable",
"embedded"));
162 aliases: [
"-deterministic"],
163 description:
"Produce a deterministic assembly (including module version GUID and timestamp)."));
166 aliases: [
"-optimize"],
170 aliases: [
"-srcpath"],
171 description:
"Prepend path and package name to source file.")
172 .LegalFilePathsOnly());
176 description:
"Specify a XML map file that rewrites entities.")
177 .LegalFilePathsOnly());
180 aliases: [
"-nostacktraceinfo"],
181 description:
"Don't create metadata to emit rich stack traces."));
184 aliases: [
"-opt:fields"],
185 description:
"Remove unused private fields."));
188 aliases: [
"-compressresources"],
189 description:
"Compress resources."));
192 aliases: [
"-strictfinalfieldsemantics"],
193 description:
" Don't allow final fields to be modified outside of initializer methods."));
196 aliases: [
"-privatepackage"],
197 description:
"Mark all classes with a package name starting with <prefix> as internal to the assembly."));
200 aliases: [
"-publicpackage"],
201 description:
"Mark all classes with a package name starting with <prefix> as public to the assembly."));
204 aliases: [
"-nowarn"],
205 description:
"Disable specific warning messages.",
206 parseArgument: ParseDiagnosticArray));
209 aliases: [
"-warnaserror"],
210 description:
"Report all warnings as errors.",
211 parseArgument: ParseDiagnosticArray));
215 aliases: [
"-runtime"],
216 description:
"Path to the IKVM.Runtime assembly.")
217 .LegalFilePathsOnly());
220 aliases: [
"-classloader"],
221 description:
"Set custom class loader class for assembly."));
225 aliases: [
"-sharedclassloader"],
226 description:
"All targets below this level share a common class loader."));
229 aliases: [
"-baseaddress"],
230 description:
"Base address for the library to be built."));
233 aliases: [
"-filealign"],
234 description:
"Specify the alignment used for output file."));
237 aliases: [
"-nopeercrossreference"],
238 description:
"Do not automatically cross reference all peers."));
241 aliases: [
"-nostdlib"],
242 description:
"Do not reference standard libraries"));
246 description:
"Additional directories to search for references."));
249 aliases: [
"-noautoserialization"],
250 description:
"Disable automatic .NET serialization support."));
253 aliases: [
"-highentropyva"],
254 description:
"Enable high entropy ASLR."));
258 description:
"Generate proxies for specified class."));
261 aliases: [
"-XX:+AllowNonVirtualCalls"],
262 description:
"Allow non-virtual calls."));
265 aliases: [
"-static"],
266 description:
"Disable dynamic binding."));
269 aliases: [
"-nojarstubs"],
270 description:
"undocumented temporary option to mitigate risk."));
273 aliases: [
"-assemblyattributes"],
274 description:
"Read assembly custom attributes from specified class file.")
275 .LegalFilePathsOnly());
279 description:
"Undocumented option to always warn if a class isn't found."));
282 aliases: [
"-noparameterreflection"],
283 description:
"Undocumented option to compile core class libraries with, to disable MethodParameter attribute."));
287 aliases: [
"-bootstrap"],
288 description:
"Undocumented option to compile core class libraries with, to allow creation of base class libraries."));
293 getDefaultValue: () =>
"text",
294 description:
"Logging options."));
304 Diagnostic[] ParseDiagnosticArray(ArgumentResult result)
306 var l =
new List<Diagnostic>();
308 foreach (var i
in result.Tokens)
310 foreach (var j
in i.Value.Split(LIST_SEPARATOR, StringSplitOptions.RemoveEmptyEntries))
315 if (j.StartsWith(
"IKVM", StringComparison.OrdinalIgnoreCase) &&
int.TryParse(j[
"IKVM".Length..], out var id2) &&
Diagnostic.
GetById(id2) is { } diagnostic2)
329 string? ParseOptionalString(ArgumentResult result)
331 if (result.Tokens.Count == 0)
334 if (result.Parent is OptionResult { IsImplicit: true })
342 var l =
new string[result.Tokens.Count];
343 for (
int i = 0; i < result.Tokens.Count; i++)
344 l[i] = result.Tokens[i].Value;
346 return string.Join(
";", l);
353 void ValidateResource(OptionResult symbolResult)
static ? Diagnostic GetById(int id)