Menu

cpp-front

Alexander Kornilov

Purpose

The plugin aims to support cppfront/cpp2 language in Gradle C++ projects.

Main features:
* integration with Gradle C++ plugins: application, library and unit-test
* embedded cppfront compiler for Windows/Linux x86-64 (current version is v0.8.1)
* support of main compiler features in plugin configuration
* parallel compilation

Required plugins

The cpp-front requires to work other Gradle core plugins: cpp-application/cpp-library/cpp-unit-test.

Usage

plugins {
    `cpp-application`
    `cpp-unit-test`

    id("net.sf.loggersoft.cpp-front") version "0.1"
}

Configuration

cppFront {
    //source.from(fileTree("dir" to "src/main/cpp2.bak", "includes" to listOf("*.cpp2")))
    //source.setFrom(fileTree("dir" to "src/main/cpp2/win", "includes" to listOf("*.cpp2")))
    //testSource.from(fileTree("dir" to "src/main/cpp2/win", "includes" to listOf("*.cpp2")))

    // The compiler binary file or path to home (inside expected 'bin' and 'include' subdirectories)
    //compilerHint = "/usr/bin/cppfront"
    //compilerHint = "C:\\Software\\cppfront\\bin\\cppfront.exe"

    //rawArgs = listOf("-verb")

    //pureCpp2 = true
    //importStd = true
    //includeStd = true
    //emitCleanCpp1 = true
    //noExceptions = true
    //noRtti = true
    //noComparisonChecks = true
    //noDivZeroChecks = true
    //noNullChecks = true
    //noSubscriptChecks = true
}

source - the main source set of the project (default is src/main/cpp2).
testSource - the test source set of the project (default is src/test/cpp2).
compilerHint - the path to home directory of cppfront toolchain (bin inside expected) or full path to cppfront compiler binary.
rawArgs - the raw command line arguments for cppfront compiler. Should begins from -
pureCpp2 - allow Cpp2 syntax only - also sets -import-std.
importStd - import all std:: via 'import std;' - ignored if -include-std is set.
includeStd - #include all std:: headers.
emitCleanCpp1 - emit clean Cpp1 without #line directives.
noExceptions - disable C++ EH - failed 'as' for 'variant' will assert.
noRtti - disable C++ RTTI - using 'as' for std::any will assert.
noComparisonChecks - disable mixed-sign comparison safety checks.
noDivZeroChecks - disable integer division by zero checks.
noNullChecks - disable null safety checks.
noSubscriptChecks - disable subscript safety checks.

Tasks

cppFrontVersion - information about cppfront toolchain

$ gradle cppFrontVersion

> Task :cppfront-app:cppFrontVersion
cpp-front compiler:
  version: v0.8.1 Build 9B08:1148
  home: /home/akornilov/.gradle/plugins/cpp-front
  compiler: /home/akornilov/.gradle/plugins/cpp-front/bin/cppfront
  include directory: /home/akornilov/.gradle/plugins/cpp-front/include

BUILD SUCCESSFUL in 817ms
21 actionable tasks: 1 executed, 20 up-to-date

Example:

Full sources of simple cppfront-app.


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.