public void fShowFile() { if (bFileIsMoreRecent) { Output.Trace("\f67NewerFile: (" + Path.GetFileNameWithoutExtension(sPath) + "):" + oMoreRecent.sPath + ": " + oMoreRecent.dtModified + " : " + dtObjFile); } }
public static void fShowResult(OutToken _oOut) { string _sOut = _oOut.sOut; CppCmd _oCmd = _oOut.oFrom; if (Data.bNowBuilding) { if (fManageMessages(_oCmd, _sOut)) { return; } if (_oOut.eType == OutType.Undefined) { Output.TraceUndefined(_sOut); return; } if (_oOut.eType == OutType.Warning) { Output.TraceWarningLite(_sOut); return; } if (_oOut.eType == OutType.Error) { Output.TraceErrorLite(_sOut); return; } //Add color manually if (_sOut.Length > 8) { if (_sOut[7] == ':') //no color by default { bool bFound = false; string _sCmd = _sOut.Substring(0, 7).ToLower(); switch (_sCmd) { case "warning": bFound = true; Output.TraceWarning(_sOut); break; } } } string _sResult = Output.Trace(_sOut, true); /* * if( Data.oMainForm != null) { * Data.oMainForm.fAddItem(_sResult); * }*/ } }
public static void StopBuild() { Data.sCmd = ""; if (Data.bNowBuilding) { fDisableBuild(); Output.Trace("\f4C--Stop Build--"); SysAPI.KillProcessAndChildren(Data.MainProcess.Id); //fClearData(); //CppCompiler.safeInstanceCount = 0; } }
public void fShowInfo(ModuleData _oModule, bool _bShowInfo) { if (wBuildTime == null) { Output.Trace("\f1B --- End --- \f13 "); return; } wBuildTime.Stop(); double nfSec = wBuildTime.ElapsedMilliseconds / 1000.0; int _nSeconde = (int)(nfSec); int _nDotSeconde = ((int)(nfSec * 100.0)) - _nSeconde * 100; // if(Data.bInConsole && !bSubArgMan) { // if( !bSubArgMan) { if (_bShowInfo) { if (CppCompiler.nError > 0) { string _sS = "s"; if (CppCompiler.nError == 1) { _sS = ""; } string _sWhat = "\f4C --- End with "; if (_oModule != null) { _sWhat = "\f4C --- Finish - " + _oModule.sAutorName + " - with "; } Output.TraceColored(_sWhat + CppCompiler.nError.ToString() + " error" + _sS + " --- " + _nSeconde + "." + _nDotSeconde + " sec"); } else { if (_oModule != null) { // Output.Trace("\f27 --- Finish - " + _oModule.sAutorName +" - \f27 " + _nSeconde + "." + _nDotSeconde + " sec" ); Output.Trace("\f2B --- Finish - " + _oModule.sAutorName + " - \f2B " + _nSeconde + "." + _nDotSeconde + " sec"); } else { Output.Trace("\f1B --- End --- \f13 " + _nSeconde + "." + _nDotSeconde + " sec"); } } // } } }
public static ModuleData fAddRequiredModule(string _sName, bool _bIsCompiler = false) { ModuleData _oModule = ModuleData.fGetModule(_sName, _bIsCompiler); string _sLastVersion = _oModule.fGetLastVersions(); // string _sFolder = _oModuleLibRT.sOutFolder + _oModuleLibRT.sPrefixFolder + _sLastVersion; //Debug.fTrace("Last: " + _sFolder); // if( !Directory.Exists(_oModuleLibRT.sFolder) ) {//Double verification? if (aCompilerData.ContainsKey(_sName)) //Bug if already exist { aCompilerData.Remove(_sName); } aCompilerData.Add(_sName, _oModule); if (_oModule.sCurrFolder == "") //Not exist, we required downlaod //Is exist? //////////// { bModuleIsRequired = true; bStartWithMessage = true; //bDontExecute = true; foreach (string _sModule in aRequiredModule) { if (_sName == _sModule) { return(_oModule); } } if (_bIsCompiler) { Output.Trace("\f4CRequired compiler: " + _sName); } else { Output.Trace("\f4CRequired lib: " + _sName); } // Output.Trace("\f1B --- End --- \f13 " + _nSeconde + "." + _nDotSeconde + " sec" ); aRequiredModule.Add(_sName); } return(_oModule); }
public static void fPrjOut(string _sLetter, string _sOut) { if (_sOut == null) { return; } string _sPrefix = _sLetter + "> "; if (_sOut.Length > 4) //ex T[1]:xxxx { if (_sOut[1] == '[') { switch (_sOut[0]) { case 'P': Output.TraceGood(_sPrefix + _sOut); break; case 'E': Output.TraceError(_sPrefix + _sOut); break; case 'W': Output.TraceWarning(_sPrefix + _sOut); break; case 'A': Output.TraceAction(_sPrefix + _sOut); break; case 'T': Output.TraceStd(_sPrefix + _sOut); break; default: Output.Trace(_sPrefix + _sOut); break; } return; } } Output.Trace(_sPrefix + _sOut); return; }
public static void fShowArg(string _sArg, bool _bSubCmd = false) { if (_sArg == "") //Already shown { return; } if (Data.bNowBuilding) { if (_bSubCmd) { Output.Trace("\f1B:\f18" + _sArg); } else { Output.Trace("\f1B|\f16" + _sArg); } } }
private void fPrintBackTrace() { foreach (Frame _oFrame in aCurrBacktrace) { // Console.WriteLine("------ " + _oFrame.sFuncName + "(" + _oFrame.sFuncParam + ")" ); Output.Trace("\f0C>>---- \f1C" + _oFrame.sFuncName + "\f13(" + _oFrame.sFuncParam + ")\fs"); string _sLine = ":" + _oFrame.nLine; //TODO changing color break linking file // string _sLine = "\f05:" + _oFrame.nLine; if (_oFrame.sFile == "??") { _sLine = ""; } Output.Trace(" \f05at \f04" + _oFrame.sFile + _sLine); foreach (Var _oVar in _oFrame.aVar) { Output.Trace(" \f05-- \f06 " + _oVar.sName + " = " + _oVar.sValue); } Output.Trace(""); } }
public void fRecewiveMsg(string _sMsg) { Debug.fTrace(_sMsg); if (_sMsg.Length <= 2) { return; } //Invalid // try { if (_sMsg[1] == ':') { switch (_sMsg[0]) { case 'P': //Print Good Output.Trace(_sMsg.Substring(2)); break; case 'G': Output.TraceGood(_sMsg); break; case 'E': break; case 'C': //Print Good fPerformCommand(_sMsg.Substring(2)); break; case 'A': break; default: break; } } }
public static void EndExecution() { fDisableBuild(); Output.Trace("\f4C--End Execution--"); // KillProcessAndChildren( MainProcess.Id ); }
public static bool fLoadModules(bool _bAutoStart = true) { bool _bFound = true; if (Data.oGuiConsole != null) { Data.bIWantGoToEnd = true; GuiConsole.sFormCmd = "GoEnd"; //fctbConsole.GoEnd(); } nLoadModuleIndex = 0; foreach (string _sModule in Data.aRequiredModule) { ModuleData _oModule = ModuleData.fFindModule(_sModule); _oModule.fGetLocalVersions(); // Http.fGetHttp( _oModule.sUrl_Project , fGetProjectData);//Get readme _oModule.fReadHttpModuleTags(); } //Wait to finish while (ModuleData.nRequestTag > 0) { Thread.CurrentThread.Join(1); } List <ModuleLink> _aLink = new List <ModuleLink>(); foreach (string _sModule in Data.aRequiredModule) { ModuleData _oModule = ModuleData.fFindModule(_sModule); if (_oModule.aLinkList.Count > 0) { foreach (string _sKeyLink in _oModule.aLinkList) { // Output.TraceWarning( "Recommended version:"); Output.TraceAction("Recommended version:" + _oModule.sName + " : " + _sKeyLink); _aLink.Add(_oModule.aLink[_sKeyLink]); break; } } else { Output.TraceError("Not found:" + _sModule); _bFound = false; } } if (_aLink.Count > 0) { // Output.TraceWarning( "Download? (yes / no)"); Output.TraceWarning("Starting Download ... (press 'n' to cancel)"); foreach (ModuleLink _oLink in _aLink) { _oLink.fDownload(); while (_oLink.bDl_InProgress) { Thread.CurrentThread.Join(1); } _oLink.fExtract(); while (_oLink.oModule.bExtact_InProgress) { Thread.CurrentThread.Join(1); } } Output.Trace(""); Output.TraceGood("---------------- All Required Module Completed ------------------"); foreach (ModuleLink _oLink in _aLink) { Output.TraceAction(_oLink.oModule.sCurrFolder); } Output.TraceGood("-----------------------------------------------------------------"); if (_bAutoStart) { Data.sCmd = "StartBuild"; } } return(_bFound); /* * foreach(ModuleLink _oLink in _aLink) { * _oLink.fExtract(); * } */ // Data.oMsgForm.fLoadNextModule(); }
public void fCompleteExtractMainArgument(ModuleData _oModule = null, bool _bShowInfo = true) { Build.fEnableBuild(); ///Check missing modules lib //if(Data.aCompilerData.Count == 0){ //} // fLibRtExist(); //fGZE_Exist(); if (Data.bModuleIsRequired || Data.bDontExecute) //Stop if we need more modules { Build.fDisableBuild(); return; } if (_bShowInfo) { if (_oModule == null) { Output.Trace("\f2A--Start Build--"); } else { // Output.Trace("\f27 - Build " + _oModule.sAutorName + " - " + _oModule.sCurrFolder + " - " ); Output.Trace("\f2B - Build " + _oModule.sAutorName + " - " + _oModule.sCurrFolder + " - "); } } ///////////////// Extract Compilers fExtractCompiler(); if (Data.bModuleIsRequired) //For compiler with "Require" Node //TODO recursive { if (!Empty.fLoadModules(false)) { Build.fDisableBuild(); return; } Data.bModuleIsRequired = false; Data.aRequiredModule.Clear(); // Empty.fLoadModules(false);//Reload after download, or look for bExtracting before fGetLastVersions fMergeCompiler(); } fExtractCompiler(); foreach (CompilerData _oLib in aLibList) //TODO separate subcompiler and extract after!? //Console.WriteLine("Extract Lib: " + _oLib.sFullName); { Debug.fTrace("Extract Lib: " + _oLib.sFullName); _oLib.fExtract(this); } ///////////////////////////// //Output.Trace("\f2A-Extracted--"); /* * foreach(CppSeq _oSeq in aCppSeq) { * sCurr_wTo = ""; * foreach(CppCmd _oCmd in _oSeq.aCppCmd) { * // _oCmd.fExtract(); * } * } */ ArgProcess.fFinishExtractArg(); }
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); }
public void fAppOut(LaunchTool _oTool, string _sOut) { //bRunning= false; if (_sOut == null || _sOut == "") { return; } // Output.Trace("Test> " +_sOut); oLaunchProject.bReceiveOutput = true; string _sColor = ""; string _sLetter = "O"; if (bCmdSend) { if (fTestEndOfCommand(_sOut)) { // fTestFrame(_sOut); return; } else { _sLetter = "C"; _sOut = sCurrentCmd; } } // if ( _sOut.StartsWith("Breakpoint") ) { if (_sOut.IndexOf("it Breakpoint ", 0) != -1) //Hit breakpoint { if (_sOut.IndexOf("GDB_Func_ExecuteCmds") != -1) //Special function { _sColor = Output.sGoodColorLite; Output.Trace(_sLetter + "> " + _sColor + _sOut); oProcess.fSend("Continue"); return; } _sColor = Output.sWarningColor; Output.Trace(_sLetter + "> " + _sColor + _sOut); fShowBacktrace(); return; } //Thread 1 received signal SIGSEGV, Segmentation fault. //Program received signal SIGSEGV, Segmentation fault if (_sOut.IndexOf("received signal", 0) != -1) { _sColor = Output.sErrorColor; Output.Trace(_sLetter + "> " + _sColor + _sOut); fShowBacktrace(); return; } Output.fPrjOut(_sLetter, _sColor + _sOut); if (nLimitNbOutput == -1) { Output.TraceError("Error: Output exceed Limit"); } // Output.Trace(_sLetter + "> " +_sColor +_sOut); }
internal void fRun(ModuleData _oModule = null, bool _bDontExecute = false, bool _bShowInfo = true, bool _bSilent = false) { bFinalised = false; if (!_bDontExecute) { aExeWaitingList = new List <LaunchTool>(); fDeletOutput(); wBuildTime = new Stopwatch(); wBuildTime.Start(); // if(Data.oMainForm != null) { Data.oLaunchProject.fSetOutput(aLinkCmdList, sCurr_wTo); // } if (!Data.bNowBuilding) { return; } //TODO test if we really use libt // Output.Trace("\f9B>> \f97 " + sAllArg); } int i = 0; foreach (CppSeq _oSeq in aCppSeq) { i++; if (!_bSilent) { Output.Trace("\f1B> \f13" + _oSeq.sSeq); // Output.Trace("\f1B> \f13 " + CppCmd.fExtractVar( _oSeq.sSeq,null) ); //Todo preextract var? } sCurr_wTo = ""; foreach (CppCmd _oCmd in _oSeq.aCppCmd) { sCurr_wTo = ""; _oCmd.fExtract(); // _oCmd.fExecute(); if (!Data.bNowBuilding) { return; } if (CppCompiler.nError > 0) { break; } } if (i == aCppSeq.Count) //Only last one? { fFinalize(); } if (!_bDontExecute) { CppCompiler.CheckAllThreadsHaveFinishedWorking(true); foreach (CppCmd _oCmd in _oSeq.aCppCmd) { _oCmd.fExecute(); if (!Data.bNowBuilding) { fShowInfo(_oModule, !_bSilent); return; } if (CppCompiler.nError > 0) { break; } // Thread.Sleep(1); } // if(Data.oMainForm != null) { //TODO better way? // Data.oLaunchProject.fSetOutput(aLinkCmdList,sCurr_wTo); // } CppCompiler.CheckAllThreadsHaveFinishedWorking(true); fWaitForWaitingList(); foreach (CppCmd _oCmd in _oSeq.aCppCmd) { _oCmd.fFinish(); if (!Data.bNowBuilding) { fShowInfo(_oModule, !_bSilent); return; } if (CppCompiler.nError > 0) { break; } } Data.oLaunchProject.fSetOutput(aLinkCmdList, sCurr_wTo); if (!Data.bNowBuilding) { fShowInfo(_oModule, !_bSilent); return; } if (CppCompiler.nError > 0) { break; } } } if (_bDontExecute) { fShowInfo(_oModule, !_bSilent); return; } ///Finalize compiler commands /// fShowInfo(_oModule, _bShowInfo); }
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-"); }
/* * public void fLaunchExe(string _sExePath, bool _bSkipLinkTime = true) { * // Debug.fTrace("fLaunchExe! " + _sExePath); * if (sViewTarget != "Build Only" && !bExportCpp){ * string _sWorkPath = _sExePath; * string _sArg = ""; * * * if(Data.fGetGlobalVar("_sPlatform") == "Web_Emsc") { * * bWeb = true; * bSanitize = false; * sBrowser = Data.fGetViewIn(); * * _sArg = "\"" + Data.fGetGlobalVar("vWebRT_Emsc") + "emrun\" "; * //_sArg += "--serve_after_close "; * _sArg += " --kill_exit "; * //_sArg += " --kill_start "; * * * _sArg += "--browser \"" + sBrowser + "\" "; * _sArg += "\"" + _sExePath + "\" "; * * _sExePath = Data.fGetGlobalVar("vWebRT_Python") + "python.exe"; * * _sWorkPath = _sExePath; * * // public * } * * * bExeLaunch = true; * * CppCompiler.CheckAllThreadsHaveFinishedWorking(true); * * //////////////////////// * * BackgroundWorker bw = new BackgroundWorker(); * * bw.DoWork += new DoWorkEventHandler( * delegate(object o, DoWorkEventArgs args) { * * * if(bSanitize) { * bSanitize = false; * Output.TraceWarning("Sanitize feature not enabled for now, please wait for next update"); * } * * * * if(bSanitize) { * //_sArg = " -batch -brief " +_sArg + _sExePath; //-results_to_stderr * // _sArg = " -batch -brief " +_sArg + _sExePath; //-results_to_stderr * _sArg = " -batch -brief -drmemory " + PathHelper.ToolDir + "/drMemory/ -dr " + PathHelper.ToolDir + "/drMemory/dynamorio/ " +_sArg + _sExePath + " -lib_blacklist * "; //-results_to_stderr * _sExePath = "Utils\\drMemory\\bin\\drmemory.exe";//PathHelper.GetExeDirectory() ; * } * * sExePath = _sExePath; * sWorkPath = _sWorkPath; * * ProcessStartInfo processStartInfo = new ProcessStartInfo(_sExePath, _sArg); * processStartInfo.UseShellExecute = false; * //Debug.fTrace("process.StartInfo.FileName: " + processStartInfo.FileName + " " + processStartInfo.Arguments ); * * * ExeProcess = new Process(); * // ExeProcess.EnableRaisingEvents = true; * // ExeProcess.Exited += new EventHandler(myProcess_Exited); * * if(bSanitize) { * * // processStartInfo.CreateNoWindow = true; ///WORK!!!!! * processStartInfo.UseShellExecute = false; * // processStartInfo.RedirectStandardOutput = true; ///WORK!!!!! * processStartInfo.RedirectStandardError = true; * * * * ExeProcess.OutputDataReceived += (sender, e) => { * if (e.Data != null) { * fSanitizeAppOutput(e.Data); * } * }; * * ExeProcess.ErrorDataReceived += (sender, e) => { * if (e.Data != null) { * fSanitizeOutput(e.Data); * } * }; * } * * * * * * ExeProcess.StartInfo = processStartInfo; * processStartInfo.WorkingDirectory = Path.GetDirectoryName(_sWorkPath); //_sExePath PathHelper.ModulesDir + "/Emscripten_x64/python/2.7.5.3_64bit/"; //TODO * // Debug.fTrace("WorkingDirectory!: " + processStartInfo.WorkingDirectory ); * * * * bool processStarted = false; * * if (bStopAll) { * bExeLaunch = false; * return; * } * * try { * if (bHasError){ * return; * } * * * processStarted = ExeProcess.Start(); * * if(bSanitize) { * // ExeProcess.BeginOutputReadLine(); ///WORK!!!!! * ExeProcess.BeginErrorReadLine(); * } * * * ////////////////////////////// !!!!! Normal !!!!! ////////////////////////////// * * while (!ExeProcess.HasExited) { * Thread.Sleep(1); * if (bStopAll) { * break; * } * } * if(!bStopAll) { * Build.EndExecution(); * } * //////////////////////////////////////////////////////////////////////////////////////// * // } * if(oForm != null) { * oForm.fLaunchEnd(); * } * * * } * catch (Exception ex) * { * // TraceManager.Add("Error : " + ex.Message + " " + ex.Data + " " + ex.GetType().Name); * } * * * bExeLaunch = false; * * }); * bw.RunWorkerAsync(); * * } else{ * * //TraceManager.Add("Success \"" + sViewTarget + "\" project"); * * } * } */ internal void fEnd() { bStopAll = true; 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(); } } // _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(); } } if (!bSanitize) { try{ /* * if (ExeProcess.MainWindowHandle == IntPtr.Zero) { * * // ExeProcess.CloseMainWindow(); * ExeProcess.Kill(); * ExeProcess.Close(); * }else { */ if (ExeProcess.CloseMainWindow()) //Todo another process // SEND WM_CLOSE { ExeProcess.WaitForExit(1000); //if hang } if (!ExeProcess.HasExited) { ExeProcess.Kill(); } //ExeProcess.Close(); // } }catch (Exception Ex) { } } while (!ExeProcess.HasExited && Base.bAlive) { Thread.CurrentThread.Join(1); } }
public static void CopyFolderContents(string sourceFolder, string destinationFolder, string mask = "*.*", string _sExept = "", Boolean createFolders = true, Boolean recurseFolders = true) { Output.TraceAction("Copy: " + sourceFolder + " to " + destinationFolder); try { if (!(sourceFolder.EndsWith(@"\") || sourceFolder.EndsWith(@"/"))) { sourceFolder += @"\"; } sourceFolder = Path.GetFullPath(sourceFolder); string _sSingleFile = ""; bool _bSourceIsFile = false; if (!Directory.Exists(sourceFolder)) { if (File.Exists(sourceFolder)) //It's a file from source { _sSingleFile = sourceFolder.Substring(0, sourceFolder.Length - 1); sourceFolder = new FileInfo(_sSingleFile).Directory.FullName + "\\"; _bSourceIsFile = true; } else { return; //No source } } string _sDestFileName = ""; if (!_bSourceIsFile) { if (!(destinationFolder.EndsWith(@"\") || destinationFolder.EndsWith(@"/"))) { destinationFolder += @"\"; } } else //Source is a file { if ((destinationFolder.EndsWith(@"\") || destinationFolder.EndsWith(@"/"))) { destinationFolder += Path.GetFileName(sourceFolder); } else { //Debug.fTrace("destinationFolder " + destinationFolder); FileInfo _oFile = new FileInfo(destinationFolder); destinationFolder = _oFile.Directory.FullName + "\\"; //Debug.fTrace("----destinationFolder " + destinationFolder); _sDestFileName = _oFile.Name; } } destinationFolder = Path.GetFullPath(destinationFolder); var exDir = sourceFolder; var dir = new DirectoryInfo(exDir); string [] _aSourceFile; if (_bSourceIsFile) { _aSourceFile = new string[] { _sSingleFile }; } else { SearchOption so = (recurseFolders ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly); string _sDir = dir.ToString(); if (_sExept == "") { _aSourceFile = Directory.GetFiles(_sDir, mask, so); } else { _aSourceFile = Directory.GetFiles(_sDir, mask, so).Except(Directory.GetFiles(_sDir, _sExept, so)).ToArray(); } } // foreach (string sourceFile in Directory.GetFiles(dir.ToString(), mask, so).Where(file => Regex.IsMatch(file, @"^.+\.(cpp|hpp|hxx|gcpp|icpp|c|h)$")) ) foreach (string sourceFile in _aSourceFile) { FileInfo srcFile = new FileInfo(sourceFile); string srcFileName = srcFile.Name; // Create a destination that matches the source structure string _sFileRelPath = _sDestFileName; if (_sDestFileName == "") { _sFileRelPath = srcFile.FullName.Replace(sourceFolder, ""); } FileInfo destFile = new FileInfo(destinationFolder + _sFileRelPath); if (!Directory.Exists(destFile.DirectoryName) && createFolders) { Directory.CreateDirectory(destFile.DirectoryName); } if (!destFile.Exists || srcFile.LastWriteTime > destFile.LastWriteTime) { File.Copy(srcFile.FullName, destFile.FullName, true); Output.Trace("\f3FCopy: \f37 " + _sFileRelPath); } } } catch (Exception ex) { // System.Diagnostics.Debug.WriteLine(ex.Message + Environment.NewLine + Environment.NewLine + ex.StackTrace); //Debug.fTrace("Error copy: " + ex.Message + " " + ex.StackTrace); Output.TraceError("Error copy: " + ex.Message + " " + ex.StackTrace); } }
public static void fShowIntroMessage() { //Debug.fTrace("Number Of Logical Processors: {0}", Environment.ProcessorCount); //Output.Trace("\f0FCwC\fs was a intelligent \f0FCwim\fs & \f0FC++\fs compiler/manager, it can be used as a \f0Bdirect remplacement\fs of \f0FGCC\fs or \f0FClang\fs"); Output.Trace("\f0FCwc\fs is an intelligent frontend Multi-languages compiler \f0B(C, C++, C~, Python, ...)\fs, it can be used as a \f0Bdirect remplacement\fs of \f0FGCC\fs or \f0FClang\fs"); Output.Trace(""); // Output.TraceColored("\f08---- CwC Inteligent compiler main feature ---"); // Debug.fTrace(); Output.Trace("Now you can build files simultaneously, with multiple input and even directly by folder"); Output.Trace(""); Output.Trace("The \f0FC++\fs compiler, by default, use the backend toolchain \f0ALibRT\fs base on \f0AClang && MinGW\fs, to build \f0Aany C++ code\fs and \f0Across-compile\fs to others platforms."); // Output.Trace("If you want someting more complete & standard, you can configure another C++ compiler"); Output.Trace(""); // Output.Trace(" \f17-Use the \f1DSetting.ini\f17 to change configuration-"); Output.Trace("\f08---- Main Cwc usage ---"); Output.Trace("Cwc can be used as any stantdard compiler by command-line"); Output.Trace("He accept all arguments of standard compilers: GCC && Clang"); Output.Trace(""); Output.Trace("\f0FThe main addition is the separators \f0D|\fs && \f0D>\fs"); Output.Trace(""); Output.Trace(" \f0D|\fs Build multiples commands simultaneously (Multithread & Output is always in same order)"); Output.Trace(" \f0D>\fs Sequences your build -> Wait for previous commands"); Output.Trace(""); Output.Trace("\f08Exemple:\fs -c Src1.cpp -o Src1.o \f0D|\fs -c Src2.cpp -o Src2.o \f0D>\fs -o App.exe Src1.o Src2.o"); Output.Trace(""); Output.Trace(""); Output.Trace("--\f37 How to use:\fs "); Output.Trace(""); Output.Trace("\f0B- The Wiki: \fs[\f09 https://github.com/VLiance/Cwc/wiki/Wiki \fs] "); Output.Trace("\f0B- Directives: \fs[\f09 https://github.com/VLiance/Cwc/wiki/Directives \fs] "); Output.Trace("\f0B- Variables: \fs[\f09 https://github.com/VLiance/Cwc/wiki/Variables \fs] "); Output.Trace(""); Output.Trace(""); Output.Trace("--\f37 Try somes Cwc Examples:\fs "); Output.Trace(""); Output.Trace("\f0F- Main Cwc examples: \f1E L:[VLiance/Demos/]\fs"); Output.Trace("\f0B- Some libs using Cwc: \fs[\f09 https://github.com/Cwc-Lib/ \fs] "); /* * // Output.Trace(" \f0E-Compiler=LibRT\fs : \f0B(Default)\fs"); * * //Output.TraceColored(" \f0E-Compiler=<name>\fs "); * Output.Trace(""); * Output.Trace("\f08---- Choose your backend Toolchain --- \f0D(Host by default on Github)"); * Output.Trace(" \f0E-_wToolchain \f0B[Server]Autor/Name[Type]/(Version)\f08 : (Default:VLiance/LibRT)\fs"); * Output.Trace(""); * Output.Trace("\f08 ---- Examples ----"); * * Output.Trace(" \f06 -{_wToolchain}= VLianceTool/LibRT \f03(Build for Windows with Clang)\fs"); * Output.Trace(" \f06 -{_wToolchain}= VLianceTool/LibRT[Mingw] \f03(Build for Windows with Mingw)\fs"); * Output.Trace(" \f06 -{_wToolchain}= VLianceTool/WebRT \f03(Build for Web with Emsc)\fs"); * * * //Output.TraceColored("Designed to be lite & minimal, it doesn't contain every possible libs. If you really want it, it still compatible with all MinGw libs, but you may loose your portability."); * Output.Trace("");*/ /* * Output.Trace("\f08----- Build to Platform Flags ---"); * Debug.fTrace(); * Output.Trace(" \f0E-Windows\fs : \f0B(Default)\fs"); * Output.Trace(" \f0E-Web_Emsc\fs : Export to Web with Emscriptem"); * Output.Trace(" \f0E-CpcDos\fs : Export to CpcDos (Windows Compatible)"); * Debug.fTrace(); */ /* * Output.Trace("\f08----- Directives --- [\f09 https://github.com/VLiance/Cwc/wiki/Directives \fs] "); * * Output.Trace(" \f0E-#To\fs (output) : \f0BTake all preceding object files in the same sequence to make an Output (.exe/.a/.dll) \fs"); * Output.Trace(" \f0E-#Copy\fs (input) (output) : \f0BCopy all files if newer (accept folder) \fs"); * Output.Trace(" \f0E-#If_NotExist\fs (inputs) :: (PassCmd) : \f0BTest of non-existance of inputs files, if yes do the PassCmd \fs"); * * Output.Trace(""); * * * Output.Trace("\f08----- Variables --- [\f09 https://github.com/VLiance/Cwc/wiki/Variables \fs] " ); * //Output.Trace("\f0F Variables are between bracket \f0D'{}'\fs, begin with \f0D'_'\f0F (cwc var)\fs or \f0D'v'\f0F(custom var) \fs"); * Output.Trace("\f0F Variables are between bracket \f0D'{}'\fs"); * Output.Trace("\f08 ---- Example ----"); * Output.Trace(" \f0E{vHelloVar}=\f0BCustomPath/\fs Example: \f0B-c src/ -o bin/\f0D{vHelloVar}\f0Boutput/ \fsResult: \f0B-c src/ -o bin/CustomPath/output/"); * Output.Trace(""); */ }
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 ----"); }