Update build setup for raspbian and debug binaries (#1384)

- Build both debug and release binaries
- Append "d" to debug libraries in the style of opencv
- Split shared and static classifiers
- Add raspbian support
This commit is contained in:
Thad House
2018-10-27 00:19:38 -07:00
committed by Peter Johnson
parent 8ff81f5a2a
commit a8aacd3657
41 changed files with 565 additions and 343 deletions

View File

@@ -1,19 +1,29 @@
import edu.wpi.first.nativeutils.*
import org.gradle.internal.os.OperatingSystem
def windowsCompilerArgs = ['/EHsc', '/DNOMINMAX', '/Zi', '/FS', '/Zc:inline', '/MT']
def windowsCCompilerArgs = ['/Zi', '/FS', '/Zc:inline', '/MT']
def windowsReleaseCompilerArgs = ['/O2']
def windowsCompilerArgs = ['/EHsc', '/DNOMINMAX', '/Zi', '/FS', '/Zc:inline', '/MP4']
def windowsCCompilerArgs = ['/Zi', '/FS', '/Zc:inline']
def windowsReleaseCompilerArgs = ['/O2', '/MD']
def windowsDebugCompilerArgs = ['/Od', '/MDd']
def windowsLinkerArgs = ['/DEBUG:FULL']
def windowsReleaseLinkerArgs = ['/OPT:REF', '/OPT:ICF']
def linuxCrossCompilerArgs = ['-std=c++14', '-Wformat=2', '-Wall', '-Wextra', '-Werror', '-pedantic', '-Wno-psabi', '-g',
'-Wno-unused-parameter', '-Wno-error=deprecated-declarations', '-fPIC', '-rdynamic',
'-pthread']
def linuxCrossCCompilerArgs = ['-Wformat=2', '-Wall', '-Wextra', '-Werror', '-pedantic', '-Wno-psabi', '-g',
'-Wno-unused-parameter', '-fPIC', '-rdynamic', '-pthread']
def linuxCrossLinkerArgs = ['-rdynamic', '-pthread', '-ldl']
def linuxCrossReleaseCompilerArgs = ['-O2']
def linuxCrossDebugCompilerArgs = ['-Og']
def linuxCompilerArgs = ['-std=c++14', '-Wformat=2', '-Wall', '-Wextra', '-Werror', '-pedantic', '-Wno-psabi', '-g',
'-Wno-unused-parameter', '-Wno-error=deprecated-declarations', '-fPIC', '-rdynamic',
'-pthread']
def linuxCCompilerArgs = ['-Wformat=2', '-Wall', '-Wextra', '-Werror', '-pedantic', '-Wno-psabi', '-g',
'-Wno-unused-parameter', '-fPIC', '-rdynamic', '-pthread']
def linuxLinkerArgs = ['-rdynamic', '-pthread', '-ldl']
def linuxReleaseCompilerArgs = ['-Og']
def linuxReleaseCompilerArgs = ['-O2']
def linuxDebugCompilerArgs = ['-O0']
def linux32BitArg = '-m32'
@@ -98,26 +108,45 @@ def mac32PlatformDetect = {
}
}
if (!project.hasProperty('skipAthena')) {
if (!project.hasProperty('skipAthena') && !project.hasProperty('onlyRaspbian')) {
model {
buildConfigs {
roboRio(CrossBuildConfig) {
architecture = 'athena'
operatingSystem = 'linux'
toolChainPrefix = 'arm-frc2019-linux-gnueabi-'
compilerArgs = linuxCompilerArgs
CCompilerArgs = linuxCCompilerArgs
linkerArgs = linuxLinkerArgs
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
releaseStripBinaries = true
compilerArgs = linuxCrossCompilerArgs
CCompilerArgs = linuxCrossCCompilerArgs
linkerArgs = linuxCrossLinkerArgs
debugCompilerArgs = linuxCrossDebugCompilerArgs
releaseCompilerArgs = linuxCrossReleaseCompilerArgs
stripBuildTypes = ['debug', 'release']
compilerFamily = 'Gcc'
}
}
}
}
if (!project.hasProperty('onlyAthena')) {
if (!project.hasProperty('skipRaspbian') && !project.hasProperty('onlyAthena')) {
model {
buildConfigs {
raspbian(CrossBuildConfig) {
architecture = 'raspbian'
operatingSystem = 'linux'
toolChainPrefix = 'arm-raspbian9-linux-gnueabihf-'
compilerArgs = linuxCrossCompilerArgs
CCompilerArgs = linuxCrossCCompilerArgs
linkerArgs = linuxCrossLinkerArgs
debugCompilerArgs = linuxCrossDebugCompilerArgs
releaseCompilerArgs = linuxCrossReleaseCompilerArgs
stripBuildTypes = ['debug', 'release']
compilerFamily = 'Gcc'
}
}
}
}
if (!project.hasProperty('onlyAthena') && !hasProperty('onlyRaspbian')) {
model {
buildConfigs {
winX86(BuildConfig) {
@@ -128,6 +157,7 @@ if (!project.hasProperty('onlyAthena')) {
linkerArgs = windowsLinkerArgs
releaseCompilerArgs = windowsReleaseCompilerArgs
releaseLinkerArgs = windowsReleaseLinkerArgs
debugCompilerArgs = windowsDebugCompilerArgs
compilerFamily = 'VisualCpp'
detectPlatform = windows32PlatformDetect
}
@@ -139,6 +169,7 @@ if (!project.hasProperty('onlyAthena')) {
linkerArgs = windowsLinkerArgs
releaseCompilerArgs = windowsReleaseCompilerArgs
releaseLinkerArgs = windowsReleaseLinkerArgs
debugCompilerArgs = windowsDebugCompilerArgs
compilerFamily = 'VisualCpp'
detectPlatform = windows64PlatformDetect
}
@@ -150,7 +181,7 @@ if (!project.hasProperty('onlyAthena')) {
linkerArgs = linuxLinkerArgs
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
releaseStripBinaries = true
stripBuildTypes = ['debug', 'release']
compilerFamily = 'Gcc'
detectPlatform = linux64IntelPlatformDetect
}
@@ -182,7 +213,7 @@ if (project.hasProperty('linuxCross')) {
linkerArgs = linuxLinkerArgs
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
releaseStripBinaries = true
stripBuildTypes = ['debug', 'release']
skipByDefault = true
compilerFamily = 'Gcc'
}
@@ -199,7 +230,7 @@ if (project.hasProperty('linuxCross')) {
linkerArgs = linuxLinkerArgs
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
releaseStripBinaries = true
stripBuildTypes = ['debug', 'release']
compilerFamily = 'Gcc'
detectPlatform = linuxArmPlatformDetect
}
@@ -207,20 +238,56 @@ if (project.hasProperty('linuxCross')) {
}
}
ext.getClassifier = { binary ->
return NativeUtils.getClassifier(binary)
ext.getPublishClassifier = { binary ->
return NativeUtils.getPublishClassifier(binary)
}
ext.getPlatformPath = { binary ->
return NativeUtils.getPlatformPath(binary)
}
ext.createComponentZipTasks = { components, name, base, type, project, func ->
ext.appendDebugPathToBinaries = { binaries->
binaries.withType(StaticLibraryBinarySpec) {
if (it.buildType.name.contains('debug')) {
def staticFileDir = it.staticLibraryFile.parentFile
def staticFileName = it.staticLibraryFile.name
def staticFileExtension = staticFileName.substring(staticFileName.lastIndexOf('.'))
staticFileName = staticFileName.substring(0, staticFileName.lastIndexOf('.'))
staticFileName = staticFileName + 'd' + staticFileExtension
def newStaticFile = new File(staticFileDir, staticFileName)
it.staticLibraryFile = newStaticFile
}
}
binaries.withType(SharedLibraryBinarySpec) {
if (it.buildType.name.contains('debug')) {
def sharedFileDir = it.sharedLibraryFile.parentFile
def sharedFileName = it.sharedLibraryFile.name
def sharedFileExtension = sharedFileName.substring(sharedFileName.lastIndexOf('.'))
sharedFileName = sharedFileName.substring(0, sharedFileName.lastIndexOf('.'))
sharedFileName = sharedFileName + 'd' + sharedFileExtension
def newSharedFile = new File(sharedFileDir, sharedFileName)
def sharedLinkFileDir = it.sharedLibraryLinkFile.parentFile
def sharedLinkFileName = it.sharedLibraryLinkFile.name
def sharedLinkFileExtension = sharedLinkFileName.substring(sharedLinkFileName.lastIndexOf('.'))
sharedLinkFileName = sharedLinkFileName.substring(0, sharedLinkFileName.lastIndexOf('.'))
sharedLinkFileName = sharedLinkFileName + 'd' + sharedLinkFileExtension
def newLinkFile = new File(sharedLinkFileDir, sharedLinkFileName)
it.sharedLibraryLinkFile = newLinkFile
it.sharedLibraryFile = newSharedFile
}
}
}
ext.createComponentZipTasks = { components, names, base, type, project, func ->
def stringNames = names.collect {it.toString()}
def configMap = [:]
components.each {
if (it in NativeLibrarySpec && it.name == name) {
if (it in NativeLibrarySpec && stringNames.contains(it.name)) {
it.binaries.each {
def target = getClassifier(it)
if (!it.buildable) return
def target = getPublishClassifier(it)
if (configMap.containsKey(target)) {
configMap.get(target).add(it)
} else {
@@ -260,14 +327,16 @@ ext.createComponentZipTasks = { components, name, base, type, project, func ->
ext.createAllCombined = { list, name, base, type, project ->
def outputsFolder = file("$project.buildDir/outputs")
def task = project.tasks.create(base + '-all', type) {
description = 'Creates component archive for all classifiers'
def task = project.tasks.create(base + "-all", type) {
description = "Creates component archive for all classifiers"
destinationDir = outputsFolder
classifier = 'all'
classifier = "all"
baseName = base
duplicatesStrategy = 'exclude'
list.each {
if (it.name.endsWith('debug')) return
from project.zipTree(it.archivePath)
dependsOn it
}
@@ -303,7 +372,7 @@ ext.includeStandardZipFormat = { task, value ->
task.from(binary.sharedLibraryLinkFile) {
into getPlatformPath(binary) + '/shared'
}
} else if (binary instanceof StaticLibraryBinarySpec) {
} else if (binary instanceof StaticLibraryBinarySpec) {
task.dependsOn binary.tasks.createStaticLib
task.from(binary.staticLibraryFile) {
into getPlatformPath(binary) + '/static'

View File

@@ -5,7 +5,7 @@ model {
artifactId = 'googletest'
headerClassifier = 'headers'
ext = 'zip'
version = '1.8.0-1-4e4df22'
version = '1.8.0-4-4e4df22'
sharedConfigs = [:]
staticConfigs = project.staticGtestConfigs
}

View File

@@ -87,7 +87,7 @@ test {
}
}
if (project.hasProperty('onlyAthena')) {
if (project.hasProperty('onlyAthena') || project.hasProperty('onlyRaspbian')) {
test.enabled = false
}

View File

@@ -53,12 +53,7 @@ addTaskToCopyAllOutputs(cppHeadersZip)
model {
publishing {
def taskList = createComponentZipTasks($.components, nativeName, zipBaseName, Zip, project, includeStandardZipFormat)
def allTask
if (!project.hasProperty('jenkinsBuild')) {
allTask = createAllCombined(taskList, nativeName, zipBaseName, Zip, project)
}
def taskList = createComponentZipTasks($.components, [nativeName], zipBaseName, Zip, project, includeStandardZipFormat)
publications {
cpp(MavenPublication) {
@@ -68,10 +63,6 @@ model {
artifact cppHeadersZip
artifact cppSourcesZip
if (!project.hasProperty('jenkinsBuild')) {
artifact allTask
}
artifactId = "${baseArtifactId}-cpp"
groupId artifactGroupId
version pubVersion

View File

@@ -60,10 +60,12 @@ model {
}
}
}
appendDebugPathToBinaries(binaries)
}
// By default, a development executable will be generated. This is to help the case of
// testing specific functionality of the library.
"${nativeName}Dev"(NativeExecutableSpec) {
targetBuildTypes 'debug'
sources {
cpp {
source {
@@ -101,7 +103,7 @@ model {
}
binaries {
withType(GoogleTestTestSuiteBinarySpec) {
if (!project.hasProperty('onlyAthena')) {
if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) {
lib library: nativeName, linkage: 'shared'
} else {
it.buildable = false

View File

@@ -71,14 +71,9 @@ addTaskToCopyAllOutputs(cppHeadersZip)
model {
publishing {
def taskList = createComponentZipTasks($.components, nativeName, zipBaseName, Zip, project, includeStandardZipFormat)
def taskList = createComponentZipTasks($.components, [nativeName, "${nativeName}JNIShared"], zipBaseName, Zip, project, includeStandardZipFormat)
def allTask
if (!project.hasProperty('jenkinsBuild')) {
allTask = createAllCombined(taskList, nativeName, zipBaseName, Zip, project)
}
def jniTaskList = createComponentZipTasks($.components, "${nativeName}JNI", jniBaseName, Jar, project, { task, value ->
def jniTaskList = createComponentZipTasks($.components, ["${nativeName}JNI"], jniBaseName, Jar, project, { task, value ->
value.each { binary ->
if (binary.buildable) {
if (binary instanceof SharedLibraryBinarySpec) {
@@ -113,10 +108,6 @@ model {
artifact cppHeadersZip
artifact cppSourcesZip
if (!project.hasProperty('jenkinsBuild')) {
artifact allTask
}
artifactId = "${baseArtifactId}-cpp"
groupId artifactGroupId
version pubVersion

View File

@@ -33,9 +33,9 @@ apply from: "${rootDir}/shared/googletest.gradle"
if (project.hasProperty('niLibraries')) {
ext {
chipObjectComponents = ["$nativeName".toString(), "${nativeName}Dev".toString(), "${nativeName}Base".toString(),
"${nativeName}JNI".toString(), "${nativeName}Test".toString()]
"${nativeName}JNI".toString(), "${nativeName}JNIShared".toString(), "${nativeName}Test".toString()]
netCommComponents = ["$nativeName".toString(), "${nativeName}Dev".toString(), "${nativeName}Base".toString(),
"${nativeName}JNI".toString(), "${nativeName}Test".toString()]
"${nativeName}JNI".toString(), "${nativeName}JNIShared".toString(), "${nativeName}Test".toString()]
useNiJava = true
}
@@ -44,17 +44,16 @@ if (project.hasProperty('niLibraries')) {
model {
components {
"${nativeName}Base"(JniNativeLibrarySpec) {
"${nativeName}Base"(NativeLibrarySpec) {
if (project.hasProperty('setBaseName')) {
baseName = setBaseName
}
javaCompileTasks << compileJava
jniCrossCompileOptions << JniCrossCompileOptions('athena')
sources {
cpp {
source {
srcDirs 'src/main/native/cpp'
include '**/*.cpp'
exclude '**/jni/*.cpp'
}
exportedHeaders {
srcDir 'src/main/native/include'
@@ -75,13 +74,10 @@ model {
}
}
}
"${nativeName}"(JniNativeLibrarySpec) {
"${nativeName}"(NativeLibrarySpec) {
if (project.hasProperty('setBaseName')) {
baseName = setBaseName
}
enableCheckTask true
javaCompileTasks << compileJava
jniCrossCompileOptions << JniCrossCompileOptions('athena')
sources {
cpp {
source {
@@ -99,21 +95,23 @@ model {
binaries.all {
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
}
appendDebugPathToBinaries(binaries)
}
"${nativeName}JNI"(JniNativeLibrarySpec) {
"${nativeName}JNIShared"(JniNativeLibrarySpec) {
if (project.hasProperty('setBaseName')) {
baseName = setBaseName
baseName = setBaseName + 'jni'
} else {
baseName = nativeName
baseName = nativeName + 'jni'
}
enableCheckTask true
javaCompileTasks << compileJava
jniCrossCompileOptions << JniCrossCompileOptions('athena')
jniCrossCompileOptions << JniCrossCompileOptions('raspbian')
sources {
cpp {
source {
srcDirs "${rootDir}/shared/singlelib"
include '**/*.cpp'
srcDirs 'src/main/native/cpp'
include '**/jni/*.cpp'
}
exportedHeaders {
srcDir 'src/main/native/include'
@@ -128,12 +126,53 @@ model {
it.buildable = false
return
}
lib library: "${nativeName}", linkage: 'shared'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
if (project.hasProperty('jniSplitSetup')) {
jniSplitSetup(it)
}
}
}
"${nativeName}JNI"(JniNativeLibrarySpec) {
if (project.hasProperty('setBaseName')) {
baseName = setBaseName + 'jni'
} else {
baseName = nativeName + 'jni'
}
enableCheckTask true
javaCompileTasks << compileJava
jniCrossCompileOptions << JniCrossCompileOptions('athena')
jniCrossCompileOptions << JniCrossCompileOptions('raspbian')
sources {
cpp {
source {
srcDirs 'src/main/native/cpp'
include '**/jni/*.cpp'
}
exportedHeaders {
srcDir 'src/main/native/include'
if (project.hasProperty('generatedHeaders')) {
srcDir generatedHeaders
}
}
}
}
binaries.all {
if (it instanceof StaticLibraryBinarySpec) {
it.buildable = false
return
}
lib library: "${nativeName}", linkage: 'static'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
if (project.hasProperty('jniSplitSetup')) {
jniSplitSetup(it)
}
}
}
// By default, a development executable will be generated. This is to help the case of
// testing specific functionality of the library.
"${nativeName}Dev"(NativeExecutableSpec) {
targetBuildTypes 'debug'
sources {
cpp {
@@ -151,6 +190,7 @@ model {
}
binaries.all {
lib library: nativeName, linkage: 'shared'
lib library: "${nativeName}JNIShared", linkage: 'shared'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
}
}
@@ -181,7 +221,7 @@ model {
}
binaries {
withType(GoogleTestTestSuiteBinarySpec) {
if (!project.hasProperty('onlyAthena')) {
if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) {
lib library: nativeName, linkage: 'shared'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
} else {

View File

@@ -16,7 +16,7 @@ model {
artifactId = 'chipobject'
headerClassifier = 'headers'
ext = 'zip'
version = '2019.4.1'
version = '2019.4.2'
sharedConfigs = chipObjectConfigs
staticConfigs = [:]
compileOnlyShared = true
@@ -26,7 +26,7 @@ model {
artifactId = 'netcomm'
headerClassifier = 'headers'
ext = 'zip'
version = '2019.4.1'
version = '2019.4.2'
sharedConfigs = netCommLibConfigs
staticConfigs = [:]
compileOnlyShared = true

View File

@@ -6,7 +6,7 @@ if (project.hasProperty('useCpp') && project.useCpp) {
artifactId = 'opencv-cpp'
headerClassifier = 'headers'
ext = 'zip'
version = '3.4.3-7'
version = '3.4.3-15'
sharedConfigs = project.sharedCvConfigs
staticConfigs = project.staticCvConfigs
linkExcludes = ['**/*java*']
@@ -17,12 +17,12 @@ if (project.hasProperty('useCpp') && project.useCpp) {
if (project.hasProperty('useJava') && project.useJava) {
dependencies {
compile 'edu.wpi.first.thirdparty.frc2019.opencv:opencv-java:3.4.3-7'
compile 'edu.wpi.first.thirdparty.frc2019.opencv:opencv-java:3.4.3-15'
if (!project.hasProperty('skipDev') || !project.skipDev) {
devCompile 'edu.wpi.first.thirdparty.frc2019.opencv:opencv-java:3.4.3-7'
devCompile 'edu.wpi.first.thirdparty.frc2019.opencv:opencv-java:3.4.3-15'
}
if (project.hasProperty('useDocumentation') && project.useDocumentation) {
javaSource 'edu.wpi.first.thirdparty.frc2019.opencv:opencv-java:3.4.3-7:sources'
javaSource 'edu.wpi.first.thirdparty.frc2019.opencv:opencv-java:3.4.3-15:sources'
}
}
}

View File

@@ -50,7 +50,7 @@ addTaskToCopyAllOutputs(cppHeadersZip)
model {
publishing {
def pluginTaskList = createComponentZipTasks($.components, pluginName, zipBaseName, Zip, project, { task, value ->
def pluginTaskList = createComponentZipTasks($.components, [pluginName], zipBaseName, Zip, project, { task, value ->
value.each { binary ->
if (binary.buildable) {
if (binary instanceof SharedLibraryBinarySpec) {
@@ -63,21 +63,12 @@ model {
}
})
def allTask
if (!project.hasProperty('jenkinsBuild')) {
allTask = createAllCombined(pluginTaskList, pluginName, zipBaseName, Zip, project)
}
publications {
cpp(MavenPublication) {
pluginTaskList.each {
artifact it
}
if (!project.hasProperty('jenkinsBuild')) {
artifact allTask
}
artifact cppHeadersZip
artifact cppSourcesZip

View File

@@ -41,8 +41,10 @@ if (!project.hasProperty('onlyAthena')) {
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
}
}
appendDebugPathToBinaries(binaries)
}
"${pluginName}Dev"(NativeExecutableSpec) {
targetBuildTypes 'debug'
sources {
cpp {
source {
@@ -55,12 +57,16 @@ if (!project.hasProperty('onlyAthena')) {
}
}
binaries.all {
project(':hal').addHalDependency(it, 'shared')
lib library: pluginName
if (project.hasProperty('includeNtCore')) {
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) {
project(':hal').addHalDependency(it, 'shared')
lib library: pluginName
if (project.hasProperty('includeNtCore')) {
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
}
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
} else {
it.buildable = false
}
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
}
}
}
@@ -72,7 +78,7 @@ if (!project.hasProperty('onlyAthena')) {
model {
tasks {
def c = $.components
if (!project.hasProperty('onlyAthena')) {
if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) {
project.tasks.create('runCpp', Exec) {
group = 'WPILib'
description = "Run the ${pluginName}Dev executable"