public CompilerSettings ParseArguments(string[] args)
{
CompilerSettings settings = new CompilerSettings ();
List<string> response_file_list = null;
bool parsing_options = true;
stop_argument = false;
for (int i = 0; i < args.Length; i++) {
string arg = args[i];
if (arg.Length == 0)
continue;
if (arg[0] == '@') {
string[] extra_args;
string response_file = arg.Substring (1);
if (response_file_list == null)
response_file_list = new List<string> ();
if (response_file_list.Contains (response_file)) {
report.Error (1515, "Response file `{0}' specified multiple times", response_file);
return null;
}
response_file_list.Add (response_file);
extra_args = LoadArgs (response_file);
if (extra_args == null) {
report.Error (2011, "Unable to open response file: " + response_file);
return null;
}
args = AddArgs (args, extra_args);
continue;
}
if (parsing_options) {
if (arg == "--") {
parsing_options = false;
continue;
}
bool dash_opt = arg[0] == '-';
bool slash_opt = arg[0] == '/';
if (dash_opt) {
switch (ParseOptionUnix (arg, ref args, ref i, settings)) {
case ParseResult.Error:
case ParseResult.Success:
continue;
case ParseResult.Stop:
stop_argument = true;
return settings;
case ParseResult.UnknownOption:
if (UnknownOptionHandler != null) {
var ret = UnknownOptionHandler (args, i);
if (ret != -1) {
i = ret;
continue;
}
}
break;
}
}
if (dash_opt || slash_opt) {
// Try a -CSCOPTION
string csc_opt = dash_opt ? "/" + arg.Substring (1) : arg;
switch (ParseOption (csc_opt, ref args, settings)) {
case ParseResult.Error:
case ParseResult.Success:
continue;
case ParseResult.UnknownOption:
// Need to skip `/home/test.cs' however /test.cs is considered as error
if ((slash_opt && arg.Length > 3 && arg.IndexOf ('/', 2) > 0))
break;
if (UnknownOptionHandler != null) {
var ret = UnknownOptionHandler (args, i);
if (ret != -1) {
i = ret;
continue;
}
}
Error_WrongOption (arg);
return null;
case ParseResult.Stop:
stop_argument = true;
return settings;
}
}
}
ProcessSourceFiles (arg, false);
}
return settings;
}