Changeset View
Changeset View
Standalone View
Standalone View
plugins/executescript/scriptappjob.cpp
Show All 23 Lines | |||||
24 | #include <QFileInfo> | 24 | #include <QFileInfo> | ||
25 | 25 | | |||
26 | #include <KLocalizedString> | 26 | #include <KLocalizedString> | ||
27 | #include <KProcess> | 27 | #include <KProcess> | ||
28 | #include <KSharedConfig> | 28 | #include <KSharedConfig> | ||
29 | #include <KShell> | 29 | #include <KShell> | ||
30 | 30 | | |||
31 | #include <interfaces/ilaunchconfiguration.h> | 31 | #include <interfaces/ilaunchconfiguration.h> | ||
32 | #include <interfaces/iruntimecontroller.h> | ||||
33 | #include <interfaces/iruntime.h> | ||||
32 | #include <outputview/outputmodel.h> | 34 | #include <outputview/outputmodel.h> | ||
33 | #include <outputview/outputdelegate.h> | 35 | #include <outputview/outputdelegate.h> | ||
34 | #include <util/processlinemaker.h> | 36 | #include <util/processlinemaker.h> | ||
35 | #include <util/environmentprofilelist.h> | 37 | #include <util/environmentprofilelist.h> | ||
36 | 38 | | |||
37 | #include <interfaces/icore.h> | 39 | #include <interfaces/icore.h> | ||
38 | #include <interfaces/iplugincontroller.h> | 40 | #include <interfaces/iplugincontroller.h> | ||
39 | #include <interfaces/idocumentcontroller.h> | 41 | #include <interfaces/idocumentcontroller.h> | ||
40 | #include <project/projectmodel.h> | 42 | #include <project/projectmodel.h> | ||
43 | #include <util/path.h> | ||||
41 | 44 | | |||
42 | #include "iexecutescriptplugin.h" | 45 | #include "iexecutescriptplugin.h" | ||
43 | #include "debug.h" | 46 | #include "debug.h" | ||
44 | 47 | | |||
45 | using namespace KDevelop; | 48 | using namespace KDevelop; | ||
46 | 49 | | |||
47 | ScriptAppJob::ScriptAppJob(ExecuteScriptPlugin* parent, KDevelop::ILaunchConfiguration* cfg) | 50 | ScriptAppJob::ScriptAppJob(ExecuteScriptPlugin* parent, KDevelop::ILaunchConfiguration* cfg) | ||
48 | : KDevelop::OutputJob( parent ), proc(new KProcess( this )), lineMaker(new KDevelop::ProcessLineMaker( proc, this )) | 51 | : KDevelop::OutputJob( parent ), proc(new KProcess( this )), lineMaker(new KDevelop::ProcessLineMaker( proc, this )) | ||
Show All 32 Lines | 52 | { | |||
81 | } else { | 84 | } else { | ||
82 | KDevelop::IDocument* document = KDevelop::ICore::self()->documentController()->activeDocument(); | 85 | KDevelop::IDocument* document = KDevelop::ICore::self()->documentController()->activeDocument(); | ||
83 | if( !document ) | 86 | if( !document ) | ||
84 | { | 87 | { | ||
85 | setError( -1 ); | 88 | setError( -1 ); | ||
86 | setErrorText( i18n( "There is no active document to launch." ) ); | 89 | setErrorText( i18n( "There is no active document to launch." ) ); | ||
87 | return; | 90 | return; | ||
88 | } | 91 | } | ||
89 | script = document->url(); | 92 | script = ICore::self()->runtimeController()->currentRuntime()->pathInRuntime(KDevelop::Path(document->url())).toUrl(); | ||
90 | } | 93 | } | ||
91 | 94 | | |||
92 | if( !err.isEmpty() ) | 95 | if( !err.isEmpty() ) | ||
93 | { | 96 | { | ||
94 | setError( -3 ); | 97 | setError( -3 ); | ||
95 | setErrorText( err ); | 98 | setErrorText( err ); | ||
96 | return; | 99 | return; | ||
97 | } | 100 | } | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | |||||
140 | // Now setup the process parameters | 143 | // Now setup the process parameters | ||
141 | 144 | | |||
142 | proc->setEnvironment(environmentProfiles.createEnvironment(envProfileName, proc->systemEnvironment())); | 145 | proc->setEnvironment(environmentProfiles.createEnvironment(envProfileName, proc->systemEnvironment())); | ||
143 | QUrl wc = iface->workingDirectory( cfg ); | 146 | QUrl wc = iface->workingDirectory( cfg ); | ||
144 | if( !wc.isValid() || wc.isEmpty() ) | 147 | if( !wc.isValid() || wc.isEmpty() ) | ||
145 | { | 148 | { | ||
146 | wc = QUrl::fromLocalFile( QFileInfo( script.toLocalFile() ).absolutePath() ); | 149 | wc = QUrl::fromLocalFile( QFileInfo( script.toLocalFile() ).absolutePath() ); | ||
147 | } | 150 | } | ||
148 | proc->setWorkingDirectory( wc.toLocalFile() ); | 151 | proc->setWorkingDirectory( ICore::self()->runtimeController()->currentRuntime()->pathInRuntime(KDevelop::Path(wc)).toLocalFile() ); | ||
149 | proc->setProperty( "executable", interpreter.first() ); | 152 | proc->setProperty( "executable", interpreter.first() ); | ||
150 | 153 | | |||
151 | QStringList program; | 154 | QStringList program; | ||
152 | if (!remoteHost.isEmpty()) { | 155 | if (!remoteHost.isEmpty()) { | ||
153 | program << QStringLiteral("ssh"); | 156 | program << QStringLiteral("ssh"); | ||
154 | QStringList parts = remoteHost.split(QLatin1Char(':')); | 157 | QStringList parts = remoteHost.split(QLatin1Char(':')); | ||
155 | program << parts.first(); | 158 | program << parts.first(); | ||
156 | if (parts.length() > 1) { | 159 | if (parts.length() > 1) { | ||
Show All 16 Lines | |||||
173 | 176 | | |||
174 | void ScriptAppJob::start() | 177 | void ScriptAppJob::start() | ||
175 | { | 178 | { | ||
176 | qCDebug(PLUGIN_EXECUTESCRIPT) << "launching?" << proc; | 179 | qCDebug(PLUGIN_EXECUTESCRIPT) << "launching?" << proc; | ||
177 | if( proc ) | 180 | if( proc ) | ||
178 | { | 181 | { | ||
179 | startOutput(); | 182 | startOutput(); | ||
180 | appendLine( i18n("Starting: %1", proc->program().join(QLatin1Char( ' ' ) ) ) ); | 183 | appendLine( i18n("Starting: %1", proc->program().join(QLatin1Char( ' ' ) ) ) ); | ||
181 | proc->start(); | 184 | ICore::self()->runtimeController()->currentRuntime()->startProcess(proc); | ||
182 | } else | 185 | } else | ||
183 | { | 186 | { | ||
184 | qWarning() << "No process, something went wrong when creating the job"; | 187 | qWarning() << "No process, something went wrong when creating the job"; | ||
185 | // No process means we've returned early on from the constructor, some bad error happened | 188 | // No process means we've returned early on from the constructor, some bad error happened | ||
186 | emitResult(); | 189 | emitResult(); | ||
187 | } | 190 | } | ||
188 | } | 191 | } | ||
189 | 192 | | |||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |