2017-10-31 09:07:53 +01:00
buildscript {
}
2018-03-12 07:29:29 +01:00
plugins {
2018-03-22 13:55:21 +01:00
id 'com.ullink.nuget' version '2.15'
// id 'net.saliman.cobertura' version '2.5.1'
2018-03-12 07:29:29 +01:00
// id 'com.jfrog.artifactory' version '4.1'
}
2018-03-22 13:55:21 +01:00
apply plugin: 'base'
apply plugin: 'nuget'
nuget {
version = '4.4.1'
}
2017-10-31 09:07:53 +01:00
def os = org . gradle . internal . os . OperatingSystem . current ( )
def String version = file ( "VERSION" ) . text . replaceAll ( "[\n\r]" , "" )
File appendDebugSuffix ( File binaryFile ) {
String name = binaryFile . getName ( )
File parent = binaryFile . getParentFile ( )
int extensionSeparatorIndex = name . lastIndexOf ( '.' )
if ( extensionSeparatorIndex = = - 1 ) {
return new File ( parent , name + "d" )
}
return new File ( parent , name . substring ( 0 , extensionSeparatorIndex ) + "d" + name . substring ( extensionSeparatorIndex ) )
}
File appendStaticSuffix ( File binaryFile ) {
def os = org . gradle . internal . os . OperatingSystem . current ( )
if ( ! os . windows ) {
return binaryFile
}
String name = binaryFile . getName ( )
File parent = binaryFile . getParentFile ( )
int extensionSeparatorIndex = name . lastIndexOf ( '.' )
if ( extensionSeparatorIndex = = - 1 ) {
return new File ( parent , name + "MT" )
}
return new File ( parent , name . substring ( 0 , extensionSeparatorIndex ) + "MT" + name . substring ( extensionSeparatorIndex ) )
}
File appendSemiStaticSuffix ( File binaryFile ) {
String name = binaryFile . getName ( )
File parent = binaryFile . getParentFile ( )
int extensionSeparatorIndex = name . lastIndexOf ( '.' )
if ( extensionSeparatorIndex = = - 1 ) {
return new File ( parent , name + "MD" )
}
return new File ( parent , name . substring ( 0 , extensionSeparatorIndex ) + "MD" + name . substring ( extensionSeparatorIndex ) )
}
File prefixByPoco ( File binaryFile ) {
String name = binaryFile . getName ( )
String prefix = ''
if ( name . startsWith ( 'lib' ) ) {
prefix = 'lib'
name = name . substring ( 3 )
}
File parent = binaryFile . getParentFile ( )
return new File ( parent , prefix + "Poco" + name ) ;
}
File suffixByArch ( File binaryFile , Platform platform ) {
if ( ! platform . operatingSystem . windows ) {
return binaryFile
}
String name = binaryFile . getName ( )
String suffix = ''
if ( platform . architecture . name = = 'x86' ) {
suffix = ''
} else
if ( platform . architecture . name = = 'x86-64' ) {
suffix = '64'
} else {
throw new GradleException ( "Unknown architecture: " + platform . architecture . name )
}
int extensionSeparatorIndex = name . lastIndexOf ( '.' )
if ( extensionSeparatorIndex = = - 1 ) {
return new File ( parent , name + suffix )
}
File parent = binaryFile . getParentFile ( )
return new File ( parent , name . substring ( 0 , extensionSeparatorIndex ) + suffix + name . substring ( extensionSeparatorIndex ) ) ;
}
File toLocalBin ( File binaryFile , Platform platform ) {
String name = binaryFile . getName ( )
String target
if ( platform . architecture . name = = 'x86' ) {
target = 'bin'
} else
if ( platform . architecture . name = = 'x86-64' ) {
target = 'bin64'
} else {
throw new GradleException ( "Unknown architecture: " + platform . architecture . name )
}
File parent = new File ( target )
return new File ( parent , name ) ;
}
File toBin ( File sharedFile , Platform platform ) {
File parent = sharedFile . parentFile
if ( parent . canonicalPath . contains ( "testsuite" ) )
return sharedFile ;
if ( parent . canonicalPath . contains ( "sample" ) )
return sharedFile ;
if ( platform . operatingSystem . linux ) {
return toLib ( sharedFile , platform )
}
String name = sharedFile . getName ( )
String target
if ( platform . architecture . name = = 'x86' ) {
target = 'bin'
} else
if ( platform . architecture . name = = 'x86-64' ) {
target = 'bin64'
} else {
throw new GradleException ( "Unknown architecture: " + platform . architecture . name )
}
File newParent = new File ( rootDir , target )
return new File ( newParent , name ) ;
}
File toLib ( File linkFile , Platform platform ) {
File parent = linkFile . parentFile
if ( parent . canonicalPath . contains ( "testsuite" ) )
return linkFile ;
if ( parent . canonicalPath . contains ( "sample" ) )
return linkFile ;
// On macOS, it creates a dylib file which is the shared and import library
if ( platform . operatingSystem . macOsX ) {
return toBin ( linkFile , platform )
}
String name = linkFile . getName ( )
String target
if ( platform . architecture . name = = 'x86' ) {
target = 'lib'
} else
if ( platform . architecture . name = = 'x86-64' ) {
target = 'lib64'
} else {
throw new GradleException ( "Unknown architecture: " + platform . architecture . name )
}
File newParent = new File ( rootDir , target )
return new File ( newParent , name ) ;
}
File toStatic ( File staticFile , Platform platform ) {
String name = staticFile . getName ( )
String target
if ( platform . architecture . name = = 'x86' ) {
target = 'lib'
} else
if ( platform . architecture . name = = 'x86-64' ) {
target = 'lib64'
} else {
throw new GradleException ( "Unknown architecture: " + platform . architecture . name )
}
File parent = new File ( rootDir , target )
return new File ( parent , name ) ;
}
File toPDB ( File binaryFile ) {
String name = binaryFile . getName ( )
File parent = binaryFile . getParentFile ( )
int extensionSeparatorIndex = name . lastIndexOf ( '.' )
return new File ( parent , name . substring ( 0 , extensionSeparatorIndex ) + ".pdb" )
}
2018-03-12 07:29:29 +01:00
File makePreBuildLibrary ( String name , Platform platform ) {
File pbl
if ( platform . architecture . name = = 'x86' ) {
pbl = new File ( WDKHome + "/Lib/" + WDKVers + "/um/x86/" + name + ".lib" )
2017-10-31 09:07:53 +01:00
2018-03-12 07:29:29 +01:00
} else
if ( platform . architecture . name = = 'x86-64' ) {
pbl = new File ( WDKHome + "/Lib/" + WDKVers + "/um/x64/" + name + ".lib" )
} else
if ( platform . architecture . name = = 'arm-v7' ) {
pbl = new File ( WDKHome + "/Lib/" + WDKVers + "/um/arm-v7/" + name + ".lib" )
} else
if ( platform . architecture . name = = 'ia-64' ) {
pbl = new File ( WDKHome + "/Lib/" + WDKVers + "/um/ia-64/" + name + ".lib" )
} else {
throw new GradleException ( "Unknown architecture: " + platform . architecture . name )
}
return pbl
}
class SliceTasksPlugin extends RuleSource {
@Mutate
void createBuildSliceTask ( ModelMap < Task > tasks , BinaryContainer binaries , BuildTypeContainer buildTypes ) {
tasks . create ( "slice" ) {
dependsOn binaries . withType ( NativeBinarySpec ) . findAll {
it . buildable & &
it . buildType = = buildTypes . debug & &
it . targetPlatform . architecture . name = = 'x86' & &
it instanceof SharedLibraryBinarySpec
}
}
}
}
2017-10-31 09:07:53 +01:00
2018-03-22 13:55:21 +01:00
2017-10-31 09:07:53 +01:00
allprojects {
2018-03-22 13:55:21 +01:00
buildDir = new File ( 'guild' ) // DO NOT REMOVE OR CHANGE to 'build' since 'build' is a Poco directory
2017-10-31 09:07:53 +01:00
file ( 'bin' ) . mkdirs ( )
file ( 'bin64' ) . mkdirs ( )
file ( 'lib' ) . mkdirs ( )
file ( 'lib64' ) . mkdirs ( )
/ *
clean . doFirst {
file ( projectDir , 'bin' ) . delete ( )
file ( projectDir , 'bin64' ) . delete ( )
file ( projectDir , 'lib' ) . delete ( )
file ( projectDir , 'lib64' ) . delete ( )
}
* /
}
subprojects {
apply plugin: 'c'
apply plugin: 'cpp'
apply plugin: 'cppunit-test-suite'
apply plugin: 'windows-resources'
apply plugin: 'windows-messages'
2018-03-12 07:29:29 +01:00
apply plugin: SliceTasksPlugin
2017-10-31 09:07:53 +01:00
2018-03-22 13:55:21 +01:00
buildDir = new File ( "guild" )
2017-10-31 09:07:53 +01:00
model {
buildTypes {
release
debug
}
/ *
toolChains {
visualCpp ( VisualCpp ) {
// Specify the installDir if Visual Studio cannot be located
2018-03-12 07:29:29 +01:00
// installDir "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community"
// installDir "C:/Program Files (x86)/Microsoft Visual Studio 14.0"
2017-10-31 09:07:53 +01:00
}
2018-03-12 07:29:29 +01:00
2017-10-31 09:07:53 +01:00
gcc ( Gcc ) {
// Uncomment to use a GCC install that is not in the PATH
// path "/usr/bin/gcc"
}
clang ( Clang )
}
* /
platforms {
win32 {
operatingSystem "windows"
architecture 'x86'
}
win64 {
operatingSystem "windows"
architecture 'x64'
}
linux32 {
operatingSystem "linux"
architecture 'x86'
}
linux64 {
operatingSystem "linux"
architecture 'x64'
}
macos {
operatingSystem "macosx"
architecture 'x64'
}
}
flavors {
bundled
// unbundled
}
repositories {
libs ( PrebuiltLibraries ) {
WS2_32 {
2018-03-12 07:29:29 +01:00
headers . srcDir WDKHome + "/Include/" + WDKVers + "/um/x86"
2017-10-31 09:07:53 +01:00
binaries . withType ( StaticLibraryBinary ) {
if ( targetPlatform . operatingSystem . windows ) {
2018-03-12 07:29:29 +01:00
staticLibraryFile = makePreBuildLibrary ( "WS2_32" , targetPlatform )
println "staticLibraryFile=" + staticLibraryFile
2017-10-31 09:07:53 +01:00
}
}
}
2018-03-12 07:29:29 +01:00
def opensslHome = new File ( rootDir , "openssl/build" )
2017-10-31 09:07:53 +01:00
def opensslBrewHome = new File ( '/usr/local/opt/openssl' )
def opensslLinuxHome = new File ( '/usr/lib/x86_64-linux-gnu' )
crypto {
headers . srcDir "$opensslHome/include"
binaries . withType ( StaticLibraryBinary ) {
def libName = "foobar"
if ( buildType = = buildTypes . debug ) {
if ( targetPlatform . name = = 'win32' ) {
2018-03-12 07:29:29 +01:00
libName = 'libcryptod.lib'
2017-10-31 09:07:53 +01:00
staticLibraryFile = file ( "$opensslHome/win32/lib/debug/$libName" )
} else if ( targetPlatform . name = = 'win64' ) {
2018-03-12 07:29:29 +01:00
libName = 'libcryptod.lib'
2017-10-31 09:07:53 +01:00
staticLibraryFile = file ( "$opensslHome/win64/lib/debug/$libName" )
} else if ( targetPlatform . operatingSystem . macOsX ) {
2018-03-12 07:29:29 +01:00
libName = 'libcryptod.a'
2017-10-31 09:07:53 +01:00
staticLibraryFile = file ( "$opensslBrewHome/lib/$libName" )
} else if ( targetPlatform . operatingSystem . linux ) {
2018-03-12 07:29:29 +01:00
libName = 'libcryptod.a'
2017-10-31 09:07:53 +01:00
staticLibraryFile = file ( "$opensslLinuxHome/$libName" )
}
} else
if ( buildType = = buildTypes . release ) {
if ( targetPlatform . name = = 'win32' ) {
libName = 'libcrypto.lib'
staticLibraryFile = file ( "$opensslHome/win32/lib/release/$libName" )
} else if ( targetPlatform . name = = 'win64' ) {
libName = 'libcrypto.lib'
staticLibraryFile = file ( "$opensslHome/win64/lib/release/$libName" )
} else if ( targetPlatform . operatingSystem . macOsX ) {
libName = 'libcrypto.a'
staticLibraryFile = file ( "$opensslBrewHome/lib/$libName" )
} else if ( targetPlatform . operatingSystem . linux ) {
libName = 'libcrypto.a'
staticLibraryFile = file ( "$opensslLinuxHome/$libName" )
}
} else {
throw new GradleException ( "Unknown buildType" + buildType )
}
}
binaries . withType ( SharedLibraryBinary ) {
def dllName
def linkName
if ( buildType = = buildTypes . debug ) {
if ( targetPlatform . name = = 'win32' ) {
2018-03-12 07:29:29 +01:00
dllName = 'libcryptod.dll'
linkName = 'libcryptod.lib'
2017-10-31 09:07:53 +01:00
sharedLibraryFile = file ( "$opensslHome/win32/bin/debug/$dllName" )
sharedLibraryLinkFile = file ( "$opensslHome/win32/bin/debug/$linkName" )
} else if ( targetPlatform . name = = 'win64' ) {
2018-03-12 07:29:29 +01:00
dllName = 'libcryptod.dll'
linkName = 'libcryptod.lib'
2017-10-31 09:07:53 +01:00
sharedLibraryFile = file ( "$opensslHome/win64/bin/debug/$dllName" )
sharedLibraryLinkFile = file ( "$opensslHome/win64/bin/debug/$linkName" )
} else if ( targetPlatform . operatingSystem . macOsX ) {
2018-03-12 07:29:29 +01:00
dllName = 'libcryptod.dylib'
linkName = 'libcryptod.dylib'
2017-10-31 09:07:53 +01:00
sharedLibraryFile = file ( "$opensslBrewHome/lib/$dllName" )
sharedLibraryLinkFile = file ( "$opensslBrewHome/lib/$linkName" )
} else if ( targetPlatform . operatingSystem . linux ) {
2018-03-12 07:29:29 +01:00
dllName = 'libcryptod.so'
linkName = 'libcryptod.so'
2017-10-31 09:07:53 +01:00
sharedLibraryFile = file ( "$opensslLinuxHome/$dllName" )
sharedLibraryLinkFile = file ( "$opensslLinuxHome/$linkName" )
}
} else
if ( buildType = = buildTypes . release ) {
if ( targetPlatform . name = = 'win32' ) {
dllName = 'libcrypto.dll'
linkName = 'libcrypto.lib'
sharedLibraryFile = file ( "$opensslHome/win32/bin/release/$dllName" )
sharedLibraryLinkFile = file ( "$opensslHome/win32/bin/release/$linkName" )
} else if ( targetPlatform . name = = 'win64' ) {
dllName = 'libcrypto.dll'
linkName = 'libcrypto.lib'
sharedLibraryFile = file ( "$opensslHome/win64/bin/release/$dllName" )
sharedLibraryLinkFile = file ( "$opensslHome/win64/bin/release/$linkName" )
} else if ( targetPlatform . operatingSystem . macOsX ) {
dllName = 'libcrypto.dylib'
linkName = 'libcrypto.dylib'
sharedLibraryFile = file ( "$opensslBrewHome/lib/$dllName" )
sharedLibraryLinkFile = file ( "$opensslBrewHome/lib/$linkName" )
} else if ( targetPlatform . operatingSystem . linux ) {
dllName = 'libcrypto.so'
linkName = 'libcrypto.so'
sharedLibraryFile = file ( "$opensslLinuxHome/$dllName" )
sharedLibraryLinkFile = file ( "$opensslLinuxHome/$linkName" )
}
} else {
throw new GradleException ( "Unknown buildType" + buildType )
}
}
}
ssl {
headers . srcDir "$opensslHome/include"
binaries . withType ( StaticLibraryBinary ) {
def libName
if ( buildType = = buildTypes . debug ) {
if ( targetPlatform . name = = 'win32' ) {
2018-03-12 07:29:29 +01:00
libName = 'libssld.lib'
2017-10-31 09:07:53 +01:00
staticLibraryFile = file ( "$opensslHome/win32/lib/debug/$libName" )
} else if ( targetPlatform . name = = 'win64' ) {
2018-03-12 07:29:29 +01:00
libName = 'libssld.lib'
2017-10-31 09:07:53 +01:00
staticLibraryFile = file ( "$opensslHome/win64/lib/debug/$libName" )
} else if ( targetPlatform . operatingSystem . macOsX ) {
2018-03-12 07:29:29 +01:00
libName = 'libssld.a'
2017-10-31 09:07:53 +01:00
staticLibraryFile = file ( "$opensslBrewHome/lib/$libName" )
} else if ( targetPlatform . operatingSystem . linux ) {
2018-03-12 07:29:29 +01:00
libName = 'libssld.a'
2017-10-31 09:07:53 +01:00
staticLibraryFile = file ( "$opensslLinuxHome/$libName" )
}
} else
if ( buildType = = buildTypes . release ) {
if ( targetPlatform . name = = 'win32' ) {
libName = 'libssl.lib'
staticLibraryFile = file ( "$opensslHome/win32/lib/release/$libName" )
} else if ( targetPlatform . name = = 'win64' ) {
libName = 'libssl.lib'
staticLibraryFile = file ( "$opensslHome/win64/lib/release/$libName" )
} else if ( targetPlatform . operatingSystem . macOsX ) {
libName = 'libssl.a'
staticLibraryFile = file ( "$opensslBrewHome/lib/$libName" )
} else if ( targetPlatform . operatingSystem . linux ) {
libName = 'libssl.a'
staticLibraryFile = file ( "$opensslLinuxHome/$libName" )
}
} else {
throw new GradleException ( "Unknown buildType" + buildType )
}
}
binaries . withType ( SharedLibraryBinary ) {
def dllName
def linkName
if ( buildType = = buildTypes . debug ) {
if ( targetPlatform . name = = 'win32' ) {
2018-03-12 07:29:29 +01:00
dllName = 'libssld.dll'
linkName = 'libssld.lib'
2017-10-31 09:07:53 +01:00
sharedLibraryFile = file ( "$opensslHome/win32/bin/debug/$dllName" )
sharedLibraryLinkFile = file ( "$opensslHome/win32/bin/debug/$linkName" )
} else if ( targetPlatform . name = = 'win64' ) {
2018-03-12 07:29:29 +01:00
dllName = 'libssld.dll'
linkName = 'libssld.lib'
2017-10-31 09:07:53 +01:00
sharedLibraryFile = file ( "$opensslHome/win64/bin/debug/$dllName" )
sharedLibraryLinkFile = file ( "$opensslHome/win64/bin/debug/$linkName" )
} else if ( targetPlatform . operatingSystem . macOsX ) {
2018-03-12 07:29:29 +01:00
dllName = 'libssld.dylib'
linkName = 'libssld.dylib'
2017-10-31 09:07:53 +01:00
sharedLibraryFile = file ( "$opensslBrewHome/lib/$dllName" )
sharedLibraryLinkFile = file ( "$opensslBrewHome/lib/$linkName" )
} else if ( targetPlatform . operatingSystem . linux ) {
2018-03-12 07:29:29 +01:00
dllName = 'libssld.so'
linkName = 'libssld.so'
2017-10-31 09:07:53 +01:00
sharedLibraryFile = file ( "$opensslLinuxHome/$dllName" )
sharedLibraryLinkFile = file ( "$opensslLinuxHome/$linkName" )
}
} else if ( buildType = = buildTypes . release ) {
if ( targetPlatform . name = = 'win32' ) {
dllName = 'libssl.dll'
linkName = 'libssl.lib'
sharedLibraryFile = file ( "$opensslHome/win32/bin/release/$dllName" )
sharedLibraryLinkFile = file ( "$opensslHome/win32/bin/release/$linkName" )
} else if ( targetPlatform . name = = 'win64' ) {
dllName = 'libssl.dll'
linkName = 'libssl.lib'
sharedLibraryFile = file ( "$opensslHome/win64/bin/release/$dllName" )
sharedLibraryLinkFile = file ( "$opensslHome/win64/bin/release/$linkName" )
} else if ( targetPlatform . operatingSystem . macOsX ) {
dllName = 'libssl.dylib'
linkName = 'libssl.dylib'
sharedLibraryFile = file ( "$opensslBrewHome/lib/$dllName" )
sharedLibraryLinkFile = file ( "$opensslBrewHome/lib/$linkName" )
} else if ( targetPlatform . operatingSystem . linux ) {
dllName = 'libssl.so'
linkName = 'libssl.so'
sharedLibraryFile = file ( "$opensslLinuxHome/$dllName" )
sharedLibraryLinkFile = file ( "$opensslLinuxHome/$linkName" )
}
} else {
throw new GradleException ( "Unknown buildType" + buildType )
}
}
}
}
}
components {
withType ( NativeComponentSpec ) {
targetPlatform "win32"
targetPlatform "win64"
targetPlatform "linux32"
targetPlatform "linux64"
targetPlatform "macos"
binaries . withType ( NativeTestSuiteBinarySpec ) {
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 )
}
}
}
binaries . withType ( NativeBinarySpec ) {
if ( toolChain in Clang ) {
cppCompiler . args "-std=c++11"
}
if ( buildType = = buildTypes . debug ) {
if ( it instanceof SharedLibraryBinarySpec ) {
sharedLibraryFile = toBin ( prefixByPoco ( appendDebugSuffix ( suffixByArch ( sharedLibraryFile , targetPlatform ) ) ) , targetPlatform )
sharedLibraryLinkFile = toLib ( prefixByPoco ( appendDebugSuffix ( sharedLibraryLinkFile ) ) , targetPlatform )
if ( targetPlatform . operatingSystem . windows ) {
// WINDOWS ONLY
linker . args "/implib:${sharedLibraryLinkFile}" // For MSVC only
// use the following for MinGW
// linker.args "-Wl,--out-implib,${sharedLibraryLinkFile}"
// This next part is simply to ensure the directory is created as the compiler (tested on MSVC only) won't create it
def binary = it // Simply to expose the binary in the `doFirst`
tasks . withType ( LinkSharedLibrary ) {
doFirst {
binary . sharedLibraryLinkFile . parentFile . mkdirs ( )
}
}
}
} else
if ( it instanceof StaticLibraryBinarySpec ) {
staticLibraryFile = toStatic ( prefixByPoco ( appendDebugSuffix ( appendStaticSuffix ( staticLibraryFile ) ) ) , targetPlatform )
def binary = it
tasks . withType ( CreateStaticLibrary ) {
doFirst {
binary . staticLibraryFile . parentFile . mkdirs ( )
}
}
} else
if ( it instanceof SemiStaticLibraryBinarySpec ) {
semiStaticLibraryFile = toStatic ( prefixByPoco ( appendDebugSuffix ( appendSemiStaticSuffix ( semiStaticLibraryFile ) ) ) , targetPlatform )
} else
if ( it instanceof NativeExecutableBinarySpec ) {
executable . file = toBin ( appendDebugSuffix ( executable . file ) , targetPlatform )
} else {
throw new GradleException ( "Unknown native library binary" )
}
} else
if ( buildType = = buildTypes . release ) {
if ( it instanceof SharedLibraryBinarySpec ) {
sharedLibraryFile = toBin ( prefixByPoco ( suffixByArch ( sharedLibraryFile , targetPlatform ) ) , targetPlatform )
sharedLibraryLinkFile = toLib ( prefixByPoco ( sharedLibraryLinkFile ) , targetPlatform )
if ( targetPlatform . operatingSystem . windows ) {
// WINDOWS ONLY
linker . args "/implib:${sharedLibraryLinkFile}" // For MSVC only
// use the following for MinGW
// linker.args "-Wl,--out-implib,${sharedLibraryLinkFile}"
// This next part is simply to ensure the directory is created as the compiler (tested on MSVC only) won't create it
def binary = it // Simply to expose the binary in the `doFirst`
tasks . withType ( LinkSharedLibrary ) {
doFirst {
binary . sharedLibraryLinkFile . parentFile . mkdirs ( )
}
}
}
} else
if ( it instanceof StaticLibraryBinarySpec ) {
staticLibraryFile = toStatic ( prefixByPoco ( appendStaticSuffix ( staticLibraryFile ) ) , targetPlatform )
def binary = it
tasks . withType ( CreateStaticLibrary ) {
doFirst {
binary . staticLibraryFile . parentFile . mkdirs ( )
}
}
} else
if ( it instanceof SemiStaticLibraryBinarySpec ) {
semiStaticLibraryFile = toStatic ( prefixByPoco ( appendSemiStaticSuffix ( semiStaticLibraryFile ) ) , targetPlatform )
def binary = it
tasks . withType ( CreateSemiStaticLibrary ) {
doFirst {
binary . semiStaticLibraryFile . parentFile . mkdirs ( )
}
}
} else
if ( it instanceof NativeExecutableBinarySpec ) {
executable . file = toBin ( executable . file , targetPlatform )
} else {
throw new GradleException ( "Unknown native library binary" )
}
} else {
throw new GradleException ( "Unknown buildType" + buildType )
}
}
}
}
binaries {
all {
if ( flavor ! = flavors . bundled ) {
cCompiler . define 'POCO_UNBUNDLED'
cppCompiler . define 'POCO_UNBUNDLED'
}
if ( buildType = = buildTypes . debug ) {
cCompiler . define '_DEBUG'
cppCompiler . define '_DEBUG'
} else
if ( buildType = = buildTypes . release ) {
cCompiler . define 'NDEBUG'
cppCompiler . define 'NDEBUG'
}
if ( toolChain in Gcc ) {
cppCompiler . define "_XOPEN_SOURCE=600"
cppCompiler . define "_REENTRANT"
cppCompiler . define "_THREAD_SAFE"
cppCompiler . define "_FILE_OFFSET_BITS=64"
cppCompiler . define "_LARGEFILE64_SOURCE"
cppCompiler . define "POCO_HAVE_FD_EPOLL"
cppCompiler . define "POCO_HAVE_ADDRINFO"
cppCompiler . define "POCO_HAVE_LIBRESOLV"
cppCompiler . args "-std=c++11"
cppCompiler . args "-fPIC"
linker . args "-lrt"
linker . args "-ldl"
linker . args "-lpthread"
}
if ( toolChain in VisualCpp ) {
if ( targetPlatform = = platforms . win64 ) {
linker . args '/MACHINE:X64'
} else {
linker . args '/MACHINE:X86'
}
if ( buildType = = buildTypes . debug ) {
cCompiler . args '/Zi'
cppCompiler . args '/Zi'
linker . args '/DEBUG'
}
cCompiler . args '/RTC1'
cCompiler . args '/FS'
cCompiler . args '/Zc:wchar_t'
cCompiler . args '/Zc:inline'
cCompiler . args '/Zc:forScope'
cCompiler . args '/GR'
cCompiler . args '/GF'
cCompiler . args '/EHsc'
cCompiler . args '/bigobj'
cCompiler . define 'WIN32'
cCompiler . define '_WIN32'
cCompiler . define '_WINDOWS'
cCompiler . define '_MBCS'
cppCompiler . args '/RTC1'
cppCompiler . args '/FS'
cppCompiler . args '/Zc:wchar_t'
cppCompiler . args '/Zc:inline'
cppCompiler . args '/Zc:forScope'
cppCompiler . args '/GR'
cppCompiler . args '/GF'
cppCompiler . args '/EHsc'
cppCompiler . args '/bigobj'
cppCompiler . define 'WIN32'
cppCompiler . define '_WIN32'
cppCompiler . define '_WINDOWS'
cppCompiler . define '_MBCS'
linker . args 'kernel32.lib'
linker . args 'user32.lib'
linker . args 'gdi32.lib'
linker . args 'winspool.lib'
linker . args 'comdlg32.lib'
linker . args 'advapi32.lib'
linker . args 'shell32.lib'
linker . args 'ole32.lib'
linker . args 'oleaut32.lib'
linker . args 'uuid.lib'
linker . args '/NXCOMPAT'
linker . args '/OPT:REF'
linker . args '/INCREMENTAL:NO'
// linker.args '/MANIFEST'
// linker.args '/MANIFESTUAC:"level='asInvoker' uiAccess='false'"'
linker . args '/OPT:ICF'
linker . args '/NOLOGO'
linker . args '/SUBSYSTEM:CONSOLE'
}
}
withType ( SharedLibraryBinarySpec ) {
if ( toolChain in VisualCpp ) {
cCompiler . define '_USRDLL'
cCompiler . define '_WINDLL'
cppCompiler . define '_USRDLL'
cppCompiler . define '_WINDLL'
if ( buildType = = buildTypes . debug ) {
cCompiler . args "/MDd"
cppCompiler . args "/MDd"
} else
if ( buildType = = buildTypes . release ) {
cCompiler . args "/MD"
cppCompiler . args "/MD"
}
}
if ( toolChain in Gcc ) {
linker . args "-Wl,-rpath,$rootDir/lib64" //FIXME
}
}
withType ( StaticLibraryBinarySpec ) {
if ( toolChain in VisualCpp ) {
cCompiler . define '_LIB'
cCompiler . define 'POCO_STATIC'
cppCompiler . define '_LIB'
cppCompiler . define 'POCO_STATIC'
if ( buildType = = buildTypes . debug ) {
cCompiler . args "/MTd"
cCompiler . args "/Fd" + toStatic ( toPDB ( staticLibraryFile ) , targetPlatform )
cppCompiler . args "/MTd"
cppCompiler . args "/Fd" + toStatic ( toPDB ( staticLibraryFile ) , targetPlatform )
} else
if ( buildType = = buildTypes . release ) {
cCompiler . args "/MT"
cppCompiler . args "/MT"
} else {
throw new GradleException ( "Unknown buildType" + buildType )
}
}
if ( toolChain in Gcc ) {
}
}
withType ( SemiStaticLibraryBinarySpec ) {
if ( toolChain in VisualCpp ) {
cCompiler . define '_LIB'
cCompiler . define 'POCO_STATIC'
cppCompiler . define '_LIB'
cppCompiler . define 'POCO_STATIC'
if ( buildType = = buildTypes . debug ) {
cCompiler . args "/MDd"
cCompiler . args "/Fd" + toStatic ( toPDB ( semiStaticLibraryFile ) , targetPlatform )
cppCompiler . args "/MDd"
cppCompiler . args "/Fd" + toStatic ( toPDB ( semiStaticLibraryFile ) , targetPlatform )
} else
if ( buildType = = buildTypes . release ) {
cCompiler . args "/MD"
cppCompiler . args "/MD"
} else {
throw new GradleException ( "Unknown buildType" + buildType )
}
}
if ( toolChain in Gcc ) {
}
}
withType ( NativeExecutableBinarySpec ) {
if ( toolChain in VisualCpp ) {
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 ) {
}
}
}
}
tasks . withType ( RunTestExecutable ) {
2018-03-22 13:55:21 +01:00
String PATH = System . getenv ( "PATH" )
String name = getName ( ) ;
if ( name . contains ( 'Win32' ) ) {
PATH = "$rootDir\\bin;$PATH"
PATH = "$rootDir\\openssl\\build\\win32\\bin\\release;$PATH"
PATH = "$rootDir\\openssl\\build\\win32\\bin\\debug;$PATH"
PATH = "$mysql32Home" . replace ( '/' , '\\' ) + "\\bin;$PATH"
PATH = "$postgres32Home" . replace ( '/' , '\\' ) + "\\bin;$PATH"
} else
if ( name . contains ( 'Win64' ) ) {
PATH = "$rootDir\\bin64;$PATH"
PATH = "$rootDir\\openssl\\build\\win64\\bin\\release;$PATH"
PATH = "$rootDir\\openssl\\build\\win64\\bin\\debug;$PATH"
PATH = "$mysql64Home" . replace ( '/' , '\\' ) + "\\bin;$PATH"
PATH = "$postgres64Home" . replace ( '/' , '\\' ) + "\\bin;$PATH"
}
environment "Path" , "$PATH"
String CPPUNIT_IGNORE ;
CPPUNIT_IGNORE = 'class CppUnit::TestCaller<class NTPClientTest>.testTimeSync' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class RawSocketTest>.testEchoIPv4' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class RawSocketTest>.testSendToReceiveFromIPv4' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ICMPClientTest>.testPing' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ICMPClientTest>.testBigPing' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class HTTPSClientSessionTest>.testProxy' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class HTTPSStreamFactoryTest>.testProxy' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class TCPServerTest>.testReuseSocket' ;
//FIXME Those tests below should work
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ProcessTest>.testLaunch' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ProcessTest>.testLaunchRedirectIn' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ProcessTest>.testLaunchRedirectOut' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ProcessTest>.testLaunchEnv' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ProcessTest>.testLaunchArgs' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ProcessTest>.testIsRunning' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ProcessTest>.testIsRunningAllowsForTermination' ;
//FIXME won't work until SharedLibraries be properly generated
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class SharedLibraryTest>.testSharedLibrary1' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class SharedLibraryTest>.testSharedLibrary2' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class SharedLibraryTest>.testSharedLibrary3' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ClassLoaderTest>.testClassLoader2' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ClassLoaderTest>.testClassLoader3' ;
environment "CPPUNIT_IGNORE" , "\"$CPPUNIT_IGNORE\""
environment "POCO_BASE" , "$rootDir"
2017-10-31 09:07:53 +01:00
args test
}
2018-03-22 13:55:21 +01:00
2017-10-31 09:07:53 +01:00
}
2018-03-22 13:55:21 +01:00
2017-12-11 18:20:44 +01:00
tasks . withType ( CppCompile ) {
maxParallelForks = 2
}
2018-03-22 13:55:21 +01:00
2017-10-31 09:07:53 +01:00
task PocoDocIni {
def file = new File ( "$rootDir/PocoDoc/PocoDoc.ini" )
file . createNewFile ( )
file . text = "" "
PocoBuild = $rootDir
PocoBase = $rootDir
PocoDoc . output = releases / poco - $ { version } - all - doc
PocoDoc . version = $ { version } - all
"" "
if ( os . windows ) {
2018-03-12 07:29:29 +01:00
def String javaVCH = VCHome . replace ( '\\' , '/' )
def String javaCLP = CLPath . replace ( '\\' , '/' )
def String javaWDK = WDKHome + "/Include/" + WDKVers
javaWDK = javaWDK . replace ( '\\' , '/' )
file . text + = "" "
2018-03-22 13:55:21 +01:00
Includes = - I $ { postgres32Home } /include,-I${mysql32Home}/ include , - ICppParser /include,-ICppUnit/ include , - ICrypto /include,-IData/ include , - IData /include,-IData/ MySQL /include,-IData/ ODBC /include,-IData/ PostgreSQL /include,-IData/ SQLite /include, -IData/ SQLite /src,-IFoundation/ include , - IJSON /include,-IMongoDB/ include , - INet /include,-INetSSL_OpenSSL/ include , - INetSSL_Win /include,-IRedis/ include , - IUtil /include,-IXML/ include , - IZip /include,-ISevenZip/ include , - IPDF / include
2018-03-12 07:29:29 +01:00
VCH = $ { javaVCH }
WDK = $ { javaWDK }
CLP = $ { javaCLP }
2017-10-31 09:07:53 +01:00
"" "
} else {
}
}
task pocoDoc ( type: Exec ) {
dependsOn ':PocoDoc::assemble'
dependsOn PocoDocIni
if ( os . windows ) {
environment "Path" , "$rootDir\\bin;$Path"
2018-03-12 07:29:29 +01:00
println environment . Path
2017-10-31 09:07:53 +01:00
executable "PocoDoc/bin/PocoDoc.exe"
2017-11-11 15:53:34 +01:00
args "/config=$rootDir/PocoDoc/cfg/mkdoc-gradle.xml"
2017-10-31 09:07:53 +01:00
args "/config=$rootDir/PocoDoc/PocoDoc.ini"
}
if ( os . linux ) {
environment "LD_LIBRARY_PATH" , "$rootDir/lib64:$LD_LIBRARY_PATH"
executable "PocoDoc/bin64/PocoDoc"
2017-11-11 15:53:34 +01:00
args "-config=$rootDir/PocoDoc/cfg/mkdoc-gradle.xml"
2017-10-31 09:07:53 +01:00
args "-config=$rootDir/PocoDoc/PocoDoc.ini"
}
if ( os . macOsX ) {
//FIXME environment "LD_LIBRARY_PATH", "$rootDir/bin:$LD_LIBRARY_PATH"
2017-11-11 15:53:34 +01:00
args "-config=$rootDir/PocoDoc/cfg/mkdoc-gradle.xml"
2017-10-31 09:07:53 +01:00
args "-config=$rootDir/PocoDoc/PocoDoc.ini"
}
// inputs.files(tasks.getByPath(':production').outputs.files)
2017-11-11 10:41:18 +01:00
inputs . files ( executable )
2017-10-31 09:07:53 +01:00
inputs . files ( fileTree ( "doc" ) . filter { it . isFile ( ) } )
2017-11-11 15:53:34 +01:00
inputs . files ( new File ( "$rootDir/PocoDoc/cfg/mkdoc-gradle.xml" ) )
2018-03-12 07:29:29 +01:00
outputs . files ( new File ( "releases/poco-${version}-all-doc/index.html" ) )
2017-10-31 09:07:53 +01:00
}
task zipDoc ( type: Zip ) {
from "releases/poco-${version}-all-doc/"
include '*'
include '*/*'
archiveName "poco-${version}-all-doc.zip"
destinationDir ( file ( 'releases' ) )
inputs . files ( new File ( "releases/$version-all-doc/index.html" ) )
outputs . files ( new File ( "releases/poco-${version}-all-doc.zip" ) )
2018-03-12 07:29:29 +01:00
dependsOn pocoDoc
2017-10-31 09:07:53 +01:00
}
def candle ( VSYEAR , VERSION , target , os ) {
return tasks . create ( "Candle-${VSYEAR}-${VERSION}-${target}" , Exec ) {
2018-03-12 07:29:29 +01:00
def Set < Task > pocos = project . getTasksByName ( 'poco' , true )
setDependsOn ( pocos )
2017-11-10 14:00:22 +01:00
dependsOn ':pocoDoc'
2017-10-31 09:07:53 +01:00
workingDir "packaging/Windows/WiX"
2018-03-12 07:29:29 +01:00
executable "${WiXHome}/bin/Candle.exe"
2017-10-31 09:07:53 +01:00
args "-arch" , "${target}"
args "-dVSYEAR=${VSYEAR}"
args "-dVERSION=${VERSION}"
args "-dPOCO=${rootDir}"
args "-dPlatform=${target}"
args "-ext" , "${WiXHome}/bin/WixUIExtension.dll"
args "-out" , "${VSYEAR}/${VSYEAR}-Poco-$VERSION-${target}.wixobj"
2017-11-15 17:59:42 +01:00
args "Poco.wxs"
2018-03-12 07:29:29 +01:00
def File index = new File ( "$rootDir/releases/poco-$VERSION-all-doc/index.html" )
inputs . files ( index )
inputs . files ( pocos . inputs . files )
2017-12-11 18:20:44 +01:00
inputs . files ( new File ( workingDir , "Poco.wxs" ) )
2018-03-12 07:29:29 +01:00
inputs . files ( project . getTasksByName ( 'poco' , true ) . outputs . files )
def File output = new File ( workingDir , "${VSYEAR}/${VSYEAR}-Poco-$VERSION-${target}.wixobj" )
outputs . files ( output )
2017-10-31 09:07:53 +01:00
onlyIf ( new Spec < Exec > ( ) {
boolean isSatisfiedBy ( Exec task ) {
return os . windows ;
}
} ) ;
}
}
def light ( VSYEAR , VERSION , target , os ) {
return tasks . create ( "Light-${VSYEAR}-${VERSION}-${target}" , Exec ) {
dependsOn candle ( VSYEAR , VERSION , target , os )
workingDir "packaging/Windows/WiX"
2018-03-12 07:29:29 +01:00
executable "${WiXHome}/bin/Light.exe"
2017-10-31 09:07:53 +01:00
args "-cultures:null"
args "-ext" , "${WiXHome}/bin/WixUIExtension.dll"
args "-out"
args "${VSYEAR}/${VSYEAR}-Poco-$VERSION-${target}.msi"
args "${VSYEAR}/${VSYEAR}-Poco-$VERSION-${target}.wixobj"
2018-03-12 07:29:29 +01:00
def File input = new File ( workingDir , "${VSYEAR}/${VSYEAR}-Poco-$VERSION-${target}.wixobj" )
inputs . files ( input )
def File output = new File ( workingDir , "${VSYEAR}/${VSYEAR}-Poco-$VERSION-${target}.msi" )
outputs . files ( output )
2017-10-31 09:07:53 +01:00
onlyIf ( new Spec < Exec > ( ) {
boolean isSatisfiedBy ( Exec task ) {
return os . windows ;
}
} ) ;
}
}
task wix ( ) {
2017-12-11 18:20:44 +01:00
dependsOn light ( 'VS2017' , version , 'x86' , os )
dependsOn light ( 'VS2017' , version , 'x64' , os )
2017-10-31 09:07:53 +01:00
onlyIf ( new Spec < Task > ( ) {
boolean isSatisfiedBy ( Task task ) {
return os . windows ;
}
} ) ;
}
2018-03-22 13:55:21 +01:00
/ *
ext . commonNuspecMetadata = [
version: '2.0.0' ,
owners: 'Günter Obiltschnig & Aleksandar Fabijanic' ,
authors: 'Applied Informatics & Contributors' ,
projectUrl: 'https://pocoproject.org/' ,
licenseUrl: 'https://pocoproject.org/license.html' ,
iconUrl: 'https://avatars1.githubusercontent.com/u/201918?v=4&s=200' ,
copyright: 'Applied Informatics copyright 2018' ,
requireLicenseAcceptance: false ,
description: 'Modern, powerful open source C++ class libraries for building network- and internet-based applications that run on desktop, server, mobile and embedded systems.' ,
tags: 'string filesystem thread date log event regex uri uuid cache native nativepackage sockets mime http ftp mail pop3 smtp html sax sax2 dom xml'
]
def pocoNugetSpec ( os ) {
return tasks . create ( "nugetSpec-$os" , nugetSpec ) {
def String vers = commonNuspecMetadata . find { it . key = = "version" } . value ;
nuspec = [
metadata: commonNuspecMetadata + [
id: "Pocoproject.Poco.vs150" ,
title: "Poco $vers" ,
dependencies: [
]
] ,
files: [
{ file ( src: "$rootDir\\packaging\\Windows\\NuGet\\Pocoproject.Poco.vs150.targets" , target: "build\\native" ) } ,
{ file ( src: "$rootDir\\bin\\Poco*.*" , target: "build\\native\\bin" , exclude: "$rootDir\\bin\\*CppParser*.*" ) } ,
{ file ( src: "$rootDir\\lib\\Poco*.*" , target: "build\\native\\lib" ) , exclude: "$rootDir\\bin\\*CppParser*.*" } ,
{ file ( src: "$rootDir\\bin64\\Poco*64.*" , target: "build\\native\\bin64" ) , exclude: "$rootDir\\bin\\*CppParser*.*" } ,
{ file ( src: "$rootDir\\lib64\\Poco*.*" , target: "build\\native\\lib64" ) , exclude: "$rootDir\\bin\\*CppParser*.*" } ,
{ file ( src: "$rootDir\\bin\\Poco*d.*" , target: "build\\native\\bin" ) , exclude: "$rootDir\\bin\\*CppParser*.*" } ,
{ file ( src: "$rootDir\\lib\\Poco*d.*" , target: "build\\native\\lib" ) , exclude: "$rootDir\\bin\\*CppParser*.*" } ,
{ file ( src: "$rootDir\\bin64\\Poco*64d.*" , target: "build\\native\\bin64" ) , exclude: "$rootDir\\bin\\*CppParser*.*" } ,
{ file ( src: "$rootDir\\lib64\\Poco*d.*" , target: "build\\native\\lib64" ) , exclude: "$rootDir\\bin\\*CppParser*.*" } ,
{ file ( src: "$rootDir\\CppUnit\\include\\**" , target: "build\\native\\inc" ) } ,
{ file ( src: "$rootDir\\Crypto\\include\\**" , target: "build\\native\\inc" ) } ,
{ file ( src: "$rootDir\\Data\\MySQL\\include\\**" , target: "build\\native\\inc" ) } ,
{ file ( src: "$rootDir\\Data\\include\\**" , target: "build\\native\\inc" ) } ,
{ file ( src: "$rootDir\\Data\\ODBC\\include\\**" , target: "build\\native\\inc" ) } ,
{ file ( src: "$rootDir\\Data\\SQLite\\include\\**" , target: "build\\native\\inc" ) } ,
{ file ( src: "$rootDir\\Encodings\\include\\**" , target: "build\\native\\inc" ) } ,
{ file ( src: "$rootDir\\Foundation\\include\\**" , target: "build\\native\\inc" ) } ,
{ file ( src: "$rootDir\\JSON\\include\\**" , target: "build\\native\\inc" ) } ,
{ file ( src: "$rootDir\\MongoDB\\include\\**" , target: "build\\native\\inc" ) } ,
{ file ( src: "$rootDir\\Net\\include\\**" , target: "build\\native\\inc" ) } ,
{ file ( src: "$rootDir\\NetSSL_OpenSSL\\include\\**" , target: "build\\native\\inc" ) } ,
{ file ( src: "$rootDir\\NetSSL_Win\\include\\**" , target: "build\\native\\inc" ) } ,
{ file ( src: "$rootDir\\PDF\\include\\**" , target: "build\\native\\inc" ) } ,
{ file ( src: "$rootDir\\Util\\include\\**" , target: "build\\native\\inc" ) } ,
{ file ( src: "$rootDir\\XML\\include\\**" , target: "build\\native\\inc" ) } ,
{ file ( src: "$rootDir\\Zip\\include\\**" , target: "build\\native\\inc" ) }
]
]
}
}
nugetPack {
destinationDir "$rootDir/packaging/Windows/Nuget"
2018-03-12 07:29:29 +01:00
def Set < Task > pocos = project . getTasksByName ( 'poco' , true )
setDependsOn ( pocos )
2018-03-22 13:55:21 +01:00
dependsOn pocoNugetSpec ( 'x86' )
}
* /
2018-03-12 07:29:29 +01:00
2018-03-22 13:55:21 +01:00
def nuget ( version , target , os ) {
return tasks . create ( "NuGet-${target}" , Exec ) {
String nugetVersion = version . replace ( 'p' , '-' )
def Set < Task > pocos = project . getTasksByName ( 'poco' , true )
setDependsOn ( pocos )
workingDir "packaging/Windows/NuGet"
2018-03-12 07:29:29 +01:00
2018-03-22 13:55:21 +01:00
executable "${NuGetHome}/NuGet.exe"
args "pack"
args "-BasePath" , "$rootDir"
args "-Version" , nugetVersion
args "-NonInteractive"
args "Pocoproject.Poco.vs150.${target}.nuspec"
2018-03-12 07:29:29 +01:00
2018-03-22 13:55:21 +01:00
inputs . files ( pocos . inputs . files )
inputs . files ( new File ( workingDir , "Pocoproject.Poco.vs150.${target}.nuspec" ) )
outputs . files ( new File ( workingDir , "Pocoproject.Poco.vs150.${target}.${version}.nupkg" ) )
onlyIf ( new Spec < Exec > ( ) {
boolean isSatisfiedBy ( Exec task ) {
return os . windows ;
}
} ) ;
}
2017-10-31 09:07:53 +01:00
}
task packaging ( ) {
if ( os . windows ) {
2018-03-22 13:55:21 +01:00
dependsOn nuget ( version , 'x86' , os )
dependsOn nuget ( version , 'x64' , os )
2017-10-31 09:07:53 +01:00
dependsOn wix
}
}
2018-03-12 07:29:29 +01:00
//
// gradle\bin\gradle Zip:testsuite:check -Ptest=-all
//
def cover ( os , Directory , Module ) {
return tasks . create ( "cover-${Module}" , Exec ) {
String PATH = System . getenv ( "PATH" )
2018-03-22 13:55:21 +01:00
PATH = "$rootDir\\bin;$PATH"
PATH = "$rootDir\\openssl\\build\\win32\\bin\\release;$PATH"
PATH = "$rootDir\\openssl\\build\\win32\\bin\\debug;$PATH"
2018-03-12 07:29:29 +01:00
PATH = "$mysql32Home" . replace ( '/' , '\\' ) + "\\lib;$PATH"
PATH = "$postgres32Home" . replace ( '/' , '\\' ) + "\\lib;$PATH"
environment "Path" , "$PATH"
// println environment.Path
environment "POCO_BASE" , "$rootDir"
// println "POCO_BASE=" + environment.POCO_BASE
String CPPUNIT_IGNORE ;
CPPUNIT_IGNORE = 'class CppUnit::TestCaller<class NTPClientTest>.testTimeSync' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class RawSocketTest>.testEchoIPv4' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class RawSocketTest>.testSendToReceiveFromIPv4' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ICMPClientTest>.testPing' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ICMPClientTest>.testBigPing' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class HTTPSClientSessionTest>.testProxy' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class HTTPSStreamFactoryTest>.testProxy' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class TCPServerTest>.testReuseSocket' ;
//FIXME Those test below should work
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ProcessTest>.testLaunch' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ProcessTest>.testLaunchRedirectIn' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ProcessTest>.testLaunchRedirectOut' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ProcessTest>.testLaunchEnv' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ProcessTest>.testLaunchArgs' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ProcessTest>.testIsRunning' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ProcessTest>.testIsRunningAllowsForTermination' ;
//FIXME won't work until SharedLibraries be properly generated
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class SharedLibraryTest>.testSharedLibrary1' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class SharedLibraryTest>.testSharedLibrary2' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class SharedLibraryTest>.testSharedLibrary3' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ClassLoaderTest>.testClassLoader2' ;
CPPUNIT_IGNORE + = ', class CppUnit::TestCaller<class ClassLoaderTest>.testClassLoader3' ;
environment "CPPUNIT_IGNORE" , "\"$CPPUNIT_IGNORE\""
// println "CPPUNIT_IGNORE=" + environment.CPPUNIT_IGNORE
def Set < Task > tests = project . getTasksByName ( "testsuite:${Module}" , true )
setDependsOn ( tests )
workingDir "coverage/${Directory}"
file ( workingDir ) . mkdirs ( )
executable "${OpenCppCoverageHome}/OpenCppCoverage.exe"
args "-q"
args "$rootDir/${Directory}/testsuite/gradle/exe/${Module}TestSuite/win32/debug/${Module}TestSuite.exe"
args "--modules" , "Poco*d.dll"
args "--export_type" , "cobertura"
args "--continue_after_cpp_exception"
args "--"
args "-all"
outputs . files ( new File ( workingDir , "${Module}TestSuite.xml" ) )
onlyIf ( new Spec < Exec > ( ) {
boolean isSatisfiedBy ( Exec task ) {
return os . windows ;
}
} ) ;
}
}
def report ( os , Directory , Module ) {
return tasks . create ( "report-${Module}" , Exec ) {
dependsOn cover ( os , Directory , Module )
executable "${ReportGeneratorHome}/ReportGenerator.exe"
args "-verbosity:Verbose"
args "-reports:coverage/${Module}/${Module}TestSuiteCoverage.xml"
args "-targetdir:coverage/${Module}"
// args "-sourcedirs:XML/src;XML/include;CppUnit/src;CppUnit/include;Foundation/src;Foundation/include"
File targetDir = new File ( "coverage/${Module}" )
inputs . files ( new File ( targetDir , "${Module}TestSuite.xml" ) )
onlyIf ( new Spec < Exec > ( ) {
boolean isSatisfiedBy ( Exec task ) {
return os . windows ;
}
} ) ;
}
}
task coverage ( ) {
if ( os . windows ) {
def Set < Task > tasksSet = project . getTasksByName ( 'testsuite' , true )
println "task coverage: covered modules"
println "--------------------------------------"
tasksSet . each { task - > println task . project . parent . path . replace ( ':' , '/' ) . substring ( 1 ) }
println "--------------------------------------"
tasksSet . each { task - > dependsOn report ( os , task . project . parent . path . replace ( ':' , '/' ) . substring ( 1 ) , task . project . parent . name ) }
}
}
/ *
task all ( ) {
FileCollection incs = task . includes ;
incs . each { dir - > fileTree ( dir ) . files . each { file - > inputs . files ( file ) } } ;
inputs . files . each { file - > println file . path }
}
* /
2017-10-31 09:07:53 +01:00
/ *
tasks { t - >
$ . components . main . binaries . each { binary - >
def stripTask = binary . tasks . taskName ( "strip" )
t . create ( stripTask ) {
dependsOn binary . tasks . link
doFirst {
if ( binary . toolChain in Gcc ) {
[ "strip" , binary . tasks . link . outputFile ] . execute ( ) . waitForOrKill ( 1000 )
}
}
}
binary . tasks . build . dependsOn stripTask
}
}
* /