mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Adds cscore and opencv to wpilib (#332)
Unit tests now run using shared wpilib as well, since we had to add a ton of sharedl ibraries anyway. Test scripts also updated to work properly.
This commit is contained in:
committed by
Peter Johnson
parent
e1bb05bc52
commit
a06dd25d56
@@ -133,6 +133,43 @@ task unzipWpiUtil(type: Copy) {
|
||||
into wpiUtilUnzipLocation
|
||||
}
|
||||
|
||||
task downloadArmCsCore() {
|
||||
description = 'Downloads the C++ ARM CsCore Uberzip maven dependency.'
|
||||
group = 'WPILib'
|
||||
def depFolder = "$buildDir/dependencies"
|
||||
def csZip = file("$depFolder/cscore-arm.zip")
|
||||
outputs.file(csZip)
|
||||
def armCsCore
|
||||
|
||||
doFirst {
|
||||
def armCsDependency = project.dependencies.create('edu.wpi.cscore.cpp:cscore:+:athena-uberzip@zip')
|
||||
def armConfig = project.configurations.detachedConfiguration(armCsDependency)
|
||||
armConfig.setTransitive(false)
|
||||
armCsCore = armConfig.files[0].canonicalFile
|
||||
}
|
||||
|
||||
doLast {
|
||||
copy {
|
||||
from armCsCore
|
||||
rename 'cscore(.+)', 'cscore-arm.zip'
|
||||
into depFolder
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def csCoreUnzipLocation = "$buildDir/cscore"
|
||||
|
||||
// Create a task that will unzip the cscore files into a temporary build directory
|
||||
task unzipCsCore(type: Copy) {
|
||||
description = 'Unzips the cscore maven dependency so that the include files and libraries can be used'
|
||||
group = 'WPILib'
|
||||
dependsOn downloadArmCsCore
|
||||
|
||||
from zipTree(downloadArmCsCore.outputs.files.singleFile)
|
||||
into csCoreUnzipLocation
|
||||
}
|
||||
|
||||
|
||||
task clean(type: Delete) {
|
||||
description = "Deletes the build directory"
|
||||
group = "Build"
|
||||
@@ -198,6 +235,26 @@ subprojects {
|
||||
addStaticWpiUtilLibraryLinks(compileTask, linker, targetPlatform)
|
||||
}
|
||||
}
|
||||
|
||||
// This defines a project property that projects depending on cscore can use to setup that dependency.
|
||||
ext.defineCsCoreProperties = {
|
||||
ext.csCore = csCoreUnzipLocation
|
||||
ext.csCoreInclude = "$csCoreUnzipLocation/include"
|
||||
ext.csLibArmLocation = "$csCoreUnzipLocation/lib"
|
||||
ext.csSharedLib = "$csLibArmLocation/libcscore.so"
|
||||
ext.cvSharedLib = "$csLibArmLocation/libopencv.so"
|
||||
|
||||
ext.addCsCoreLibraryLinks = { compileTask, linker, targetPlatform ->
|
||||
compileTask.dependsOn project(':').unzipCsCore
|
||||
String architecture = targetPlatform.architecture
|
||||
if (architecture.contains('arm')) {
|
||||
linker.args << '-L' + csLibArmLocation
|
||||
linker.args csSharedLib
|
||||
linker.args cvSharedLib
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugins.withType(CppPlugin).whenPluginAdded {
|
||||
// We use a custom-built cross compiler with the prefix arm-frc-linux-gnueabi-<util name>
|
||||
// If this ever changes, the prefix will need to be changed here
|
||||
|
||||
@@ -19,6 +19,8 @@ dependencies {
|
||||
compile wpilibj
|
||||
compile files(wpilibj.sourceSets.test.output.classesDir)
|
||||
compile 'edu.wpi.first.wpilib.networktables.java:NetworkTables:+:arm'
|
||||
compile 'edu.wpi.first.wpilib.networktables.java:NetworkTables:+:arm'
|
||||
compile 'edu.wpi.cscore.java:cscore:+:arm'
|
||||
}
|
||||
|
||||
def nativeDirectory = "$buildDir/output"
|
||||
@@ -30,16 +32,21 @@ clean {
|
||||
task copyRobotLibraries(type: Copy) {
|
||||
description = 'Copies all native libraries to an easy to find folder'
|
||||
group = 'WPILib'
|
||||
destinationDir = file(nativeDirectory)
|
||||
dependsOn shadowJar
|
||||
dependsOn ':hal:build'
|
||||
dependsOn ':wpilibj:build'
|
||||
|
||||
from (shadowJar)
|
||||
from (shadowJar) {
|
||||
into '/'
|
||||
}
|
||||
|
||||
project(':wpilibj').model {
|
||||
binaries {
|
||||
withType(SharedLibraryBinarySpec) { spec ->
|
||||
from(spec.sharedLibraryFile)
|
||||
from(spec.sharedLibraryFile) {
|
||||
into '/'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,19 +54,32 @@ task copyRobotLibraries(type: Copy) {
|
||||
project(':hal').model {
|
||||
binaries {
|
||||
withType(SharedLibraryBinarySpec) { spec ->
|
||||
from(spec.sharedLibraryFile)
|
||||
from(spec.sharedLibraryFile) {
|
||||
into '/'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
defineNetworkTablesProperties()
|
||||
defineWpiUtilProperties()
|
||||
defineCsCoreProperties()
|
||||
|
||||
from file(netSharedLib)
|
||||
from (file(netSharedLib)) {
|
||||
into '/'
|
||||
}
|
||||
|
||||
from file(wpiUtilSharedLib)
|
||||
from (file(wpiUtilSharedLib)) {
|
||||
into '/'
|
||||
}
|
||||
|
||||
from (file(csLibArmLocation).path) {
|
||||
include '**/*so.3.1'
|
||||
include '**/libcscore.so'
|
||||
include '**/libopencv_java310.so'
|
||||
into '/'
|
||||
}
|
||||
|
||||
into nativeDirectory
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,38 +10,6 @@ ext.hal = project(':hal').projectDir.getAbsolutePath()
|
||||
model {
|
||||
components {
|
||||
myRobotcpp(NativeExecutableSpec) {
|
||||
targetPlatform 'arm'
|
||||
binaries.all {
|
||||
tasks.withType(CppCompile) {
|
||||
addNiLibraryLinks(linker, targetPlatform)
|
||||
addStaticNetworkTablesLibraryLinks(it, linker, targetPlatform)
|
||||
}
|
||||
|
||||
cppCompiler.args '-pthread', '-Wno-unused-variable'
|
||||
linker.args '-pthread', '-Wno-unused-variable', '-Wl,-rpath,/opt/GenICam_v2_3/bin/Linux_armv7-a'
|
||||
}
|
||||
sources {
|
||||
cpp {
|
||||
source {
|
||||
srcDir 'src'
|
||||
include '**/*.cpp'
|
||||
}
|
||||
exportedHeaders {
|
||||
srcDirs = ['include',
|
||||
"${project.athena}/include", "${project.shared}/include",
|
||||
"${project.hal}/include/HAL", netTablesInclude, wpiUtilInclude]
|
||||
include '**/*.h'
|
||||
}
|
||||
|
||||
lib project: ':wpilibc', library: 'wpilibc', linkage: 'static'
|
||||
lib project: ':hal', library: 'HALAthena', linkage: 'static'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Shared target used just to check that wpilib is fully linked
|
||||
// Use the static target for normal linking
|
||||
myRobotcppShared(NativeExecutableSpec) {
|
||||
targetPlatform 'arm'
|
||||
binaries.all {
|
||||
tasks.withType(CppCompile) {
|
||||
@@ -72,3 +40,71 @@ model {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def nativeDirectory = "$buildDir/output"
|
||||
|
||||
clean {
|
||||
delete nativeDirectory
|
||||
}
|
||||
|
||||
task copyRobotLibraries(type: Copy) {
|
||||
description = 'Copies all native libraries to an easy to find folder'
|
||||
group = 'WPILib'
|
||||
destinationDir = file(nativeDirectory)
|
||||
dependsOn ':hal:build'
|
||||
dependsOn ':wpilibc:build'
|
||||
dependsOn check
|
||||
|
||||
project(':wpilibc').model {
|
||||
binaries {
|
||||
withType(SharedLibraryBinarySpec) { spec ->
|
||||
from(spec.sharedLibraryFile) {
|
||||
into '/'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
project.model {
|
||||
binaries {
|
||||
withType(NativeExecutableBinarySpec) { spec ->
|
||||
from(spec.executableFile) {
|
||||
into '/'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
project(':hal').model {
|
||||
binaries {
|
||||
withType(SharedLibraryBinarySpec) { spec ->
|
||||
from(spec.sharedLibraryFile) {
|
||||
into '/'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
defineNetworkTablesProperties()
|
||||
defineWpiUtilProperties()
|
||||
defineCsCoreProperties()
|
||||
|
||||
from (file(netSharedLib)) {
|
||||
into '/'
|
||||
}
|
||||
|
||||
from (file(wpiUtilSharedLib)) {
|
||||
into '/'
|
||||
}
|
||||
|
||||
from (file(csLibArmLocation).path) {
|
||||
include '**/*so.3.1'
|
||||
include '**/libcscore.so'
|
||||
include '**/libopencv_java310.so'
|
||||
into '/'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
build.dependsOn copyRobotLibraries
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
/* GNU ld script */
|
||||
OUTPUT_FORMAT(elf32-littlearm)
|
||||
GROUP ( AS_NEEDED ( -lwpilibc -lHALAthena -lntcore -lwpiutil -lnilibraries ) )
|
||||
GROUP ( AS_NEEDED ( -lwpilibc -lHALAthena -lntcore -lwpiutil -lcscore -lopencv -lnilibraries ) )
|
||||
|
||||
@@ -34,7 +34,7 @@ DEFAULT_JAVA_TEST_ARGS=""
|
||||
DEFAULT_LOCAL_JAVA_TEST_FILE=../wpilibjIntegrationTests/build/libs/wpilibjIntegrationTests-all.jar
|
||||
|
||||
JAVA_REPORT=javareport.xml
|
||||
DEFAULT_LIBRARY_JAVA_FILES=../wpilibjIntegrationTests/build/nativelibraries
|
||||
DEFAULT_LIBRARY_JAVA_DESTINATION=/usr/local/frc/lib
|
||||
DEFAULT_LIBRARY_NATIVE_FILES=../wpilibjIntegrationTests/build/nativelibraries
|
||||
DEFAULT_LIBRARY_NATIVE_DESTINATION=/usr/local/frc/lib
|
||||
DEFAULT_LOCAL_JAVA_TEST_RESULT=${DEFAULT_LOCAL_TEST_RESULTS_DIR}/${JAVA_REPORT}
|
||||
DEFAULT_DESTINATION_JAVA_TEST_RESULTS=${DEFAULT_DESTINATION_TEST_RESULTS_DIR}/AntReports/TEST-edu.wpi.first.wpilibj.test.TestSuite.xml
|
||||
|
||||
@@ -76,16 +76,19 @@ SCP_TEST_SCRIPT="scp config.sh ${DEFAULT_LOCAL_RUN_TEST_SCRIPT} ${ROBOT_ADDRESS}
|
||||
SSH_CHMOD_AND_MAKE_TEMP_TEST_DIR="ssh -t ${ROBOT_ADDRESS} \"chmod a+x ${DEFAULT_DESTINATION_RUN_TEST_SCRIPT}; mkdir ${DEFAULT_TEST_SCP_DIR}; touch ${DESTINATION_TEST_FILE}\""
|
||||
SCP_TEST_PROGRAM="scp ${LOCAL_TEST_FILE} ${ROBOT_ADDRESS}:${DESTINATION_TEST_FILE}"
|
||||
SSH_RUN_TESTS="ssh -t ${ROBOT_ADDRESS} ${DEFAULT_DESTINATION_RUN_TEST_SCRIPT} ${LANGUAGE} $(whoami) ${MUTEX_OVERRIDE_PARAM_TEXT}-d ${DEFAULT_TEST_SCP_DIR} ${TEST_RUN_ARGS}"
|
||||
SCP_JAVA_LIBRARIES="scp ${DEFAULT_LIBRARY_JAVA_FILES}/* ${ROBOT_ADDRESS}:${DEFAULT_LIBRARY_JAVA_DESTINATION}"
|
||||
SCP_NATIVE_LIBRARIES="scp ${DEFAULT_LIBRARY_NATIVE_FILES}/* ${ROBOT_ADDRESS}:${DEFAULT_LIBRARY_NATIVE_DESTINATION}"
|
||||
CONFIG_NATIVE_LIBRARIES="ssh -t ${ADMIN_ROBOT_ADDRESS} ldconfig"
|
||||
|
||||
if [ $(which sshpass) ]; then
|
||||
sshpass -p "" ${SCP_JAVA_LIBRARIES}
|
||||
sshpass -p "" ${SCP_NATIVE_LIBRARIES}
|
||||
sshpass -p "" ${CONFIG_NATIVE_LIBRARIES}
|
||||
sshpass -p "" ${SCP_TEST_SCRIPT}
|
||||
sshpass -p "" ${SSH_CHMOD_AND_MAKE_TEMP_TEST_DIR}
|
||||
sshpass -p "" ${SCP_TEST_PROGRAM}
|
||||
sshpass -p "" ${SSH_RUN_TESTS}
|
||||
else
|
||||
eval ${SCP_JAVA_LIBRARIES}
|
||||
eval ${SCP_NATIVE_LIBRARIES}
|
||||
eval ${CONFIG_NATIVE_LIBRARIES}
|
||||
eval ${SCP_TEST_SCRIPT}
|
||||
eval ${SSH_CHMOD_AND_MAKE_TEMP_TEST_DIR}
|
||||
eval ${SCP_TEST_PROGRAM}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
defineNetworkTablesProperties()
|
||||
defineWpiUtilProperties()
|
||||
defineCsCoreProperties()
|
||||
|
||||
debugStripSetup(project)
|
||||
|
||||
@@ -14,6 +15,7 @@ model {
|
||||
cppCompiler.args "-DNAMESPACED_WPILIB"
|
||||
addNiLibraryLinks(linker, targetPlatform)
|
||||
addNetworkTablesLibraryLinks(it, linker, targetPlatform)
|
||||
addCsCoreLibraryLinks(it, linker, targetPlatform)
|
||||
}
|
||||
}
|
||||
sources {
|
||||
@@ -23,7 +25,7 @@ model {
|
||||
includes = ['**/*.cpp']
|
||||
}
|
||||
exportedHeaders {
|
||||
srcDirs = ["${project.shared}/include", "${project.athena}/include", netTablesInclude, wpiUtilInclude]
|
||||
srcDirs = ["${project.shared}/include", "${project.athena}/include", netTablesInclude, wpiUtilInclude, csCoreInclude]
|
||||
includes = ['**/*.h']
|
||||
}
|
||||
lib project: ':hal', library: 'HALAthena', linkage: 'shared'
|
||||
|
||||
@@ -2,6 +2,7 @@ apply plugin: 'cpp'
|
||||
|
||||
defineNetworkTablesProperties()
|
||||
defineWpiUtilProperties()
|
||||
defineCsCoreProperties()
|
||||
|
||||
ext.shared = "${project(':wpilibc').projectDir.getAbsolutePath()}/shared"
|
||||
ext.athena = "${project(':wpilibc').projectDir.getAbsolutePath()}/athena"
|
||||
@@ -15,7 +16,8 @@ model {
|
||||
tasks.withType(CppCompile) {
|
||||
cppCompiler.args "-DNAMESPACED_WPILIB"
|
||||
addNiLibraryLinks(linker, targetPlatform)
|
||||
addStaticNetworkTablesLibraryLinks(it, linker, targetPlatform)
|
||||
addNetworkTablesLibraryLinks(it, linker, targetPlatform)
|
||||
addCsCoreLibraryLinks(it, linker, targetPlatform)
|
||||
}
|
||||
|
||||
cppCompiler.args '-pthread', '-Wno-unused-variable'
|
||||
@@ -35,12 +37,12 @@ model {
|
||||
exportedHeaders {
|
||||
srcDirs = ['include', 'gtest', 'gtest/include',
|
||||
"${project.athena}/include", "${project.shared}/include",
|
||||
"${project.hal}/include/HAL", netTablesInclude]
|
||||
"${project.hal}/include/HAL", netTablesInclude, wpiUtilInclude, csCoreInclude]
|
||||
include '**/*.h'
|
||||
}
|
||||
|
||||
lib project: ':wpilibc', library: 'wpilibc', linkage: 'static'
|
||||
lib project: ':hal', library: 'HALAthena', linkage: 'static'
|
||||
lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared'
|
||||
lib project: ':hal', library: 'HALAthena', linkage: 'shared'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,10 @@ dependencies {
|
||||
athenaCompile sourceSets.shared.output
|
||||
athenaCompile 'edu.wpi.first.wpilib.networktables.java:NetworkTables:+:arm'
|
||||
athenaRuntime 'edu.wpi.first.wpilib.networktables.java:NetworkTables:+:arm'
|
||||
athenaCompile 'edu.wpi.cscore.java:cscore:+:arm'
|
||||
athenaRuntime 'edu.wpi.cscore.java:cscore:+:arm'
|
||||
athenaCompile 'org.opencv:opencv-java:+'
|
||||
athenaRuntime 'org.opencv:opencv-java:+'
|
||||
}
|
||||
|
||||
defineWpiUtilProperties()
|
||||
|
||||
@@ -19,6 +19,8 @@ dependencies {
|
||||
compile wpilibj
|
||||
compile files(wpilibj.sourceSets.test.output.classesDir)
|
||||
compile 'edu.wpi.first.wpilib.networktables.java:NetworkTables:+:arm'
|
||||
compile 'edu.wpi.cscore.java:cscore:+:arm'
|
||||
compile 'org.opencv:opencv-java:+'
|
||||
compile 'junit:junit:4.11'
|
||||
compile 'com.googlecode.junit-toolbox:junit-toolbox:2.0'
|
||||
compile 'org.apache.ant:ant:1.9.4'
|
||||
@@ -36,14 +38,28 @@ clean {
|
||||
task copyIntegrationLibraries(type: Copy) {
|
||||
description = 'Copies all native libraries to an easy to find folder'
|
||||
group = 'WPILib'
|
||||
destinationDir = file(nativeDirectory)
|
||||
dependsOn shadowJar
|
||||
dependsOn ':hal:build'
|
||||
dependsOn ':wpilibj:build'
|
||||
dependsOn ':wpilibc:build'
|
||||
|
||||
project(':wpilibj').model {
|
||||
binaries {
|
||||
withType(SharedLibraryBinarySpec) { spec ->
|
||||
from(spec.sharedLibraryFile)
|
||||
from(spec.sharedLibraryFile) {
|
||||
into '/'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
project(':wpilibc').model {
|
||||
binaries {
|
||||
withType(SharedLibraryBinarySpec) { spec ->
|
||||
from(spec.sharedLibraryFile) {
|
||||
into '/'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,19 +67,31 @@ task copyIntegrationLibraries(type: Copy) {
|
||||
project(':hal').model {
|
||||
binaries {
|
||||
withType(SharedLibraryBinarySpec) { spec ->
|
||||
from(spec.sharedLibraryFile)
|
||||
from(spec.sharedLibraryFile) {
|
||||
into '/'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
defineNetworkTablesProperties()
|
||||
defineWpiUtilProperties()
|
||||
defineCsCoreProperties()
|
||||
|
||||
from file(netSharedLib)
|
||||
from (file(netSharedLib)) {
|
||||
into '/'
|
||||
}
|
||||
|
||||
from file(wpiUtilSharedLib)
|
||||
from (file(wpiUtilSharedLib)) {
|
||||
into '/'
|
||||
}
|
||||
|
||||
into nativeDirectory
|
||||
from (file(csLibArmLocation).path) {
|
||||
include '**/*so.3.1'
|
||||
include '**/libcscore.so'
|
||||
include '**/libopencv_java310.so'
|
||||
into '/'
|
||||
}
|
||||
}
|
||||
|
||||
compileJava.dependsOn tasks.getByPath(':wpilibj:testClasses')
|
||||
|
||||
Reference in New Issue
Block a user