Menu

cpp-build-tuner

Alexander Kornilov
There is a newer version of this page. You can find it here.

Purpose

The plugin provides basic build tuning according to the current profile (Debug/Release) and used toolchain. Also, some customization is available via the plugin configuration section.

Required plugins

The cpp-build-tuner require to work another Gradle core plugins: cpp-application/cpp-library/cpp-unit-test.

Usage

plugins {
    id 'cpp-library'
    id 'cpp-unit-test'
    id 'loggersoft.cpp-build-tuner' version '1.1'
}

Supported toolchains

MSVC and GCC compatible toolchains.

Profit

The plugin tries to reduce build time for the Debug variant and save maximum information for debugging. In opposite, for Release variant debug information is disabled and maximum speed optimizations (include link-time optimizations) are enabled.

Configuration

buildTuner {

    lto = false

    gtest = '1.8.1'

    libraries {
        common = ['cutils.lib']
        windows = ['ole32', 'user32']
        linux = ['pthread', 'z']
    }

    libDirs.common = ['../build/debug', '../release']
}
  • lto (boolean) - disable or enable LTO (link-time optimizations) on Release. By default LTO is enabled.
  • gtest (string) - the version of Google Test for test binary. At the moment only version 1.8.1 for GCC, MinGW-W64, and MSVC is supported.
  • libraries (container) - the list of libraries for the linker. The field has three parameters (list of strings) inside: common - libraries which will be used on any platform, windows - only on Windows and linux - only on Linux.
  • libDirs (container) - the list of directories on the local file system to search the linker libraries. Inside has the same platform-specific structure as the libraries container (see above).

Run application

The plugin provides an extension for cpp-application which allow running application via Gradle (like as Java Application plugin).
For application projects, a plugin adds tasks: run, runDebug (same as run) and runRelease. Those tasks depend on assemble, assembleDebug and assembleRelease correspondently.
Also, you can pass command-line arguments as in Java Application plugin:

gradle run --args="arg1 arg2 ..."

MongoDB Logo MongoDB