From fa580caa00588e86361cf5abcfcb8129afcab83a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Thu, 25 Apr 2024 16:13:46 -0300 Subject: [PATCH] Added some logs. --- src/tools/ecode/projectbuild.cpp | 11 ++++++++--- src/tools/ecode/terminalmanager.cpp | 30 ++++++++++++++++++----------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/tools/ecode/projectbuild.cpp b/src/tools/ecode/projectbuild.cpp index 23c412576..6dbb5aaa9 100644 --- a/src/tools/ecode/projectbuild.cpp +++ b/src/tools/ecode/projectbuild.cpp @@ -728,25 +728,30 @@ void ProjectBuildManager::runConfig( StatusAppOutputController* saoc ) { } } - if ( nullptr == run ) + if ( nullptr == run ) { + Log::info( "No run configuration found to run with runName: %s", mConfig.runName ); return; + } ProjectBuildCommand finalBuild( build->replaceVars( *run ) ); replaceDynamicVars( finalBuild ); - auto cmd = finalBuild.cmd + " " + finalBuild.args; + auto cmd = String::trim( finalBuild.cmd ) + " " + finalBuild.args; if ( finalBuild.runInTerminal ) { UITerminal* term = mApp->getTerminalManager()->createTerminalInSplitter( finalBuild.workingDir, false ); + Log::info( "Running \"%s\" in terminal", cmd ); if ( term == nullptr || term->getTerm() == nullptr ) { mApp->getTerminalManager()->openInExternalTerminal( cmd, finalBuild.workingDir ); } else { term->executeFile( cmd ); } } else { - // Sys::execute( cmd, finalBuild.workingDir ); + Log::info( "Running \"%s\" in app", cmd ); finalBuild.config = build->getConfig(); saoc->run( finalBuild, {} ); } + } else { + Log::info( "ProjectBuildManager::runConfig is already running or isRunningApp() is true" ); } } diff --git a/src/tools/ecode/terminalmanager.cpp b/src/tools/ecode/terminalmanager.cpp index 286f173e7..030e6c94b 100644 --- a/src/tools/ecode/terminalmanager.cpp +++ b/src/tools/ecode/terminalmanager.cpp @@ -339,17 +339,24 @@ if not %autoclose%==1 pause )shellscript"; if ( !cmd.empty() && !scriptsPath.empty() ) { std::string runHelperPath = scriptsPath + "ecode-run-helper.bat"; - if ( !FileSystem::fileExists( runHelperPath ) ) - FileSystem::fileWrite( runHelperPath, RUN_HELPER ); - std::string cmdDir = String::trim( FileSystem::fileRemoveFileName( cmd ) ); - if ( cmdDir.empty() ) - cmdDir = workingDir; - std::string cmdFile = String::trim( FileSystem::fileNameFromPath( cmd ) ); - auto fcmd = "cmd.exe /q /c " + quoteString( "\"" + runHelperPath + "\" \"" + cmdDir + - "\" 0 \"" + cmdFile + "\"" ); - Log::info( "Running: %s", fcmd ); - Sys::execute( fcmd, workingDir ); - return; + bool canContinue = true; + if ( !FileSystem::fileExists( runHelperPath ) ) { + if ( !FileSystem::fileWrite( runHelperPath, RUN_HELPER ) ) + canContinue = false; + } + if ( canContinue ) { + std::string cmdDir = String::trim( FileSystem::fileRemoveFileName( cmd ) ); + if ( cmdDir.empty() ) + cmdDir = workingDir; + std::string cmdFile = String::trim( FileSystem::fileNameFromPath( cmd ) ); + auto fcmd = "cmd.exe /q /c " + quoteString( "\"" + runHelperPath + "\" \"" + cmdDir + + "\" 0 \"" + cmdFile + "\"" ); + Log::info( "Running: %s", fcmd ); + Sys::execute( fcmd, workingDir ); + return; + } else { + Log::info( "Couldn't write runHelperPath %s", runHelperPath ); + } } std::vector options; @@ -406,6 +413,7 @@ static void openExternal( const std::string&, const std::string& cmd, const std: void TerminalManager::openInExternalTerminal( const std::string& cmd, const std::string& workingDir ) { + Log::info( "Trying to open in external terminal: %s %s", cmd, workingDir ); openExternal( mApp->termConfig().shell, cmd, mApp->getScriptsPath(), workingDir ); }