diff --git a/examples/vendor/.gitignore b/examples/vendor/.gitignore new file mode 100644 index 00000000..a332fb25 --- /dev/null +++ b/examples/vendor/.gitignore @@ -0,0 +1,160 @@ +# Created by https://www.gitignore.io/api/c++,java,linux,macos,gradle,windows,visualstudiocode + +### C++ ### +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +### Gradle ### +.gradle +/build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 +# gradle/wrapper/gradle-wrapper.properties + +# # VS Code Specific Java Settings +.classpath +.project +.settings/ +bin/ + + +# End of https://www.gitignore.io/api/c++,java,linux,macos,gradle,windows,visualstudiocode diff --git a/examples/vendor/.wpilib/wpilib_preferences.json b/examples/vendor/.wpilib/wpilib_preferences.json new file mode 100644 index 00000000..0cd78f99 --- /dev/null +++ b/examples/vendor/.wpilib/wpilib_preferences.json @@ -0,0 +1,6 @@ +{ + "enableCppIntellisense": true, + "currentLanguage": "cpp", + "projectYear": "2019", + "teamNumber": 0 +} \ No newline at end of file diff --git a/examples/vendor/azure-init.yml b/examples/vendor/azure-init.yml new file mode 100644 index 00000000..ecc8043d --- /dev/null +++ b/examples/vendor/azure-init.yml @@ -0,0 +1,6 @@ +# Azure has a gradle init file that doesn't work in Gradle 5.0, so we have to delete it. +steps: +- task: DeleteFiles@1 + inputs: + sourceFolder: '/Users/vsts/.gradle/init.d/' + contents: 'log-gradle-version-plugin.gradle' \ No newline at end of file diff --git a/examples/vendor/azure-pipelines.yml b/examples/vendor/azure-pipelines.yml new file mode 100644 index 00000000..edbe298d --- /dev/null +++ b/examples/vendor/azure-pipelines.yml @@ -0,0 +1,26 @@ +resources: + containers: + - container: wpilib + image: wpilib/roborio-cross-ubuntu:2019-18.04 + +jobs: +- job: Windows + pool: + vmImage: 'VS2017-Win2016' + steps: + - template: azure-init.yml + - template: azure-steps.yml + +- job: macOS + pool: + vmImage: 'macOS-10.13' + steps: + - template: azure-init.yml + - template: azure-steps.yml + +- job: Linux + pool: + vmImage: 'Ubuntu-16.04' + container: wpilib + steps: + - template: azure-steps.yml \ No newline at end of file diff --git a/examples/vendor/azure-steps.yml b/examples/vendor/azure-steps.yml new file mode 100644 index 00000000..7e4a1a7a --- /dev/null +++ b/examples/vendor/azure-steps.yml @@ -0,0 +1,22 @@ +steps: +- task: Gradle@2 + inputs: + workingDirectory: '' + gradleWrapperFile: 'gradlew' + gradleOptions: '-Xmx3072m' + publishJUnitResults: false + testResultsFiles: '**/TEST-*.xml' + tasks: 'clean build doxygen javadoc publish' + # WPILib docker image has roborio image, all other platforms need not build it. + options: --stacktrace -Ptoolchain-optional-roboRio + +- task: CopyFiles@2 + inputs: + sourceFolder: 'build/mvnDistRepo' + contents: '**/*' + targetFolder: $(Build.ArtifactStagingDirectory)/mvnDistRepo + +- task: PublishBuildArtifacts@1 + inputs: + artifactName: 'maven' + pathtoPublish: $(Build.ArtifactStagingDirectory)/mvnDistRepo \ No newline at end of file diff --git a/examples/vendor/build.gradle b/examples/vendor/build.gradle new file mode 100644 index 00000000..e55016f4 --- /dev/null +++ b/examples/vendor/build.gradle @@ -0,0 +1,25 @@ +plugins { + id 'org.ysb33r.doxygen' version '0.5' + id 'maven-publish' + id "edu.wpi.first.GradleRIO" version "2019.1.1-beta-4c" +} + +ext.uuid = 'YOUR_UUID_HERE' +ext.mavenUrl = 'YOUR_MAVEN_SERVER_HERE' +ext.jsonUrl = 'YOUR_VENDORDEPS_JSON_URL_HERE' + +group = 'my.vendor' +ext.vendorLibraryName = 'MyVendorLibrary' +version = '2019.1.1' + +ext.libraryJavaName = "${ext.vendorLibraryName}-Java" +ext.libraryCppName = "${ext.vendorLibraryName}-cpp" + +apply from: 'publishingtools.gradle' +apply from: 'cpp.gradle' +apply from: 'java.gradle' +apply from: 'vendordeps.gradle' + +wrapper { + gradleVersion = 5.0 +} \ No newline at end of file diff --git a/examples/vendor/cpp.gradle b/examples/vendor/cpp.gradle new file mode 100644 index 00000000..d919858f --- /dev/null +++ b/examples/vendor/cpp.gradle @@ -0,0 +1,88 @@ +apply plugin: 'cpp' +apply plugin: 'google-test-test-suite' + +model { + components { + "${vendorLibraryName}"(NativeLibrarySpec) { + targetPlatform wpi.platforms.roborio + targetPlatform wpi.platforms.desktop + + binaries.all { + sources { + cpp(CppSourceSet) { + def target = targetPlatform.name == wpi.platforms.roborio ? 'robot' : 'simulation' + source { + srcDir 'src/main/cpp_common' + srcDir "src/main/cpp_${target}" + include '**/*.cpp' + } + exportedHeaders { + srcDir 'src/main/include' // Only src/main/include is included in the final maven package. + srcDir "src/main/cpp_${target}" + include '**/*.h', '**/*.hpp', '**/*.inc' + } + } + } + } + + useLibrary(it, "wpilib") + } + } + testSuites { + "${vendorLibraryName}Test"(GoogleTestTestSuiteSpec) { + testing $.components.get(vendorLibraryName) + + sources.cpp { + source { + srcDir 'src/test/cpp' + include '**/*.cpp' + } + } + + useLibrary(it, "wpilib", "googletest") + } + } +} + +doxygen { + executables { + doxygen version : '1.8.13' + } + + generate_html true + javadoc_autobrief true + source project.file('src/main/include') +} + +// Maven Publishing + +task zipHeaders(type: Zip) { + from fileTree('src/main/include') + + classifier = 'headers' +} + +task zipDoxygen(type: Zip) { + from doxygen + + classifier = 'doxygen' +} + +publishing { + publications { + "${libraryCppName}"(MavenPublication) { + artifactId libraryCppName + + artifact zipHeaders { + classifier 'headers' + } + + artifact zipDoxygen { + classifier 'doxygen' + } + + binaryArtifacts(it, vendorLibraryName) + } + } +} + diff --git a/examples/vendor/gradle/wrapper/gradle-wrapper.jar b/examples/vendor/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..457aad0d Binary files /dev/null and b/examples/vendor/gradle/wrapper/gradle-wrapper.jar differ diff --git a/examples/vendor/gradle/wrapper/gradle-wrapper.properties b/examples/vendor/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..ddb6d949 --- /dev/null +++ b/examples/vendor/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=permwrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=permwrapper/dists diff --git a/examples/vendor/gradlew b/examples/vendor/gradlew new file mode 100755 index 00000000..af6708ff --- /dev/null +++ b/examples/vendor/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +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"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/examples/vendor/gradlew.bat b/examples/vendor/gradlew.bat new file mode 100644 index 00000000..0f8d5937 --- /dev/null +++ b/examples/vendor/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +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" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/examples/vendor/java.gradle b/examples/vendor/java.gradle new file mode 100644 index 00000000..21fad28c --- /dev/null +++ b/examples/vendor/java.gradle @@ -0,0 +1,43 @@ +apply plugin: 'java' + +repositories { + mavenCentral() +} + +dependencies { + compile wpi.deps.wpilib() + testCompile 'junit:junit:4.12' +} + +targetCompatibility = '11' +sourceCompatibility = '11' + +// Maven Publishing + +task sourcesJar(type: Jar, dependsOn: classes) { + from sourceSets.main.allSource + + classifier = 'sources' +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + from javadoc.destinationDir + + classifier = 'javadoc' +} + +publishing { + publications { + "${libraryJavaName}"(MavenPublication) { + artifactId libraryJavaName + + artifact jar + artifact sourcesJar { + classifier 'sources' + } + artifact javadocJar { + classifier 'javadoc' + } + } + } +} \ No newline at end of file diff --git a/examples/vendor/publishingtools.gradle b/examples/vendor/publishingtools.gradle new file mode 100644 index 00000000..2f1f3188 --- /dev/null +++ b/examples/vendor/publishingtools.gradle @@ -0,0 +1,49 @@ +plugins.withType(CppPlugin).whenPluginAdded { + ext.binaryPublishers = [:] + ext.binaryArtifacts = { scope, name -> + if (binaryPublishers[name] == null) + binaryPublishers[name] = [] + binaryPublishers[name] << [scope: scope] + } + + model { + binaries { + withType(NativeBinarySpec) { + def bin = it + if (buildable && !(it instanceof TestSuiteBinarySpec)) { + def shared = bin instanceof SharedLibraryBinary + def taskSuffix = "${component.name}${targetPlatform.name}${buildType.name}${shared ? 'shared' : 'static'}" + def source = (shared ? bin.sharedLibraryFile : bin.staticLibraryFile) + + def zipTask = task "zip${taskSuffix}"(type: Zip) { + from(source) + into(targetPlatform.name) + + baseName = component.name + classifier = targetPlatform.name + + dependsOn bin.tasks.withType(AbstractLinkTask) + } + + binaryPublishers[bin.component.name]?.each { entry -> + entry.scope.artifact(zipTask) { + classifier targetPlatform.name + (buildType.name == 'debug' ? 'debug' : '') + (shared ? '' : 'static') + } + } + } + } + } + } +} + +publishing { + repositories { + maven { + name = "distLocal" + url = "${rootProject.buildDir}/mvnDistRepo" + } + } + publications.all { + groupId group + } +} \ No newline at end of file diff --git a/examples/vendor/settings.gradle b/examples/vendor/settings.gradle new file mode 100644 index 00000000..fe5cfe3f --- /dev/null +++ b/examples/vendor/settings.gradle @@ -0,0 +1,27 @@ +import org.gradle.internal.os.OperatingSystem + +pluginManagement { + repositories { + mavenLocal() + gradlePluginPortal() + String frcYear = '2019' + File frcHome + if (OperatingSystem.current().isWindows()) { + String publicFolder = System.getenv('PUBLIC') + if (publicFolder == null) { + publicFolder = "C:\\Users\\Public" + } + frcHome = new File(publicFolder, "frc${frcYear}") + } else { + def userFolder = System.getProperty("user.home") + frcHome = new File(userFolder, "frc${frcYear}") + } + def frcHomeMaven = new File(frcHome, 'maven') + maven { + name 'frcHome' + url frcHomeMaven + } + } +} + +rootProject.name = 'VendorLibrary' \ No newline at end of file diff --git a/examples/vendor/src/main/cpp_common/MyVendorLibrary.cpp b/examples/vendor/src/main/cpp_common/MyVendorLibrary.cpp new file mode 100644 index 00000000..c1a0be10 --- /dev/null +++ b/examples/vendor/src/main/cpp_common/MyVendorLibrary.cpp @@ -0,0 +1,5 @@ +#include "MyVendorLibrary.h" + +std::string MyVendorLibrary::WhoAreYou() { + return "The Developer"; +} \ No newline at end of file diff --git a/examples/vendor/src/main/cpp_robot/MyVendorLibrary.cpp b/examples/vendor/src/main/cpp_robot/MyVendorLibrary.cpp new file mode 100644 index 00000000..f20842b7 --- /dev/null +++ b/examples/vendor/src/main/cpp_robot/MyVendorLibrary.cpp @@ -0,0 +1,5 @@ +#include "MyVendorLibrary.h" + +std::string MyVendorLibrary::WhoAmI() { + return "The Robot"; +} \ No newline at end of file diff --git a/examples/vendor/src/main/cpp_simulation/MyVendorLibrary.cpp b/examples/vendor/src/main/cpp_simulation/MyVendorLibrary.cpp new file mode 100644 index 00000000..3c984134 --- /dev/null +++ b/examples/vendor/src/main/cpp_simulation/MyVendorLibrary.cpp @@ -0,0 +1,5 @@ +#include "MyVendorLibrary.h" + +std::string MyVendorLibrary::WhoAmI() { + return "A Simulation"; +} \ No newline at end of file diff --git a/examples/vendor/src/main/include/MyVendorLibrary.h b/examples/vendor/src/main/include/MyVendorLibrary.h new file mode 100644 index 00000000..0f11068e --- /dev/null +++ b/examples/vendor/src/main/include/MyVendorLibrary.h @@ -0,0 +1,9 @@ +#pragma once + +#include + +class MyVendorLibrary { + public: + std::string WhoAmI(); // This function differs between robot and simulation + std::string WhoAreYou(); // This function is the same between robot and simulation +}; \ No newline at end of file diff --git a/examples/vendor/src/main/java/my/vendor/MyVendorLibrary.java b/examples/vendor/src/main/java/my/vendor/MyVendorLibrary.java new file mode 100644 index 00000000..081f1d7f --- /dev/null +++ b/examples/vendor/src/main/java/my/vendor/MyVendorLibrary.java @@ -0,0 +1,18 @@ +package my.vendor; + +import edu.wpi.first.wpilibj.RobotBase; + +public class MyVendorLibrary { + + public String whoAreYou() { + return "The Developer"; + } + + public String whoAmI() { + if (RobotBase.isReal()) + return "The Robot"; + else + return "A Simulation"; + } + +} \ No newline at end of file diff --git a/examples/vendor/src/test/cpp/MyVendorLibraryTest.cpp b/examples/vendor/src/test/cpp/MyVendorLibraryTest.cpp new file mode 100644 index 00000000..31f36699 --- /dev/null +++ b/examples/vendor/src/test/cpp/MyVendorLibraryTest.cpp @@ -0,0 +1,17 @@ +#include + +#include "MyVendorLibrary.h" + +TEST(MyVendorLibrary, WhoAreYou) { + MyVendorLibrary lib; + ASSERT_EQ(lib.WhoAreYou(), "The Developer"); +} + +TEST(MyVendorLibrary, WhoAmI) { + MyVendorLibrary lib; +#ifdef __FRC_ROBORIO__ + ASSERT_EQ(lib.WhoAmI(), "The Robot"); +#else + ASSERT_EQ(lib.WhoAmI(), "A Simulation"); +#endif +} \ No newline at end of file diff --git a/examples/vendor/src/test/cpp/main.cpp b/examples/vendor/src/test/cpp/main.cpp new file mode 100644 index 00000000..cab8aa43 --- /dev/null +++ b/examples/vendor/src/test/cpp/main.cpp @@ -0,0 +1,10 @@ +#include + +#include "gtest/gtest.h" + +int main(int argc, char** argv) { + HAL_Initialize(500, 0); + ::testing::InitGoogleTest(&argc, argv); + int ret = RUN_ALL_TESTS(); + return ret; +} diff --git a/examples/vendor/src/test/java/MyVendorLibraryTest.java b/examples/vendor/src/test/java/MyVendorLibraryTest.java new file mode 100644 index 00000000..dbd97d58 --- /dev/null +++ b/examples/vendor/src/test/java/MyVendorLibraryTest.java @@ -0,0 +1,22 @@ +import org.junit.Test; +import static org.junit.Assert.assertEquals; + +import edu.wpi.first.wpilibj.RobotBase; +import my.vendor.MyVendorLibrary; + +public class MyVendorLibraryTest { + @Test + public void whoAmI() { + MyVendorLibrary lib = new MyVendorLibrary(); + if (RobotBase.isReal()) + assertEquals("The Robot", lib.whoAmI()); + else + assertEquals("A Simulation", lib.whoAmI()); + } + + @Test + public void whoAreYou() { + MyVendorLibrary lib = new MyVendorLibrary(); + assertEquals("The Developer", lib.whoAreYou()); + } +} \ No newline at end of file diff --git a/examples/vendor/vendordeps.gradle b/examples/vendor/vendordeps.gradle new file mode 100644 index 00000000..8582328e --- /dev/null +++ b/examples/vendor/vendordeps.gradle @@ -0,0 +1,78 @@ +import groovy.json.JsonOutput + +Map vendorJson() { + return [ + fileName: "${ext.vendorLibraryName}.json", + name: ext.vendorLibraryName, + version: project.version, + uuid: ext.uuid, + mavenUrls: [ + ext.mavenUrl + ], + jsonUrl: ext.jsonUrl, + cppDependencies: [ + [ + groupId: project.group, + artifactId: ext.libraryCppName, + version: project.version, + libName: ext.vendorLibraryName, + configuration: "native_${ext.vendorLibraryName}", + headerClassifier: 'headers', + sharedLibrary: true, + skipInvalidPlatforms: true, + binaryPlatforms: [ + "linuxx86-64", + "windowsx86-64", + "osxx86-64", + "linuxathena" + ] + ] + ], + javaDependencies: [ + groupId: project.group, + artifactId: ext.libraryJavaName, + version: project.version + ] + ] +} + +String vendorJsonString() { + return JsonOutput.prettyPrint(JsonOutput.toJson(vendorJson())) +} + +task generateVendorDepsJson() { + def outfile = new File(buildDir, "${project.ext.vendorLibraryName}.json") + outputs.file(outfile) + + doLast { + outfile.text = vendorJsonString() + } +} + +publishing { + publications { + vendordeps(MavenPublication) { + artifactId "${project.ext.vendorLibraryName}-FRCDeps" + artifact(generateVendorDepsJson.outputs.files.files[0]) { + builtBy generateVendorDepsJson + } + } + } +} + +afterEvaluate { + publishing.repositories.all { + def vendorTask = task "writeLatestVendorDepsTo${name}"() { + def outfile = new File(new File(url), "${project.ext.vendorLibraryName}.json") + outputs.file(outfile) + + doLast { + outfile.text = vendorJsonString() + } + } + + tasks.withType(PublishToMavenRepository).all { + dependsOn vendorTask + } + } +} \ No newline at end of file