Update to new Native Utils (#1696)

Also update to azure 2019 windows image
This commit is contained in:
Thad House
2019-06-28 14:09:10 -07:00
committed by Peter Johnson
parent 30e936837c
commit 3dfb01d45b
36 changed files with 408 additions and 659 deletions

View File

@@ -1,251 +1,40 @@
import edu.wpi.first.nativeutils.*
import org.gradle.internal.os.OperatingSystem
def windowsCompilerArgs = ['/EHsc', '/D_CRT_SECURE_NO_WARNINGS', '/Zi', '/FS', '/Zc:inline', '/W3', '/wd4244', '/wd4267', '/wd4146', '/wd4996', '/std:c++17', '/Zc:throwingNew', '/permissive-', '/WX']
def windowsCCompilerArgs = ['/Zi', '/FS', '/Zc:inline', '/W3', '/WX']
def windowsReleaseCompilerArgs = ['/O2', '/MD']
def windowsDebugCompilerArgs = ['/Od', '/MDd']
def windowsLinkerArgs = ['/DEBUG:FULL']
def windowsReleaseLinkerArgs = ['/OPT:REF', '/OPT:ICF']
def linuxCrossCompilerArgs = ['-std=c++17', '-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++17', '-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 = ['-O2']
def linuxDebugCompilerArgs = ['-O0']
def linux32BitArg = '-m32'
def macCompilerArgs = ['-std=c++17', '-Wall', '-Wextra', '-Werror', '-pedantic-errors', '-fPIC', '-g',
'-Wno-unused-parameter', '-Wno-error=deprecated-declarations', '-Wno-missing-field-initializers',
'-Wno-unused-private-field', '-Wno-unused-const-variable', '-pthread']
def macCCompilerArgs = ['-Wall', '-Wextra', '-Werror', '-pedantic-errors', '-fPIC', '-g',
'-Wno-unused-parameter', '-Wno-missing-field-initializers', '-Wno-unused-private-field']
def macObjCLinkerArgs = ['-std=c++17', '-stdlib=libc++','-fobjc-arc', '-g', '-fPIC', '-Wall', '-Wextra', '-Werror']
def macReleaseCompilerArgs = ['-O2']
def macDebugCompilerArgs = ['-O0']
def macLinkerArgs = ['-framework', 'CoreFoundation', '-framework', 'AVFoundation', '-framework', 'Foundation', '-framework', 'CoreMedia', '-framework', 'CoreVideo']
def mac32BitArg = '-m32'
def buildAll = project.hasProperty('buildAll')
def windows64PlatformDetect = {
def arch = System.getProperty("os.arch")
def isWin = OperatingSystem.current().isWindows()
if (buildAll) {
return isWin
} else {
return isWin && arch == 'amd64'
nativeUtils.addWpiNativeUtils()
nativeUtils.withRaspbian()
nativeUtils {
wpi {
configureDependencies {
wpiVersion = "-1"
niLibVersion = "2019.12.1"
opencvVersion = "3.4.4-5"
googleTestVersion = "1.8.1-1-f71fb4f"
}
}
}
def windows32PlatformDetect = {
def arch = System.getProperty("os.arch")
def isWin = OperatingSystem.current().isWindows()
if (buildAll) {
return isWin
} else {
return isWin && arch == 'x86'
}
nativeUtils.wpi.addWarnings()
nativeUtils.wpi.addWarningsAsErrors()
nativeUtils.setSinglePrintPerPlatform()
toolchainsPlugin.crossCompilers.named(nativeUtils.wpi.platforms.roborio) {
optional.set(true)
}
def linux32IntelPlatformDetect = {
def arch = System.getProperty("os.arch")
def isLinux = OperatingSystem.current().isLinux()
def isIntel = (arch == 'amd64' || arch == 'i386')
if (buildAll) {
return isLinux && isIntel
} else {
return isLinux && arch == 'i386'
}
}
def linux64IntelPlatformDetect = {
def arch = System.getProperty("os.arch")
def isLinux = OperatingSystem.current().isLinux()
def isIntel = (arch == 'amd64' || arch == 'i386')
if (buildAll) {
return isLinux && isIntel
} else {
return isLinux && arch == 'amd64'
}
}
def linuxArmPlatformDetect = {
def arch = System.getProperty("os.arch")
def isIntel = (arch == 'amd64' || arch == 'i386')
return OperatingSystem.current().isLinux() && !isIntel
}
def mac64PlatformDetect = {
def arch = System.getProperty("os.arch")
def isMac = OperatingSystem.current().isMacOsX()
if (buildAll) {
return isMac
} else {
return isMac && arch == 'x86_64'
}
}
def mac32PlatformDetect = {
def arch = System.getProperty("os.arch")
def isMac = OperatingSystem.current().isMacOsX()
if (buildAll) {
return isMac
} else {
return isMac && arch == 'x86'
}
}
if (!project.hasProperty('skipAthena') && !project.hasProperty('onlyRaspbian')) {
model {
buildConfigs {
roboRio(CrossBuildConfig) {
architecture = 'athena'
operatingSystem = 'linux'
toolChainPrefix = 'arm-frc2019-linux-gnueabi-'
compilerArgs = linuxCrossCompilerArgs
CCompilerArgs = linuxCrossCCompilerArgs
linkerArgs = linuxCrossLinkerArgs
debugCompilerArgs = linuxCrossDebugCompilerArgs
releaseCompilerArgs = linuxCrossReleaseCompilerArgs
stripBuildTypes = ['debug', 'release']
compilerFamily = 'Gcc'
}
model {
components {
all {
nativeUtils.useAllPlatforms(it)
}
}
}
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'
}
binaries {
withType(NativeBinarySpec).all {
nativeUtils.usePlatformArguments(it)
}
}
}
if (!project.hasProperty('onlyAthena') && !hasProperty('onlyRaspbian')) {
model {
buildConfigs {
winX86(BuildConfig) {
architecture = 'x86'
operatingSystem = 'windows'
compilerArgs = windowsCompilerArgs
CCompilerArgs = windowsCCompilerArgs
linkerArgs = windowsLinkerArgs
releaseCompilerArgs = windowsReleaseCompilerArgs
releaseLinkerArgs = windowsReleaseLinkerArgs
debugCompilerArgs = windowsDebugCompilerArgs
compilerFamily = 'VisualCpp'
detectPlatform = windows32PlatformDetect
}
winX64(BuildConfig) {
architecture = 'x86-64'
operatingSystem = 'windows'
compilerArgs = windowsCompilerArgs
CCompilerArgs = windowsCCompilerArgs
linkerArgs = windowsLinkerArgs
releaseCompilerArgs = windowsReleaseCompilerArgs
releaseLinkerArgs = windowsReleaseLinkerArgs
debugCompilerArgs = windowsDebugCompilerArgs
compilerFamily = 'VisualCpp'
detectPlatform = windows64PlatformDetect
}
linuxX64(BuildConfig) {
architecture = 'x86-64'
operatingSystem = 'linux'
compilerArgs = linuxCompilerArgs
CCompilerArgs = linuxCCompilerArgs
linkerArgs = linuxLinkerArgs
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
stripBuildTypes = ['debug', 'release']
compilerFamily = 'Gcc'
detectPlatform = linux64IntelPlatformDetect
}
macX64(BuildConfig) {
architecture = 'x86-64'
operatingSystem = 'osx'
compilerArgs = macCompilerArgs
CCompilerArgs = macCCompilerArgs
debugCompilerArgs = macDebugCompilerArgs
releaseCompilerArgs = macReleaseCompilerArgs
objCppCompilerArgs = macObjCLinkerArgs
linkerArgs = macLinkerArgs
compilerFamily = 'Clang'
detectPlatform = mac64PlatformDetect
}
}
}
}
if (project.hasProperty('linuxCross')) {
model {
buildConfigs {
linuxArm(CrossBuildConfig) {
architecture = 'nativearm'
operatingSystem = 'linux'
toolChainPrefix = 'PLEASE_PROVIDE_A_COMPILER_NAME'
compilerArgs = linuxCompilerArgs
CCompilerArgs = linuxCCompilerArgs
linkerArgs = linuxLinkerArgs
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
stripBuildTypes = ['debug', 'release']
skipByDefault = true
compilerFamily = 'Gcc'
}
}
}
} else {
model {
buildConfigs {
linuxArm(BuildConfig) {
architecture = 'nativearm'
operatingSystem = 'linux'
compilerArgs = linuxCompilerArgs
CCompilerArgs = linuxCCompilerArgs
linkerArgs = linuxLinkerArgs
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
stripBuildTypes = ['debug', 'release']
compilerFamily = 'Gcc'
detectPlatform = linuxArmPlatformDetect
}
}
}
}
ext.getPublishClassifier = { binary ->
return NativeUtils.getPublishClassifier(binary)
}
ext.getPlatformPath = { binary ->
return NativeUtils.getPlatformPath(binary)
}
ext.appendDebugPathToBinaries = { binaries->
binaries.withType(StaticLibraryBinarySpec) {
if (it.buildType.name.contains('debug')) {
@@ -287,7 +76,7 @@ ext.createComponentZipTasks = { components, names, base, type, project, func ->
if (it in NativeLibrarySpec && stringNames.contains(it.name)) {
it.binaries.each {
if (!it.buildable) return
def target = getPublishClassifier(it)
def target = nativeUtils.getPublishClassifier(it)
if (configMap.containsKey(target)) {
configMap.get(target).add(it)
} else {
@@ -358,38 +147,26 @@ ext.includeStandardZipFormat = { task, value ->
if (binary instanceof SharedLibraryBinarySpec) {
task.dependsOn binary.tasks.link
task.from(new File(binary.sharedLibraryFile.absolutePath + ".debug")) {
into getPlatformPath(binary) + '/shared'
into nativeUtils.getPlatformPath(binary) + '/shared'
}
def sharedPath = binary.sharedLibraryFile.absolutePath
sharedPath = sharedPath.substring(0, sharedPath.length() - 4)
task.from(new File(sharedPath + '.pdb')) {
into getPlatformPath(binary) + '/shared'
into nativeUtils.getPlatformPath(binary) + '/shared'
}
task.from(binary.sharedLibraryFile) {
into getPlatformPath(binary) + '/shared'
into nativeUtils.getPlatformPath(binary) + '/shared'
}
task.from(binary.sharedLibraryLinkFile) {
into getPlatformPath(binary) + '/shared'
into nativeUtils.getPlatformPath(binary) + '/shared'
}
} else if (binary instanceof StaticLibraryBinarySpec) {
task.dependsOn binary.tasks.createStaticLib
task.from(binary.staticLibraryFile) {
into getPlatformPath(binary) + '/static'
into nativeUtils.getPlatformPath(binary) + '/static'
}
}
}
}
}
ext.getCurrentArch = {
def arch = System.getProperty('os.arch');
if (arch.equals("x86") || arch.equals("i386")) {
return 'x86'
} else if (arch.equals("amd64") || arch.equals("x86_64")) {
return 'x86-64'
} else {
return arch
}
}

View File

@@ -1,13 +1,8 @@
model {
dependencyConfigs {
googletest(DependencyConfig) {
groupId = 'edu.wpi.first.thirdparty.frc2019'
artifactId = 'googletest'
headerClassifier = 'headers'
ext = 'zip'
version = '1.8.1-1-f71fb4f'
sharedConfigs = [:]
staticConfigs = project.staticGtestConfigs
binaries {
withType(GoogleTestTestSuiteBinarySpec).all {
if (it.targetPlatform.name != nativeUtils.wpi.platforms.raspbian)
nativeUtils.useRequiredLibrary(it, 'googletest_static')
}
}
}

View File

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

View File

@@ -1,6 +1,5 @@
apply plugin: 'checkstyle'
apply plugin: 'pmd'
checkstyle {
toolVersion = "8.12"
@@ -8,10 +7,14 @@ checkstyle {
config = resources.text.fromFile(new File(configDir, "checkstyle.xml"))
}
pmd {
toolVersion = '6.7.0'
consoleOutput = true
reportsDir = file("$project.buildDir/reports/pmd")
ruleSetFiles = files(new File(rootDir, "styleguide/pmd-ruleset.xml"))
ruleSets = []
if (!project.hasProperty('skipPMD')) {
apply plugin: 'pmd'
pmd {
toolVersion = '6.7.0'
consoleOutput = true
reportsDir = file("$project.buildDir/reports/pmd")
ruleSetFiles = files(new File(rootDir, "styleguide/pmd-ruleset.xml"))
ruleSets = []
}
}

View File

@@ -103,7 +103,7 @@ model {
}
binaries {
withType(GoogleTestTestSuiteBinarySpec) {
if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) {
if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian')) {
lib library: nativeName, linkage: 'shared'
} else {
it.buildable = false
@@ -121,7 +121,7 @@ model {
if (it in NativeExecutableSpec && it.name == "${nativeName}Dev") {
it.binaries.each {
if (!found) {
def arch = it.targetPlatform.architecture.name
def arch = it.targetPlatform.name
if (arch == systemArch) {
dependsOn it.tasks.install
commandLine it.tasks.install.runScriptFile.get().asFile.toString()

View File

@@ -82,13 +82,13 @@ model {
task.outputs.file(hashFile)
task.inputs.file(binary.sharedLibraryFile)
task.from(hashFile) {
into getPlatformPath(binary)
into nativeUtils.getPlatformPath(binary)
}
task.doFirst {
hashFile.text = MessageDigest.getInstance("MD5").digest(binary.sharedLibraryFile.bytes).encodeHex().toString()
}
task.from(binary.sharedLibraryFile) {
into getPlatformPath(binary)
into nativeUtils.getPlatformPath(binary)
}
}
}

View File

@@ -106,8 +106,8 @@ model {
}
enableCheckTask true
javaCompileTasks << compileJava
jniCrossCompileOptions << JniCrossCompileOptions('athena')
jniCrossCompileOptions << JniCrossCompileOptions('raspbian')
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.roborio)
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.raspbian)
sources {
cpp {
source {
@@ -144,8 +144,8 @@ model {
}
enableCheckTask true
javaCompileTasks << compileJava
jniCrossCompileOptions << JniCrossCompileOptions('athena')
jniCrossCompileOptions << JniCrossCompileOptions('raspbian')
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.roborio)
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.raspbian)
sources {
cpp {
source {
@@ -224,7 +224,7 @@ model {
}
binaries {
withType(GoogleTestTestSuiteBinarySpec) {
if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) {
if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian')) {
lib library: nativeName, linkage: 'shared'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
} else {
@@ -243,7 +243,7 @@ model {
if (it in NativeExecutableSpec && it.name == "${nativeName}Dev") {
it.binaries.each {
if (!found) {
def arch = it.targetPlatform.architecture.name
def arch = it.targetPlatform.name
if (arch == systemArch) {
dependsOn it.tasks.install
commandLine it.tasks.install.runScriptFile.get().asFile.toString()

View File

@@ -1,37 +1,10 @@
def netCommLibConfigs = [:];
def chipObjectConfigs = [:];
project.chipObjectComponents.each { String s->
chipObjectConfigs[s] = ['linux:athena']
}
project.netCommComponents.each { String s->
netCommLibConfigs[s] = ['linux:athena']
}
def niLibrariesVersion = '2019.12.1'
model {
dependencyConfigs {
chipobject(DependencyConfig) {
groupId = 'edu.wpi.first.ni-libraries'
artifactId = 'chipobject'
headerClassifier = 'headers'
ext = 'zip'
version = niLibrariesVersion
sharedConfigs = chipObjectConfigs
staticConfigs = [:]
compileOnlyShared = true
}
netcomm(DependencyConfig) {
groupId = 'edu.wpi.first.ni-libraries'
artifactId = 'netcomm'
headerClassifier = 'headers'
ext = 'zip'
version = niLibrariesVersion
sharedConfigs = netCommLibConfigs
staticConfigs = [:]
compileOnlyShared = true
binaries {
all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
nativeUtils.useRequiredLibrary(it, 'netcomm_shared', 'chipobject_shared')
}
}
}
}

View File

@@ -2,16 +2,19 @@ def opencvVersion = '3.4.4-5'
if (project.hasProperty('useCpp') && project.useCpp) {
model {
dependencyConfigs {
opencv(DependencyConfig) {
groupId = 'edu.wpi.first.thirdparty.frc2019.opencv'
artifactId = 'opencv-cpp'
headerClassifier = 'headers'
ext = 'zip'
version = opencvVersion
sharedConfigs = project.sharedCvConfigs
staticConfigs = project.staticCvConfigs
linkExcludes = ['**/*java*']
binaries {
withType(NativeBinarySpec).all {
def binary = it
project.sharedCvConfigs.each {
if (binary.component.name == it.key) {
nativeUtils.useRequiredLibrary(binary, 'opencv_shared')
}
}
project.staticCvConfigs.each {
if (binary.component.name == it.key) {
nativeUtils.useRequiredLibrary(binary, 'opencv_static')
}
}
}
}
}

View File

@@ -56,7 +56,7 @@ model {
if (binary instanceof SharedLibraryBinarySpec) {
task.dependsOn binary.buildTask
task.from(binary.sharedLibraryFile) {
into getPlatformPath(binary) + '/shared'
into nativeUtils.getPlatformPath(binary) + '/shared'
}
}
}

View File

@@ -10,7 +10,7 @@ ext {
apply from: "${rootDir}/shared/nilibraries.gradle"
if (!project.hasProperty('onlyAthena')) {
if (!project.hasProperty('onlylinuxathena')) {
ext.skipAthena = true
apply from: "${rootDir}/shared/config.gradle"
@@ -57,7 +57,7 @@ if (!project.hasProperty('onlyAthena')) {
}
}
binaries.all {
if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) {
if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian')) {
project(':hal').addHalDependency(it, 'shared')
lib library: pluginName
if (project.hasProperty('includeNtCore')) {
@@ -78,7 +78,7 @@ if (!project.hasProperty('onlyAthena')) {
model {
tasks {
def c = $.components
if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) {
if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian')) {
project.tasks.create('runCpp', Exec) {
group = 'WPILib'
description = "Run the ${pluginName}Dev executable"
@@ -88,7 +88,7 @@ model {
if (it in NativeExecutableSpec && it.name == "${pluginName}Dev") {
it.binaries.each {
if (!found) {
def arch = it.targetPlatform.architecture.name
def arch = it.targetPlatform.name
if (arch == systemArch) {
dependsOn it.tasks.install
commandLine it.tasks.install.runScriptFile.get().asFile.toString()