From 151486c8406f677908c315b3d0673b62c7f79835 Mon Sep 17 00:00:00 2001 From: Will Toth Date: Wed, 22 Jan 2020 20:32:38 -0600 Subject: [PATCH] Initial changes to gradle files for 2020 --- Source/.vscode/settings.json | 3 +- Source/build.gradle | 60 ++-- Source/config.gradle | 284 ++---------------- Source/dependencies.gradle | 106 +------ .../gradle/wrapper/gradle-wrapper.properties | 2 +- Source/publish.gradle | 10 +- Source/settings.gradle | 1 - 7 files changed, 75 insertions(+), 391 deletions(-) diff --git a/Source/.vscode/settings.json b/Source/.vscode/settings.json index feb5bb9..dbe225c 100644 --- a/Source/.vscode/settings.json +++ b/Source/.vscode/settings.json @@ -73,7 +73,8 @@ "string_view": "cpp", "vl53l0x_platform.h": "c", "xxatomic": "cpp", - "vl53l0x_platform_log.h": "c" + "vl53l0x_platform_log.h": "c", + "i2c.h": "c" }, "java.configuration.updateBuildConfiguration": "automatic" } \ No newline at end of file diff --git a/Source/build.gradle b/Source/build.gradle index 3af4335..fb206b5 100644 --- a/Source/build.gradle +++ b/Source/build.gradle @@ -1,10 +1,21 @@ plugins { id 'cpp' id 'java' - id 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin' version '2.2' - 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.wpilib.repositories.WPILibRepositoriesPlugin' version '2020.2' + id 'edu.wpi.first.NativeUtils' version '2020.5.2' + id 'edu.wpi.first.GradleJni' version '0.10.1' + id 'edu.wpi.first.GradleVsCode' version '0.10.0' +} + +allprojects { + repositories { + mavenCentral() + } + if (project.hasProperty('releaseMode')) { + wpilibRepositories.addAllReleaseRepositories(it) + } else { + wpilibRepositories.addAllDevelopmentRepositories(it) + } } apply from: 'config.gradle' @@ -15,29 +26,21 @@ ext.sharedConfigs = [DistanceSensor: []] apply from: 'dependencies.gradle' -model { +nativeUtils { exportsConfigs { - DistanceSensor(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'] + DistanceSensor { } - DistanceSensorDriver(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'] + DistanceSensorDriver { } } + privateExportsConfigs { + //DistanceSensorDriver { + //exportsFile = project.file("src/main/driver/symbols.txt") + //} + } +} + +model { components { DistanceSensor(NativeLibrarySpec) { sources { @@ -54,11 +57,13 @@ model { binaries.all { lib library: "DistanceSensorDriver", linkage: 'shared' } + + nativeUtils.useRequiredLibrary(it, "wpilib_shared") } DistanceSensorDriver(JniNativeLibrarySpec) { enableCheckTask true javaCompileTasks << compileJava - jniCrossCompileOptions << JniCrossCompileOptions('athena') + jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.roborio) sources { cpp { source { @@ -70,12 +75,17 @@ model { } } } + nativeUtils.useRequiredLibrary(it, "wpilib_shared") } } } +javadoc { + options.addBooleanOption('-no-module-directories', true) +} + apply from: 'publish.gradle' wrapper { - gradleVersion = '5.0' + gradleVersion = '6.0' } diff --git a/Source/config.gradle b/Source/config.gradle index c206e04..a9b2921 100644 --- a/Source/config.gradle +++ b/Source/config.gradle @@ -1,252 +1,38 @@ -import edu.wpi.first.nativeutils.* import org.gradle.internal.os.OperatingSystem -def windowsCompilerArgs = ['/EHsc', '/DNOMINMAX', '/Zi', '/FS', '/Zc:inline', '/MP4', '-D__WINDOWS__'] -def windowsCCompilerArgs = ['/Zi', '/FS', '/Zc:inline'] -def windowsReleaseCompilerArgs = ['/O2', '/MD'] -def windowsDebugCompilerArgs = ['/Od', '/MDd'] -def windowsLinkerArgs = ['/DEBUG:FULL'] -def windowsReleaseLinkerArgs = ['/OPT:REF', '/OPT:ICF'] +nativeUtils.addWpiNativeUtils() +nativeUtils.withRoboRIO() -def linuxCrossCompilerArgs = ['-std=c++14', '-Wformat=2', '-Wall', '-Wextra', '-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 = ['-O2'] -def linuxDebugCompilerArgs = ['-O0'] -def linux32BitArg = '-m32' - -def macCompilerArgs = ['-std=c++14', '-Wall', '-Wextra', '-Werror', '-pedantic-errors', '-fPIC', '-g', - '-Wno-unused-parameter', '-Wno-error=deprecated-declarations', - '-Wno-unused-private-field', '-Wno-unused-const-variable', '-pthread'] -def macCCompilerArgs = ['-Wall', '-Wextra', '-Werror', '-pedantic-errors', '-fPIC', '-g', - '-Wno-unused-parameter', '-Wno-unused-private-field'] -def macObjCLinkerArgs = ['-std=c++14', '-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' - } -} - -def windows32PlatformDetect = { - def arch = System.getProperty("os.arch") - def isWin = OperatingSystem.current().isWindows() - if (buildAll) { - return isWin - } else { - return isWin && arch == 'x86' - } -} - -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' - } - } +nativeUtils { + wpi { + configureDependencies { + wpiVersion = "2020.+" + niLibVersion = "2020.10.1" + opencvVersion = "3.4.7-2" + googleTestVersion = "1.9.0-3-437e100" } + } } -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' - } - } - } -} +nativeUtils.wpi.addWarnings() +// ST's VL53L0X libraries contain many warnings +//nativeUtils.wpi.addWarningsAsErrors() -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 - } -//Disable building on mac because Clang does -// macX64(BuildConfig) { -// architecture = 'x86-64' -// operatingSystem = 'osx' -// compilerArgs = macCompilerArgs -// CCompilerArgs = macCCompilerArgs -// debugCompilerArgs = macDebugCompilerArgs -// releaseCompilerArgs = macReleaseCompilerArgs -// objCppCompilerArgs = macObjCLinkerArgs -// linkerArgs = macLinkerArgs -// compilerFamily = 'Clang' -// detectPlatform = mac64PlatformDetect -// } - } - } -} +nativeUtils.setSinglePrintPerPlatform() -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' - } +model { + components { + all { + nativeUtils.useAllPlatforms(it) } } -} 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 - } + binaries { + withType(NativeBinarySpec).all { + nativeUtils.usePlatformArguments(it) } } } -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')) { @@ -288,7 +74,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 { @@ -303,9 +89,9 @@ ext.createComponentZipTasks = { components, names, base, type, project, func -> configMap.each { key, value -> def task = project.tasks.create(base + "-${key}", type) { description = 'Creates component archive for platform ' + key - destinationDir = outputsFolder + destinationDirectory = outputsFolder classifier = key - baseName = '_M_' + base + archiveBaseName = '_M_' + base duplicatesStrategy = 'exclude' from(licenseFile) { @@ -359,38 +145,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/Source/dependencies.gradle b/Source/dependencies.gradle index d6a7e82..4dc62a1 100644 --- a/Source/dependencies.gradle +++ b/Source/dependencies.gradle @@ -1,101 +1,9 @@ -model { - dependencyConfigs { - chipobject(DependencyConfig) { - groupId = 'edu.wpi.first.ni-libraries' - artifactId = 'chipobject' - headerClassifier = 'headers' - ext = 'zip' - version = '2019.12.1' - sharedConfigs = project.sharedNiConfigs - staticConfigs = [:] - } - netcomm(DependencyConfig) { - groupId = 'edu.wpi.first.ni-libraries' - artifactId = 'netcomm' - headerClassifier = 'headers' - ext = 'zip' - version = '2019.12.1' - sharedConfigs = project.sharedNiConfigs - staticConfigs = [:] - } - hal(DependencyConfig) { - groupId = 'edu.wpi.first.hal' - artifactId = 'hal-cpp' - headerClassifier = 'headers' - sourceClassifier = 'sources' - ext = 'zip' - version = '2019.+' - sharedConfigs = project.sharedBaseConfigs - staticConfigs = [:] - } - wpiutil(DependencyConfig) { - groupId = 'edu.wpi.first.wpiutil' - artifactId = 'wpiutil-cpp' - headerClassifier = 'headers' - sourceClassifier = 'sources' - ext = 'zip' - version = '2019.+' - sharedConfigs = project.sharedBaseConfigs - staticConfigs = [:] - } - ntcore(DependencyConfig) { - groupId = 'edu.wpi.first.ntcore' - artifactId = 'ntcore-cpp' - headerClassifier = 'headers' - sourceClassifier = 'sources' - ext = 'zip' - version = '2019.+' - sharedConfigs = project.sharedConfigs - staticConfigs = [:] - } - cscore(DependencyConfig) { - groupId = 'edu.wpi.first.cscore' - artifactId = 'cscore-cpp' - headerClassifier = 'headers' - sourceClassifier = 'sources' - ext = 'zip' - version = '2019.+' - sharedConfigs = project.sharedConfigs - staticConfigs = [:] - } - wpilibc(DependencyConfig) { - groupId = 'edu.wpi.first.wpilibc' - artifactId = 'wpilibc-cpp' - headerClassifier = 'headers' - sourceClassifier = 'sources' - ext = 'zip' - version = '2019.+' - sharedConfigs = project.sharedConfigs - staticConfigs = [:] - } - cameraserver(DependencyConfig) { - groupId = 'edu.wpi.first.cameraserver' - artifactId = 'cameraserver-cpp' - headerClassifier = 'headers' - sourceClassifier = 'sources' - ext = 'zip' - version = '2019.+' - sharedConfigs = project.sharedConfigs - staticConfigs = [:] - } - opencv(DependencyConfig) { - groupId = 'edu.wpi.first.thirdparty.frc2019.opencv' - artifactId = 'opencv-cpp' - headerClassifier = 'headers' - ext = 'zip' - version = '3.4.3-19' - sharedConfigs = project.sharedConfigs - staticConfigs = [:] - } - } -} - dependencies { - compile 'edu.wpi.first.cscore:cscore-java:2019.+' - compile 'edu.wpi.first.cameraserver:cameraserver-java:2019.+' - compile 'edu.wpi.first.ntcore:ntcore-java:2019.+' - compile 'edu.wpi.first.wpilibj:wpilibj-java:2019.+' - compile 'edu.wpi.first.wpiutil:wpiutil-java:2019.+' - compile 'edu.wpi.first.hal:hal-java:2019.+' - compile 'edu.wpi.first.thirdparty.frc2019.opencv:opencv-java:3.4.3-19' + implementation 'edu.wpi.first.cscore:cscore-java:2020.+' + implementation 'edu.wpi.first.cameraserver:cameraserver-java:2020.+' + implementation 'edu.wpi.first.ntcore:ntcore-java:2020.+' + implementation 'edu.wpi.first.wpilibj:wpilibj-java:2020.+' + implementation 'edu.wpi.first.wpiutil:wpiutil-java:2020.+' + implementation 'edu.wpi.first.hal:hal-java:2020.+' + implementation 'edu.wpi.first.thirdparty.frc2020.opencv:opencv-java:3.4.7-2' } diff --git a/Source/gradle/wrapper/gradle-wrapper.properties b/Source/gradle/wrapper/gradle-wrapper.properties index 75b8c7c..9492014 100644 --- a/Source/gradle/wrapper/gradle-wrapper.properties +++ b/Source/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-6.0.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/Source/publish.gradle b/Source/publish.gradle index bbf57d8..578596b 100644 --- a/Source/publish.gradle +++ b/Source/publish.gradle @@ -1,16 +1,8 @@ apply plugin: 'maven-publish' -// Ensure that the WPILibVersioningPlugin is setup by setting the release type, if releaseType wasn't -// already specified on the command line -if (!hasProperty('releaseType')) { - WPILibVersion { - releaseType = 'OFFICIAL' - } -} - ext.licenseFile = files("$rootDir/LICENSE.txt") -def pubVersion = '0.0.6' +def pubVersion = '0.1.0' def outputsFolder = file("$buildDir/allOutputs") diff --git a/Source/settings.gradle b/Source/settings.gradle index af1e8e2..3b58236 100644 --- a/Source/settings.gradle +++ b/Source/settings.gradle @@ -4,4 +4,3 @@ pluginManagement { gradlePluginPortal() } } -enableFeaturePreview('STABLE_PUBLISHING')