builders: update cmake to match CMake plugin versions 2.x
Change-Id: I664b4e201825616c037ba2d53feafa5c0291e983 Signed-off-by: Lucas Dutra Nunes <ldnunes@ossystems.com.br> story: 2000438
This commit is contained in:
parent
bafc09598f
commit
e411ba62fc
@ -44,6 +44,7 @@ from jenkins_jobs.errors import JenkinsJobsException
|
||||
from jenkins_jobs.errors import MissingAttributeError
|
||||
import jenkins_jobs.modules.base
|
||||
from jenkins_jobs.modules.helpers import append_git_revision_config
|
||||
import pkg_resources
|
||||
from jenkins_jobs.modules.helpers import cloudformation_init
|
||||
from jenkins_jobs.modules.helpers import cloudformation_region_dict
|
||||
from jenkins_jobs.modules.helpers import cloudformation_stack
|
||||
@ -2088,22 +2089,20 @@ def cmake(parser, xml_parent, data):
|
||||
Execute a CMake target. Requires the Jenkins `CMake Plugin
|
||||
<CMake+Plugin>`.
|
||||
|
||||
This builder is compatible with both versions 2.x and 1.x of the
|
||||
plugin. When specifying paramenters from both versions only the ones from
|
||||
the installed version in Jenkins will be used, and the rest will be
|
||||
ignored.
|
||||
|
||||
:arg str source-dir: the source code directory relative to the workspace
|
||||
directory. (required)
|
||||
:arg str build-dir: The directory where the project will be built in.
|
||||
Relative to the workspace directory. (optional)
|
||||
:arg list install-dir: The directory where the project will be installed
|
||||
in, relative to the workspace directory. (optional)
|
||||
:arg list build-type: Sets the "build type" option. A custom type different
|
||||
than the default ones specified on the CMake plugin can also be set,
|
||||
which will be automatically used in the "Other Build Type" option of
|
||||
the plugin. (default Debug)
|
||||
|
||||
:type Default types present in the CMake plugin:
|
||||
* **Debug**
|
||||
* **Release**
|
||||
* **RelWithDebInfo**
|
||||
* **MinSizeRel**
|
||||
:arg str build-type: Sets the "build type" option for CMake (default
|
||||
"Debug").
|
||||
:arg str preload-script: Path to a CMake preload script file. (optional)
|
||||
:arg str other-arguments: Other arguments to be added to the CMake
|
||||
call. (optional)
|
||||
:arg bool clean-build-dir: If true, delete the build directory before each
|
||||
build (default false).
|
||||
|
||||
:arg list generator: The makefile generator (default "Unix Makefiles").
|
||||
|
||||
@ -2126,20 +2125,68 @@ def cmake(parser, xml_parent, data):
|
||||
* **Visual Studio 9 2008 Win64**
|
||||
* **Watcom WMake**
|
||||
|
||||
:arg str make-command: The make command (default "make").
|
||||
:arg str install-command: The install command (default "make install").
|
||||
:arg str preload-script: Path to a CMake preload script file. (optional)
|
||||
:arg str other-arguments: Other arguments to be added to the CMake
|
||||
call. (optional)
|
||||
:arg str custom-cmake-path: Path to cmake executable. (optional)
|
||||
:arg bool clean-build-dir: If true, delete the build directory before each
|
||||
build (default false).
|
||||
:arg bool clean-install-dir: If true, delete the install dir before each
|
||||
build (default false).
|
||||
:Version 2.x: Parameters that available only to versions 2.x of the plugin
|
||||
|
||||
Example:
|
||||
* **working-dir** (`str`): The directory where the project will be
|
||||
built in. Relative to the workspace directory. (optional)
|
||||
* **installation-name** (`str`): The CMake installation to be used on
|
||||
this builder. Use one defined in your Jenkins global configuration
|
||||
page (default "InSearchPath").
|
||||
* **build-tool-invocations** (`list`): list of build tool invocations
|
||||
that will happen during the build:
|
||||
|
||||
.. literalinclude:: ../../tests/builders/fixtures/cmake-complete.yaml
|
||||
:Build tool invocations:
|
||||
* **use-cmake** (`str`) -- Whether to run the actual build tool
|
||||
directly (by expanding ``$CMAKE_BUILD_TOOL``) or to have
|
||||
cmake run the build tool (by invoking ``cmake --build
|
||||
<dir>``) (default false).
|
||||
* **arguments** (`str`) -- Specify arguments to pass to the
|
||||
build tool or cmake (separated by spaces). Arguments may
|
||||
contain spaces if they are enclosed in double
|
||||
quotes. (optional)
|
||||
* **environment-variables** (`str`) -- Specify extra
|
||||
environment variables to pass to the build tool as
|
||||
key-value pairs here. Each entry must be on its own line,
|
||||
for example:
|
||||
|
||||
``DESTDIR=${WORKSPACE}/artifacts/dir``
|
||||
|
||||
``KEY=VALUE``
|
||||
|
||||
:Version 1.x: Parameters available only to versions 1.x of the plugin
|
||||
|
||||
* **build-dir** (`str`): The directory where the project will be built
|
||||
in. Relative to the workspace directory. (optional)
|
||||
* **install-dir** (`str`): The directory where the project will be
|
||||
installed in, relative to the workspace directory. (optional)
|
||||
* **build-type** (`list`): Sets the "build type" option. A custom type
|
||||
different than the default ones specified on the CMake plugin can
|
||||
also be set, which will be automatically used in the "Other Build
|
||||
Type" option of the plugin. (default "Debug")
|
||||
|
||||
:Default types present in the CMake plugin:
|
||||
* **Debug**
|
||||
* **Release**
|
||||
* **RelWithDebInfo**
|
||||
* **MinSizeRel**
|
||||
|
||||
* **make-command** (`str`): The make command (default "make").
|
||||
* **install-command** (`arg`): The install command (default "make
|
||||
install").
|
||||
* **custom-cmake-path** (`str`): Path to cmake executable. (optional)
|
||||
* **clean-install-dir** (`bool`): If true, delete the install dir
|
||||
before each build (default false).
|
||||
|
||||
Example (Versions 2.x):
|
||||
|
||||
.. literalinclude::
|
||||
../../tests/builders/fixtures/cmake/version-2.0/complete-2.x.yaml
|
||||
:language: yaml
|
||||
|
||||
Example (Versions 1.x):
|
||||
|
||||
.. literalinclude::
|
||||
../../tests/builders/fixtures/cmake/version-1.10/complete-1.x.yaml
|
||||
:language: yaml
|
||||
"""
|
||||
|
||||
@ -2153,6 +2200,49 @@ def cmake(parser, xml_parent, data):
|
||||
except KeyError:
|
||||
raise MissingAttributeError('source-dir')
|
||||
|
||||
XML.SubElement(cmake, 'generator').text = str(
|
||||
data.get('generator', "Unix Makefiles"))
|
||||
|
||||
XML.SubElement(cmake, 'preloadScript').text = str(
|
||||
data.get('preload-script', ''))
|
||||
|
||||
XML.SubElement(cmake, 'cleanBuild').text = str(
|
||||
data.get('clean-build-dir', False)).lower()
|
||||
|
||||
plugin_info = parser.registry.get_plugin_info("CMake plugin")
|
||||
version = pkg_resources.parse_version(plugin_info.get("version", "1.0"))
|
||||
|
||||
# Version 2.x breaks compatibility. So parse the input data differently
|
||||
# based on it:
|
||||
if version >= pkg_resources.parse_version("2.0"):
|
||||
XML.SubElement(cmake, 'workingDir').text = str(
|
||||
data.get('working-dir', ''))
|
||||
|
||||
XML.SubElement(cmake, 'buildType').text = str(
|
||||
data.get('build-type', 'Debug'))
|
||||
|
||||
XML.SubElement(cmake, 'installationName').text = str(
|
||||
data.get('installation-name', 'InSearchPath'))
|
||||
|
||||
XML.SubElement(cmake, 'toolArgs').text = str(
|
||||
data.get('other-arguments', ''))
|
||||
|
||||
tool_steps = XML.SubElement(cmake, 'toolSteps')
|
||||
|
||||
for step_data in data.get('build-tool-invocations', []):
|
||||
tagname = 'hudson.plugins.cmake.BuildToolStep'
|
||||
step = XML.SubElement(tool_steps, tagname)
|
||||
|
||||
XML.SubElement(step, 'withCmake').text = str(
|
||||
step_data.get('use-cmake', False)).lower()
|
||||
|
||||
XML.SubElement(step, 'args').text = str(
|
||||
step_data.get('arguments', ''))
|
||||
|
||||
XML.SubElement(step, 'vars').text = str(
|
||||
step_data.get('environment-variables', ''))
|
||||
|
||||
else:
|
||||
build_dir = XML.SubElement(cmake, 'buildDir')
|
||||
build_dir.text = data.get('build-dir', '')
|
||||
|
||||
@ -2161,14 +2251,14 @@ def cmake(parser, xml_parent, data):
|
||||
|
||||
# The options buildType and otherBuildType work together on the CMake
|
||||
# plugin:
|
||||
# * If the passed value is one of the predefined values, set buildType to
|
||||
# it and otherBuildType to blank;
|
||||
# * If the passed value is one of the predefined values, set buildType
|
||||
# to it and otherBuildType to blank;
|
||||
# * Otherwise, set otherBuildType to the value, and buildType to
|
||||
# "Debug". The CMake plugin will ignore the buildType option.
|
||||
#
|
||||
# It is strange and confusing that the plugin author chose to do something
|
||||
# like that instead of simply passing a string "buildType" option, so this
|
||||
# was done to simplify it for the JJB user.
|
||||
# It is strange and confusing that the plugin author chose to do
|
||||
# something like that instead of simply passing a string "buildType"
|
||||
# option, so this was done to simplify it for the JJB user.
|
||||
build_type = XML.SubElement(cmake, 'buildType')
|
||||
build_type.text = data.get('build-type', BUILD_TYPES[0])
|
||||
|
||||
@ -2180,33 +2270,25 @@ def cmake(parser, xml_parent, data):
|
||||
else:
|
||||
other_build_type.text = ''
|
||||
|
||||
generator = XML.SubElement(cmake, 'generator')
|
||||
generator.text = data.get('generator', "Unix Makefiles")
|
||||
|
||||
make_command = XML.SubElement(cmake, 'makeCommand')
|
||||
make_command.text = data.get('make-command', 'make')
|
||||
|
||||
install_command = XML.SubElement(cmake, 'installCommand')
|
||||
install_command.text = data.get('install-command', 'make install')
|
||||
|
||||
preload_script = XML.SubElement(cmake, 'preloadScript')
|
||||
preload_script.text = data.get('preload-script', '')
|
||||
|
||||
other_cmake_args = XML.SubElement(cmake, 'cmakeArgs')
|
||||
other_cmake_args.text = data.get('other-arguments', '')
|
||||
|
||||
custom_cmake_path = XML.SubElement(cmake, 'projectCmakePath')
|
||||
custom_cmake_path.text = data.get('custom-cmake-path', '')
|
||||
|
||||
clean_build_dir = XML.SubElement(cmake, 'cleanBuild')
|
||||
clean_build_dir.text = str(data.get('clean-build-dir', False)).lower()
|
||||
|
||||
clean_install_dir = XML.SubElement(cmake, 'cleanInstallDir')
|
||||
clean_install_dir.text = str(data.get('clean-install-dir',
|
||||
False)).lower()
|
||||
|
||||
# The plugin generates this tag, but there doesn't seem to be anything
|
||||
# that can be configurable by it. Let's keep it to mantain compatibility:
|
||||
# that can be configurable by it. Let's keep it to maintain
|
||||
# compatibility:
|
||||
XML.SubElement(cmake, 'builderImpl')
|
||||
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
plugins_info.yaml
|
@ -3,17 +3,17 @@
|
||||
<builders>
|
||||
<hudson.plugins.cmake.CmakeBuilder>
|
||||
<sourceDir>path/to/source</sourceDir>
|
||||
<generator>Unix Makefiles</generator>
|
||||
<preloadScript/>
|
||||
<cleanBuild>false</cleanBuild>
|
||||
<buildDir>path/to/build</buildDir>
|
||||
<installDir>path/to/install</installDir>
|
||||
<buildType>Debug</buildType>
|
||||
<otherBuildType/>
|
||||
<generator>Unix Makefiles</generator>
|
||||
<makeCommand>make</makeCommand>
|
||||
<installCommand>make install</installCommand>
|
||||
<preloadScript/>
|
||||
<cmakeArgs/>
|
||||
<projectCmakePath/>
|
||||
<cleanBuild>false</cleanBuild>
|
||||
<cleanInstallDir>false</cleanInstallDir>
|
||||
<builderImpl/>
|
||||
</hudson.plugins.cmake.CmakeBuilder>
|
@ -0,0 +1 @@
|
||||
plugins_info.yaml
|
@ -3,17 +3,17 @@
|
||||
<builders>
|
||||
<hudson.plugins.cmake.CmakeBuilder>
|
||||
<sourceDir>path/to/source</sourceDir>
|
||||
<generator>NMake Makefiles</generator>
|
||||
<preloadScript>path/to/source/cmake.preload</preloadScript>
|
||||
<cleanBuild>true</cleanBuild>
|
||||
<buildDir>path/to/build</buildDir>
|
||||
<installDir>path/to/install</installDir>
|
||||
<buildType>Debug</buildType>
|
||||
<otherBuildType>CustomReleaseType</otherBuildType>
|
||||
<generator>NMake Makefiles</generator>
|
||||
<makeCommand>/usr/bin/make</makeCommand>
|
||||
<installCommand>make new-install</installCommand>
|
||||
<preloadScript>path/to/source/cmake.preload</preloadScript>
|
||||
<cmakeArgs>-DCMAKE_FIND_ROOT_PATH="path/to/something/else"</cmakeArgs>
|
||||
<projectCmakePath>/usr/bin/cmake</projectCmakePath>
|
||||
<cleanBuild>true</cleanBuild>
|
||||
<cleanInstallDir>true</cleanInstallDir>
|
||||
<builderImpl/>
|
||||
</hudson.plugins.cmake.CmakeBuilder>
|
@ -0,0 +1,3 @@
|
||||
- longName: 'CMake plugin'
|
||||
shortName: 'cmakebuilder'
|
||||
version: "1.10"
|
@ -0,0 +1 @@
|
||||
plugins_info.yaml
|
16
tests/builders/fixtures/cmake/version-2.0/common-2.x.xml
Normal file
16
tests/builders/fixtures/cmake/version-2.0/common-2.x.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<hudson.plugins.cmake.CmakeBuilder>
|
||||
<sourceDir>path/to/source</sourceDir>
|
||||
<generator>Unix Makefiles</generator>
|
||||
<preloadScript/>
|
||||
<cleanBuild>false</cleanBuild>
|
||||
<workingDir>path/to/build</workingDir>
|
||||
<buildType>Debug</buildType>
|
||||
<installationName>InSearchPath</installationName>
|
||||
<toolArgs/>
|
||||
<toolSteps/>
|
||||
</hudson.plugins.cmake.CmakeBuilder>
|
||||
</builders>
|
||||
</project>
|
@ -0,0 +1,7 @@
|
||||
builders:
|
||||
- cmake:
|
||||
source-dir: 'path/to/source'
|
||||
working-dir: 'path/to/build'
|
||||
build-type: 'Debug'
|
||||
clean-build-dir: false
|
||||
clean-install-dir: false
|
@ -0,0 +1 @@
|
||||
plugins_info.yaml
|
31
tests/builders/fixtures/cmake/version-2.0/complete-2.x.xml
Normal file
31
tests/builders/fixtures/cmake/version-2.0/complete-2.x.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<hudson.plugins.cmake.CmakeBuilder>
|
||||
<sourceDir>path/to/source</sourceDir>
|
||||
<generator>NMake Makefiles</generator>
|
||||
<preloadScript>path/to/source/cmake.preload</preloadScript>
|
||||
<cleanBuild>true</cleanBuild>
|
||||
<workingDir>path/to/build</workingDir>
|
||||
<buildType>CustomReleaseType</buildType>
|
||||
<installationName>CMake custom install</installationName>
|
||||
<toolArgs>-DCMAKE_FIND_ROOT_PATH="path/to/something/else"</toolArgs>
|
||||
<toolSteps>
|
||||
<hudson.plugins.cmake.BuildToolStep>
|
||||
<withCmake>true</withCmake>
|
||||
<args>clean</args>
|
||||
<vars>DESTDIR=${WORKSPACE}/artifacts/dir
|
||||
URL=http://www.example.org/
|
||||
</vars>
|
||||
</hudson.plugins.cmake.BuildToolStep>
|
||||
<hudson.plugins.cmake.BuildToolStep>
|
||||
<withCmake>false</withCmake>
|
||||
<args>test</args>
|
||||
<vars>RESTRICT="TRUE"
|
||||
TARGET="NONE"
|
||||
</vars>
|
||||
</hudson.plugins.cmake.BuildToolStep>
|
||||
</toolSteps>
|
||||
</hudson.plugins.cmake.CmakeBuilder>
|
||||
</builders>
|
||||
</project>
|
22
tests/builders/fixtures/cmake/version-2.0/complete-2.x.yaml
Normal file
22
tests/builders/fixtures/cmake/version-2.0/complete-2.x.yaml
Normal file
@ -0,0 +1,22 @@
|
||||
builders:
|
||||
- cmake:
|
||||
source-dir: 'path/to/source'
|
||||
working-dir: 'path/to/build'
|
||||
install-dir: 'path/to/install'
|
||||
build-type: 'CustomReleaseType'
|
||||
generator: 'NMake Makefiles'
|
||||
installation-name: 'CMake custom install'
|
||||
preload-script: 'path/to/source/cmake.preload'
|
||||
other-arguments: '-DCMAKE_FIND_ROOT_PATH="path/to/something/else"'
|
||||
clean-build-dir: true
|
||||
build-tool-invocations:
|
||||
- use-cmake: true
|
||||
arguments: 'clean'
|
||||
environment-variables: |
|
||||
DESTDIR=${WORKSPACE}/artifacts/dir
|
||||
URL=http://www.example.org/
|
||||
- use-cmake: false
|
||||
arguments: 'test'
|
||||
environment-variables: |
|
||||
RESTRICT="TRUE"
|
||||
TARGET="NONE"
|
@ -0,0 +1,3 @@
|
||||
- longName: 'CMake plugin'
|
||||
shortName: 'cmakebuilder'
|
||||
version: "2.0"
|
Loading…
Reference in New Issue
Block a user