示例#1
0
文件: Build.cs 项目: VLiance/Cwc-src
        public static void StopBuild()
        {
            Data.sCmd = "";
            if (Data.bNowBuilding)
            {
                fDisableBuild();
                Output.Trace("\f4C--Stop Build--");
                SysAPI.KillProcessAndChildren(Data.MainProcess.Id);
                //fClearData();

                //CppCompiler.safeInstanceCount = 0;
            }
        }
示例#2
0
        internal static void fLaunchUpdate(string sCurrFolder, string _sVersion)
        {
            LaunchTool _oUpd = new LaunchTool();

            _oUpd.bOutput         = false;
            _oUpd.UseShellExecute = true;
            _oUpd.fLaunchExe(sCurrFolder + "cwc.exe", " -wCwcUpd " + PathHelper.GetExeDirectory() + " -wCwcVer " + _sVersion, "", "", true);
            //		Console.WriteLine("Update to ver "  +_sVersion );
            while (!_oUpd.bExeLaunched && Base.bAlive)
            {
                Thread.Sleep(1);
            }
            SysAPI.fQuit(true);
        }
示例#3
0
        internal static void fRestart(string sCurrFolder)
        {
            LaunchTool _oUpd = new LaunchTool();

            _oUpd.bOutput         = false;
            _oUpd.UseShellExecute = true;
            //	_oUpd.fLaunchExe( sCurrFolder + "cwc.exe", "Updated ", "","",true);
            _oUpd.fLaunchExe(sCurrFolder + "cwc.exe", "-wCwcUpdated " + Data.sUpdateVer, "", "", true);
            //				_process.StartInfo.Arguments = "Updated " + _sVersion + " " + Data.sWorkDir + " " + Data.sResendArg;
            while (!_oUpd.bExeLaunched && Base.bAlive)
            {
                Thread.Sleep(1);
            }
            SysAPI.fQuit(true);
        }
示例#4
0
文件: SysAPI.cs 项目: VLiance/Cwc-src
        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);
            }
        }
示例#5
0
        static int Main(string[] args)
        {
            // redirect console output to parent process;
            // must be before any calls to Console.WriteLine()
            AttachConsole(ATTACH_PARENT_PROCESS);

            Sys.fGetParentProcess();
            Console.WriteLine("Systeme mode: " + Sys.sParentName);

            if (Sys.sParentName == "cmd")
            {
                Data.bConsoleMode = true;
            }

            Data.fSetDefaultVar(args);
            Data.fCheckUpdate();

            Data.fCreateConfigMng();

            if (Data.bConsoleMode)
            {
                SysAPI.fStartConsole();
            }

            if (!Data.bConsoleMode || SysAPI.bIsLoadedFromAnotherCwcInstance)
            {
                Data.bGUI = false;
                if (!Data.bModeIDE)
                {
                    // Base.bAlive = false; //not work??
                }
            }

            Data.fGetMainArg();
            fCheckForRegistringFiles();

            if (!Data.bConsoleMode)
            {
                GuiManager.fCreateGUI();
            }


            if (Data.sArg == "") //No Argument

            {
                Output.Trace("\f0AVersion " + Data.sVersion + "\fs \n");
                Msg.fShowIntroMessage();
                SysAPI.fSetWorkingDir(PathHelper.ExeWorkDir);
            }
            else
            {
                Console.WriteLine("fBeginBuild ");
                Build.fBeginBuild();
            }

            CppCompiler.CheckAllThreadsHaveFinishedWorking(true);
            Build.fDisableBuild();

            if (Data.oGuiConsole != null)
            {
                if (!Data.oGuiConsole.fCheckForDemos())
                {
                    Program.fCheckForRegistringFiles(true); //Register if first use
                }
            }

            if (!Data.bConsoleMode)
            {
                if (Data.bModeIDE)
                {
                    Base.bAlive = true;
                    // PipeInput.fLaunchPipeInput();
                }
                Build.fStartLoopTestingIdeLinkedClosing();
            }
            Build.fMainLoop();

            //if(Data.bConsoleMode) {SendKeys.SendWait("{ENTER}"); }
            return(0);
        }
示例#6
0
        internal void fEnd()
        {
            //  Output.Trace("\f18--Try to Close--");
            bStopAll = true;

            if (dExit != null)
            {
                dExit(this);
            }
            ;
            SysAPI.KillProcessAndChildren(Data.MainProcess.Id);   //TODO more gentle with -- SEND WM_CLOSE -- ?


            while (!ExeProcess.HasExited && Base.bAlive)
            {
                Thread.CurrentThread.Join(1);
            }


            return;


///////////////////////////////////////////////

            if (bSanitize)
            {
                List <Process> children = GetChildProcesses(ExeProcess);
                foreach (Process _procChild in children)
                {
                    // Debug.fTrace("---------------ID: " + _procChild.Id.ToString());

                    //      Debug.fTrace("sExePath: " +sExePath);


                    /* //Try to nurge, (not the besst way)
                     * ProcessStartInfo processStartInfo = new ProcessStartInfo(sExePath, " -nudge " + _procChild.Id.ToString());
                     * processStartInfo.UseShellExecute = false;
                     *
                     * ExeProcess.StartInfo = processStartInfo;
                     * processStartInfo.WorkingDirectory = Path.GetDirectoryName(sWorkPath); //_sExePath PathHelper.ModulesDir + "/Emscripten_x64/python/2.7.5.3_64bit/"; //TODO
                     * ExeProcess.Start();
                     */

                    try{
                        if (_procChild.CloseMainWindow())   //Todo another process  // SEND WM_CLOSE
                        //	Debug.fTrace("");
                        {
                            Output.Trace("\f4C-- SEND WM_CLOSE --");
                            //   _procChild.WaitForExit(1000); //if hang
                        }
                        else
                        {
                            if (!_procChild.HasExited)
                            {
                                Output.Trace("\f4C-- KILL --");
                                _procChild.Kill();
                                if (dExit != null)
                                {
                                    dExit(this);
                                }
                                ;
                            }
                        }
                        // _procChild.Close();
                    }catch (Exception Ex) { }


                    // .CloseMainWindow();


                    //   _procChild.WaitForExit(1000); //if hang


                    //      _procChild.WaitForExit(1000); //if hang
                    //    _procChild.Kill();
                    //  _procChild.CloseMainWindow();
                    //   _procChild.Close();
                    //  ExeProcess.Clos();
                    //  _procChild.Kill();
                }
            }
            else
            {
                List <Process> children = GetChildProcesses(ExeProcess);
                foreach (Process _procChild in children)  //TODO recursive of child process?

                {
                    try{
                        //Output.TraceError("Try to kill");

                        /*
                         * if (ExeProcess.MainWindowHandle == IntPtr.Zero) {
                         *
                         * // ExeProcess.CloseMainWindow();
                         *     ExeProcess.Kill();
                         *     ExeProcess.Close();
                         * }else {
                         */
                        if (!_procChild.HasExited)
                        {
                            //  Output.TraceError("not HasExited");

                            try{ if (_procChild.CloseMainWindow()) //Todo another process  // SEND WM_CLOSE
                                 {
                                     _procChild.WaitForExit(1000); //if hang
                                 }
                            }catch (Exception Ex) { }


                            if (!_procChild.HasExited)
                            {
                                // Output.TraceError("alwaus not HasExited");
                                //  Output.Trace("\f4C-- KILL --");
                                _procChild.Kill();
                                if (dExit != null)
                                {
                                    dExit(this);
                                }
                                ;
                            }
                        }



                        //ExeProcess.Close();
                        // }
                    }catch (Exception Ex) { }
                }
            }

            while (!ExeProcess.HasExited && Base.bAlive)
            {
                Thread.CurrentThread.Join(1);
            }
            //             Output.Trace("\f18-Finish-");
        }
示例#7
0
        public static void fUpdateFiles(string _sSource)
        {
            Base.bAlive = true;
//Thread.Sleep(10000);

            Output.TraceGood("Update Cwc to ver: " + Data.sUpdateVer);

            string _sBaseSrc  = PathHelper.GetExeDirectory();
            string _sBaseDest = _sSource;


            // Output.TraceGood("Copy Tools: " +_sBaseSrc  + "Tools/"+   "    "+_sBaseDest + "Tools/");

            try {
                FileUtils.CopyFolderContents(_sBaseSrc + "Utils/", _sBaseDest + "Utils/");                 //TODO on run pass only?
            }catch (Exception e) {
                Output.TraceError(e.Message);
            }

            Output.Trace("--- Copy Cwc ----");
            //Thread.Sleep(10);

            //Use Retry
            int    _nCount      = 16;
            int    _nRetryCount = _nCount;
            string _sErrror     = "";

            while (_nRetryCount > 0)
            {
                try {
                    _sErrror = "";
                    File.Copy(_sBaseSrc + "cwc.exe", _sBaseDest + "cwc.exe", true);
                    //_nRetryCount  =0;
                    break;
                }catch (Exception e) {
                    if (_nRetryCount == _nCount - 1)
                    {
                        Output.TraceWarning(e.Message);
                        Output.TraceWarning("Retrying...");
                    }
                    else
                    {
                        if (_nRetryCount != _nCount)
                        {
                            Output.TraceWarning(_nRetryCount.ToString());
                        }
                    }
                    _nRetryCount--;
                    Thread.Sleep(1000);
                    //Output.TraceError(e.GetType().Name);//IOException


                    _sErrror = e.Message;
                }
            }
            if (_sErrror != "")
            {
                Output.TraceError("Can't update cwc, please retry later...");
                Thread.Sleep(3000);
            }
            else
            {
                Output.TraceGood("--- Done ----");
//				Thread.Sleep(3000);
            }



            fRestart(_sBaseDest);
            //Cwc copy
            SysAPI.fQuit();


            //Console.WriteLine("--- Done ----");
        }
示例#8
0
        public static string fExpand(string _sFullArg, int _nIndex)
        {
//	Debug.fTrace("---fExpand!!!!! " + _sFullArg);
            //List<string> _sList = new List<string> ();

            string _sResult    = "";
            int    _nSartIndex = 0;
            int    _nEndIndex  = 0;
            int    _nIndexOfA  = _nIndex;

            ///////////////////////////////// Begin with @
            while (_nIndexOfA != -1)
            {
                _sResult  += _sFullArg.Substring(_nSartIndex, _nIndexOfA - _nSartIndex);
                _nEndIndex = fGetEndFile(_sFullArg, _nIndexOfA + 1);


                string _sFile = _sFullArg.Substring(_nIndexOfA + 1, _nEndIndex - (_nIndexOfA + 1));

                //Debug.fTrace("-****************************!!!fExpand  " + _sFile);
                if (_sFile == "wDeloc")                  //Special deloc command to quit
                //Debug.fTrace("!!!---DELOCATISE!!!!!");
                {
                    _sFullArg = _sFullArg.Replace("@wDeloc", "");                     //remove all wDeloc
                    Console.Error.WriteLine("wOut|" + _sFullArg);                     //Use special stream to resend args
                    SysAPI.fQuit(true);
                }


                string _sPath;
                if (_sFile.Length > 2 && _sFile[1] == ':')                 //Absolute path
                {
                    _sPath = _sFile;
                }
                else
                {
                    _sPath = PathHelper.ExeWorkDir + _sFile;                     //Relative path
                }

                string _sText = "";

                string _sExt = Path.GetExtension(_sPath).ToLower();



                try {
                    switch (_sExt)
                    {
                    case ".bat":
                    case ".exe":
                        _sText = Delocalise.fDelocalise(_sPath);
                        break;

                    default:
                        _sText = File.ReadAllText(_sPath);

                        break;
                    }
                }catch (Exception Ex) {
                    Output.TraceError("Error Expand File: " + Ex.Message + " : " + _sPath);
                };

                _sResult   += _sText;
                _nSartIndex = _nEndIndex;

                //   _nSartIndex = _nEndIndex;
                _nIndexOfA = _sFullArg.IndexOf('@', _nEndIndex);
            }

            _sResult += _sFullArg.Substring(_nEndIndex, _sFullArg.Length - _nEndIndex);



            /*
             * string[] _aFiles =   _sFullArg.Split('@');
             * foreach(string _sFileArg in _aFiles) {
             *
             *  int _nIndex = _sFileArg.IndexOf(' ');
             *  if(_nIndex == -1) {
             *      _nIndex = _sFileArg.IndexOf('\t');  //TODO make "OR" combinaison
             *  }
             *  if(_nIndex == -1) {
             *      _nIndex = _sFileArg.IndexOf('\n');
             *  }
             *  if(_nIndex == -1) {
             *      _nIndex = _sFileArg.IndexOf('|');
             *  }
             *  if(_nIndex == -1) {
             *      _nIndex = _sFileArg.IndexOf('>');
             *  }
             *   if(_nIndex == -1) {
             *      _nIndex = _sFileArg.Length;
             *  }
             *
             *   string _sFile = _sFileArg.Substring(0, _nIndex);
             *
             *   string _sPath = PathHelper.GetCurrentDirectory() + _sFile;
             *   string _sText = "";
             *  try {
             *      _sText = File.ReadAllText(_sPath);
             *  }catch(Exception Ex) {};
             *
             *   string _sArg =  _sFileArg.Substring(_nIndex);
             *  _sResult += _sText + _sArg;
             *
             *
             * }     */

            //   return _sResult.Replace('\n', ' ');
            //  return _sResult.Replace('\n', ' ').Replace('\r', ' ');
            return(_sResult);
        }
示例#9
0
 public override void fStop()
 {
     SysAPI.fSend_CTRL_C(oProcess.ExeProcess);
     bRunning = false;
     oProcess.fSend("break");
 }