poco/Data/PostgreSQL/build.gradle
2018-05-11 17:03:06 +02:00

360 lines
14 KiB
Groovy

model {
repositories {
libs(PrebuiltLibraries) {
intl {
binaries.withType(StaticLibraryBinary) {
def libName = "foobar"
if (buildType == buildTypes.debug) {
if (targetPlatform.name == 'win32') {
libName = 'libintl.lib'
headers.srcDir "$postgres32Home/include"
staticLibraryFile = new File("$postgres32Home/lib/$libName")
} else
if (targetPlatform.name == 'win64') {
libName = 'libintl.lib'
headers.srcDir "$postgres64Home/include"
staticLibraryFile = new File("$postgres64Home/lib/$libName")
} else
if (targetPlatform.operatingSystem.macOsX) {
libName = 'libintl.lib'
//staticLibraryFile = new File("$postgres32OSXHome/lib/$libName")
} else
if (targetPlatform.operatingSystem.linux) {
libName = 'libintl.a'
staticLibraryFile = new File("$postgres32LinuxLib/$libName")
}
} else
if (buildType == buildTypes.release) {
if (targetPlatform.name == 'win32') {
libName = 'libintl.lib'
headers.srcDir "$postgres32Home/include"
staticLibraryFile = new File("$postgres32Home/lib/$libName")
} else
if (targetPlatform.name == 'win64') {
libName = 'libintl.lib'
headers.srcDir "$postgres64Home/include"
staticLibraryFile = new File("$postgres64Home/lib/$libName")
} else
if (targetPlatform.operatingSystem.macOsX) {
libName = 'libintl.a'
staticLibraryFile = new File("$postgres32LinuxLib/$libName")
} else
if (targetPlatform.operatingSystem.linux) {
libName = 'libintl.a'
staticLibraryFile = new File("$postgres32LinuxLib/$libName")
}
}
}
binaries.withType(SharedLibraryBinary) {
def dllName
def linkName
if (buildType == buildTypes.debug) {
if (targetPlatform.name == 'win32') {
dllName = 'libintl-8.dll'
linkName = 'libintl.lib'
headers.srcDir "$postgres32Home/include"
sharedLibraryFile = new File("$postgres32Home/bin/$dllName")
sharedLibraryLinkFile = new File("$postgres32Home/lib/$linkName")
} else
if (targetPlatform.name == 'win64') {
dllName = 'libintl-8.dll'
linkName = 'libintl.lib'
headers.srcDir "$postgres64Home/include"
sharedLibraryFile = new File("$postgres64Home/bin/$dllName")
sharedLibraryLinkFile = new File("$postgres64Home/lib/$linkName")
} else
if (targetPlatform.operatingSystem.macOsX) {
dllName = 'libintl-8.dll'
linkName = 'libintl.lib'
//staticLibraryFile = new File("$postgres32OSXHome/lib/$libName")
} else
if (targetPlatform.operatingSystem.linux) {
dllName = 'libintl-8.so'
linkName = 'libintl.a'
headers.srcDir "$postgres32LinuxInc"
sharedLibraryFile = new File("$postgres32LinuxLib/lib/$dllName")
sharedLibraryLinkFile = new File("$postgres32LinuxLib/lib/$linkName")
}
} else
if (buildType == buildTypes.release) {
if (targetPlatform.name == 'win32') {
dllName = 'libintl-8.dll'
linkName = 'libintl.lib'
headers.srcDir "$postgres32Home/include"
sharedLibraryFile = new File("$postgres32Home/bin/$dllName")
sharedLibraryLinkFile = new File("$postgres32Home/lib/$linkName")
} else
if (targetPlatform.name == 'win64') {
dllName = 'libintl-8.dll'
linkName = 'libintl.lib'
headers.srcDir "$postgres64Home/include"
sharedLibraryFile = new File("$postgres64Home/bin/$dllName")
sharedLibraryLinkFile = new File("$postgres64Home/lib/$linkName")
} else
if (targetPlatform.operatingSystem.macOsX) {
dllName = 'libintl-8.so'
linkName = 'libintl.a'
sharedLibraryFile = new File("$postgres32LinuxLib/lib/$dllName")
sharedLibraryLinkFile = new File("$postgres32LinuxLib/lib/$linkName")
} else
if (targetPlatform.operatingSystem.linux) {
dllName = 'libintl-8.so'
linkName = 'libintl.a'
sharedLibraryFile = new File("$postgres32LinuxLib/lib/$dllName")
sharedLibraryLinkFile = new File("$postgres32LinuxLib/lib/$linkName")
}
}
}
}
iconv {
binaries.withType(StaticLibraryBinary) {
def libName = "foobar"
if (buildType == buildTypes.debug) {
if (targetPlatform.name == 'win32') {
libName = 'iconv.lib'
headers.srcDir "$postgres32Home/include"
staticLibraryFile = new File("$postgres32Home/lib/$libName")
} else
if (targetPlatform.name == 'win64') {
libName = 'iconv.lib'
headers.srcDir "$postgres64Home/include"
staticLibraryFile = new File("$postgres64Home/lib/$libName")
} else
if (targetPlatform.operatingSystem.macOsX) {
libName = 'iconv.a'
//staticLibraryFile = new File("$postgres32OSXHome/lib/$libName")
} else
if (targetPlatform.operatingSystem.linux) {
libName = 'iconv.a'
staticLibraryFile = new File("$postgres32LinuxLib/$libName")
}
} else
if (buildType == buildTypes.release) {
libName = 'iconv.lib'
if (targetPlatform.name == 'win32') {
headers.srcDir "$postgres32Home/include"
staticLibraryFile = new File("$postgres32Home/lib/$libName")
} else
if (targetPlatform.name == 'win64') {
headers.srcDir "$postgres64Home/include"
staticLibraryFile = new File("$postgres64Home/lib/$libName")
} else
if (targetPlatform.operatingSystem.macOsX) {
//staticLibraryFile = new File("$postgres32OSXHome/lib/$libName")
} else
if (targetPlatform.operatingSystem.linux) {
libName = 'iconv.a'
staticLibraryFile = new File("$postgres32LinuxLib/$libName")
}
}
}
binaries.withType(SharedLibraryBinary) {
def dllName
def linkName
if (buildType == buildTypes.debug) {
if (targetPlatform.name == 'win32') {
dllName = 'libiconv-2.dll'
linkName = 'iconv.lib'
headers.srcDir "$postgres32Home/include"
sharedLibraryFile = new File("$postgres32Home/bin/$dllName")
sharedLibraryLinkFile = new File("$postgres32Home/lib/$linkName")
} else
if (targetPlatform.name == 'win64') {
dllName = 'libiconv-2.dll'
linkName = 'iconv.lib'
headers.srcDir "$postgres64Home/include"
sharedLibraryFile = new File("$postgres64Home/bin/$dllName")
sharedLibraryLinkFile = new File("$postgres64Home/lib/$linkName")
} else
if (targetPlatform.operatingSystem.macOsX) {
dllName = 'libiconv-2.so'
linkName = 'iconv.a'
//staticLibraryFile = new File("$postgres32OSXHome/lib/$libName")
} else
if (targetPlatform.operatingSystem.linux) {
dllName = 'libiconv-2.so'
linkName = 'iconv.a'
sharedLibraryFile = new File("$postgres32LinuxLib/lib/$dllName")
sharedLibraryLinkFile = new File("$postgres32LinuxLib/lib/$linkName")
}
} else
if (buildType == buildTypes.release) {
if (targetPlatform.name == 'win32') {
dllName = 'libiconv-2.dll'
linkName = 'iconv.lib'
headers.srcDir "$postgres32Home/include"
sharedLibraryFile = new File("$postgres32Home/bin/$dllName")
sharedLibraryLinkFile = new File("$postgres32Home/lib/$linkName")
} else
if (targetPlatform.name == 'win64') {
dllName = 'libiconv-2.dll'
linkName = 'iconv.lib'
headers.srcDir "$postgres64Home/include"
sharedLibraryFile = new File("$postgres64Home/bin/$dllName")
sharedLibraryLinkFile = new File("$postgres64Home/lib/$linkName")
} else
if (targetPlatform.operatingSystem.macOsX) {
dllName = 'libiconv-2.so'
linkName = 'iconv.a'
//staticLibraryFile = new File("$postgres32OSXHome/lib/$libName")
} else
if (targetPlatform.operatingSystem.linux) {
dllName = 'libiconv-2.so'
linkName = 'iconv.a'
sharedLibraryFile = new File("$postgres32LinuxLib/lib/$dllName")
sharedLibraryLinkFile = new File("$postgres32LinuxLib/lib/$linkName")
}
}
}
}
postgres {
binaries.withType(StaticLibraryBinary) {
def libName = "foobar"
if (buildType == buildTypes.debug) {
libName = 'libpq.lib'
if (targetPlatform.name == 'win32') {
headers.srcDir "$postgres32Home/include"
staticLibraryFile = new File("$postgres32Home/lib/$libName")
} else
if (targetPlatform.name == 'win64') {
headers.srcDir "$postgres64Home/include"
staticLibraryFile = new File("$postgres64Home/lib/$libName")
} else
if (targetPlatform.operatingSystem.macOsX) {
staticLibraryFile = new File("$postgres32OSXHome/lib/$libName")
} else
if (targetPlatform.operatingSystem.linux) {
libName = 'libpq.a'
headers.srcDir "$postgres32LinuxInc"
staticLibraryFile = new File("$postgres32LinuxLib/lib/$libName")
}
} else
if (buildType == buildTypes.release) {
if (targetPlatform.name == 'win32') {
libName = 'libpq.lib'
headers.srcDir "$postgres32Home/include"
staticLibraryFile = new File("$postgres32Home/lib/$libName")
} else
if (targetPlatform.name == 'win64') {
libName = 'libpq.lib'
headers.srcDir "$postgres64Home/include"
staticLibraryFile = new File("$postgres64Home/lib/$libName")
} else
if (targetPlatform.operatingSystem.macOsX) {
staticLibraryFile = new File("$postgres32OSXHome/lib/$libName")
} else
if (targetPlatform.operatingSystem.linux) {
libName = 'libpq.a'
staticLibraryFile = new File("$postgres32LinuxLib/lib/$libName")
}
}
}
binaries.withType(SharedLibraryBinary) {
def dllName
def linkName
if (buildType == buildTypes.debug) {
if (targetPlatform.name == 'win32') {
dllName = 'libpq.dll'
linkName = 'libpq.lib'
headers.srcDir "$postgres32Home/include"
sharedLibraryFile = new File("$postgres32Home/lib/$dllName")
sharedLibraryLinkFile = new File("$postgres32Home/lib/$linkName")
} else
if (targetPlatform.name == 'win64') {
dllName = 'libpq.dll'
linkName = 'libpq.lib'
headers.srcDir "$postgres64Home/include"
sharedLibraryFile = new File("$postgres64Home/lib/$dllName")
sharedLibraryLinkFile = new File("$postgres64Home/lib/$linkName")
} else
if (targetPlatform.operatingSystem.macOsX) {
dllName = 'libpq.dll'
linkName = 'libpq.lib'
headers.srcDir "$postgres32Home/include"
sharedLibraryFile = new File("$postgres32Home/lib/$dllName")
sharedLibraryLinkFile = new File("$postgres32Home/lib/$linkName")
} else
if (targetPlatform.operatingSystem.linux) {
dllName = 'libpq.so'
linkName = 'libpq.a'
headers.srcDir "$postgres32LinuxInc"
sharedLibraryFile = new File("$postgres32LinuxLib/lib/$dllName")
sharedLibraryLinkFile = new File("$postgres32LinuxLib/lib/$linkName")
}
} else
if (buildType == buildTypes.release) {
dllName = 'libpq.dll'
linkName = 'libpq.lib'
if (targetPlatform.name == 'win32') {
headers.srcDir "$postgres32Home/include"
sharedLibraryFile = new File("$postgres32Home/lib/$dllName")
sharedLibraryLinkFile = new File("$postgres32Home/lib/$linkName")
} else
if (targetPlatform.name == 'win64') {
headers.srcDir "$postgres64Home/include"
sharedLibraryFile = new File("$postgres64Home/lib/$dllName")
sharedLibraryLinkFile = new File("$postgres64Home/lib/$linkName")
} else
if (targetPlatform.operatingSystem.macOsX) {
dllName = 'libpq.so'
linkName = 'libpq.a'
headers.srcDir "$postgres32LinuxInc"
sharedLibraryFile = new File("$postgres32LinuxLib/lib/$dllName")
sharedLibraryLinkFile = new File("$postgres32LinuxLib/lib/$linkName")
} else
if (targetPlatform.operatingSystem.linux) {
dllName = 'libpq.so'
linkName = 'libpq.a'
headers.srcDir "$postgres32LinuxInc"
sharedLibraryFile = new File("$postgres32LinuxLib/lib/$dllName")
sharedLibraryLinkFile = new File("$postgres32LinuxLib/lib/$linkName")
}
}
}
}
}
}
components {
DataPostgreSQL(NativeLibrarySpec) {
sources {
rc {
source {
srcDir '../..'
include 'DLLVersion.rc'
}
}
cpp {
source {
srcDir 'src'
include '**/*.cpp'
}
exportedHeaders {
srcDir 'include'
}
// lib library: 'postgres'
lib project: ':Data', library: 'Data'
lib project: ':Foundation', library: 'Foundation'
}
}
}
}
binaries {
all {
if (toolChain in Gcc) {
cppCompiler.args ( "-I", "/usr/include/postgresql")
linker.args ( "-L", "/usr/lib/x86_64-linux-gnu/")
linker.args ( "-l", "pq")
}
}
withType(SharedLibraryBinarySpec) {
if (toolChain in VisualCpp) {
cppCompiler.define "PostgreSQL_EXPORTS"
}
}
withType(StaticLibraryBinarySpec) {
}
}
}
task poco { dependsOn "assemble" }