diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 97ef121a50..cb0626903d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -31,7 +31,7 @@ stages: publishJUnitResults: false testResultsFiles: '**/TEST-*.xml' tasks: 'build' - options: '-PonlyAthena' + options: '-Ponlylinuxathena' # checkStyleRunAnalysis: true # pmdRunAnalysis: true @@ -55,7 +55,7 @@ stages: publishJUnitResults: true testResultsFiles: '**/TEST-*.xml' tasks: 'build' - options: '-PonlyRaspbian' + options: '-Ponlylinuxraspbian' # checkStyleRunAnalysis: true # pmdRunAnalysis: true @@ -79,7 +79,7 @@ stages: publishJUnitResults: true testResultsFiles: '**/TEST-*.xml' tasks: 'build' - options: '-PskipAthena' + options: '-Pskiplinuxathena -Pskiplinuxraspbian' # checkStyleRunAnalysis: true # pmdRunAnalysis: true @@ -130,7 +130,7 @@ stages: - job: Windows_64_Bit pool: - vmImage: 'vs2017-win2016' + vmImage: 'windows-2019' steps: - powershell: | mkdir build @@ -151,6 +151,7 @@ stages: publishJUnitResults: true testResultsFiles: '**/TEST-*.xml' tasks: 'build' + options: '-PskipPMD' # checkStyleRunAnalysis: true # pmdRunAnalysis: true @@ -161,7 +162,7 @@ stages: - job: Windows_32_Bit pool: - vmImage: 'vs2017-win2016' + vmImage: 'windows-2019' steps: - powershell: | mkdir build @@ -182,6 +183,7 @@ stages: publishJUnitResults: true testResultsFiles: '**/TEST-*.xml' tasks: 'build' + options: '-PskipPMD' # checkStyleRunAnalysis: true # pmdRunAnalysis: true - task: PublishPipelineArtifact@0 @@ -212,6 +214,7 @@ stages: publishJUnitResults: true testResultsFiles: '**/TEST-*.xml' tasks: 'build' + #options: '' # checkStyleRunAnalysis: true # pmdRunAnalysis: true diff --git a/build.gradle b/build.gradle index aac1e12af2..acb8310039 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,14 @@ +import edu.wpi.first.toolchain.* + plugins { id 'base' id 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin' version '2.3' - id 'edu.wpi.first.NativeUtils' version '2.1.2' - id 'edu.wpi.first.GradleJni' version '0.3.1' - id 'edu.wpi.first.GradleVsCode' version '0.7.1' + id 'edu.wpi.first.NativeUtils' apply false + id 'edu.wpi.first.GradleJni' version '0.4.1' + id 'edu.wpi.first.GradleVsCode' version '0.8.0' id 'idea' id 'visual-studio' - id 'com.gradle.build-scan' version '2.0.2' + id 'com.gradle.build-scan' version '2.3' id 'net.ltgt.errorprone' version '0.6' apply false id 'com.github.johnrengelman.shadow' version '4.0.3' apply false } @@ -99,6 +101,10 @@ subprojects { } } -wrapper { - gradleVersion = '5.0' +ext.getCurrentArch = { + return NativePlatforms.desktop +} + +wrapper { + gradleVersion = '5.4.1' } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 0000000000..7bab0117e9 --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,9 @@ +repositories { + maven { + url "https://plugins.gradle.org/m2/" + mavenLocal() + } +} +dependencies { + compile "edu.wpi.first:native-utils:2019.5.12" +} diff --git a/buildSrc/src/main/groovy/MultiBuilds.groovy b/buildSrc/src/main/groovy/MultiBuilds.groovy index aa1a225e16..8df7fc6d4c 100644 --- a/buildSrc/src/main/groovy/MultiBuilds.groovy +++ b/buildSrc/src/main/groovy/MultiBuilds.groovy @@ -47,16 +47,6 @@ class MultiBuilds implements Plugin { @CompileStatic static class Rules extends RuleSource { - @Mutate - void setupBuildTypes(BuildTypeContainer buildTypes, ProjectLayout projectLayout) { - def project = (Project) projectLayout.projectIdentifier - if (project.hasProperty('releaseBuild')) { - buildTypes.create('debug') - } else { - buildTypes.create('release') - } - } - @CompileDynamic private static void setBuildableFalseDynamically(NativeBinarySpec binary) { binary.buildable = false diff --git a/buildSrc/src/main/groovy/SingleNativeBuild.groovy b/buildSrc/src/main/groovy/SingleNativeBuild.groovy index 20d415da07..2b7e087b24 100644 --- a/buildSrc/src/main/groovy/SingleNativeBuild.groovy +++ b/buildSrc/src/main/groovy/SingleNativeBuild.groovy @@ -40,6 +40,7 @@ import org.gradle.platform.base.ComponentType; import org.gradle.platform.base.TypeBuilder; import org.gradle.nativeplatform.tasks.ObjectFilesToBinary; import groovy.transform.CompileStatic; +import edu.wpi.first.nativeutils.tasks.ExportsGenerationTask @CompileStatic class SingleNativeBuild implements Plugin { @@ -94,8 +95,7 @@ class SingleNativeBuild implements Plugin { return } def tmpBaseBin = (NativeBinarySpec) oTmpBaseBin - if (tmpBaseBin.targetPlatform.operatingSystem.name == binary.targetPlatform.operatingSystem.name && - tmpBaseBin.targetPlatform.architecture.name == binary.targetPlatform.architecture.name && + if (tmpBaseBin.targetPlatform.name == binary.targetPlatform.name && tmpBaseBin.buildType == binary.buildType) { baseBin = tmpBaseBin } @@ -105,6 +105,10 @@ class SingleNativeBuild implements Plugin { if (binary instanceof SharedLibraryBinarySpec) { def sBinary = (SharedLibraryBinarySpec) binary ObjectFilesToBinary link = (ObjectFilesToBinary) sBinary.tasks.link + ExportsGenerationTask exportsTask = binary.tasks.withType(ExportsGenerationTask)[0] + if (exportsTask != null) { + exportsTask.dependsOn compileTask + } link.dependsOn compileTask link.inputs.dir compileTask.objectFileDir def tree = project.fileTree(compileTask.objectFileDir) diff --git a/cameraserver/build.gradle b/cameraserver/build.gradle index 2b19454a27..d59d74983d 100644 --- a/cameraserver/build.gradle +++ b/cameraserver/build.gradle @@ -30,23 +30,20 @@ ext { apply from: "${rootDir}/shared/opencv.gradle" -model { - // Exports config is a utility to enable exporting all symbols in a C++ library on windows to a DLL. - // This removes the need for DllExport on a library. However, the gradle C++ builder has a bug - // where some extra symbols are added that cannot be resolved at link time. This configuration - // lets you specify specific symbols to exlude from exporting. - exportsConfigs { - cameraserver(ExportsConfig) { - x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', - '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', - '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', - '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] - x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', - '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', - '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', - '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] - } +nativeUtils.exportsConfigs { + cameraserver { + x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', + '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', + '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', + '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] + x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', + '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', + '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', + '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] } +} + +model { components {} binaries { all { @@ -66,7 +63,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) { def filePath = it.tasks.install.installDirectory.get().toString() + File.separatorChar + 'lib' diff --git a/cscore/build.gradle b/cscore/build.gradle index 40cb97dafa..53a762beec 100644 --- a/cscore/build.gradle +++ b/cscore/build.gradle @@ -20,7 +20,7 @@ ext { useJava = true useCpp = true splitSetup = { - if (it.targetPlatform.operatingSystem.name == 'osx') { + if (it.targetPlatform.operatingSystem.isMacOsX()) { it.sources { macObjCpp(ObjectiveCppSourceSet) { source { @@ -43,7 +43,7 @@ ext { } } } - } else if (it.targetPlatform.operatingSystem.name == 'linux') { + } else if (it.targetPlatform.operatingSystem.isLinux()) { it.sources { cscoreLinuxCpp(CppSourceSet) { source { @@ -56,7 +56,7 @@ ext { } } } - } else if (it.targetPlatform.operatingSystem.name == 'windows') { + } else if (it.targetPlatform.operatingSystem.isWindows()) { it.sources { cscoreWindowsCpp(CppSourceSet) { source { @@ -88,43 +88,28 @@ examplesTree.list(new FilenameFilter() { apply from: "${rootDir}/shared/opencv.gradle" -model { - // Exports config is a utility to enable exporting all symbols in a C++ library on windows to a DLL. - // This removes the need for DllExport on a library. However, the gradle C++ builder has a bug - // where some extra symbols are added that cannot be resolved at link time. This configuration - // lets you specify specific symbols to exlude from exporting. - exportsConfigs { - cscore(ExportsConfig) { - x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', - '_CT??_R0?AVbad_cast', - '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', - '_TI5?AVfailure'] - x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', - '_CT??_R0?AVbad_cast', - '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', - '_TI5?AVfailure'] +nativeUtils.exportsConfigs { + cscore { + x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', + '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', + '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', + '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] + x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', + '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', + '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', + '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] + } + cscoreJNI { + x86SymbolFilter = { symbols -> + symbols.removeIf({ !it.startsWith('CS_') }) } - cscoreJNI(ExportsConfig) { - x86SymbolFilter = { symbols -> - def retList = [] - symbols.each { symbol -> - if (symbol.startsWith('CS_')) { - retList << symbol - } - } - return retList - } - x64SymbolFilter = { symbols -> - def retList = [] - symbols.each { symbol -> - if (symbol.startsWith('CS_')) { - retList << symbol - } - } - return retList - } + x64SymbolFilter = { symbols -> + symbols.removeIf({ !it.startsWith('CS_') }) } } +} + +model { components { examplesMap.each { key, value -> "${key}"(NativeExecutableSpec) { diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 457aad0d98..5c2d1cf016 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 75b8c7c8c6..f4d7b2bf61 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index af6708ff22..b0d6d0ab5d 100755 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m"' +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" diff --git a/gradlew.bat b/gradlew.bat index 0f8d5937c4..15e1ee37a7 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem http://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/hal/build.gradle b/hal/build.gradle index 2f49ee5c99..08eadb202d 100644 --- a/hal/build.gradle +++ b/hal/build.gradle @@ -67,7 +67,7 @@ ext { it.tasks.withType(AbstractNativeSourceCompileTask) { it.dependsOn generateUsageReporting } - if (it.targetPlatform.architecture.name == 'athena') { + if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { it.sources { athenaJniCpp(CppSourceSet) { source { @@ -99,7 +99,7 @@ ext { it.tasks.withType(AbstractNativeSourceCompileTask) { it.dependsOn generateUsageReporting } - if (it.targetPlatform.architecture.name == 'athena') { + if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { it.sources { athenaCpp(CppSourceSet) { source { @@ -163,41 +163,23 @@ cppHeadersZip { } } -model { - // Exports config is a utility to enable exporting all symbols in a C++ library on windows to a DLL. - // This removes the need for DllExport on a library. However, the gradle C++ builder has a bug - // where some extra symbols are added that cannot be resolved at link time. This configuration - // lets you specify specific symbols to exlude from exporting. - exportsConfigs { - hal(ExportsConfig) { - x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', - '_CT??_R0?AVbad_cast', - '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', - '_TI5?AVfailure'] - x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', - '_CT??_R0?AVbad_cast', - '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', - '_TI5?AVfailure'] +nativeUtils.exportsConfigs { + hal { + x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', + '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', + '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', + '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] + x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', + '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', + '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', + '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] + } + halJNI { + x86SymbolFilter = { symbols -> + symbols.removeIf({ !it.startsWith('HAL_') && !it.startsWith('HALSIM_') }) } - halJNI(ExportsConfig) { - x86SymbolFilter = { symbols -> - def retList = [] - symbols.each { symbol -> - if (symbol.startsWith('HAL_') || symbol.startsWith('HALSIM_')) { - retList << symbol - } - } - return retList - } - x64SymbolFilter = { symbols -> - def retList = [] - symbols.each { symbol -> - if (symbol.startsWith('HAL_') || symbol.startsWith('HALSIM_')) { - retList << symbol - } - } - return retList - } + x64SymbolFilter = { symbols -> + symbols.removeIf({ !it.startsWith('HAL_') && !it.startsWith('HALSIM_') }) } } } diff --git a/hal/simjni.gradle b/hal/simjni.gradle index 599f0949b7..c1aef73dc4 100644 --- a/hal/simjni.gradle +++ b/hal/simjni.gradle @@ -12,7 +12,7 @@ task generateAthenaSimFiles() { it.all { component -> if (component in getJniSpecClass()) { component.binaries.all { binary -> - if (binary.targetPlatform.architecture.name == 'athena') { + if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { binary.tasks.withType(CppCompile) { it.dependsOn createdTask } diff --git a/myRobot/build.gradle b/myRobot/build.gradle index 0c047e84d7..8f296cec22 100644 --- a/myRobot/build.gradle +++ b/myRobot/build.gradle @@ -110,7 +110,7 @@ model { if (it in NativeExecutableSpec && it.name == "myRobotCpp") { 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() @@ -129,14 +129,14 @@ model { } installAthena(Task) { $.binaries.each { - if (it in NativeExecutableBinarySpec && it.targetPlatform.architecture.name == 'athena' && it.component.name == 'myRobotCpp') { + if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.roborio && it.component.name == 'myRobotCpp') { dependsOn it.tasks.install } } } installAthenaStatic(Task) { $.binaries.each { - if (it in NativeExecutableBinarySpec && it.targetPlatform.architecture.name == 'athena' && it.component.name == 'myRobotCppStatic') { + if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.roborio && it.component.name == 'myRobotCppStatic') { dependsOn it.tasks.install } } diff --git a/ntcore/build.gradle b/ntcore/build.gradle index 659b0f9214..5739b71113 100644 --- a/ntcore/build.gradle +++ b/ntcore/build.gradle @@ -5,45 +5,29 @@ ext { apply from: "${rootDir}/shared/jni/setupBuild.gradle" -model { - // Exports config is a utility to enable exporting all symbols in a C++ library on windows to a DLL. - // This removes the need for DllExport on a library. However, the gradle C++ builder has a bug - // where some extra symbols are added that cannot be resolved at link time. This configuration - // lets you specify specific symbols to exlude from exporting. - exportsConfigs { - ntcore(ExportsConfig) { - x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', - '_CT??_R0?AVbad_cast', - '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', - '_TI5?AVfailure'] - x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', - '_CT??_R0?AVbad_cast', - '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', - '_TI5?AVfailure'] +nativeUtils.exportsConfigs { + ntcore { + x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', + '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', + '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', + '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] + x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', + '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', + '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', + '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] + } + ntcoreJNI { + x86SymbolFilter = { symbols -> + symbols.removeIf({ !it.startsWith('NT_') }) } - ntcoreJNI(ExportsConfig) { - x86SymbolFilter = { symbols -> - def retList = [] - symbols.each { symbol -> - if (symbol.startsWith('NT_')) { - retList << symbol - } - } - return retList - } - x64SymbolFilter = { symbols -> - def retList = [] - symbols.each { symbol -> - if (symbol.startsWith('NT_')) { - retList << symbol - } - } - return retList - } + x64SymbolFilter = { symbols -> + symbols.removeIf({ !it.startsWith('NT_') }) } } } -pmdMain { - pmdMain.enabled = false +if (!project.hasProperty('skipPMD')) { + pmdMain { + pmdMain.enabled = false + } } diff --git a/shared/config.gradle b/shared/config.gradle index d5ac9b17da..2a66371269 100644 --- a/shared/config.gradle +++ b/shared/config.gradle @@ -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 - } -} diff --git a/shared/googletest.gradle b/shared/googletest.gradle index 893c17c73b..4ca8eca770 100644 --- a/shared/googletest.gradle +++ b/shared/googletest.gradle @@ -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') } } } diff --git a/shared/java/javacommon.gradle b/shared/java/javacommon.gradle index 969b4876a8..cd011455d3 100644 --- a/shared/java/javacommon.gradle +++ b/shared/java/javacommon.gradle @@ -87,7 +87,7 @@ test { } } -if (project.hasProperty('onlyAthena') || project.hasProperty('onlyRaspbian')) { +if (project.hasProperty('onlylinuxathena') || project.hasProperty('onlylinuxraspbian')) { test.enabled = false } diff --git a/shared/java/javastyle.gradle b/shared/java/javastyle.gradle index e0919883a5..6e4e2611ad 100644 --- a/shared/java/javastyle.gradle +++ b/shared/java/javastyle.gradle @@ -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 = [] + } } diff --git a/shared/javacpp/setupBuild.gradle b/shared/javacpp/setupBuild.gradle index d2cdd1d866..078af7df36 100644 --- a/shared/javacpp/setupBuild.gradle +++ b/shared/javacpp/setupBuild.gradle @@ -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() diff --git a/shared/jni/publish.gradle b/shared/jni/publish.gradle index a6a1abe11b..7908304525 100644 --- a/shared/jni/publish.gradle +++ b/shared/jni/publish.gradle @@ -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) } } } diff --git a/shared/jni/setupBuild.gradle b/shared/jni/setupBuild.gradle index a22a67d185..d73476d3f0 100644 --- a/shared/jni/setupBuild.gradle +++ b/shared/jni/setupBuild.gradle @@ -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() diff --git a/shared/nilibraries.gradle b/shared/nilibraries.gradle index 937abbf7a0..49e99b0d51 100644 --- a/shared/nilibraries.gradle +++ b/shared/nilibraries.gradle @@ -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') + } + } } } diff --git a/shared/opencv.gradle b/shared/opencv.gradle index 09fa8be465..21540fe8a4 100644 --- a/shared/opencv.gradle +++ b/shared/opencv.gradle @@ -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') + } + } } } } diff --git a/shared/plugins/publish.gradle b/shared/plugins/publish.gradle index a9ba5384fd..5379b44a53 100644 --- a/shared/plugins/publish.gradle +++ b/shared/plugins/publish.gradle @@ -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' } } } diff --git a/shared/plugins/setupBuild.gradle b/shared/plugins/setupBuild.gradle index ba4c6f0b65..8591f079d2 100644 --- a/shared/plugins/setupBuild.gradle +++ b/shared/plugins/setupBuild.gradle @@ -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() diff --git a/simulation/gz_msgs/build.gradle b/simulation/gz_msgs/build.gradle index 8264ceb2b8..aa0982595c 100644 --- a/simulation/gz_msgs/build.gradle +++ b/simulation/gz_msgs/build.gradle @@ -1,95 +1,95 @@ -plugins { - id 'cpp' - id 'java' - id 'com.google.protobuf' version '0.8.6' - id 'edu.wpi.first.NativeUtils' -} - -description = "A C++ and Java library to pass FRC Simulation Messages in and out of Gazebo." - -/* The simulation does not run on real hardware; so we always skip Athena */ -ext.skipAthena = true -ext.skipRaspbian = true -apply from: "${rootDir}/shared/config.gradle" - -/* Use a sort of poor man's autoconf to find the protobuf development - files; on Debian, those are supplied by libprotobuf-dev. - - This should get skipped on Windows. - - TODO: Add Windows support for the simulation code */ - -def protobuf_version = "" -try { - protobuf_version = "pkg-config --modversion protobuf".execute().text.trim() - println "Protobuf version is [${protobuf_version}]" -} catch(Exception ex) { -} - -if (!protobuf_version?.trim()) { - println "Protobuf is not available. (pkg-config --modversion protobuf failed)" - protobuf_version = "+" - if (project.hasProperty("makeSim")) { - /* Force the build even though we did not find protobuf. */ - println "makeSim set. Forcing build - failure likely." - } - else { - ext.skip_gz_msgs = true - println "Skipping gz_msgs." - } -} - -tasks.whenTaskAdded { task -> - task.onlyIf { !project.hasProperty('skip_gz_msgs') } -} - -dependencies { - compile "com.google.protobuf:protobuf-java:${protobuf_version}" - compile "com.google.protobuf:protoc:${protobuf_version}" -} - -/* There is a nice gradle plugin for protobuf, and the protoc tool - is included; using it simplifies our build process. - The trick is that we have to use the same version as the system - copy of libprotobuf-dev */ -protobuf { - protoc { - artifact = "com.google.protobuf:protoc:${protobuf_version}" - } - - generatedFilesBaseDir = "$buildDir/generated" - generateProtoTasks { - all().each { task -> - task.builtins { - cpp { - outputSubDir = 'simulation/gz_msgs' - } - } - } - } -} - -model { - components { - gz_msgs(NativeLibrarySpec) { - sources { - cpp { - source { - srcDir "$buildDir/generated/main/simulation/gz_msgs" - builtBy tasks.generateProto - } - exportedHeaders { - srcDir "src/include" - srcDir "$buildDir/generated/main" - } - } - } - /* We must compile with -fPIC to link the static library into an so */ - binaries { - all { - cppCompiler.args "-fPIC" - } - } - } - } -} +plugins { + id 'cpp' + id 'java' + id 'com.google.protobuf' version '0.8.8' + id 'edu.wpi.first.NativeUtils' +} + +description = "A C++ and Java library to pass FRC Simulation Messages in and out of Gazebo." + +/* The simulation does not run on real hardware; so we always skip Athena */ +ext.skipAthena = true +ext.skipRaspbian = true +apply from: "${rootDir}/shared/config.gradle" + +/* Use a sort of poor man's autoconf to find the protobuf development + files; on Debian, those are supplied by libprotobuf-dev. + + This should get skipped on Windows. + + TODO: Add Windows support for the simulation code */ + +def protobuf_version = "" +try { + protobuf_version = "pkg-config --modversion protobuf".execute().text.trim() + println "Protobuf version is [${protobuf_version}]" +} catch(Exception ex) { +} + +if (!protobuf_version?.trim()) { + println "Protobuf is not available. (pkg-config --modversion protobuf failed)" + protobuf_version = "+" + if (project.hasProperty("makeSim")) { + /* Force the build even though we did not find protobuf. */ + println "makeSim set. Forcing build - failure likely." + } + else { + ext.skip_gz_msgs = true + println "Skipping gz_msgs." + } +} + +tasks.whenTaskAdded { task -> + task.onlyIf { !project.hasProperty('skip_gz_msgs') } +} + +dependencies { + compile "com.google.protobuf:protobuf-java:${protobuf_version}" + compile "com.google.protobuf:protoc:${protobuf_version}" +} + +/* There is a nice gradle plugin for protobuf, and the protoc tool + is included; using it simplifies our build process. + The trick is that we have to use the same version as the system + copy of libprotobuf-dev */ +protobuf { + protoc { + artifact = "com.google.protobuf:protoc:${protobuf_version}" + } + + generatedFilesBaseDir = "$buildDir/generated" + generateProtoTasks { + all().each { task -> + task.builtins { + cpp { + outputSubDir = 'simulation/gz_msgs' + } + } + } + } +} + +model { + components { + gz_msgs(NativeLibrarySpec) { + sources { + cpp { + source { + srcDir "$buildDir/generated/main/simulation/gz_msgs" + builtBy tasks.generateProto + } + exportedHeaders { + srcDir "src/include" + srcDir "$buildDir/generated/main" + } + } + } + /* We must compile with -fPIC to link the static library into an so */ + binaries { + all { + cppCompiler.args "-fPIC" + } + } + } + } +} diff --git a/simulation/halsim_adx_gyro_accelerometer/build.gradle b/simulation/halsim_adx_gyro_accelerometer/build.gradle index c9f754dde6..f73804d9a0 100644 --- a/simulation/halsim_adx_gyro_accelerometer/build.gradle +++ b/simulation/halsim_adx_gyro_accelerometer/build.gradle @@ -11,7 +11,7 @@ ext { apply from: "${rootDir}/shared/config.gradle" -if (!project.hasProperty('onlyAthena')) { +if (!project.hasProperty('onlylinuxathena')) { ext { sharedCvConfigs = [halsim_adx_gyro_accelerometerTest: []] @@ -37,19 +37,20 @@ if (!project.hasProperty('onlyAthena')) { apply from: "${rootDir}/shared/nilibraries.gradle" - model { - exportsConfigs { - halsim_adx_gyro_accelerometer(ExportsConfig) { - x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', - '_CT??_R0?AVbad_cast', - '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', - '_TI5?AVfailure'] - x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', - '_CT??_R0?AVbad_cast', - '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', - '_TI5?AVfailure'] - } + nativeUtils.exportsConfigs { + halsim_adx_gyro_accelerometer { + x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', + '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', + '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', + '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] + x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', + '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', + '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', + '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] } + } + + model { components { "${nativeName}Base"(NativeLibrarySpec) { sources { @@ -68,7 +69,7 @@ if (!project.hasProperty('onlyAthena')) { it.buildable = false return } - if (it.targetPlatform.architecture.name == 'athena') { + if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { it.buildable = false return } @@ -89,7 +90,7 @@ if (!project.hasProperty('onlyAthena')) { } } binaries.all { - if (it.targetPlatform.architecture.name == 'athena') { + if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { it.buildable = false return } @@ -114,7 +115,7 @@ if (!project.hasProperty('onlyAthena')) { } } binaries.all { - if (it.targetPlatform.architecture.name == 'athena') { + if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { it.buildable = false return } @@ -126,7 +127,7 @@ if (!project.hasProperty('onlyAthena')) { } binaries { withType(GoogleTestTestSuiteBinarySpec) { - if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) { + if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian')) { lib project: ':ntcore', library: 'ntcore', linkage: 'shared' lib project: ':cscore', library: 'cscore', linkage: 'shared' project(':hal').addHalDependency(it, 'shared') @@ -147,7 +148,7 @@ if (!project.hasProperty('onlyAthena')) { model { testSuites { - if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) { + if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian')) { "${nativeName}Test"(GoogleTestTestSuiteSpec) { for(NativeComponentSpec c : $.components) { if (c.name == nativeName) { diff --git a/simulation/halsim_ds_socket/build.gradle b/simulation/halsim_ds_socket/build.gradle index 0200980c99..98c5fe7ccb 100644 --- a/simulation/halsim_ds_socket/build.gradle +++ b/simulation/halsim_ds_socket/build.gradle @@ -21,7 +21,7 @@ apply from: "${rootDir}/shared/plugins/setupBuild.gradle" model { testSuites { def comps = $.components - if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) { + if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian')) { "${pluginName}Test"(GoogleTestTestSuiteSpec) { for(NativeComponentSpec c : comps) { if (c.name == pluginName) { diff --git a/simulation/lowfi_simulation/build.gradle b/simulation/lowfi_simulation/build.gradle index 2b97416e54..e42ea3bfa6 100644 --- a/simulation/lowfi_simulation/build.gradle +++ b/simulation/lowfi_simulation/build.gradle @@ -12,7 +12,7 @@ ext { apply from: "${rootDir}/shared/config.gradle" -if (!project.hasProperty('onlyAthena')) { +if (!project.hasProperty('onlylinuxathena')) { ext { sharedCvConfigs = [lowfi_simTest: []] @@ -40,19 +40,20 @@ if (!project.hasProperty('onlyAthena')) { apply from: "${rootDir}/shared/nilibraries.gradle" - model { - exportsConfigs { - lowfi_sim(ExportsConfig) { - x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', - '_CT??_R0?AVbad_cast', - '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', - '_TI5?AVfailure'] - x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', - '_CT??_R0?AVbad_cast', - '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', - '_TI5?AVfailure'] - } + nativeUtils.exportsConfigs { + lowfi_sim { + x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', + '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', + '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', + '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] + x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', + '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', + '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', + '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] } + } + + model { components { "${nativeName}Base"(NativeLibrarySpec) { sources { @@ -71,7 +72,7 @@ if (!project.hasProperty('onlyAthena')) { it.buildable = false return } - if (it.targetPlatform.architecture.name == 'athena') { + if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { it.buildable = false return } @@ -93,7 +94,7 @@ if (!project.hasProperty('onlyAthena')) { } } binaries.all { - if (it.targetPlatform.architecture.name == 'athena') { + if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { it.buildable = false return } @@ -119,7 +120,7 @@ if (!project.hasProperty('onlyAthena')) { } } binaries.all { - if (it.targetPlatform.architecture.name == 'athena') { + if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { it.buildable = false return } @@ -150,7 +151,7 @@ if (!project.hasProperty('onlyAthena')) { model { testSuites { - if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) { + if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian')) { "${nativeName}Test"(GoogleTestTestSuiteSpec) { for(NativeComponentSpec c : $.components) { if (c.name == nativeName) { diff --git a/wpilibc/build.gradle b/wpilibc/build.gradle index 3b5b3e12a0..61154d3c23 100644 --- a/wpilibc/build.gradle +++ b/wpilibc/build.gradle @@ -81,19 +81,20 @@ ext { apply from: "${rootDir}/shared/nilibraries.gradle" -model { - exportsConfigs { - wpilibc(ExportsConfig) { - x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', - '_CT??_R0?AVbad_cast', - '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', - '_TI5?AVfailure'] - x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', - '_CT??_R0?AVbad_cast', - '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', - '_TI5?AVfailure'] - } +nativeUtils.exportsConfigs { + wpilibc { + x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', + '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', + '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', + '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] + x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', + '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', + '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', + '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] } +} + +model { components { "${nativeName}Base"(NativeLibrarySpec) { sources { @@ -202,7 +203,7 @@ model { } } withType(GoogleTestTestSuiteBinarySpec) { - if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) { + if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian')) { lib project: ':ntcore', library: 'ntcore', linkage: 'shared' lib project: ':cscore', library: 'cscore', linkage: 'shared' project(':hal').addHalDependency(it, 'shared') diff --git a/wpilibcExamples/build.gradle b/wpilibcExamples/build.gradle index af1b25af9c..ec790c0df1 100644 --- a/wpilibcExamples/build.gradle +++ b/wpilibcExamples/build.gradle @@ -94,7 +94,7 @@ model { project(':hal').addHalDependency(binary, 'shared') lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared' lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' - if (binary.targetPlatform.architecture.name != 'athena') { + if (binary.targetPlatform.name != nativeUtils.wpi.platforms.roborio) { lib project: ':simulation:halsim_lowfi', library: 'halsim_lowfi', linkage: 'shared' lib project: ':simulation:halsim_adx_gyro_accelerometer', library: 'halsim_adx_gyro_accelerometer', linkage: 'shared' lib project: ':simulation:halsim_print', library: 'halsim_print', linkage: 'shared' @@ -144,7 +144,7 @@ model { cppCompiler.args "/wd4996" } } - if (binary.targetPlatform.architecture.name != 'athena') { + if (binary.targetPlatform.name != nativeUtils.wpi.platforms.roborio) { lib project: ':simulation:halsim_lowfi', library: 'halsim_lowfi', linkage: 'shared' lib project: ':simulation:halsim_adx_gyro_accelerometer', library: 'halsim_adx_gyro_accelerometer', linkage: 'shared' lib project: ':simulation:halsim_print', library: 'halsim_print', linkage: 'shared' diff --git a/wpilibcIntegrationTests/build.gradle b/wpilibcIntegrationTests/build.gradle index 0dea400675..8a3797b7f5 100644 --- a/wpilibcIntegrationTests/build.gradle +++ b/wpilibcIntegrationTests/build.gradle @@ -32,8 +32,9 @@ model { wpilibcIntegrationTests(NativeExecutableSpec) { targetBuildTypes 'debug' baseName = 'FRCUserProgram' + nativeUtils.useRequiredLibrary(it, 'googletest_static') binaries.all { binary -> - if (binary.targetPlatform.architecture.name == 'athena') { + if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { binary.sources { athenaCpp(CppSourceSet) { source { @@ -82,7 +83,7 @@ model { copyWpilibCTestLibrariesToOutput(Copy) { def task = it $.binaries.each { - if (it in NativeExecutableBinarySpec && it.targetPlatform.architecture.name == 'athena') { + if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.roborio && it.buildable) { def installTask = it.tasks.install task.dependsOn installTask task.from(installTask.executableFile) { @@ -99,7 +100,7 @@ model { } // This is in a separate if statement because of what I would assume is a bug in grade. // Will file an issue on their side. - if (!project.hasProperty('skipAthena')) { + if (!project.hasProperty('skiponlyathena')) { build.dependsOn copyWpilibCTestLibrariesToOutput } } diff --git a/wpilibj/build.gradle b/wpilibj/build.gradle index 82e94bb4f2..8e19140432 100644 --- a/wpilibj/build.gradle +++ b/wpilibj/build.gradle @@ -133,7 +133,7 @@ model { if (it in NativeExecutableSpec && it.name == "wpilibjDev") { 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() diff --git a/wpilibjExamples/build.gradle b/wpilibjExamples/build.gradle index 55087ba754..d57e143928 100644 --- a/wpilibjExamples/build.gradle +++ b/wpilibjExamples/build.gradle @@ -1,5 +1,4 @@ apply plugin: 'java' -apply plugin: 'pmd' ext { useJava = true @@ -21,11 +20,15 @@ dependencies { compile project(':cameraserver') } -pmd { - 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 { + consoleOutput = true + reportsDir = file("$project.buildDir/reports/pmd") + ruleSetFiles = files(new File(rootDir, "styleguide/pmd-ruleset.xml")) + ruleSets = [] + } } gradle.projectsEvaluated { diff --git a/wpiutil/build.gradle b/wpiutil/build.gradle index 6b77b39608..c3634f6176 100644 --- a/wpiutil/build.gradle +++ b/wpiutil/build.gradle @@ -29,7 +29,7 @@ ext { } } } - if (it.targetPlatform.operatingSystem.name != 'windows') { + if (!it.targetPlatform.operatingSystem.isWindows()) { it.cppCompiler.define '_GNU_SOURCE' it.sources { libuvUnixCpp(CppSourceSet) { @@ -62,7 +62,7 @@ ext { } } } - if (it.targetPlatform.operatingSystem.name == 'windows') { + if (it.targetPlatform.operatingSystem.isWindows()) { if (it in SharedLibraryBinarySpec) { it.cppCompiler.define 'BUILDING_UV_SHARED' } @@ -77,7 +77,7 @@ ext { } } } - } else if (it.targetPlatform.operatingSystem.name == 'osx') { + } else if (it.targetPlatform.operatingSystem.isMacOsX()) { it.sources { libuvMacCpp(CppSourceSet) { source { @@ -132,6 +132,19 @@ file("$projectDir/examples").list(new FilenameFilter() { apply from: "${rootDir}/shared/javacpp/setupBuild.gradle" +nativeUtils.exportsConfigs { + wpiutil { + x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', + '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', + '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', + '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] + x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', + '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', + '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', + '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] + } +} + cppHeadersZip { from('src/main/native/libuv/include') { into '/' @@ -148,23 +161,9 @@ model { } } } +} - // Exports config is a utility to enable exporting all symbols in a C++ library on windows to a DLL. - // This removes the need for DllExport on a library. However, the gradle C++ builder has a bug - // where some extra symbols are added that cannot be resolved at link time. This configuration - // lets you specify specific symbols to exlude from exporting. - exportsConfigs { - wpiutil(ExportsConfig) { - x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', - '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', - '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', - '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] - x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', - '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', - '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', - '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] - } - } +model { components { examplesMap.each { key, value -> "${key}"(NativeExecutableSpec) {