Beispiel #1
0
        private static void ExecuteProgramUnchecked(string[] args)
        {
            Dictionary <string, string> argLookup = FlagParser.Parse(args);

            if (argLookup.ContainsKey(FlagParser.GEN_DEFAULT_PROJ))
            {
                DefaultProjectGenerator         generator = new DefaultProjectGenerator(argLookup[FlagParser.GEN_DEFAULT_PROJ].Trim());
                Dictionary <string, FileOutput> project   = generator.Validate().Export();

                string directory = System.IO.Path.Combine(
                    System.IO.Directory.GetCurrentDirectory(),
                    generator.ProjectID);
                new FileOutputExporter(directory).ExportFiles(project);

                Console.WriteLine("Empty project exported to directory '" + generator.ProjectID + "/'");
            }
            else
            {
                Program.Compile(argLookup);
            }
#if DEBUG
            if (argLookup != null)
            {
                if (argLookup.ContainsKey(FlagParser.SHOW_PERFORMANCE_MARKERS))
                {
                    string summary = PerformanceTimer.GetSummary();
                    Console.WriteLine(summary);
                }
            }
#endif
        }
Beispiel #2
0
        public ExportCommand DoWorkImpl()
        {
            string[] commandLineArgs = Program.GetCommandLineArgs();

            ExportCommand command = FlagParser.Parse(commandLineArgs);

            // TODO: I don't like this here.
            command.PlatformProvider = new PlatformProvider();

            return(command);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Dictionary <string, string> argLookup = null;

            using (new PerformanceSection("Crayon"))
            {
#if DEBUG
                args = GetEffectiveArgs(args);

                // First chance exceptions should crash in debug builds.
                argLookup = FlagParser.Parse(args);
                Program.Compile(argLookup);

                // Crash if there were any graphics contexts that weren't cleaned up.
                // This is okay on Windows, but on OSX this is a problem, so ensure that a
                // regressions are quickly noticed.
                SystemBitmap.Graphics.EnsureCleanedUp();
#else
                if (args.Length == 0)
                {
                    System.Console.WriteLine(USAGE);
                }
                else
                {
                    try
                    {
                        argLookup = FlagParser.Parse(args);
                        Program.Compile(argLookup);
                    }
                    catch (InvalidOperationException e)
                    {
                        System.Console.Error.WriteLine(e.Message);
                    }
                    catch (ParserException e)
                    {
                        System.Console.Error.WriteLine(e.Message);
                    }
                }
#endif
            }
#if DEBUG
            if (argLookup != null)
            {
                if (argLookup.ContainsKey(FlagParser.SHOW_PERFORMANCE_MARKERS))
                {
                    string summary = PerformanceTimer.GetSummary();
                    Console.WriteLine(summary);
                }
            }
#endif
        }
Beispiel #4
0
        private static async Task MainTask(string[] args)
        {
            Wax.WaxHub waxHub = new Wax.WaxHub();

            waxHub.SourceRoot         = SourceDirectoryFinder.CrayonSourceDirectory;
            waxHub.ErrorsAsExceptions = !IS_RELEASE;

            waxHub.RegisterService(new Router.RouterService());
            waxHub.RegisterService(new AssemblyResolver.AssemblyService());
            waxHub.RegisterService(new Runtime.RuntimeService());
            waxHub.RegisterService(new Builder.BuilderService());
            waxHub.RegisterService(new U3.U3Service());

            Wax.ToolchainCommand command = FlagParser.Parse(args);

            if (command.UseOutputPrefixes)
            {
                Wax.ConsoleWriter.EnablePrefixes();
            }

            foreach (string directory in GetExtensionDirectories())
            {
                waxHub.RegisterExtensionDirectory(directory);
            }

            waxHub.RegisterLibraryDirectory(GetLibraryDirectory());

            Dictionary <string, object> result = await waxHub.SendRequest("router", command);

            Wax.Error[] errors = Wax.Error.GetErrorsFromResult(result);

            if (command.UseJsonOutput)
            {
                string jsonErrors = "{\"errors\":[" +
                                    string.Join(',', errors.Select(err => err.ToJson())) +
                                    "]}";
                Wax.ConsoleWriter.Print(Wax.ConsoleMessageType.COMPILER_INFORMATION, jsonErrors);
            }
            else if (errors.Length > 0)
            {
                ErrorPrinter.ShowErrors(errors, waxHub.ErrorsAsExceptions);
            }
        }
Beispiel #5
0
        public override CrayonWorkerResult DoWorkImpl(CrayonWorkerResult[] args)
        {
            string[] commandLineArgs = Program.GetCommandLineArgs();

            ExportCommand command = FlagParser.Parse(commandLineArgs);

            // TODO: I don't like these here.
            command.PlatformProvider       = new PlatformProvider();
            command.InlineImportCodeLoader = new InlineImportCodeLoader();

            CrayonWorkerResult result = new CrayonWorkerResult()
            {
                Value = command,
            };

            ExecutionType action = this.IdentifyUseCase(command);

            switch (action)
            {
            case ExecutionType.SHOW_USAGE: result.SetField("IsDisplayUsage", true); break;

            case ExecutionType.GENERATE_DEFAULT_PROJECT: result.SetField("IsGenerateDefaultProject", true); break;

            case ExecutionType.EXPORT_VM_BUNDLE: result.SetField("IsExportCbxVmBundle", true); break;

            case ExecutionType.EXPORT_VM_STANDALONE: result.SetField("IsExportStandaloneVm", true); break;

            case ExecutionType.EXPORT_CBX: result.SetField("IsExportStandaloneCbx", true); break;

            case ExecutionType.RUN_CBX: result.SetField("IsRunCbx", true); break;

            default: throw new Exception();
            }

            result.SetField("ShowPerformance", command.ShowPerformanceMarkers);
            result.SetField("ShowLibraryDeps", command.ShowLibraryDepTree);

            return(result);
        }