Exemple #1
0
        static void Main(string[] args)
        {
            string watchDirectory = null;

            ShowStartupBanner();

            // Initialize LPHP-Compiler
            LPHPCompiler.Init();

            // Set LPHP-Debug Mode
            LPHPDebugger.PrintDebug = LPHPDebugger.DebugOutputs.ToConsole;

            // Enable the creation of a log file
            LPHPDebugger.CreateLogFile = true;

            // Check if the project-path is provided upon startup
            if (args.Length > 0)
            {
                if (Directory.Exists(args[0].ToString()))
                {
                    watchDirectory = args[0].ToString();
                }
                else
                {
                    LPHPDebugger.PrintError("*** LPHP Startup Error ***");
                    LPHPDebugger.PrintError("The path provided is not a valid directory.");
                }
            }
            else
            {
                LPHPDebugger.PrintWarning("No path provided upon startup. Please provide a path to your LPHP-project at startup, or enter it below:");

                do
                {
                    Console.Write("LPHP Project Path > ");
                    watchDirectory = Console.ReadLine();
                    Console.WriteLine("");

                    if (!Directory.Exists(watchDirectory))
                    {
                        LPHPDebugger.PrintError("The entered path is not valid! Please try again.");
                    }
                }while (!Directory.Exists(watchDirectory));
            }

            Console.Write("Watching directory \"");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(watchDirectory);
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("\"");

            // Set up the watchdog and set the project-root
            LPHPWatchdog.Init(watchDirectory);

            // Run the LPHP-Watchdog on the given directory
            LPHPWatchdog.Run();
        }
Exemple #2
0
        private void bgwLPHPCompiler_DoWork(object sender, DoWorkEventArgs e)
        {
            // Initialize LPHP-Compiler
            LPHPCompiler.Init();

            // Initialize LPHP-Watchdog
            LPHPWatchdog.Init(txbProjectDirectory.Text);

            // Set LPHP-Debug Mode
            LPHPDebugger.PrintDebug = DebugToTxb;

            // Enable the creation of a log file
            LPHPDebugger.CreateLogFile = true;
            while (true)
            {
                if (bgwLPHPCompiler.CancellationPending)
                {
                    return;
                }

                if (QueueLPHPRestart)
                {
                    bgwLPHPCompiler.ReportProgress(0, new Tuple <string, Color>("Reloading LPHP-Config...", Color.Yellow));
                    LPHPCompiler.Init();
                    LPHPWatchdog.Init(txbProjectDirectory.Text);
                    QueueLPHPRestart = false;
                }

                // Run the LPHP-Watchdog on the given directory
                int watchdogResult = LPHPWatchdog.RunOnce();

                if (watchdogResult == -1)
                {
                    bgwLPHPCompiler.ReportProgress(0, new Tuple <string, Color>("Stopping LPHP-Engine.", Color.OrangeRed));
                    bgwLPHPCompiler.CancelAsync();
                }

                if (watchdogResult == -2)
                {
                    bgwLPHPCompiler.ReportProgress(0, new Tuple <string, Color>("Problem detected. Halting LPHP for 5 seconds.", Color.OrangeRed));

                    if (lastCompilerResult == 0)
                    {
                        nicLPHPNic.BalloonTipTitle = "LPHP Compilation Error";
                        nicLPHPNic.BalloonTipText  = "LPHP has encountered an error during compilation.\r\n Open LPHP for more information.";
                        nicLPHPNic.BalloonTipIcon  = ToolTipIcon.Error;
                        nicLPHPNic.ShowBalloonTip(3000);
                    }

                    Thread.Sleep(5000);
                }

                lastCompilerResult = watchdogResult;
            }
        }