Hi, we have a project that uses the native software model to compile cpp components and now I want to use the new ” cpp-library ” plugin .
Can someone help me with that?. I have tried to change few things but the userguide seems to be missing few things I need.
Thanks in advance
The file is as below ::
description = 'Loader'
apply plugin: 'google-test-test-suite'
// compile cpp
model {
binaries {
all {
if (toolChain in Gcc)
{
// setting for debug and code coverage
if ( project.hasProperty("debug") && project.properties['debug']){
cppCompiler.args "-O0", "-g3", "-fexceptions", "-fpermissive", "-Wno-write-strings", "-coverage"
cppCompiler.args "-fPIC", "-m64"
linker.args "-coverage"
}
// setting for optimized build
cppCompiler.args "-O3", "-fexceptions", "-fpermissive", "-Wno-write-strings"
cppCompiler.args "-fPIC", "-m64"
}
}
withType(GoogleTestTestSuiteBinarySpec) {
cppCompiler.define "QGC_UNIT_TEST"
lib library: "gtest", linkage: "static"
lib project: ":qgi", library: "tdqgi", linkage: "static"
cppCompiler.args '-pthread', '-lrt', '-coverage'
linker.args '-pthread', '-ldl', '-lrt', '-coverage'
}
}
components {
tdqgc(NativeLibrarySpec) {
version computeVersion(connectorsVersion)
sources {
cpp {
source {
srcDirs "src/main/cpp/"
include "*.cpp", "*.cc"
}
exportedHeaders {
srcDirs "src/main/cpp",
"${project(':qgi').projectDir}/src/main/cpp/include/"
include "*.h", "*.hpp"
}
lib library: 'jsoncpp', linkage: 'static'
lib project: ':qgi', library: 'uds', linkage: 'static'
lib project: ':qgi', library: 'shm', linkage: 'static'
}
}
}
}
testSuites {
qgcTest(GoogleTestTestSuiteSpec) {
sources{
cpp {
source {
srcDirs 'src/test/cpp'
include "*.cpp"
}
lib project: ':qgi', library: 'uds', linkage: 'static'
lib project: ':qgi', library: 'shm', linkage: 'static'
}
}
testing $.components.tdqgc
}
}
tasks {
copyDependentDebugObjects(Copy) {
from "${rootDir}/qgi/toolchain/jsoncpp/libjsoncpp.a"
from "${project(':qgi').buildDir}/objs/shm/static/shmCpp/"
from "${project(':qgi').buildDir}/objs/uds/static/udsCpp/"
into "${project.buildDir}/objs/main/shared/mainCpp"
}
tdqgcStaticLibrary.dependsOn copyDependentDebugObjects
makeLibjsoncpp(Exec) {
workingDir "${project(':qgi').projectDir}/toolchain/jsoncpp"
commandLine 'make'
}
linkTdqgcSharedLibrary.dependsOn makeLibjsoncpp
}
repositories {
libs(PrebuiltLibraries) {
tdqgi {
headers.srcDir "${project(':qgi').projectDir}/src/main/cpp/include"
binaries.withType(StaticLibraryBinary) {
staticLibraryFile = file("${project(':qgi').projectDir}/build/libs/tdqgi/static/libtdqgi.a")
}
}
jsoncpp {
headers.srcDir "${rootDir}/qgi/toolchain/jsoncpp/include/"
binaries.withType(StaticLibraryBinary) {
staticLibraryFile = file("${rootDir}/qgi/toolchain/jsoncpp/libjsoncpp.a")
}
}
gtest {
headers.srcDir "${rootDir}/qgi/toolchain/googletest/include"
binaries.withType(StaticLibraryBinary) {
staticLibraryFile = file ("${rootDir}/qgi/toolchain/googletest/make/gtest_main.a")
}
}
gmock {
headers.srcDir "${rootDir}/../toolchain/googlemock/include"
binaries.withType(StaticLibraryBinary) {
staticLibraryFile = file ("${rootDir}/../toolchain/googlemock/make/gmock_main.a")
}
}
}
}
}
// build distribution package
def distributionConfiguration = {
dependsOn assemble
into("${version}") {
into ('lib') {
def tdqgcSharedFile = project(':TeradataConnector:Loader').buildDir.toString() + '/' + project(':TeradataConnector:Loader').libsDirName + '/tdqgc/shared/libtdqgc.so'
from(tdqgcSharedFile) {
fileMode 0755
}
}
into ('bin') {
from ( rootProject.projectDir.toString() + '/TeradataConnector/TDInstall' ) {
eachFile { file ->
if(file.getName().endsWith(".sh") ) {
file.setMode(0750)
}
}
}
include "*"
}
}
}
tasks.withType(RunTestExecutable) {
args "--gtest_output=xml:qgc_utest.xml"
}
//=============================================
// LCOV and unit tests
//=============================================
task lcovgen(type: Exec) {
commandLine '../../../toolchain/lcov-1.11/bin/lcov', '-d', '.', '-c', '-o', 'qgc_lcov'
}
task lcovclean(dependsOn: ["lcovgen"], type: Exec) {
def lcovremove = ["/usr/include*", "toolchain*", "Commons*", "QGC/TeradataConnector/Loader/src/test/*", "cpp/src/proto*"]
def cmdl = ['../../../toolchain/lcov-1.11/bin/lcov', '--remove', 'qgc_lcov'] + lcovremove + [ '-o', 'qgc_lcov']
commandLine cmdl
}
//lcovgen.finalizeBy lcovclean
lcovclean.mustRunAfter lcovgen
task genhtml(dependsOn: ["lcovclean"], type: Exec) {
commandLine '../../../toolchain/lcov-1.11/bin/genhtml', 'qgc_lcov', 'qgc_lcov', '-o', 'coverage'
}
task lcov(dependsOn: ["genhtml"]){
}
//=============================================
//=============================================
project(':TeradataConnector').distributionTar {
configure distributionConfiguration
}