Пример #1
0
        static public void fQuit(bool _bForceQuitConsole = false)
        {
            //      MessageBox.Show("QUIIIIIIIIIIIIIIII!!!!!!!!!!");

            /*
             * if (oLaunchProject.oCurLaunch != null && oLaunchProject.oCurLaunch.sExeName == "gdb") {
             *  oLaunchProject.oCurLaunch.fSend("set confirm off");
             *  oLaunchProject.oCurLaunch.fSend("quit");
             * }*/
            //fSaveConsolePosition();

            if (!bQuitSavedCfg)
            {
                bQuitSavedCfg = true;
                Data.oConfigMng.SaveConfig();                     //save screenn coordinate
            }

            //	MessageBox.Show("QUIIIIIIIIIIIIIIII!!!!!!!!!! ",  "ass", MessageBoxButtons.OK, MessageBoxIcon.Warning);
//MessageBox.Show("********QUIIIIIIIIIIIIIIII!!!!!!!!!! ",  "aaa", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            Base.bAlive   = false;
            Data.bModeIDE = false;
            Build.StopBuild();
            Thread.CurrentThread.Join(1);


/*
 *                if(oMainForm != null && !oMainForm.IsDisposed) {
 *                              oMainForm.AppQuit();
 *                      }*/

            SysAPI.KillProcessAndChildren(Data.MainProcess.Id);
            //	PipeInput.fTestIdeClosed();

/*
 *           if(oMainForm != null) {
 *              oMainForm.AppQuit();
 *          }*/
            if (_bForceQuitConsole)
            {
                //   Thread.Sleep(1000); //Last chance for other thread
                Thread.Sleep(90);    //Last chance for other thread
                Environment.Exit(1);
            }
        }
Пример #2
0
        public void fCancel()
        {
            if (oCurLaunch != null)
            {
                oCurLaunch.fEnd();
                //   Build.fDisableBuild();
                //   oCurLaunch = null;
                //   Data.EndExecution();
            }
            else if (Data.bNowBuilding)
            {
                Build.StopBuild();
            }
            else
            {
                //    fResetList();
                //  Data.StartBuild();
                //  Data.sCmd = "StartBuild";

                //Start Last Launch
                Delocalise.fDelocaliseInMainThread(Config.sLastRecentPath);
            }
        }
Пример #3
0
        public void fGetCompilerList()
        {
            if (bGetCompilerList)
            {
                return; //Already done
            }
            bGetCompilerList = true;
            Output.TraceAction("Get: " + sName);


            //fGetCompilerData
            //Debug.fTrace("fGetCompilerList : " +  sCurrFolder + "wType/");
            aCompilerData = new List <CompilerData>();
            aPlatformData = new Dictionary <string, CompilerData>();


            string _sFoundPath = PathHelper.fFindFolder(sCurrFolder, "cwc", 5);

            if (_sFoundPath == "")  //Default
            {
                _sFoundPath = sCurrFolder;
            }
            // Output.TraceAction("FOund?: " + _sFoundPath);
            String[] _aFiles = Directory.GetFiles(_sFoundPath, "*.cwcfg");
            if (_aFiles.Length == 0)
            {
                Output.TraceError("Cannot find '*.cwcfg' file in " + sCurrFolder);
                Data.bDontExecute = true;
                Build.StopBuild();
                return;
            }
            foreach (string _sCwcfg_File in _aFiles)
            {
                //     Output.TraceGood("Found " +  _sCwcfg_File);
                CompilerData _oCompilerData = new CompilerData(this, _sCwcfg_File);
                if (bIsCompiler)//It's a Compiler
                {
                    aCompilerData.Add(_oCompilerData);
                    //Output.TraceGood("Add:  " + _oCompilerData.sSubName);
                    aPlatformData.Add(_oCompilerData.sSubName, _oCompilerData);
                }
                else   //It's a lib
                {
                    oLibData = _oCompilerData;
                }
            }

            /*
             *
             *          string _sCompilerPlatform = sCurrFolder+ "wType/";
             *          if(!Directory.Exists(_sCompilerPlatform)) {//backward compatibility
             *      _sCompilerPlatform = sCurrFolder+ "_sPlatform/";
             * }
             *          if(Directory.Exists(_sCompilerPlatform)) {
             *
             *                  string[] _aFile = Directory.GetFiles( _sCompilerPlatform,"*.xml");
             *                  foreach (string _sFile in  _aFile){
             *                  //	Debug.fTrace("found:  " + _sFile);
             *                          CompilerData _oCompilerData = new CompilerData(this, _sFile );
             *                          aCompilerData.Add(_oCompilerData);
             *                                          //Debug.fTrace("Add:  " + _oCompilerData.sSubName);
             *                          aPlatformData.Add(_oCompilerData.sSubName,_oCompilerData );
             *                  }
             *                  if(_aFile.Length == 0){
             *                          Output.TraceError("Compiler " +sAutorName +  " 'wType' forlder require xml data");
             *                          Data.bDontExecute = true;
             *                          Build.StopBuild();
             *                  }
             *          //Debug.fTrace("---------------------:  " );
             *          }else{
             *                  Output.TraceError("Compiler " + sAutorName +  " require '_sPlatform' forlder with xml data");
             *                  Data.bDontExecute = true;
             *                  Build.StopBuild();
             *          }
             */
        }
Пример #4
0
        internal static string fSend2App(CppCmd _oCmd, string _sExplicite_Name, string _sExplicite_App, string _sExplicite_Call, bool _bWaitToFinish = false, List <CppCmd> aSubInputCmd = null)
        {
            bool _bFinished = false;

            if (_bWaitToFinish)
            {
                sProcOutputRetrun = "";
            }

            string _sExe = fExtracQuote(_sExplicite_App);
            string _sArg = fExtracQuote_sArg + " " + _sExplicite_Call;

            //TODO merge with fSend2Compiler
            Output.TraceAction(_sExplicite_Name + " => " + _sExplicite_Call);

            uint _nMyTicket = 0;

            lock (oLockTicket) {
                _nMyTicket = nTotalTicket;
                nTotalTicket++;
            }

            if (bHasError || !Data.bNowBuilding)
            {
                return("");
            }

            CheckAllThreadsHaveFinishedWorking();
            if (bHasError || !Data.bNowBuilding)
            {
                return("");
            }
            Interlocked.Increment(ref safeInstanceCount);

            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += new DoWorkEventHandler(
                delegate(object o, DoWorkEventArgs args){
                if (bHasError || !Data.bNowBuilding)
                {
                    Interlocked.Decrement(ref safeInstanceCount);
                    return;
                }

                StringBuilder output = new StringBuilder();
                StringBuilder error  = new StringBuilder();

                using (AutoResetEvent outputWaitHandle = new AutoResetEvent(false))
                    using (AutoResetEvent errorWaitHandle = new AutoResetEvent(false)) {
                        using (Process process = new Process()) {
                            _oCmd.oCurrProcess     = process;
                            _oCmd.sLaunchCmdResult = "";

                            process.StartInfo.FileName  = _sExe;
                            process.StartInfo.Arguments = _sArg;

                            process.StartInfo.CreateNoWindow = true;
                            //process.StartInfo.CreateNoWindow = false;
                            process.StartInfo.UseShellExecute        = false;
                            process.StartInfo.RedirectStandardOutput = true;
                            process.StartInfo.RedirectStandardError  = true;

                            if (aSubInputCmd != null)
                            {
                                process.StartInfo.RedirectStandardInput = true;
                            }

                            process.StartInfo.WorkingDirectory = _oCmd.s_pProject;

                            try  {
                                process.OutputDataReceived += (sender, e) => {
                                    if (e.Data != null)
                                    {
                                        fCompilerError(e.Data, _sExplicite_Name + " : " + _sExplicite_Call, _nMyTicket, false, _oCmd);
                                    }
                                };
                                process.ErrorDataReceived += (sender, e) => {
                                    if (e.Data != null)
                                    {
                                        fCompilerError(e.Data, _sExplicite_Name + " : " + _sExplicite_Call, _nMyTicket, true, _oCmd);
                                    }
                                };

                                Console.WriteLine("Start " + process.StartInfo.FileName);
                                Console.WriteLine("arg " + process.StartInfo.Arguments);

                                process.Start();
                                process.BeginOutputReadLine();
                                process.BeginErrorReadLine();
                                fLaunchInputApp(process, aSubInputCmd);

                                process.WaitForExit();
                                ///////////////////////////////////////
                                ///Wait for displaying in order
                                ////////////////////////////////////////*
                                while (Base.bAlive && Data.bNowBuilding)
                                {
                                    Thread.CurrentThread.Join(1);
                                    lock (oLockTicket) {
                                        if (nCurrentTicket == _nMyTicket)
                                        {
                                            // Console.WriteLine("*** Process  " + nCurrentTicket + " " + _oCmd == null );
                                            fShowSendedCmd(_oCmd);
                                            fShowProcOutput(_oCmd);
                                            if (nErrorTicket == nCurrentTicket && (nError > 0))
                                            {
                                                //Console.WriteLine(":: " +  GuiForm.fIsChecked("afterFileErrorToolStripMenuItem")); //TODO TODOTODO
                                                fShowProcOutput(_oCmd);
                                                Build.StopBuild(); //Dont display other file errors
                                                break;
                                            }
                                            nCurrentTicket++;
                                            break;
                                        }
                                    }
                                }
                                ///////////////////////////////////////////////
                            }catch (Exception e) {
                                Output.TraceError("Error with " + process.StartInfo.FileName + "[" + process.StartInfo.Arguments + "]:" + e.Message);
                            } finally {}

                            try { while (!process.HasExited)
                                  {
                                      Thread.CurrentThread.Join(1);
                                      if (!Data.bNowBuilding)
                                      {
                                          break;
                                      }
                                  }
                            }catch (Exception e) {}

                            _bFinished = true;
                            Interlocked.Decrement(ref safeInstanceCount); //safeInstanceCount never decremented if after  fAddCommandLineVerificationToDepedancesFile?? on link time : exception?
                        }
                    }
            });
            worker.RunWorkerAsync();

            if (_oCmd.bRetryForInput)
            {
                while (!_bFinished)
                {
                    Thread.CurrentThread.Join(1);
                }
                if (_oCmd.sLaunchCmdResult == "")
                {
                    //Recursive call
                    //Thread.Sleep(1); //Minimal wait
                    return(fSend2App(_oCmd, _sExplicite_Name, _sExplicite_App, _sExplicite_Call, _bWaitToFinish, aSubInputCmd));
                }
                return(_oCmd.sLaunchCmdResult);
            }

            if (_bWaitToFinish)
            {
                while (!_bFinished)
                {
                    Thread.CurrentThread.Join(1);
                }
                return(sProcOutputRetrun.Trim());
            }

            return("");
        }
Пример #5
0
        public static void fSend2Compiler(string _sArg, bool _bLinkTime = false, bool _bCompileAndLink = false, CppCmd _oCmd = null, string _sAllFile = "")
        {
            //string _sPlatform = _oCmd.oParent.sPlatform;
            string _sPlatform = _oCmd.oParent.fGetVar("_sPlatform");

            if (_oCmd.oCompiler == null)
            {
                //Debug.fTrace("Unknow Compiler");
                Output.TraceError("Unknow Compiler");
                return;
            }

            string _sInfo = "";

            if (_oCmd != null && _bLinkTime)
            {
                if (_oCmd.bToStaticLib)
                {
                    _sInfo = " [Static_Link]";
                }
                else if (_oCmd.bToDynamicLib)
                {
                    _sInfo = " [Dynamic_Link]";
                }
                else
                {
                    _sInfo = " [Link]";
                }
            }

            string _sObjectList = "";

            if (_sAllFile != "")
            {
                _sObjectList = "[\f1B" + _sAllFile + "\f1F]";
            }

            string _sFinalArg = _sArg.Replace("\\\"", "\"");

            _sFinalArg = _sFinalArg.Replace("%%", "¶"); //A way to keep %
            _sFinalArg = _sFinalArg.Replace('%', '\\'); //Backslash special char % transform, we must have a ways to send backslash to compiler
            _sFinalArg = _sFinalArg.Replace('¶', '%');  //A way to keep %

            _oCmd.sCommandToShow = "\f1F (" + _oCmd.sExecutableName + _oCmd.sExecutableType + _sInfo + ")" + _sObjectList + "  " + _sFinalArg;

            uint _nMyTicket = 0;

            lock (oLockTicket) {
                _nMyTicket = nTotalTicket;
                nTotalTicket++;
            }

            if (bHasError || !Data.bNowBuilding)
            {
                return;
            }

            CheckAllThreadsHaveFinishedWorking();
            if (bHasError || !Data.bNowBuilding)
            {
                return;
            }
            Interlocked.Increment(ref safeInstanceCount);
            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += new DoWorkEventHandler(
                delegate(object o, DoWorkEventArgs args)
            {
                if (bHasError || !Data.bNowBuilding)
                {
                    Interlocked.Decrement(ref safeInstanceCount);
                    // Debug.fTrace("Dec " + safeInstanceCount);
                    return;
                }

                StringBuilder output = new StringBuilder();
                StringBuilder error  = new StringBuilder();

                using (AutoResetEvent outputWaitHandle = new AutoResetEvent(false))
                    using (AutoResetEvent errorWaitHandle = new AutoResetEvent(false))
                    {
                        using (Process process = new Process()) {
                            process.StartInfo.FileName  = _oCmd.sExecutable;
                            process.StartInfo.Arguments = _sFinalArg;

                            process.StartInfo.CreateNoWindow         = true;
                            process.StartInfo.UseShellExecute        = false;
                            process.StartInfo.RedirectStandardOutput = true;
                            process.StartInfo.RedirectStandardError  = true;

                            process.StartInfo.WorkingDirectory = _oCmd.s_pProject;

                            try  {
                                if (process.StartInfo.FileName.Length + process.StartInfo.Arguments.Length >= 32700) // Command line size limitation, real 32768
                                //Todo verify for .wdat folder?
                                {
                                    process.StartInfo.Arguments = "@.wdat/arg.wdat";
                                    File.WriteAllText(@".wdat/arg.wdat", _sFinalArg);
                                }

                                process.OutputDataReceived += (sender, e) => { if (e.Data != null)
                                                                               {
                                                                                   fCompilerError(e.Data, _sArg, _nMyTicket, false, _oCmd);
                                                                               }
                                };
                                process.ErrorDataReceived += (sender, e) => { if (e.Data != null)
                                                                              {
                                                                                  fCompilerError(e.Data, _sArg, _nMyTicket, true, _oCmd);
                                                                              }
                                };

                                process.Start();
                                process.BeginOutputReadLine();
                                process.BeginErrorReadLine();
                                process.WaitForExit();

                                ///////////////////////////////////////
                                ///Wait for displaying in order
                                //////////////////////////////////////
                                while (Base.bAlive && Data.bNowBuilding)
                                {
                                    Thread.CurrentThread.Join(1);
                                    lock (oLockTicket) {
                                        if (nCurrentTicket == _nMyTicket)
                                        {
                                            fShowSendedCmd(_oCmd);
                                            fShowProcOutput(_oCmd);

                                            if (nErrorTicket == nCurrentTicket && (nError > 0))  //&& GuiForm.fIsChecked("afterFileErrorToolStripMenuItem") //TODO
                                            {
                                                fShowProcOutput(_oCmd);
                                                Build.StopBuild(); //Dont display other file errors
                                                break;
                                            }


                                            nCurrentTicket++;
                                            break;
                                        }
                                    }
                                }
                                ////////////////////////////////////
                            }catch (Exception e) {
                                Output.TraceError(e.Message);
                                string _sSended = process.StartInfo.FileName + " " + process.StartInfo.Arguments;
                                Output.TraceAction(_sSended);
                                if (_sSended.Length >= 32768)
                                {
                                    Output.TraceWarning("You may have exceeded the maximum command line size of 32768 characters: " + _sSended.Length + " chars");
                                }
                                Interlocked.Decrement(ref safeInstanceCount);
                                return;
                            }



                            while (!process.HasExited)
                            {
                                Thread.CurrentThread.Join(1);
                                if (!Data.bNowBuilding)
                                {
                                    break;
                                }
                            }

                            Interlocked.Decrement(ref safeInstanceCount); //safeInstanceCount never decremented if after  fAddCommandLineVerificationToDepedancesFile?? on link time : exception?
                            if (_oCmd != null && !_bLinkTime)
                            {
                                _oCmd.fAddCommandLineVerificationToDepedancesFile(_oCmd); //TODO is infinite loop?
                            }
                        }
                    }
            });
            worker.RunWorkerAsync();
        }