Skip to content

Commit

Permalink
[JENKINS-27203] eliminated double variable expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
15knots committed Jun 19, 2015
1 parent c0dbeff commit e775945
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
22 changes: 9 additions & 13 deletions src/main/java/hudson/plugins/cmake/CmakeBuilder.java
Expand Up @@ -145,13 +145,12 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
listener.getLogger().println(ioe.getMessage());
return false;
}
String theBuildType = prepareBuildType();

listener.getLogger().println("Build dir : " + theBuildDir.toString());
listener.getLogger().println("Source dir : " + theSourceDir.toString());
listener.getLogger().println("Install dir : " + theInstallDir.toString());
String cmakeCall = prepareCmakeCall(build, listener, envs,
theSourceDir, theInstallDir, theBuildType);
theSourceDir, theInstallDir);
listener.getLogger().println("CMake call : " + cmakeCall);

final CmakeLauncher cmakeLauncher =
Expand All @@ -162,11 +161,11 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
return false;
}

if (!cmakeLauncher.launchMake(getMakeCommand())) {
if (!cmakeLauncher.launchMake( Util.replaceMacro(getMakeCommand(), envs))) {
return false;
}

return cmakeLauncher.launchInstall(installDir, getInstallCommand());
return cmakeLauncher.launchInstall(installDir, Util.replaceMacro(getInstallCommand(), envs));
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException ie) {
Expand All @@ -177,21 +176,18 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen

private String prepareCmakeCall(AbstractBuild<?, ?> build,
BuildListener listener, EnvVars envs, String theSourceDir,
String theInstallDir, String theBuildType) throws IOException,
String theInstallDir) throws IOException,
InterruptedException {
String cmakeBin = checkCmake(build.getBuiltOn(), listener, envs);
String cmakeCall =
builderImpl.buildCMakeCall(cmakeBin,
this.generator,
this.preloadScript,
Util.replaceMacro(this.generator, envs),
Util.replaceMacro(this.preloadScript,envs),
theSourceDir,
theInstallDir,
theBuildType, Util.replaceMacro(cmakeArgs, envs));
return Util.replaceMacro(cmakeCall, envs);
}

private String prepareBuildType() {
return this.buildType;
Util.replaceMacro(this.buildType, envs),
Util.replaceMacro(cmakeArgs, envs));
return cmakeCall;
}

private String prepareInstallDir(BuildListener listener, EnvVars envs,
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/hudson/plugins/cmake/CmakeLauncher.java
Expand Up @@ -3,7 +3,6 @@
import hudson.EnvVars;
import hudson.FilePath;
import hudson.Launcher;
import hudson.Util;
import hudson.model.BuildListener;

import java.io.IOException;
Expand Down Expand Up @@ -39,7 +38,6 @@ public boolean launchMake(String makeCommand) throws IOException, InterruptedExc
if (makeCommand.trim().isEmpty()) {
return true;
}
makeCommand = Util.replaceMacro(makeCommand, envs);
int result = launcher.launch().stdout(listener).cmdAsSingleString(makeCommand).envs(this.envs)
.pwd(new FilePath(this.workSpace, this.buildDir)).join();
return (result == 0);
Expand All @@ -51,7 +49,6 @@ public boolean launchInstall(String installDir, String installCommand) throws IO
if (!doInstall) {
return true;
}
installCommand = Util.replaceMacro(installCommand, this.envs);
int result = launcher.launch().stdout(listener).cmdAsSingleString(installCommand).envs(this.envs)
.pwd(new FilePath(this.workSpace, this.buildDir)).join();
return (result == 0);
Expand Down

0 comments on commit e775945

Please sign in to comment.