Beispiel #1
0
        private static int ExecuteApp(string[] args)
        {
            // Support Response File
            foreach (var arg in args)
            {
                if (arg.Contains(".rsp"))
                {
                    args = ParseResponseFile(arg);

                    if (args == null)
                    {
                        return(1);
                    }
                }
            }

            try
            {
                var cmdLineArgs = ArgumentsParser.Parse(args);

                if (cmdLineArgs.IsHelp)
                {
                    return(cmdLineArgs.ReturnCode);
                }

                var config = cmdLineArgs.GetNativeCompileSettings();

                DirectoryExtensions.CleanOrCreateDirectory(config.OutputDirectory);
                DirectoryExtensions.CleanOrCreateDirectory(config.IntermediateDirectory);

                // run mcg if requested
                if (config.EnableInterop)
                {
                    int exitCode = 0;
                    if ((exitCode = RunMcg(config)) > 0)
                    {
                        return(exitCode);
                    }

                    string interopAssemblyPath = Path.Combine(Path.GetDirectoryName(config.InputManagedAssemblyPath), "Interop");
                    string inputAssemblyName   = Path.GetFileNameWithoutExtension(config.InputManagedAssemblyPath);
                    config.AddReference(Path.Combine(interopAssemblyPath, inputAssemblyName + ".mcginterop.dll"));
                }

                var nativeCompiler = NativeCompiler.Create(config);

                var result = nativeCompiler.CompileToNative(config);

                return(result ? 0 : 1);
            }
            catch (Exception ex)
            {
#if DEBUG
                Console.WriteLine(ex);
#else
                Reporter.Error.WriteLine(ex.Message);
#endif
                return(1);
            }
        }
Beispiel #2
0
        private static int ExecuteApp(string[] args)
        {
            // Support Response File
            foreach (var arg in args)
            {
                if (arg.Contains(".rsp"))
                {
                    args = ParseResponseFile(arg);

                    if (args == null)
                    {
                        return(1);
                    }
                }
            }

            try
            {
                var cmdLineArgs = ArgumentsParser.Parse(args);

                if (cmdLineArgs.IsHelp)
                {
                    return(cmdLineArgs.ReturnCode);
                }

                var config = cmdLineArgs.GetNativeCompileSettings();

                DirectoryExtensions.CleanOrCreateDirectory(config.OutputDirectory);
                DirectoryExtensions.CleanOrCreateDirectory(config.IntermediateDirectory);

                // run mcg if requested
                if (config.EnableInterop)
                {
                    int exitCode = 0;
                    if ((exitCode = RunMcg(config)) > 0)
                    {
                        return(exitCode);
                    }
                    CompileMcgGeneratedCode(config);
                }

                var nativeCompiler = NativeCompiler.Create(config);

                var result = nativeCompiler.CompileToNative(config);

                return(result ? 0 : 1);
            }
            catch (Exception ex)
            {
#if DEBUG
                Console.WriteLine(ex);
#else
                Reporter.Error.WriteLine(ex.Message);
#endif
                return(1);
            }
        }