Example #1
0
        static int Main(string[] args)
        {
            var files  = new List <string>();
            var config = new Config();

            config.ParseArgs(args);
            if (!config.Validate())
            {
                ConsoleOps.Usage(true);
            }
            ConsoleOps.Info("{0}", config);
            ConsoleOps.Info("compiling...");

            // we don't use the engine, but we create it so we can have a default context.
            ScriptEngine engine = Python.CreateEngine();

            ClrModule.CompileModules(DefaultContext.DefaultCLS, config.Output + ".dll", new Dictionary <string, object> {
                { "mainModule", config.MainName }
            }, config.Files.ToArray());

            if (config.Target != PEFileKinds.Dll)
            {
                GenerateExe(config);
            }

            ConsoleOps.Info("Saved to {0}", config.Output);
            return(0);
        }
Example #2
0
        public static int Main(string[] args)
        {
            var files  = new List <string>();
            var config = new Config();

            config.ParseArgs(args);
            if (!config.Validate())
            {
                ConsoleOps.Usage(true);
            }

            // we don't use the engine, but we create it so we can have a default context.
            ScriptEngine engine = Python.CreateEngine(config.PythonOptions);

            ConsoleOps.Info($"IronPython Compiler for {engine.Setup.DisplayName} ({engine.LanguageVersion})");
            ConsoleOps.Info($"{config}");
            ConsoleOps.Info("compiling...");

            var compileOptions = new Dictionary <string, object>()
            {
                { "mainModule", config.MainName },
                { "assemblyFileVersion", config.FileVersion },
                { "copyright", config.Copyright },
                { "productName", config.ProductName },
                { "productVersion", config.ProductVersion },
            };

            try
            {
                ClrModule.CompileModules(DefaultContext.DefaultCLS,
                                         Path.Combine(config.OutputPath, Path.ChangeExtension(config.Output, ".dll")),
                                         compileOptions,
                                         config.Files.ToArray());

                var outputfilename = Path.Combine(config.OutputPath, Path.ChangeExtension(config.Output, ".dll"));
                if (config.Target != PEFileKinds.Dll)
                {
                    outputfilename = Path.Combine(config.OutputPath, Path.ChangeExtension(config.Output, ".exe"));
                    GenerateExe(config);
                }
                ConsoleOps.Info($"Saved to {outputfilename}");
            }
            catch (Exception e)
            {
                Console.WriteLine();
                ConsoleOps.Error(true, e.Message);
            }
            return(0);
        }
Example #3
0
        static int Main(string[] args)
        {
            var files = new List<string>();
            var config = new Config();
            config.ParseArgs(args);
            if (!config.Validate()) {
                ConsoleOps.Usage(true);
            }
            ConsoleOps.Info("{0}", config);
            ConsoleOps.Info("compiling...");

            // we don't use the engine, but we create it so we can have a default context.
            ScriptEngine engine = Python.CreateEngine();

            ClrModule.CompileModules(DefaultContext.DefaultCLS, config.Output + ".dll", new Dictionary<string, object> { { "mainModule", config.MainName } }, config.Files.ToArray());

            if (config.Target != PEFileKinds.Dll) {
                GenerateExe(config);
            }

            ConsoleOps.Info("Saved to {0}", config.Output);
            return 0;
        }