Exemple #1
0
        public override bool Execute()
        {
            var outputPath       = this.OutputPath.ItemSpec.Trim();
            var debugInformation = string.IsNullOrWhiteSpace(this.DebugInformation)
                ? DebugInformationOptions.CommentOnly
                : (DebugInformationOptions)Enum.Parse(typeof(DebugInformationOptions), this.DebugInformation);

            var logw = new LogWriter(message =>
                                     this.Log.LogMessage(
                                         MessageImportance.High,
                                         "{0}", message));

            SimpleDriver.TranslateAll(
                logw,
                outputPath,
                this.ReadSymbols,
                this.EnableCpp,
                this.EnableBundler,
                debugInformation,
                this.AssemblyPaths.
                Select(path => path.ItemSpec.Trim()).
                ToArray());

            return(true);
        }
Exemple #2
0
        public static int Main(string[] args)
        {
            var extractor = new CommandLineExtractor <IL2COption>();

            try
            {
                var option = extractor.Extract(args);

                var debugInformationOptions = option.DebugFull
                    ? DebugInformationOptions.Full
                    : option.Debug
                        ? DebugInformationOptions.CommentOnly
                        : DebugInformationOptions.None;

                SimpleDriver.Translate(
                    Console.Out,
                    option.AssemblyPath,
                    option.OutputPath,
                    option.ReadSymbols,
                    option.Cpp,
                    debugInformationOptions);

                return(0);
            }
            catch (CommandLineArgumentException ex)
            {
                extractor.WriteUsages(Console.Error);
                return(Marshal.GetHRForException(ex));
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex);
                return(Marshal.GetHRForException(ex));
            }
        }
Exemple #3
0
        public override bool Execute()
        {
            var outputPath       = this.OutputPath.ItemSpec.Trim();
            var debugInformation = string.IsNullOrWhiteSpace(this.DebugInformation)
                ? DebugInformationOptions.CommentOnly
                : (DebugInformationOptions)Enum.Parse(typeof(DebugInformationOptions), this.DebugInformation);

            var tw = new LogWriter(message =>
                                   this.Log.LogMessage(
                                       MessageImportance.High,
                                       "{0}", message));

            foreach (var assemblyPath in this.AssemblyPaths)
            {
                SimpleDriver.Translate(
                    tw,
                    assemblyPath.ItemSpec.Trim(),
                    outputPath,
                    this.ReadSymbols,
                    this.EnableCpp,
                    debugInformation);
            }

            return(true);
        }
Exemple #4
0
        public static int Main(string[] args)
        {
            try
            {
                var debugInformationOptions = DebugInformationOptions.None;
                var readSymbols             = true;
                var enableBundler           = false;
                var enableCpp = false;
                var help      = false;

                var options = new OptionSet()
                {
                    { "g1|debug", "Emit debug informations (contains only comments)", v => debugInformationOptions = DebugInformationOptions.CommentOnly },
                    { "g|g2|debug-full", "Emit debug informations (contains line numbers)", v => debugInformationOptions = DebugInformationOptions.Full },
                    { "no-read-symbols", "NO read symbol files", _ => readSymbols = false },
                    { "cpp", "Produce C++ extension files (apply extension *.cpp instead *.c, body will not change)", _ => enableCpp = true },
                    { "bundler", "Produce bundler source file", _ => enableBundler = true },
                    { "h|help", "Print this help", _ => help = true },
                };

                var extra = options.Parse(args);
                if (help || (extra.Count < 2))
                {
                    Console.Out.WriteLine("usage: il2c.exe [options] <output_path> <assembly_path>");
                    options.WriteOptionDescriptions(Console.Out);
                }
                else
                {
                    var outputPath    = extra[0];
                    var assemblyPaths = extra.Skip(1);

                    SimpleDriver.TranslateAll(
                        Console.Out,
                        outputPath,
                        readSymbols,
                        enableCpp,
                        enableBundler,
                        debugInformationOptions,
                        assemblyPaths);
                }

                return(0);
            }
            catch (OptionException ex)
            {
                Console.Error.WriteLine(ex.Message);
                return(Marshal.GetHRForException(ex));
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex);
                return(Marshal.GetHRForException(ex));
            }
        }
Exemple #5
0
        public static int Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.Error.WriteLine("Usage: IL2C.exe [options] <target assembly> <output path>");
                Console.Error.WriteLine("  --cpp       : Produce C++ files (apply extension *.cpp instead *.c, body will not changed)");
                Console.Error.WriteLine("  --debug     : Emit debug informations (contains only comments)");
                Console.Error.WriteLine("  --debug-full: Emit debug informations (contains line numbers)");

                return(0);
            }

            var options = args
                          .Where(arg => arg.StartsWith("--"))
                          .Select(arg => arg.Substring(2))
                          .ToArray();
            var paths = args
                        .Where(arg => !arg.StartsWith("--"))
                        .ToArray();

            var enableCpp = options.Contains("cpp");
            var debug     = options.Contains("debug");
            var debugFull = options.Contains("debug-full");

            var debugInformationOptions = debugFull
                ? DebugInformationOptions.Full
                : debug
                    ? DebugInformationOptions.CommentOnly
                    : DebugInformationOptions.None;

            var assemblyPath = paths[0];
            var outputPath   = paths[1];

            SimpleDriver.Translate(
                Console.Out,
                assemblyPath,
                outputPath,
                enableCpp,
                debugInformationOptions);

            return(0);
        }