private static bool TryParseArgs()

in Iris/ic/CompilerRunner.cs [51:118]


        private static bool TryParseArgs(string[] args, out string sourceFile, out CompilationFlags flags)
        {
            sourceFile = null;
            flags = 0;
            if (args.Length < 1)
                return false;

            foreach (string arg in args)
            {
                string normalizedArg = arg.ToUpper();
                switch (normalizedArg)
                {
                    case "/32":
                        flags |= CompilationFlags.Platform32;
                        break;
                    case "/64":
                        flags |= CompilationFlags.Platform64;
                        break;
                    case "/NODEBUG":
                        flags |= CompilationFlags.NoDebug;
                        break;
                    case "/ASM":
                        flags |= CompilationFlags.Assembly;
                        break;
                    default:
                        if (normalizedArg.StartsWith("/"))
                        {
                            Console.WriteLine("Unrecognized option {0}", normalizedArg);
                            return false;
                        }
                        if (!File.Exists(arg))
                        {
                            Console.WriteLine("Source file '{0}' not found", arg);
                            return false;
                        }
                        if (sourceFile != null)
                        {
                            Console.WriteLine("Multiple source files specified.  Only one file is supported");
                            return false;
                        }
                        sourceFile = arg;
                        break;
                }
            }

            if (flags.HasFlag(CompilationFlags.Platform32) && flags.HasFlag(CompilationFlags.Platform64))
            {
                Console.WriteLine("Both 32-bit and 64-bit platforms specified.  Only one platform is supported");
                return false;
            }

            if (!flags.HasFlag(CompilationFlags.Platform32) && !flags.HasFlag(CompilationFlags.Platform64))
                flags |= CompilationFlags.Platform32;

            if (sourceFile == null)
                return false;

// NOTE: Currently this project is always compiled for .NET Core, so this #if will always be true. But leaving
// in case one wants to modify the project to run on desktop. Note that currently this compiler uses the assemblies
// that it is running on as reference assemblies. So to produce .NET Framework assemblies it needs to be running
// on the .NET Framework.
#if NETCOREAPP
            flags |= CompilationFlags.NetCore;
            flags |= CompilationFlags.WriteDll; // force running application through dotnet
#endif

            return true;
        }