import org.gradle.nativeplatform.test.cppunit.CppUnitTestSuiteSpec model { components { withType(NativeComponentSpec) { binaries.withType(NativeBinarySpec) { if (buildType == buildTypes.debug) { if (it instanceof NativeExecutableBinarySpec) { executable.file = toLocalBin(appendDebugSuffix(executable.file), targetPlatform) } } else if (buildType == buildTypes.release) { if (it instanceof NativeExecutableBinarySpec) { executable.file = toLocalBin(executable.file, targetPlatform) } } } } TestSuite(NativeLibrarySpec) { sources { cpp { source { srcDir 'src' include '**/*.cpp' exclude '*Driver.cpp' } exportedHeaders { srcDir 'src' } lib project: ':CppUnit', library: 'CppUnit', linkage: 'shared' lib project: ':Data:MySQL', library: 'mysql', linkage: 'shared' lib project: ':Data:MySQL', library: 'DataMySQL', linkage: 'shared' lib project: ':Data', library: 'Data', linkage: 'shared' lib project: ':Util', library: 'Util' lib project: ':JSON', library: 'JSON' lib project: ':XML', library: 'XML' lib project: ':Foundation', library: 'Foundation', linkage: 'shared' } } } } testSuites { MySQLTestSuite(org.gradle.nativeplatform.test.cppunit.CppUnitTestSuiteSpec) { testing $.components.TestSuite binaries.all { String PATH = tasks.run.environment.get("Path") if (targetPlatform.name.equals("win32")) { PATH = "$mysql32Home" + "/bin;$PATH" } else if (targetPlatform.name.equals("win64")) { PATH = "$mysql64Home" + "/bin;$PATH" } tasks.run.environment "Path", PATH } } } binaries { all { cppCompiler.define "THREADSAFE" cppCompiler.define "__LCC__" } withType(org.gradle.nativeplatform.test.cppunit.CppUnitTestSuiteBinarySpec) { lib project: ':CppUnit', library: 'CppUnit', linkage: 'shared' if (toolChain in VisualCpp) { cppCompiler.define "WINVER=0x0600" if (buildType == buildTypes.debug) { cCompiler.args "/MDd" cppCompiler.args "/MDd" } else if (buildType == buildTypes.release) { cCompiler.args "/MD" cppCompiler.args "/MD" } else { throw new GradleException("Unknown buildType" + buildType) } } if (toolChain in Gcc) { def String LIB64SUFFIX = "64" cppCompiler.define "NO_TCL" cppCompiler.args ( "-I", "/usr/local/include/mysql/" ) cppCompiler.args ( "-I", "/usr/include/mysql/" ) cppCompiler.args ( "-I", "/usr/mysql/include/mysql" ) cppCompiler.args ( "-I", "/usr/local/mysql/include" ) linker.args ( "-L", "/usr/lib/x86_64-linux-gnu") linker.args ( "-L", "/usr/local/lib$LIB64SUFFIX/mysql" ) linker.args ( "-L", "/usr/lib$LIB64SUFFIX/mysql" ) linker.args ( "-L", "/usr/mysql/lib$LIB64SUFFIX" ) linker.args ( "-L", "/usr/mysql/lib$LIB64SUFFIX/mysql" ) linker.args ( "-L", "/usr/local/mysql/lib$LIB64SUFFIX" ) linker.args ( "-l", "mysqlclient" ) } } } } task testsuite { dependsOn "assemble" }