Skip to content
Permalink
Browse files

Progress on [JENKINS-38227]

  • Loading branch information...
15knots committed Sep 16, 2016
1 parent ebb3ea2 commit cfa73debff9f0706e9b20b40b906788795ff79ed
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>cmakebuilder</name>
<comment/>
<comment>The Jenkins Plugins Parent POM Project. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
<projects/>
<buildSpec>
<buildCommand>
@@ -106,14 +106,11 @@ protected Object readResolve() {
*/
@DataBoundSetter
public void setGenerator(String generator) {
generator = Util.fixEmptyAndTrim(generator);
this.generator = DescriptorImpl.getDefaultGenerator().equals(generator)
? null : generator;
this.generator = Util.fixEmptyAndTrim(generator);
}

public String getGenerator() {
return this.generator == null ? DescriptorImpl.getDefaultGenerator()
: generator;
return generator;
}

@DataBoundSetter
@@ -303,7 +300,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
* the name of the cmake binary, either as an absolute or
* relative file system path.
* @param generator
* the name of the build-script generator
* the name of the build-script generator or {@code null}
* @param preloadScript
* name of the pre-load a script to populate the cache or
* {@code null}
@@ -323,7 +320,9 @@ private static ArgumentListBuilder buildCMakeCall(final String cmakeBin,
ArgumentListBuilder args = new ArgumentListBuilder();

args.add(cmakeBin);
args.add("-G").add(generator);
if (generator != null) {
args.add("-G").add(generator);
}
if (preloadScript != null) {
args.add("-C").add(preloadScript);
}
@@ -410,14 +409,6 @@ public DescriptorImpl() {
load();
}

/**
* Gets the default generator to use if the builder`s generator field is
* <code>null</code>.
*/
public static String getDefaultGenerator() {
return "Unix Makefiles";
}

/**
* This human readable name is used in the configuration screen.
*/
@@ -4,7 +4,7 @@
<f:select />
</f:entry>
<f:entry title="Script Generator" field="generator">
<f:textbox default="${descriptor.defaultGenerator}" />
<f:textbox />
</f:entry>
<f:entry title="Source Directory" field="sourceDir">
<f:textbox />
@@ -1,5 +1,5 @@
<div>CMake´s <a href="http://www.cmake.org/cmake/help/latest/manual/cmake-generators.7.html#cmake-generators" target="_blank">
buildscript generator</a> to use (e.g. <code>Unix Makefiles</code>).</br>
buildscript generator</a> to use (e.g. <code>Unix Makefiles</code>). Leave empty to let CMake choose a generator.</br>
Possible generators include:
<ul>
<li><a href="http://www.cmake.org/cmake/help/latest/generator/Borland Makefiles.html">Borland Makefiles</a></li>
@@ -19,6 +19,8 @@
<li><a href="http://www.cmake.org/cmake/help/latest/generator/Xcode.html">Xcode</a> (<code><strong>CMAKE_BUILD_TOOL</strong></code> not exposed,
<a href="https://issues.jenkins-ci.org/browse/JENKINS-29142" target="_blank">generation failure workaround</a>)</li>
</ul>
<p><strong>HINT</strong>: This field does not require quotes if the
generator name contains spaces.</p>
<p>
The build tool corresponding to the specified script generator is exposed in the
<code><strong>CMAKE_BUILD_TOOL</strong></code> build variable,
@@ -27,6 +29,4 @@
from the generated CMake cache file, but these generators do not set
<code>CMAKE_MAKE_PROGRAM</code> at buildscript <strong>generation</strong> time).<br>
</p>
<p><strong>HINT</strong>: This field does not require quotes if the
generator name contains spaces.</p>
</div>
@@ -1,8 +1,7 @@
package hudson.plugins.cmake;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNull;

import org.junit.Test;

@@ -13,29 +12,13 @@
*/
public class CmakeBuilderTest {

/**
* Verify that a default generator is set.
*/
@Test
public void testDefaultGenerator() throws Exception {
CmakeBuilder cmb = new CmakeBuilder(CmakeTool.DEFAULT);
final String generator = cmb.getGenerator();
assertNotNull(generator);
assertTrue(generator.trim().length() > 0);
}

/**
* Verify that a default generator is set even if set to null.
*/
@Test
public void testDefaultGeneratorSet() throws Exception {
public void testSetGenerator() throws Exception {
CmakeBuilder cmb = new CmakeBuilder(CmakeTool.DEFAULT);
final String setGenerator = "null: gipsnich";
cmb.setGenerator(setGenerator);
assertEquals(setGenerator, cmb.getGenerator());
cmb.setGenerator(null);
String generator = cmb.getGenerator();
assertNotNull(generator);
assertTrue(generator.trim().length() > 0);
assertNull(cmb.getGenerator());
}
}

0 comments on commit cfa73de

Please sign in to comment.
You can’t perform that action at this time.