Switches to the new build system (#87)

* Removes old build system

* Removes old gmock

* Adds new gmock

* Moves source files to new locations

* Adds new build system
This commit is contained in:
Thad House
2017-08-18 17:52:08 -07:00
committed by Peter Johnson
parent 9d45088127
commit 133540f577
96 changed files with 940 additions and 1687 deletions

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
gradlew.bat eol=crlf

6
.gitignore vendored
View File

@@ -27,8 +27,8 @@
.vs/
*.def
!ntcore.def
!ntcore-jni.def
!cscore.def
!cscore-jni.def
*.opensdf
*.vcxproj
*.vcxproj.user
@@ -41,7 +41,7 @@
# Build directories
/.gradle
/build*
/build/
!build.gradle
/native
/arm

31
.travis.yml Normal file
View File

@@ -0,0 +1,31 @@
language: java
matrix:
include:
- os: linux
dist: trusty
sudo: required
- os: osx
osx_image: xcode8
addons:
apt:
packages:
- g++-multilib
- lib32stdc++6
before_install:
- .travis-scripts/install.sh
install:
- ./gradlew build -PbuildAll
script:
- ./gradlew build -PbuildAll
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/

View File

@@ -1,18 +1,27 @@
version: "{branch} {build}"
image:
- Visual Studio 2015
build:
verbosity: detailed
build_script:
- gradlew.bat assemble --info -PskipArm
- gradlew.bat tasks
test_script:
- gradlew.bat check --info -PskipArm
- cmd: >-
SET JAVA_HOME=C:\Program Files\Java\jdk1.8.0
environment:
matrix:
- JAVA_HOME: C:\Program Files\Java\jdk1.8.0
- JAVA_HOME: C:\Program Files (x86)\Java\jdk1.8.0
gradlew.bat clean
gradlew.bat check --info
SET JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0
gradlew.bat clean
gradlew.bat check --info
cache:
- C:\Users\appveyor\.gradle

View File

@@ -1,85 +1,260 @@
import edu.wpi.first.nativeutils.NativeUtils
import org.gradle.api.file.FileCollection
import org.gradle.internal.os.OperatingSystem
import edu.wpi.first.nativeutils.tasks.JNIHeaders
plugins {
id 'net.ltgt.errorprone' version '0.0.8'
id 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin' version '1.6'
}
allprojects {
buildscript {
repositories {
mavenCentral()
mavenLocal()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'gradle.plugin.edu.wpi.first:native-utils:1.2.11'
classpath 'gradle.plugin.edu.wpi.first.wpilib.versioning:wpilib-version-plugin:1.6'
}
}
ext.buildArm = !project.hasProperty('skipArm')
ext.includeJava = !project.hasProperty('skipJava')
if (hasProperty('makeDesktop')) {
println 'Making desktop classifier jar. NOTE: This desktop version should only be used for local testing.' +
'It will only support the current platform, and will override fetching the latest development version from' +
' the maven repo until you manually delete it!'
repositories {
mavenCentral()
}
ext.getPlatformPath2 = { targetPlatform ->
if (targetPlatform.architecture.arm) {
return 'Linux/arm'
} else if (targetPlatform.operatingSystem.linux) {
if (targetPlatform.architecture.amd64) {
return 'Linux/amd64'
} else {
return 'Linux/' + targetPlatform.architecture.name
}
} else if (targetPlatform.operatingSystem.windows) {
if (targetPlatform.architecture.amd64) {
return 'Windows/amd64'
} else {
return 'Windows/' + targetPlatform.architecture.name
}
} else if (targetPlatform.operatingSystem.macOsX) {
if (targetPlatform.architecture.amd64) {
return 'Mac OS X/x86_64'
} else {
return 'Mac OS X/' + targetPlatform.architecture.name
}
} else {
return targetPlatform.operatingSystem.name + '/' + targetPlatform.architecture.name
}
ext.getClassifier = { binary->
return NativeUtils.getClassifier(binary)
}
ext.getPlatformPath = { binary ->
return getPlatformPath2(binary.targetPlatform)
ext.getPlatformPath = { binary->
return NativeUtils.getPlatformPath(binary)
}
apply from: "dependencies.gradle"
ext.getJNIHeadersClass = {
return JNIHeaders
}
ext.setupDefines = { project, binaries ->
binaries.all {
if (project.hasProperty('debug')) {
project.setupDebugDefines(cppCompiler, linker)
} else {
project.setupReleaseDefines(cppCompiler, linker)
}
tasks.withType(CppCompile) {
if (!project.hasProperty('compilerPrefix') && targetPlatform.architecture.name == 'arm-v7') {
project.addWpiUtilSharedLibraryLinks(it, linker, targetPlatform)
} else {
project.addWpiUtilStaticLibraryLinks(it, linker, targetPlatform)
apply plugin: 'cpp'
apply plugin: 'google-test'
apply plugin: 'visual-studio'
apply plugin: 'edu.wpi.first.NativeUtils'
apply plugin: 'java'
apply from: 'config.gradle'
if (project.hasProperty('onlyAthena')) {
test.enabled = false
}
sourceSets {
dev
}
task nativeTestFilesJar(type: Jar) {
destinationDir = project.buildDir
classifier = "nativeTestFiles"
project.model {
binaries {
withType(SharedLibraryBinarySpec) { binary ->
if (binary.component.name == 'cscoreJNI') {
from(binary.sharedLibraryFile) {
into NativeUtils.getPlatformPath(binary)
}
dependsOn binary.buildTask
}
}
project.addOpenCvLibraryLinks(it, linker, targetPlatform)
}
}
}
apply from: "cscore.gradle"
task run(type: JavaExec) {
classpath = sourceSets.dev.runtimeClasspath
// Empty task for build so that cscoreSourceZip will be
// built when running ./gradlew build
task build
main = 'edu.wpi.cscore.DevMain'
}
build.dependsOn cscoreSourceZip
test.dependsOn nativeTestFilesJar
run.dependsOn nativeTestFilesJar
build.dependsOn devClasses
dependencies {
compile 'edu.wpi.first.wpiutil:wpiutil-java:+'
compile 'org.opencv:opencv-java:3.2.0'
testCompile 'junit:junit:4.12'
testRuntime files(project(':').nativeTestFilesJar.archivePath)
testRuntime 'org.opencv:opencv-jni:3.2.0:all'
devCompile 'edu.wpi.first.wpiutil:wpiutil-java:+'
devCompile 'org.opencv:opencv-java:3.2.0'
devCompile sourceSets.main.output
devRuntime files(project(':').nativeTestFilesJar.archivePath)
devRuntime 'org.opencv:opencv-jni:3.2.0:all'
}
model {
jniConfigs {
cscore(JNIConfig) {
jniDefinitionClasses = [ "edu.wpi.cscore.CameraServerJNI" ]
jniArmHeaderLocations = [ all: file("${rootDir}/src/arm-linux-jni") ]
sourceSets = [ project.sourceSets.main ]
}
cscoreJNI(JNIConfig) {
jniDefinitionClasses = [ "edu.wpi.cscore.CameraServerJNI" ]
jniArmHeaderLocations = [ all: file("${rootDir}/src/arm-linux-jni") ]
sourceSets = [ project.sourceSets.main ]
}
}
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' ]
}
cscoreJNI(ExportsConfig) {
x86SymbolFilter = { symbols->
def retList = []
symbols.each { symbol->
if (symbol.startsWith('NT_') || symbol.startsWith('Java_') || symbol.startsWith('JNI_')) {
retList << symbol
}
}
return retList
}
x64SymbolFilter = { symbols->
def retList = []
symbols.each { symbol->
if (symbol.startsWith('NT_') || symbol.startsWith('Java_') || symbol.startsWith('JNI_')) {
retList << symbol
}
}
return retList
}
}
}
dependencyConfigs {
wpiutil(DependencyConfig) {
groupId = 'edu.wpi.first.wpiutil'
artifactId = 'wpiutil-cpp'
headerClassifier = 'headers'
ext = 'zip'
version = '+'
sharedConfigs = [ cscore: [],
cscoreDev: [],
cscoreTestingBaseTest: [] ]
staticConfigs = [ cscoreJNI: [] ]
}
opencv(DependencyConfig) {
groupId = 'org.opencv'
artifactId = 'opencv-cpp'
headerClassifier = 'headers'
ext = 'zip'
version = '3.2.0'
sharedConfigs = [ cscore: [],
cscoreDev: [],
cscoreTestingBaseTest: [] ]
staticConfigs = [ cscoreJNI: [] ]
}
}
components {
cscore(NativeLibrarySpec) {
sources {
cpp {
source {
srcDirs 'src/main/native/cpp'
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/main/native/include'
}
}
}
}
cscoreJNI(NativeLibrarySpec) {
baseName = 'cscore'
sources {
cpp {
source {
srcDirs 'src/main/native/cpp'
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/main/native/include'
}
}
}
}
if (!project.hasProperty('skipTestExe')) {
cscoreDev(NativeExecutableSpec) {
sources {
cpp {
lib library: "cscore"
source {
srcDirs 'src/dev/native/cpp'
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/dev/native/include'
}
}
}
}
}
cscoreTestingBase(NativeLibrarySpec) { }
}
testSuites {
cscoreTestingBaseTest {
sources {
cpp.source.srcDir 'src/test/native/cpp'
cpp.exportedHeaders {
srcDirs 'src/test/native/include', 'src/main/native/cpp'
}
}
}
}
binaries {
withType(StaticLibraryBinarySpec) {
if (it.component.name == 'cscoreJNI') {
it.buildable = false
}
}
withType(GoogleTestTestSuiteBinarySpec) {
if (it.component.testedComponent.name.contains('TestingBase') && !project.hasProperty('onlyAthena')) {
lib project: ':gmock', library: 'gmock', linkage: 'static'
lib library: 'cscore', linkage: 'shared'
} else {
it.buildable = false
}
}
}
tasks {
def c = $.components
project.tasks.create('runCpp', Exec) {
def found = false
c.each {
if (it in NativeExecutableSpec && it.name == 'cscoreDev') {
it.binaries.each {
if (!found) {
def arch = it.targetPlatform.architecture.name
if (arch == 'x86-64' || arch == 'x86') {
dependsOn it.tasks.install
commandLine it.tasks.install.runScript
found = true
}
}
}
}
}
}
}
}
apply from: 'publish.gradle'
task wrapper(type: Wrapper) {
gradleVersion = '3.3'
gradleVersion = '4.1'
}

229
config.gradle Normal file
View File

@@ -0,0 +1,229 @@
import edu.wpi.first.nativeutils.*
import org.gradle.internal.os.OperatingSystem
def windowsCompilerArgs = ['/EHsc', '/DNOMINMAX', '/D_SCL_SECURE_NO_WARNINGS', '/D_WINSOCK_DEPRECATED_NO_WARNINGS',
'/Zi', '/FS', '/Zc:inline', '/MT']
def windowsReleaseCompilerArgs = ['/O2']
def windowsLinkerArgs = [ '/DEBUG:FULL' ]
def windowsReleaseLinkerArgs = [ '/OPT:REF', '/OPT:ICF' ]
def linuxCompilerArgs = ['-std=c++11', '-Wformat=2', '-Wall', '-Wextra', '-Werror', '-pedantic', '-Wno-psabi', '-g',
'-Wno-unused-parameter', '-fPIC', '-rdynamic', '-Wno-error=deprecated-declarations', '-pthread']
def linuxLinkerArgs = ['-rdynamic', '-pthread']
def linuxReleaseCompilerArgs = ['-O2']
def linuxDebugCompilerArgs = ['-O0']
def linux32BitArg = '-m32'
def macCompilerArgs = ['-std=c++11', '-Wall', '-Wextra', '-Werror', '-pedantic-errors', '-fPIC', '-g',
'-Wno-unused-parameter', '-Wno-missing-field-initializers', '-Wno-unused-private-field']
def macReleaseCompilerArgs = ['-O2']
def macDebugCompilerArgs = ['-O0']
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')) {
model {
buildConfigs {
roboRio(CrossBuildConfig) {
architecture = 'athena'
operatingSystem = 'linux'
toolChainPrefix = 'arm-frc-linux-gnueabi-'
compilerArgs = linuxCompilerArgs
linkerArgs = linuxLinkerArgs
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
releaseStripBinaries = true
compilerFamily = 'Gcc'
exclude << 'gmock'
exclude << 'wpiutilTestingBase'
}
}
}
}
if (!project.hasProperty('onlyAthena')) {
model {
buildConfigs {
winX86(BuildConfig) {
architecture = 'x86'
operatingSystem = 'windows'
compilerArgs = windowsCompilerArgs
linkerArgs = windowsLinkerArgs
releaseCompilerArgs = windowsReleaseCompilerArgs
releaseLinkerArgs = windowsReleaseLinkerArgs
compilerFamily = 'VisualCpp'
detectPlatform = windows32PlatformDetect
}
winX64(BuildConfig) {
architecture = 'x86-64'
operatingSystem = 'windows'
compilerArgs = windowsCompilerArgs
linkerArgs = windowsLinkerArgs
releaseCompilerArgs = windowsReleaseCompilerArgs
releaseLinkerArgs = windowsReleaseLinkerArgs
compilerFamily = 'VisualCpp'
detectPlatform = windows64PlatformDetect
}
linuxX86(BuildConfig) {
architecture = 'x86'
operatingSystem = 'linux'
compilerArgs = linuxCompilerArgs
compilerArgs << linux32BitArg
linkerArgs = linuxLinkerArgs
linkerArgs << linux32BitArg
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
compilerFamily = 'Gcc'
detectPlatform = linux32IntelPlatformDetect
}
linuxX64(BuildConfig) {
architecture = 'x86-64'
operatingSystem = 'linux'
compilerArgs = linuxCompilerArgs
linkerArgs = linuxLinkerArgs
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
compilerFamily = 'Gcc'
detectPlatform = linux64IntelPlatformDetect
}
/* 32 bit Mac OS X not supported by OpenCV.
* If support is ever added, will add this back in
macX86(BuildConfig) {
architecture = 'x86'
operatingSystem = 'osx'
compilerArgs = macCompilerArgs
compilerArgs << mac32BitArg
linkerArgs << mac32BitArg
debugCompilerArgs = macDebugCompilerArgs
releaseCompilerArgs = macReleaseCompilerArgs
compilerFamily = 'Clang'
detectPlatform = mac32PlatformDetect
}
*/
macX64(BuildConfig) {
architecture = 'x86-64'
operatingSystem = 'osx'
compilerArgs = macCompilerArgs
debugCompilerArgs = macDebugCompilerArgs
releaseCompilerArgs = macReleaseCompilerArgs
compilerFamily = 'Clang'
detectPlatform = mac64PlatformDetect
}
raspbian(CrossBuildConfig) {
architecture = 'raspbian'
operatingSystem = 'linux'
toolChainPrefix = 'arm-linux-gnueabihf-'
compilerArgs = linuxCompilerArgs
linkerArgs = linuxLinkerArgs
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
skipByDefault = true
compilerFamily = 'Gcc'
exclude << 'gmock'
}
armhf(CrossBuildConfig) {
architecture = 'armhf'
operatingSystem = 'linux'
toolChainPrefix = 'arm-linux-gnueabihf-'
compilerArgs = linuxCompilerArgs
linkerArgs = linuxLinkerArgs
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
skipByDefault = true
compilerFamily = 'Gcc'
exclude << 'gmock'
}
aarch(CrossBuildConfig) {
architecture = 'aarch'
operatingSystem = 'linux'
toolChainPrefix = 'aarch-linux-gnu-'
compilerArgs = linuxCompilerArgs
linkerArgs = linuxLinkerArgs
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
skipByDefault = true
compilerFamily = 'Gcc'
exclude << 'gmock'
}
linuxArm(BuildConfig) {
architecture = 'arm'
operatingSystem = 'linux'
compilerArgs = linuxCompilerArgs
linkerArgs = linuxLinkerArgs
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
compilerFamily = 'Gcc'
detectPlatform = linuxArmPlatformDetect
}
}
}
}

View File

@@ -1,168 +0,0 @@
LIBRARY CSCORE
EXPORTS
CS_GetPropertyKind @1
CS_GetPropertyName @2
CS_GetProperty @3
CS_SetProperty @4
CS_GetPropertyMin @5
CS_GetPropertyMax @6
CS_GetPropertyStep @7
CS_GetPropertyDefault @8
CS_GetStringProperty @9
CS_SetStringProperty @10
CS_GetEnumPropertyChoices @11
CS_CreateUsbCameraDev @12
CS_CreateUsbCameraPath @13
CS_CreateHttpCamera @14
CS_CreateHttpCameraMulti @15
CS_CreateCvSource @16
CS_GetSourceName @17
CS_GetSourceDescription @18
CS_GetSourceLastFrameTime @19
CS_IsSourceConnected @20
CS_GetSourceProperty @21
CS_EnumerateSourceProperties @22
CS_CopySource @23
CS_ReleaseSource @24
CS_PutSourceFrameCpp @25
CS_NotifySourceError @26
CS_SetSourceConnected @27
CS_CreateSourceProperty @28
CS_CreateCvSink @29
CS_CreateCvSinkCallback @30
CS_GetSinkName @31
CS_GetSinkDescription @32
CS_SetSinkSource @33
CS_GetSinkSourceProperty @34
CS_GetSinkSource @35
CS_CopySink @36
CS_ReleaseSink @37
CS_GrabSinkFrameCpp @38
CS_GetSinkError @39
CS_SetSinkEnabled @40
CS_EnumerateUsbCameras @41
CS_FreeEnumeratedUsbCameras @42
CS_EnumerateSources @43
CS_ReleaseEnumeratedSources @44
CS_EnumerateSinks @45
CS_ReleaseEnumeratedSinks @46
CS_FreeString @47
CS_FreeEnumPropertyChoices @48
CS_FreeEnumeratedProperties @49
CS_SetSinkDescription @50
CS_GetSinkKind @51
CS_GetSourceKind @52
CS_GetSourceVideoMode @53
CS_SetSourceVideoModeDiscrete @54
CS_SetSourcePixelFormat @55
CS_SetSourceResolution @56
CS_SetSourceFPS @57
CS_EnumerateSourceVideoModes @58
CS_EnumerateSourceSinks @59
CS_FreeEnumeratedVideoModes @60
CS_SetSourceDescription @61
CS_SetSourceEnumPropertyChoices @62
CS_CreateMjpegServer @63
CS_GetMjpegServerListenAddress @64
CS_GetMjpegServerPort @65
CS_GetUsbCameraPath @66
CS_AddListener @67
CS_RemoveListener @68
CS_GetHostname @69
CS_GetNetworkInterfaces @70
CS_FreeNetworkInterfaces @71
CS_FreeHttpCameraUrls @72
CS_GetHttpCameraKind @73
CS_GetHttpCameraUrls @74
CS_SetHttpCameraUrls @75
CS_SetLogger @76
CS_SetCameraBrightness @77
CS_GetCameraBrightness @78
CS_SetCameraWhiteBalanceAuto @79
CS_SetCameraWhiteBalanceHoldCurrent @80
CS_SetCameraWhiteBalanceManual @81
CS_SetCameraExposureAuto @82
CS_SetCameraExposureHoldCurrent @83
CS_SetCameraExposureManual @84
CS_SetDefaultLogger @85
CS_GrabSinkFrameTimeout @86
CS_GrabSinkFrameTimeoutCpp @87
; JNI functions
JNI_OnLoad
JNI_OnUnload
Java_edu_wpi_cscore_CameraServerJNI_getPropertyKind
Java_edu_wpi_cscore_CameraServerJNI_getPropertyName
Java_edu_wpi_cscore_CameraServerJNI_getProperty
Java_edu_wpi_cscore_CameraServerJNI_setProperty
Java_edu_wpi_cscore_CameraServerJNI_getPropertyMin
Java_edu_wpi_cscore_CameraServerJNI_getPropertyMax
Java_edu_wpi_cscore_CameraServerJNI_getPropertyStep
Java_edu_wpi_cscore_CameraServerJNI_getPropertyDefault
Java_edu_wpi_cscore_CameraServerJNI_getStringProperty
Java_edu_wpi_cscore_CameraServerJNI_setStringProperty
Java_edu_wpi_cscore_CameraServerJNI_getEnumPropertyChoices
Java_edu_wpi_cscore_CameraServerJNI_createUsbCameraDev
Java_edu_wpi_cscore_CameraServerJNI_createUsbCameraPath
Java_edu_wpi_cscore_CameraServerJNI_createHttpCamera
Java_edu_wpi_cscore_CameraServerJNI_createHttpCameraMulti
Java_edu_wpi_cscore_CameraServerJNI_createCvSource
Java_edu_wpi_cscore_CameraServerJNI_getSourceKind
Java_edu_wpi_cscore_CameraServerJNI_getSourceName
Java_edu_wpi_cscore_CameraServerJNI_getSourceDescription
Java_edu_wpi_cscore_CameraServerJNI_getSourceLastFrameTime
Java_edu_wpi_cscore_CameraServerJNI_isSourceConnected
Java_edu_wpi_cscore_CameraServerJNI_getSourceProperty
Java_edu_wpi_cscore_CameraServerJNI_enumerateSourceProperties
Java_edu_wpi_cscore_CameraServerJNI_getSourceVideoMode
Java_edu_wpi_cscore_CameraServerJNI_setSourceVideoMode
Java_edu_wpi_cscore_CameraServerJNI_setSourcePixelFormat
Java_edu_wpi_cscore_CameraServerJNI_setSourceResolution
Java_edu_wpi_cscore_CameraServerJNI_setSourceFPS
Java_edu_wpi_cscore_CameraServerJNI_enumerateSourceVideoModes
Java_edu_wpi_cscore_CameraServerJNI_enumerateSourceSinks
Java_edu_wpi_cscore_CameraServerJNI_copySource
Java_edu_wpi_cscore_CameraServerJNI_releaseSource
Java_edu_wpi_cscore_CameraServerJNI_setCameraBrightness
Java_edu_wpi_cscore_CameraServerJNI_getCameraBrightness
Java_edu_wpi_cscore_CameraServerJNI_setCameraWhiteBalanceAuto
Java_edu_wpi_cscore_CameraServerJNI_setCameraWhiteBalanceHoldCurrent
Java_edu_wpi_cscore_CameraServerJNI_setCameraWhiteBalanceManual
Java_edu_wpi_cscore_CameraServerJNI_setCameraExposureAuto
Java_edu_wpi_cscore_CameraServerJNI_setCameraExposureHoldCurrent
Java_edu_wpi_cscore_CameraServerJNI_setCameraExposureManual
Java_edu_wpi_cscore_CameraServerJNI_getUsbCameraPath
Java_edu_wpi_cscore_CameraServerJNI_getHttpCameraKind
Java_edu_wpi_cscore_CameraServerJNI_setHttpCameraUrls
Java_edu_wpi_cscore_CameraServerJNI_getHttpCameraUrls
Java_edu_wpi_cscore_CameraServerJNI_putSourceFrame
Java_edu_wpi_cscore_CameraServerJNI_notifySourceError
Java_edu_wpi_cscore_CameraServerJNI_setSourceConnected
Java_edu_wpi_cscore_CameraServerJNI_setSourceDescription
Java_edu_wpi_cscore_CameraServerJNI_createSourceProperty
Java_edu_wpi_cscore_CameraServerJNI_setSourceEnumPropertyChoices
Java_edu_wpi_cscore_CameraServerJNI_createMjpegServer
Java_edu_wpi_cscore_CameraServerJNI_createCvSink
Java_edu_wpi_cscore_CameraServerJNI_getSinkKind
Java_edu_wpi_cscore_CameraServerJNI_getSinkName
Java_edu_wpi_cscore_CameraServerJNI_getSinkDescription
Java_edu_wpi_cscore_CameraServerJNI_setSinkSource
Java_edu_wpi_cscore_CameraServerJNI_getSinkSourceProperty
Java_edu_wpi_cscore_CameraServerJNI_getSinkSource
Java_edu_wpi_cscore_CameraServerJNI_copySink
Java_edu_wpi_cscore_CameraServerJNI_releaseSink
Java_edu_wpi_cscore_CameraServerJNI_getMjpegServerListenAddress
Java_edu_wpi_cscore_CameraServerJNI_getMjpegServerPort
Java_edu_wpi_cscore_CameraServerJNI_setSinkDescription
Java_edu_wpi_cscore_CameraServerJNI_grabSinkFrame
Java_edu_wpi_cscore_CameraServerJNI_grabSinkFrameTimeout
Java_edu_wpi_cscore_CameraServerJNI_getSinkError
Java_edu_wpi_cscore_CameraServerJNI_setSinkEnabled
Java_edu_wpi_cscore_CameraServerJNI_addListener
Java_edu_wpi_cscore_CameraServerJNI_removeListener
Java_edu_wpi_cscore_CameraServerJNI_setLogger
Java_edu_wpi_cscore_CameraServerJNI_enumerateUsbCameras
Java_edu_wpi_cscore_CameraServerJNI_enumerateSources
Java_edu_wpi_cscore_CameraServerJNI_enumerateSinks
Java_edu_wpi_cscore_CameraServerJNI_getHostname
Java_edu_wpi_cscore_CameraServerJNI_getNetworkInterfaces

View File

@@ -1,89 +0,0 @@
LIBRARY CSCORE
EXPORTS
CS_GetPropertyKind @1
CS_GetPropertyName @2
CS_GetProperty @3
CS_SetProperty @4
CS_GetPropertyMin @5
CS_GetPropertyMax @6
CS_GetPropertyStep @7
CS_GetPropertyDefault @8
CS_GetStringProperty @9
CS_SetStringProperty @10
CS_GetEnumPropertyChoices @11
CS_CreateUsbCameraDev @12
CS_CreateUsbCameraPath @13
CS_CreateHttpCamera @14
CS_CreateHttpCameraMulti @15
CS_CreateCvSource @16
CS_GetSourceName @17
CS_GetSourceDescription @18
CS_GetSourceLastFrameTime @19
CS_IsSourceConnected @20
CS_GetSourceProperty @21
CS_EnumerateSourceProperties @22
CS_CopySource @23
CS_ReleaseSource @24
CS_PutSourceFrameCpp @25
CS_NotifySourceError @26
CS_SetSourceConnected @27
CS_CreateSourceProperty @28
CS_CreateCvSink @29
CS_CreateCvSinkCallback @30
CS_GetSinkName @31
CS_GetSinkDescription @32
CS_SetSinkSource @33
CS_GetSinkSourceProperty @34
CS_GetSinkSource @35
CS_CopySink @36
CS_ReleaseSink @37
CS_GrabSinkFrameCpp @38
CS_GetSinkError @39
CS_SetSinkEnabled @40
CS_EnumerateUsbCameras @41
CS_FreeEnumeratedUsbCameras @42
CS_EnumerateSources @43
CS_ReleaseEnumeratedSources @44
CS_EnumerateSinks @45
CS_ReleaseEnumeratedSinks @46
CS_FreeString @47
CS_FreeEnumPropertyChoices @48
CS_FreeEnumeratedProperties @49
CS_SetSinkDescription @50
CS_GetSinkKind @51
CS_GetSourceKind @52
CS_GetSourceVideoMode @53
CS_SetSourceVideoModeDiscrete @54
CS_SetSourcePixelFormat @55
CS_SetSourceResolution @56
CS_SetSourceFPS @57
CS_EnumerateSourceVideoModes @58
CS_EnumerateSourceSinks @59
CS_FreeEnumeratedVideoModes @60
CS_SetSourceDescription @61
CS_SetSourceEnumPropertyChoices @62
CS_CreateMjpegServer @63
CS_GetMjpegServerListenAddress @64
CS_GetMjpegServerPort @65
CS_GetUsbCameraPath @66
CS_AddListener @67
CS_RemoveListener @68
CS_GetHostname @69
CS_GetNetworkInterfaces @70
CS_FreeNetworkInterfaces @71
CS_FreeHttpCameraUrls @72
CS_GetHttpCameraKind @73
CS_GetHttpCameraUrls @74
CS_SetHttpCameraUrls @75
CS_SetLogger @76
CS_SetCameraBrightness @77
CS_GetCameraBrightness @78
CS_SetCameraWhiteBalanceAuto @79
CS_SetCameraWhiteBalanceHoldCurrent @80
CS_SetCameraWhiteBalanceManual @81
CS_SetCameraExposureAuto @82
CS_SetCameraExposureHoldCurrent @83
CS_SetCameraExposureManual @84
CS_SetDefaultLogger @85
CS_GrabSinkFrameTimeout @86
CS_GrabSinkFrameTimeoutCpp @87

View File

@@ -1,355 +0,0 @@
import org.gradle.internal.os.OperatingSystem
def cscoreSetupModel = { project ->
project.model {
components {
cscore(NativeLibrarySpec) {
if (project.isArm) {
targetPlatform 'arm'
} else {
//targetPlatform 'x86'
targetPlatform 'x64'
}
setupDefines(project, binaries)
if (includeJava) {
project.setupJniIncludes(binaries)
project.checkNativeSymbols(project.getNativeJNISymbols)
binaries.all {
project.setupDef(linker, "${rootDir}/cscore-jni.def")
}
} else {
binaries.all {
project.setupDef(linker, "${rootDir}/cscore.def")
}
}
sources {
cpp {
source {
srcDirs = ["${rootDir}/src"]
if (includeJava) {
srcDirs "${rootDir}/java/lib"
}
includes = ['**/*.cpp']
}
exportedHeaders {
srcDirs = ["${rootDir}/include", project.wpiUtilInclude, project.openCvInclude]
if (includeJava) {
project.jniHeadersCscore.outputs.files.each { file ->
srcDirs file.getPath()
}
}
includes = ['**/*.h']
}
}
}
}
}
}
}
def cscoreSetupExamplesModel = { project ->
project.model {
components {
if (!OperatingSystem.current().isWindows() || project.isArm) {
enum_usb(NativeExecutableSpec) {
if (project.isArm) {
targetPlatform 'arm'
} else {
//targetPlatform 'x86'
targetPlatform 'x64'
}
setupDefines(project, binaries)
sources {
cpp {
source {
srcDir "${rootDir}/examples/enum_usb"
include '**/*.cpp'
}
exportedHeaders {
srcDirs = ["${rootDir}/include", "${rootDir}/wpiutil/include"]
include '**/*.h'
}
lib library: 'cscore', linkage: 'static'
}
}
}
usbstream(NativeExecutableSpec) {
if (project.isArm) {
targetPlatform 'arm'
} else {
//targetPlatform 'x86'
targetPlatform 'x64'
}
setupDefines(project, binaries)
sources {
cpp {
source {
srcDir "${rootDir}/examples/usbstream"
include '**/*.cpp'
}
exportedHeaders {
srcDirs = ["${rootDir}/include", "${rootDir}/wpiutil/include"]
include '**/*.h'
}
lib library: 'cscore', linkage: 'static'
}
}
}
usbcvstream(NativeExecutableSpec) {
if (project.isArm) {
targetPlatform 'arm'
} else {
//targetPlatform 'x86'
targetPlatform 'x64'
}
setupDefines(project, binaries)
sources {
cpp {
source {
srcDir "${rootDir}/examples/usbcvstream"
include '**/*.cpp'
}
exportedHeaders {
srcDirs = ["${rootDir}/include", "${rootDir}/wpiutil/include", project.openCvInclude]
include '**/*.h'
}
lib library: 'cscore', linkage: 'static'
}
}
}
settings(NativeExecutableSpec) {
if (project.isArm) {
targetPlatform 'arm'
} else {
//targetPlatform 'x86'
targetPlatform 'x64'
}
setupDefines(project, binaries)
sources {
cpp {
source {
srcDir "${rootDir}/examples/settings"
include '**/*.cpp'
}
exportedHeaders {
srcDirs = ["${rootDir}/include", "${rootDir}/wpiutil/include", project.openCvInclude]
include '**/*.h'
}
lib library: 'cscore', linkage: 'static'
}
}
}
}
httpcvstream(NativeExecutableSpec) {
if (project.isArm) {
targetPlatform 'arm'
} else {
//targetPlatform 'x86'
targetPlatform 'x64'
}
setupDefines(project, binaries)
sources {
cpp {
source {
srcDir "${rootDir}/examples/httpcvstream"
include '**/*.cpp'
}
exportedHeaders {
srcDirs = ["${rootDir}/include", "${rootDir}/wpiutil/include", project.openCvInclude]
include '**/*.h'
}
lib library: 'cscore', linkage: 'static'
}
}
}
}
}
}
def cscoreZipTask = { project ->
project.ext.cscoreZip = project.tasks.create("${project.isArm ? 'arm' : 'native'}CscoreZip", Zip) {
description = 'Creates platform-specific zip of the desktop cscore libraries.'
group = 'WPILib'
destinationDir = project.buildDir
baseName = 'cscore'
if (project.isArm && project.hasProperty('compilerPrefix')
&& project.hasProperty('armSuffix')) {
classifier = "${project.buildPlatform}${project.armSuffix}"
} else {
classifier = "${project.buildPlatform}"
}
duplicatesStrategy = 'exclude'
from(file('include')) {
into 'include'
}
if (!project.hasProperty('skipJava')) {
project.jniHeadersCscore.outputs.each {
from(it) {
into 'include'
}
}
}
project.model {
binaries {
withType(StaticLibraryBinarySpec) { binary ->
from(binary.staticLibraryFile) {
into getPlatformPath(binary)
}
}
withType(SharedLibraryBinarySpec) { binary ->
from(binary.sharedLibraryFile) {
into getPlatformPath(binary)
}
from (new File(binary.sharedLibraryFile.absolutePath + ".debug")) {
into getPlatformPath(binary)
}
}
}
}
}
project.build.dependsOn project.cscoreZip
project.debugStripSetup()
project.tasks.whenTaskAdded { task ->
def name = task.name.toLowerCase()
if (name.contains("cscoresharedlibrary") || name.contains("cscorestaticlibrary") || name.contains("cscoretest")) {
project.cscoreZip.dependsOn task
}
}
}
def cscoreAthenaUberZipTask = { pjt ->
if (pjt.isArm && !project.hasProperty('compilerPrefix')) {
pjt.ext.cscoreAthenaUberZip = pjt.tasks.create("athenaCscoreUberZip", Zip) {
description = 'Create athena zip of cscore libraries including opencv'
group = 'WPILib'
destinationDir = pjt.buildDir
baseName = 'cscore'
classifier = 'athena-uberzip'
duplicatesStrategy = 'exclude'
from(file('include')) {
into 'include'
}
if (!pjt.hasProperty('skipJava')) {
pjt.jniHeadersCscore.outputs.each {
from(it) {
into 'include'
}
}
}
from(file("${pjt.openCvInclude}")) {
exclude 'META-INF'
into 'include'
}
pjt.model {
def openCvPlatform = pjt.getOpenCvPlatformPackage(targetPlatform)
from(file("${pjt.openCv}/${openCvPlatform}")) {
exclude 'META-INF'
into 'lib'
}
binaries {
withType(SharedLibraryBinarySpec) { binary ->
from(binary.sharedLibraryFile) {
into 'lib'
}
from (new File(binary.sharedLibraryFile.absolutePath + ".debug")) {
into 'lib'
}
}
}
}
}
pjt.build.dependsOn pjt.cscoreAthenaUberZip
pjt.tasks.whenTaskAdded { task ->
def name = task.name.toLowerCase()
if (name.contains("cscoresharedlibrary") || name.contains("cscorestaticlibrary") || name.contains("cscoretest")) {
pjt.cscoreAthenaUberZip.dependsOn task
}
}
}
}
if (buildArm) {
project(':arm') {
apply plugin: 'cpp'
apply from: "${rootDir}/toolchains/arm.gradle"
if (includeJava) {
apply from: "${rootDir}/java/java.gradle"
}
cscoreSetupModel(project)
cscoreSetupExamplesModel(project)
cscoreZipTask(project)
useWpiUtil(project)
useOpenCv(project)
cscoreAthenaUberZipTask(project)
}
}
project(':native') {
apply plugin: 'cpp'
apply from: "${rootDir}/toolchains/native.gradle"
//if (!project.hasProperty("withoutTests")) {
// apply from: "${rootDir}/test/tests.gradle"
//}
if (includeJava) {
apply from: "${rootDir}/java/java.gradle"
}
cscoreSetupModel(project)
cscoreSetupExamplesModel(project)
cscoreZipTask(project)
useWpiUtil(project)
useOpenCv(project)
}
task cscoreSourceZip(type: Zip) {
description = 'Creates a sources-zip of the cscore source files'
group = 'WPILib'
destinationDir = project.buildDir
baseName = 'cscore'
classifier = "sources"
duplicatesStrategy = 'exclude'
from('src') {
into 'src'
}
from('include') {
into 'include'
}
if (includeJava) {
from('java/lib') {
into 'src'
}
if (!OperatingSystem.current().isWindows()) {
project(':native').jniHeadersCscore.outputs.each {
from(it) {
into 'include'
}
}
}
}
}

View File

@@ -1,230 +0,0 @@
ext.useWpiUtil = { project ->
project.tasks.create(name: "downloadWpiUtil") {
description = 'Downloads the wpiutil maven dependency.'
group = 'WPILib'
def depFolder = "${project.buildDir}/dependencies"
def utilZip = file("${depFolder}/wpiutil.zip")
outputs.file(utilZip)
def wpiUtil
doFirst {
def wpiUtilDependency
if (project.isArm && project.hasProperty('compilerPrefix') && project.hasProperty('armSuffix')) {
wpiUtilDependency = project.dependencies.create("edu.wpi.first.wpilib:wpiutil:+:arm${project.armSuffix}@zip")
} else {
wpiUtilDependency = project.dependencies.create("edu.wpi.first.wpilib:wpiutil:+:${project.isArm ? 'arm' : 'desktop'}@zip")
}
def wpiUtilConfig = project.configurations.detachedConfiguration(wpiUtilDependency)
wpiUtilConfig.setTransitive(false)
wpiUtil = wpiUtilConfig.files[0].canonicalFile
}
doLast {
copy {
from wpiUtil
rename 'wpiutil(.+)', 'wpiutil.zip'
into depFolder
}
}
}
def wpiUtilUnzipLocation = "${project.buildDir}/wpiutil"
// Create a task that will unzip the wpiutil files into a temporary build directory
project.tasks.create(name: "unzipWpiUtil", type: Copy) {
description = 'Unzips the wpiutil maven dependency so that the include files and libraries can be used'
group = 'WPILib'
dependsOn project.tasks.downloadWpiUtil
from zipTree(project.tasks.downloadWpiUtil.outputs.files.singleFile)
into wpiUtilUnzipLocation
}
project.ext.wpiUtil = wpiUtilUnzipLocation
project.ext.wpiUtilInclude = "$wpiUtilUnzipLocation/include"
project.ext.addWpiUtilStaticLibraryLinks = { compileTask, linker, targetPlatform ->
compileTask.dependsOn project.tasks.unzipWpiUtil
String path = project.getPlatformPath2(targetPlatform)
if (targetPlatform.operatingSystem.windows) {
linker.args "${project.wpiUtil}/${path}/wpiutil.lib"
} else {
linker.args "${project.wpiUtil}/${path}/libwpiutil.a"
}
}
project.ext.addWpiUtilSharedLibraryLinks = { compileTask, linker, targetPlatform ->
compileTask.dependsOn project.tasks.unzipWpiUtil
String path = project.getPlatformPath2(targetPlatform)
if (targetPlatform.operatingSystem.windows) {
linker.args "${project.wpiUtil}/${path}/wpiutil.dll"
} else {
linker.args "${project.wpiUtil}/${path}/libwpiutil.so"
}
}
}
ext.getOpenCvPlatformPackage = { targetPlatform ->
if (targetPlatform.architecture.arm && project.hasProperty('compilerPrefix') && project.hasProperty('armSuffix')) {
return "linux-arm${project.armSuffix}"
} else if (targetPlatform.architecture.arm) {
return 'linux-arm'
} else if (targetPlatform.operatingSystem.linux) {
if (targetPlatform.architecture.amd64) {
return 'linux-x86_64'
} else {
return 'linux-' + targetPlatform.architecture.name
}
} else if (targetPlatform.operatingSystem.windows) {
if (targetPlatform.architecture.amd64) {
return 'windows-x86_64'
} else {
return 'windows-' + targetPlatform.architecture.name
}
} else if (targetPlatform.operatingSystem.macOsX) {
if (targetPlatform.architecture.amd64) {
return 'osx-x86_64'
} else {
return 'osx-' + targetPlatform.architecture.name
}
} else {
return targetPlatform.operatingSystem.name + '-' + targetPlatform.architecture.name
}
}
task downloadOpenCvHeaders() {
description = 'Downloads the OpenCV Headers maven dependency.'
group = 'WPILib'
def depFolder = "${buildDir}/dependencies"
def openCvHeadersZip = file("${depFolder}/opencv-headers.zip")
outputs.file(openCvHeadersZip)
def openCvHeaders
doFirst {
def openCvHeadersDependency = project.dependencies.create("org.opencv:opencv-headers:3.1.0@jar")
def openCvHeadersConfig = project.configurations.detachedConfiguration(openCvHeadersDependency)
openCvHeadersConfig.setTransitive(false)
openCvHeaders = openCvHeadersConfig.files[0].canonicalFile
}
doLast {
copy {
from openCvHeaders
rename 'opencv-headers(.+)', 'opencv-headers.zip'
into depFolder
}
}
}
ext.useOpenCv = { project ->
def openCvUnzipLocation = "${project.buildDir}/opencv"
project.tasks.create(name: "unzipOpenCvHeaders", type: Copy) {
description = 'Unzips the OpenCV maven dependency so that the include files and libraries can be used'
group = 'OpenCv'
dependsOn downloadOpenCvHeaders
from zipTree(downloadOpenCvHeaders.outputs.files.singleFile)
into "${openCvUnzipLocation}/include"
}
project.ext.openCv = openCvUnzipLocation
project.ext.openCvInclude = "$openCvUnzipLocation/include"
project.ext.addOpenCvLibraryLinks = { compileTask, linker, targetPlatform ->
def openCvPlatform = project.getOpenCvPlatformPackage(targetPlatform)
def openCvNativesFolder = "${project.openCv}/${openCvPlatform}"
if (project.tasks.findByPath("unzipOpenCvNatives_${openCvPlatform}") == null) {
project.tasks.create(name: "downloadOpenCvNatives_${openCvPlatform}") {
description = 'Downloads the OpenCV natives maven dependency.'
group = 'OpenCv'
def depFolder = "${project.buildDir}/dependencies"
def openCvNativesZip = file("${depFolder}/opencv-natives-${openCvPlatform}.zip")
outputs.file(openCvNativesZip)
def openCvNatives
doFirst {
def openCvNativesDependency = project.dependencies.create("org.opencv:opencv-natives:3.1.0:${openCvPlatform}@jar")
def openCvNativesConfig = project.configurations.detachedConfiguration(openCvNativesDependency)
openCvNativesConfig.setTransitive(false)
openCvNatives = openCvNativesConfig.files[0].canonicalFile
}
doLast {
copy {
from openCvNatives
rename 'opencv-natives(.+)', "opencv-natives-${openCvPlatform}.zip"
into depFolder
}
}
}
project.tasks.create(name: "unzipOpenCvNatives_${openCvPlatform}", type: Copy) {
description = 'Unzips the OpenCV maven dependency so that the include files and libraries can be used'
group = 'OpenCv'
dependsOn "downloadOpenCvNatives_${openCvPlatform}"
from zipTree(project.tasks["downloadOpenCvNatives_${openCvPlatform}"].outputs.files.singleFile)
into openCvNativesFolder
exclude '**/MANIFEST.MF'
}
}
if (project.includeJava && project.tasks.findByPath("unzipOpenCvJni_${openCvPlatform}") == null) {
project.tasks.create(name: "downloadOpenCvJni_${openCvPlatform}") {
description = 'Downloads the OpenCV JNI maven dependency.'
group = 'OpenCv'
def depFolder = "${project.buildDir}/dependencies"
def openCvJniZip = file("${depFolder}/opencv-jni-${openCvPlatform}.zip")
outputs.file(openCvJniZip)
def openCvJni
doFirst {
def openCvJniDependency = project.dependencies.create("org.opencv:opencv-jni:3.1.0:${openCvPlatform}@jar")
def openCvJniConfig = project.configurations.detachedConfiguration(openCvJniDependency)
openCvJniConfig.setTransitive(false)
openCvJni = openCvJniConfig.files[0].canonicalFile
}
doLast {
copy {
from openCvJni
rename 'opencv-jni(.+)', "opencv-jni-${openCvPlatform}.zip"
into depFolder
}
}
}
project.tasks.create(name: "unzipOpenCvJni_${openCvPlatform}", type: Copy) {
description = 'Unzips the OpenCV maven dependency so that the include files and libraries can be used'
group = 'OpenCv'
dependsOn "downloadOpenCvJni_${openCvPlatform}"
from zipTree(project.tasks["downloadOpenCvJni_${openCvPlatform}"].outputs.files.singleFile)
into openCvNativesFolder
exclude '**/MANIFEST.MF'
}
}
compileTask.dependsOn "unzipOpenCvHeaders", "unzipOpenCvNatives_${openCvPlatform}"
if (project.includeJava) {
compileTask.dependsOn "unzipOpenCvJni_${openCvPlatform}"
}
if (targetPlatform.operatingSystem.windows) {
linker.args new String("${openCvNativesFolder}\\opencv.lib").replace('/', '\\')
linker.args new String("${openCvNativesFolder}\\Release\\libjpeg.lib").replace('/', '\\')
linker.args new String("${openCvNativesFolder}\\Release\\libpng.lib").replace('/', '\\')
linker.args new String("${openCvNativesFolder}\\Release\\zlib.lib").replace('/', '\\')
linker.args "kernel32.lib"
linker.args "user32.lib"
linker.args "gdi32.lib"
linker.args "Ole32.lib"
linker.args "OleAut32.lib"
linker.args "comdlg32.lib"
linker.args "advapi32.lib"
linker.args "Vfw32.lib"
} else {
linker.args "-L${openCvNativesFolder}"
linker.args "-lopencv"
linker.args "-ldl"
}
}
}

View File

@@ -1,49 +1,38 @@
import org.gradle.internal.os.OperatingSystem
apply plugin: 'cpp'
apply plugin: 'visual-studio'
if (!project.hasProperty('onlyAthena')) {
apply plugin: 'cpp'
apply plugin: 'visual-studio'
apply plugin: 'edu.wpi.first.NativeUtils'
// Apply the correct toolchain settings for the target platform
if (OperatingSystem.current().isLinux()) {
apply from: '../toolchains/linux.gradle'
} else if (OperatingSystem.current().isMacOsX()) {
apply from: '../toolchains/mac.gradle'
} else if (OperatingSystem.current().isWindows()) {
apply from: '../toolchains/windows.gradle'
} else {
throw new GradleException("ntcore does not support building on ${OperatingSystem.current().getFamilyName()}.")
}
ext.gmockProject = true
model {
platforms {
x86 {
architecture 'x86'
}
x64 {
architecture 'x86_64'
}
}
components {
gmock(NativeLibrarySpec) {
targetPlatform 'x86'
targetPlatform 'x64'
sources {
cpp {
source {
srcDirs = ['src', 'gtest/src']
includes = ['*-all.cc']
}
exportedHeaders {
srcDirs = ['include', 'gtest/include', '.', 'gtest']
includes = ['**/*.h', '**/*.cc']
apply from: '../config.gradle'
model {
components {
gmock(NativeLibrarySpec) {
sources {
cpp {
source {
srcDirs = ['src', 'gtest/src']
includes = ['*-all.cc']
}
exportedHeaders {
srcDirs = ['include', 'gtest/include', '.', 'gtest']
includes = ['**/*.h', '**/*.cc']
}
}
}
}
binaries.all {
if (toolChain in VisualCpp) {
cppCompiler.args '-D_UNICODE', '-DUNICODE', '-DWIN32', '-D_WIN32', '-DSTRICT', '-DWIN32_LEAN_AND_MEAN', '-D_HAS_EXCEPTIONS=1'
} else {
cppCompiler.args '-Wall', '-Wshadow', '-fexceptions', '-Wextra', '-Wno-unused-parameter', '-Wno-missing-field-initializers', '-pthread', '-fPIC'
binaries.all {
if (toolChain in VisualCpp) {
cppCompiler.args '-D_UNICODE', '-DUNICODE', '-DWIN32', '-D_WIN32', '-DSTRICT', '-DWIN32_LEAN_AND_MEAN', '-D_HAS_EXCEPTIONS=1'
} else {
cppCompiler.args '-Wall', '-Wshadow', '-fexceptions', '-Wextra', '-Wno-unused-parameter', '-Wno-missing-field-initializers', '-pthread', '-fPIC'
}
}
binaries.withType(SharedLibraryBinarySpec) {
buildable = false
}
}
}

Binary file not shown.

View File

@@ -1,6 +1,5 @@
#Wed Jan 04 18:51:47 PST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-bin.zip

6
gradlew vendored
View File

@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
warn () {
echo "$*"
}
die ( ) {
die () {
echo
echo "$*"
echo
@@ -155,7 +155,7 @@ if $cygwin ; then
fi
# Escape application args
save ( ) {
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}

168
gradlew.bat vendored
View File

@@ -1,84 +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=
@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
@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=
@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

View File

@@ -1,185 +0,0 @@
import org.gradle.internal.os.OperatingSystem
apply plugin: 'java'
apply plugin: 'net.ltgt.errorprone'
repositories {
mavenCentral()
}
configurations.errorprone {
resolutionStrategy.force 'com.google.errorprone:error_prone_core:2.0.9'
}
def generatedJNIHeaderLoc = "${buildDir}/include"
sourceSets {
main {
java {
srcDirs = ["${rootDir}/java/src"]
}
}
}
dependencies {
compile 'org.opencv:opencv-java:3.1.0'
runtime 'org.opencv:opencv-java:3.1.0'
}
jar {
description = 'Generates cscore jar, with the JNI shared libraries embedded'
baseName = 'cscore'
if (project.isArm && project.hasProperty('compilerPrefix')
&& project.hasProperty('armSuffix')) {
classifier = "${buildPlatform}${project.armSuffix}"
} else {
classifier = "${buildPlatform}"
}
duplicatesStrategy = 'exclude'
dependsOn { classes }
model {
binaries {
withType(SharedLibraryBinarySpec) { binary ->
// Only include the native file if not cross compiling to the roboRIO
if (!project.isArm || project.hasProperty('compilerPrefix'))
from(file(binary.sharedLibraryFile)) {
into getPlatformPath(binary)
}
}
}
}
}
project.tasks.whenTaskAdded { task ->
if (isArm) {
if (task.name == 'cscoreSharedLibrary') jar.dependsOn task
} else {
if (task.name == 'cscoreX64SharedLibrary' || task.name == 'cscoreX86SharedLibrary')
jar.dependsOn task
}
}
task cscoreJavaSource(type: Jar, dependsOn: classes) {
description = 'Generates the source jar for cscore java'
group = 'WPILib'
baseName = 'cscore'
classifier = "sources"
duplicatesStrategy = 'exclude'
from sourceSets.main.allJava
}
task cscoreJavadoc(type: Jar, dependsOn: javadoc) {
description = 'Generates the javadoc jar for cscore java'
group = 'WPILib'
baseName = 'cscore'
classifier = "javadoc"
duplicatesStrategy = 'exclude'
from javadoc.destinationDir
}
build.dependsOn cscoreJavaSource
build.dependsOn cscoreJavadoc
/**
* Generates the JNI headers
*/
task jniHeadersCscore {
description = 'Generates JNI headers from edu.wpi.cscore.*'
group = 'WPILib'
def outputFolder = file(generatedJNIHeaderLoc)
inputs.files sourceSets.main.output
outputs.file outputFolder
doLast {
outputFolder.mkdirs()
exec {
executable org.gradle.internal.jvm.Jvm.current().getExecutable('javah')
args '-d', outputFolder
args '-classpath', sourceSets.main.runtimeClasspath.asPath
args 'edu.wpi.cscore.CameraServerJNI'
}
}
}
ext.getNativeJNISymbols = {
def symbolsList = []
jniHeadersCscore.outputs.files.each {
FileTree tree = fileTree(dir: it)
tree.each { File file ->
file.eachLine { line ->
if (line.trim()) {
if (line.startsWith("JNIEXPORT ") && line.contains('JNICALL')) {
def (p1, p2) = line.split('JNICALL').collect { it.trim() }
// p2 is our JNI call
symbolsList << p2
}
}
}
}
}
return symbolsList
}
clean {
delete generatedJNIHeaderLoc
}
compileJava {
options.compilerArgs << '-Xlint:unchecked'
}
javadoc {
options.addStringOption('Xdoclint:none', '-quiet')
}
// This creates a lambda that the main build.gradle can access, which sets up the JNI includes for the
// target build platform. This lambda is exposed as a property in the main build.gradle.
ext.setupJniIncludes = { binaries ->
def platformSpecificIncludeFlag = { loc, cppCompiler ->
if (OperatingSystem.current().isWindows()) {
cppCompiler.args "/I$loc"
} else {
cppCompiler.args '-I', loc
}
}
binaries.all {
tasks.withType(CppCompile) {
if (buildPlatform == 'arm') {
cppCompiler.args '-I', file("${rootDir}/java/arm-linux").absolutePath
cppCompiler.args '-I', file("${rootDir}/java/arm-linux/linux").absolutePath
} else {
def jdkLocation = org.gradle.internal.jvm.Jvm.current().javaHome
platformSpecificIncludeFlag("${jdkLocation}/include", cppCompiler)
if (targetPlatform.operatingSystem.macOsX) {
platformSpecificIncludeFlag("${jdkLocation}/include/darwin", cppCompiler)
} else if (targetPlatform.operatingSystem.linux) {
platformSpecificIncludeFlag("${jdkLocation}/include/linux", cppCompiler)
} else if (targetPlatform.operatingSystem.windows) {
platformSpecificIncludeFlag("${jdkLocation}/include/win32", cppCompiler)
} else if (targetPlatform.operatingSystem.freeBSD) {
platformSpecificIncludeFlag("${jdkLocation}/include/freebsd", cppCompiler)
} else if (file("$jdkLocation/include/darwin").exists()) {
// TODO: As of Gradle 2.8, targetPlatform.operatingSystem.macOsX returns false
// on El Capitan. We therefore manually test for the darwin folder and include it
// if it exists
platformSpecificIncludeFlag("${jdkLocation}/include/darwin", cppCompiler)
}
}
jniHeadersCscore.outputs.files.each { file ->
if (buildPlatform == 'arm') {
cppCompiler.args '-I', file.getPath()
} else {
platformSpecificIncludeFlag(file.getPath(), cppCompiler)
}
}
dependsOn jniHeadersCscore
}
}
}

View File

@@ -1,5 +1,3 @@
import org.gradle.internal.os.OperatingSystem
apply plugin: 'maven-publish'
apply plugin: 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin'
@@ -9,96 +7,262 @@ if (!hasProperty('releaseType')) {
}
}
def csVersion
if (project.hasProperty("csPublishVersion")) {
csVersion = project.csPublishVersion
def pubVersion
if (project.hasProperty("publishVersion")) {
pubVersion = project.publishVersion
} else {
csVersion = WPILibVersion.version
pubVersion = WPILibVersion.version
}
def csFile = file("$buildDir/cscore.txt")
def outputsFolder = file("$buildDir/outputs")
def versionFile = file("$outputsFolder/version.txt")
task outputVersions() {
description = 'Prints the version of cscore to a file for use by the downstream packaging project'
description = 'Prints the versions of cscore to a file for use by the downstream packaging project'
group = 'Build'
outputs.files(csFile)
outputs.files(versionFile)
doFirst {
buildDir.mkdir()
outputsFolder.mkdir()
}
doLast {
csFile.write csVersion
versionFile.write pubVersion
}
}
task clean(type: Delete) {
delete csFile
}
build.dependsOn outputVersions
outputVersions.mustRunAfter clean
def baseArtifactId = 'cscore'
def artifactGroupId = 'edu.wpi.first.cscore'
project(':native').build.dependsOn outputVersions
if (project.buildArm) {
project(':arm').build.dependsOn outputVersions
}
def licenseFile = file("$rootDir/license.txt")
// We change what repo we publish to depending on whether this is a development, beta, stable, or full
// release. This is set up in the main gradle file.
publishing {
publications {
def nat = project('native')
if (!project.hasProperty('skipJava')) {
java(MavenPublication) {
artifact nat.jar
if (!project.buildArm) {
artifact nat.cscoreJavaSource
artifact nat.cscoreJavadoc
task cppSourcesZip(type: Zip) {
destinationDir = outputsFolder
classifier = "sources"
from(licenseFile) {
into '/'
}
from('src/main/native/cpp') {
into '/'
}
model {
tasks {
it.each {
if (it in getJNIHeadersClass()) {
from (it.outputs.files) {
into '/'
}
dependsOn it
}
if (project.buildArm) {
def camArm = project('arm')
artifact camArm.jar
// If the library is not embedded include it in the repo
if (!project.hasProperty('compilerPrefix')) {
artifact camArm.cscoreZip
artifact camArm.athenaCscoreUberZip {
classifier = 'athena-uberzip'
}
}
}
}
task cppHeadersZip(type: Zip) {
destinationDir = outputsFolder
classifier = "headers"
from(licenseFile) {
into '/'
}
from('src/main/native/include') {
into '/'
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
if (project.hasProperty('jenkinsBuild')) {
jar {
classifier = 'javaArtifact'
}
}
artifacts {
archives sourcesJar
archives javadocJar
archives cppHeadersZip
archives cppSourcesZip
}
def createComponentZipTasks = { components, name, base, type, project, func ->
def configMap = [:]
components.each {
if (it in NativeLibrarySpec && it.name == name) {
it.binaries.each {
def target = getClassifier(it)
if (configMap.containsKey(target)) {
configMap.get(target).add(it)
} else {
configMap.put(target, [])
configMap.get(target).add(it)
}
}
}
}
def taskList = []
configMap.each { key, value ->
def baseN = base + name
def task = project.tasks.create(baseN + "-${key}", type) {
description = 'Creates component archive for platform ' + key
destinationDir = outputsFolder
classifier = key
baseName = baseN + '-classifier'
duplicatesStrategy = 'exclude'
from(licenseFile) {
into '/'
}
func(it, value)
}
taskList.add(task)
project.build.dependsOn task
project.artifacts {
task
}
}
return taskList
}
model {
publishing {
def cscoreTaskList = createComponentZipTasks($.components, 'cscore', 'zipcppcscore', Zip, project, { task, value ->
value.each { binary->
if (binary.buildable) {
if (binary instanceof SharedLibraryBinarySpec) {
task.dependsOn binary.buildTask
task.from(new File(binary.sharedLibraryFile.absolutePath + ".debug")) {
into getPlatformPath(binary) + '/shared'
}
task.from (binary.sharedLibraryFile) {
into getPlatformPath(binary) + '/shared'
}
task.from (binary.sharedLibraryLinkFile) {
into getPlatformPath(binary) + '/shared'
}
} else if (binary instanceof StaticLibraryBinarySpec) {
task.dependsOn binary.buildTask
task.from (binary.staticLibraryFile) {
into getPlatformPath(binary) + '/static'
}
}
artifact camArm.cscoreJavaSource
artifact camArm.cscoreJavadoc
}
if (project.hasProperty('makeDesktop')) {
artifact nat.jar, {
classifier = 'desktop'
}
})
def cscoreJNITaskList = createComponentZipTasks($.components, 'cscoreJNI', 'jnijnicscore', Jar, project, { task, value ->
value.each { binary->
if (binary.buildable) {
if (binary instanceof SharedLibraryBinarySpec) {
task.dependsOn binary.buildTask
task.from (binary.sharedLibraryFile) {
into getPlatformPath(binary)
}
}
}
groupId 'edu.wpi.cscore.java'
artifactId 'cscore'
version csVersion
}
})
def allJniTask
if (!project.hasProperty('jenkinsBuild')) {
allJniTask = project.tasks.create("cscoreJNIAllJar", Jar) {
description = 'Creates a jar with all JNI artifacts'
classifier = 'all'
baseName = 'jnijnicscorecscoreJNI'
destinationDir = outputsFolder
duplicatesStrategy = 'exclude'
cscoreJNITaskList.each {
it.outputs.files.each {
from project.zipTree(it)
}
dependsOn it
}
}
project.build.dependsOn allJniTask
}
cpp(MavenPublication) {
artifact nat.cscoreZip
artifact cscoreSourceZip
if (project.buildArm) {
artifact project(':arm').cscoreZip
if (!project.hasProperty('compilerPrefix')) {
artifact project(':arm').athenaCscoreUberZip {
classifier = 'athena-uberzip'
}
}
}
if (project.hasProperty('makeDesktop')) {
artifact nat.cscoreZip, {
classifier = 'desktop'
}
}
groupId 'edu.wpi.cscore.cpp'
artifactId 'cscore'
version csVersion
def allCppTask
if (!project.hasProperty('jenkinsBuild')) {
allCppTask = project.tasks.create("cscoreAllZip", Zip) {
description = 'Creates a zip with all Cpp artifacts'
classifier = 'all'
baseName = 'zipcppcscorecscore'
destinationDir = outputsFolder
duplicatesStrategy = 'exclude'
cscoreTaskList.each {
it.outputs.files.each {
from project.zipTree(it)
}
dependsOn it
}
}
project.build.dependsOn allCppTask
}
publications {
cpp(MavenPublication) {
cscoreTaskList.each {
artifact it
}
artifact cppHeadersZip
artifact cppSourcesZip
if (!project.hasProperty('jenkinsBuild')) {
artifact allCppTask
}
artifactId = "${baseArtifactId}-cpp"
groupId artifactGroupId
version pubVersion
}
jni(MavenPublication) {
cscoreJNITaskList.each {
artifact it
}
if (!project.hasProperty('jenkinsBuild')) {
artifact allJniTask
}
artifactId = "${baseArtifactId}-jni"
groupId artifactGroupId
version pubVersion
}
}
}
}
publishing {
publications {
java(MavenPublication) {
artifact jar
artifact sourcesJar
artifact javadocJar
artifactId = "${baseArtifactId}-java"
groupId artifactGroupId
version pubVersion
}
}
}

View File

@@ -1,6 +1 @@
include 'native'
include 'gmock'
if (!hasProperty('skipArm')) {
include 'arm'
}

View File

@@ -0,0 +1,12 @@
package edu.wpi.cscore;
import edu.wpi.cscore.CameraServerJNI;
import edu.wpi.first.wpiutil.RuntimeDetector;
public class DevMain {
public static void main(String[] args) {
System.out.println("Hello World!");
System.out.println(RuntimeDetector.getPlatformPath());
System.out.println(CameraServerJNI.getHostname());
}
}

View File

@@ -0,0 +1,6 @@
#include <iostream>
#include "cscore.h"
int main() {
std::cout << cs::GetHostname() << std::endl;
}

View File

@@ -15,30 +15,20 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.function.Consumer;
import org.opencv.core.Core;
import edu.wpi.first.wpiutil.RuntimeDetector;
public class CameraServerJNI {
static boolean libraryLoaded = false;
static boolean cvLibraryLoaded = false;
static File jniLibrary = null;
static boolean cvLibraryLoaded = false;
static File cvJniLibrary = null;
static {
if (!libraryLoaded) {
try {
System.loadLibrary("cscore");
} catch (UnsatisfiedLinkError e) {
try {
String osname = System.getProperty("os.name");
String resname;
if (osname.startsWith("Windows"))
resname = "/Windows/" + System.getProperty("os.arch") + "/";
else
resname = "/" + osname + "/" + System.getProperty("os.arch") + "/";
System.out.println("platform: " + resname);
if (osname.startsWith("Windows"))
resname += "cscore.dll";
else if (osname.startsWith("Mac"))
resname += "libcscore.dylib";
else
resname += "libcscore.so";
String resname = RuntimeDetector.getLibraryResource("cscore");
InputStream is = CameraServerJNI.class.getResourceAsStream(resname);
if (is != null) {
// create temporary file
@@ -72,18 +62,54 @@ public class CameraServerJNI {
}
}
libraryLoaded = true;
if (!cvLibraryLoaded) {
}
String opencvName = Core.NATIVE_LIBRARY_NAME;
if (!cvLibraryLoaded) {
try {
System.loadLibrary(opencvName);
} catch (UnsatisfiedLinkError e) {
try {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
} catch (UnsatisfiedLinkError ex) {
String resname = RuntimeDetector.getLibraryResource(opencvName);
InputStream is = CameraServerJNI.class.getResourceAsStream(resname);
if (is != null) {
// create temporary file
if (System.getProperty("os.name").startsWith("Windows"))
cvJniLibrary = File.createTempFile("OpenCVJNI", ".dll");
else if (System.getProperty("os.name").startsWith("Mac"))
cvJniLibrary = File.createTempFile("libOpenCVJNI", ".dylib");
else
cvJniLibrary = File.createTempFile("libOpenCVJNI", ".so");
// flag for delete on exit
cvJniLibrary.deleteOnExit();
OutputStream os = new FileOutputStream(cvJniLibrary);
byte[] buffer = new byte[1024];
int readBytes;
try {
while ((readBytes = is.read(buffer)) != -1) {
os.write(buffer, 0, readBytes);
}
} finally {
os.close();
is.close();
}
System.load(cvJniLibrary.getAbsolutePath());
} else {
System.loadLibrary(opencvName);
}
} catch (IOException ex) {
ex.printStackTrace();
System.exit(1);
}
cvLibraryLoaded = true;
}
cvLibraryLoaded = true;
}
}
public static void ForceLoad() {}
//
// Property Functions
//

View File

@@ -0,0 +1,11 @@
package edu.wpi.cscore;
import org.junit.Test;
public class JNITest {
@Test
public void jniLinkTest() {
// Test to verify that the JNI test link works correctly.
edu.wpi.cscore.CameraServerJNI.getHostname();
}
}

View File

@@ -7,7 +7,7 @@
#include "gtest/gtest.h"
#include "cameraserver.h"
#include "cscore.h"
namespace cs {
@@ -18,7 +18,7 @@ class CameraSourceTest : public ::testing::Test {
};
TEST_F(CameraSourceTest, HTTPCamera) {
auto source = HTTPCamera("axis", "http://localhost:8000");
auto source = HttpCamera("axis", "http://localhost:8000");
}
} // namespace cs

View File

@@ -1,49 +0,0 @@
apply plugin: 'google-test'
model {
testSuites {
cameraserverTest {
if (!project.hasProperty('skipJava')) {
setupJniIncludes(binaries)
}
sources {
cpp {
source {
srcDirs = ["${rootDir}/test/unit"]
includes = ['**/*.cpp']
}
exportedHeaders {
srcDirs = ["${rootDir}/include", "${rootDir}/src", "${rootDir}/gmock/include", "${rootDir}/gmock/gtest/include"]
includes = ['**/*.h']
}
}
}
binaries.all {
lib project: ':gmock', library: 'gmock', linkage: 'static'
lib library: 'cameraserver', linkage: 'static'
tasks.withType(CppCompile) {
project.addWpiUtilLibraryLinks(it, linker, targetPlatform)
project.addOpenCvLibraryLinks(it, linker, targetPlatform)
}
}
}
}
}
model {
binaries {
withType(GoogleTestTestSuiteBinarySpec) {
lib project: ':gmock', library: "gmock", linkage: "static"
lib library: 'cameraserver', linkage: 'static'
tasks.withType(CppCompile) {
project.addWpiUtilLibraryLinks(it, linker, targetPlatform)
}
if (targetPlatform.operatingSystem.windows) {
cppCompiler.args '/EHsc', '/DNOMINMAX', '/D_SCL_SECURE_NO_WARNINGS', '/D_WINSOCK_DEPRECATED_NO_WARNINGS'
} else {
cppCompiler.args '-pthread', '-std=c++1y'
linker.args '-pthread'
}
}
}
}

View File

@@ -1,100 +0,0 @@
ext.isArm = true
ext.buildPlatform = 'arm'
def compilerPrefix = project.hasProperty('compilerPrefix') ? project.compilerPrefix : 'arm-frc-linux-gnueabi-'
def toolChainPath = project.hasProperty('toolChainPath') ? project.toolChainPath : null
model {
platforms {
arm {
architecture 'arm'
operatingSystem 'linux'
}
}
toolChains {
armGcc(Gcc) {
if (toolChainPath != null) path(toolChainPath)
target("arm") {
// 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
cCompiler.executable = compilerPrefix + cCompiler.executable
cppCompiler.executable = compilerPrefix + cppCompiler.executable
linker.executable = compilerPrefix + linker.executable
assembler.executable = compilerPrefix + assembler.executable
// Gradle auto-adds the -m32 argument to the linker and compiler. Our compiler only supports
// arm, and doesn't understand this flag, so it is removed from both
cppCompiler.withArguments { args ->
args << '-std=c++1y' << '-Wformat=2' << '-Wall' << '-Wextra' << '-Werror' << '-pedantic'
args << '-Wno-psabi' << '-Wno-unused-parameter' << '-fPIC' << '-rdynamic'
//TODO: When the compiler allows us to actually call deprecated functions from within
// deprecated function, remove this line (this will cause calling deprecated functions
// to be treated as a warning rather than an error).
args << '-Wno-error=deprecated-declarations' << '-pthread'
args.remove('-m32')
}
linker.withArguments { args ->
args << '-rdynamic' << '-pthread'
args.remove('-m32')
}
staticLibArchiver.executable = compilerPrefix + staticLibArchiver.executable
}
}
}
}
ext.binTools = { tool ->
if (toolChainPath != null) return "${toolChainPath}/${compilerPrefix}${tool}"
return "${compilerPrefix}${tool}"
}
ext.setupReleaseDefines = { cppCompiler, linker ->
cppCompiler.args '-O2', '-g'
}
ext.setupDebugDefines = { cppCompiler, linker ->
cppCompiler.args '-g', '-O0'
}
// Used only on Windows.
ext.setupDef = { linker, deffile -> }
ext.debugStripSetup = {
if (!project.hasProperty('debug')) {
project.tasks.whenObjectAdded { task ->
if (task.name.contains('link') && task.name.contains('SharedLibrary')) {
def library = task.outputFile.absolutePath
def debugLibrary = task.outputFile.absolutePath + ".debug"
task.doLast {
exec { commandLine binTools('objcopy'), '--only-keep-debug', library, debugLibrary }
exec { commandLine binTools('strip'), '-g', library }
exec { commandLine binTools('objcopy'), "--add-gnu-debuglink=$debugLibrary", library }
}
}
}
}
}
ext.checkNativeSymbols = { getSymbolFunc ->
project.tasks.whenObjectAdded { task ->
if (task.name.contains('link') && task.name.contains('SharedLibrary')) {
def library = task.outputFile.absolutePath
task.doLast {
def nmOutput = new ByteArrayOutputStream()
exec {
commandLine binTools('nm'), library
standardOutput nmOutput
}
// Remove '\r' so we can check for full string contents
String nmSymbols = nmOutput.toString().replace('\r', '')
def symbolList = getSymbolFunc()
symbolList.each {
//Add \n so we can check for the exact symbol
def found = nmSymbols.contains(it + '\n')
if (!found) {
throw new GradleException("Found a definition that does not have a matching symbol ${it}")
}
}
}
}
}
}

View File

@@ -1,87 +0,0 @@
model {
toolChains {
gcc(Gcc) {
target('x86') {
cppCompiler.withArguments { args ->
args << '-std=c++11' << '-Wformat=2' << '-Wall' << '-Wextra' << '-Werror' << '-pedantic'
args << '-Wno-psabi' << '-Wno-unused-parameter' << '-fPIC' << '-rdynamic'
//TODO: When the compiler allows us to actually call deprecated functions from within
// deprecated function, remove this line (this will cause calling deprecated functions
// to be treated as a warning rather than an error).
args << '-Wno-error=deprecated-declarations' << '-pthread'
args << '-m32'
}
linker.withArguments { args ->
args << '-rdynamic' << '-pthread'
args << '-m32'
}
}
target('x64') {
cppCompiler.withArguments { args ->
args << '-std=c++11' << '-Wformat=2' << '-Wall' << '-Wextra' << '-Werror' << '-pedantic'
args << '-Wno-psabi' << '-Wno-unused-parameter' << '-fPIC' << '-rdynamic'
//TODO: When the compiler allows us to actually call deprecated functions from within
// deprecated function, remove this line (this will cause calling deprecated functions
// to be treated as a warning rather than an error).
args << '-Wno-error=deprecated-declarations' << '-pthread'
}
linker.withArguments { args ->
args << '-rdynamic' << '-pthread'
}
}
}
}
}
ext.setupReleaseDefines = { cppCompiler, linker ->
cppCompiler.args '-O2', '-g'
}
ext.setupDebugDefines = { cppCompiler, linker ->
cppCompiler.args '-g', '-O0'
}
// Used only on Windows.
ext.setupDef = { linker, deffile -> }
ext.debugStripSetup = {
if (!project.hasProperty('debug')) {
project.tasks.whenObjectAdded { task ->
if (task.name.contains('link') && task.name.contains('SharedLibrary')) {
def library = task.outputFile.absolutePath
def debugLibrary = task.outputFile.absolutePath + ".debug"
task.doLast {
exec { commandLine "objcopy", '--only-keep-debug', library, debugLibrary }
exec { commandLine "strip", '-g', library }
exec { commandLine "objcopy", "--add-gnu-debuglink=$debugLibrary", library }
}
}
}
}
}
ext.checkNativeSymbols = { getSymbolFunc ->
project.tasks.whenObjectAdded { task ->
if (task.name.contains('link') && task.name.contains('SharedLibrary')) {
def library = task.outputFile.absolutePath
task.doLast {
def nmOutput = new ByteArrayOutputStream()
exec {
commandLine "nm", library
standardOutput nmOutput
}
// Remove '\r' so we can check for full string contents
String nmSymbols = nmOutput.toString().replace('\r', '')
def symbolList = getSymbolFunc()
symbolList.each {
//Add \n so we can check for the exact symbol
def found = nmSymbols.contains(it + '\n')
if (!found) {
throw new GradleException("Found a definition that does not have a matching symbol ${it}")
}
}
}
}
}
}

View File

@@ -1,74 +0,0 @@
model {
toolChains {
clang(Clang) {
target('x86') {
cppCompiler.withArguments { args ->
args << '-std=c++11' << '-Wall' << '-Wextra' << '-Werror' << '-pedantic-errors'
args << '-fPIC' << '-m32'
args << '-Wno-unused-parameter' << '-Wno-missing-field-initializers' << '-Wno-unused-private-field'
}
linker.withArguments { args ->
args << '-m32'
}
}
target('x64') {
cppCompiler.withArguments { args ->
args << '-std=c++11' << '-Wall' << '-Wextra' << '-Werror' << '-pedantic-errors'
args << '-fPIC'
args << '-Wno-missing-field-initializers' << '-Wno-unused-private-field' << '-Wno-unused-parameter'
}
}
}
}
}
ext.setupReleaseDefines = { cppCompiler, linker ->
cppCompiler.args '-O2'
}
ext.setupDebugDefines = { cppCompiler, linker ->
cppCompiler.args '-g', '-O0'
}
// Used only on Windows.
ext.setupDef = { linker, deffile -> }
ext.debugStripSetup = {
if (!project.hasProperty('debug')) {
project.tasks.whenObjectAdded { task ->
if (task.name.contains('link') && task.name.contains('SharedLibrary')) {
def library = task.outputFile.absolutePath
task.doLast {
exec { commandLine "dsymutil", library }
exec { commandLine "strip", '-S', library }
}
}
}
}
}
ext.checkNativeSymbols = { getSymbolFunc ->
project.tasks.whenObjectAdded { task ->
if (task.name.contains('link') && task.name.contains('SharedLibrary')) {
def library = task.outputFile.absolutePath
task.doLast {
def nmOutput = new ByteArrayOutputStream()
exec {
commandLine "nm", library
standardOutput nmOutput
}
// Remove '\r' so we can check for full string contents
String nmSymbols = nmOutput.toString().replace('\r', '')
def symbolList = getSymbolFunc()
symbolList.each {
//Add \n so we can check for the exact symbol
def found = nmSymbols.contains(it + '\n')
if (!found) {
throw new GradleException("Found a definition that does not have a matching symbol ${it}")
}
}
}
}
}
}

View File

@@ -1,25 +0,0 @@
import org.gradle.internal.os.OperatingSystem
ext.isArm = false
ext.buildPlatform = OperatingSystem.current().getFamilyName()
if (OperatingSystem.current().isLinux()) {
apply from: "${rootDir}/toolchains/linux.gradle"
} else if (OperatingSystem.current().isMacOsX()) {
apply from: "${rootDir}/toolchains/mac.gradle"
} else if (OperatingSystem.current().isWindows()) {
apply from: "${rootDir}/toolchains/windows.gradle"
} else {
throw new GradleException("${name} does not support building on ${ext.buildPlatform}.")
}
model {
platforms {
x86 {
architecture 'x86'
}
x64 {
architecture 'x86_64'
}
}
}

View File

@@ -1,32 +0,0 @@
model {
toolChains {
visualCpp(VisualCpp) {
eachPlatform {
cppCompiler.withArguments { args ->
args << '/EHsc' << '/DNOMINMAX' << '/D_SCL_SECURE_NO_WARNINGS' << '/D_WINSOCK_DEPRECATED_NO_WARNINGS'
}
}
}
}
}
ext.setupReleaseDefines = { cppCompiler, linker ->
cppCompiler.args '/O2', '/Zi', '/FS'
}
ext.setupDebugDefines = { cppCompiler, linker ->
cppCompiler.args '/Zi', '/FS'
linker.args '/DEBUG'
}
ext.setupDef = { linker, deffile ->
linker.args "/DEF:${deffile}"
}
// This is a noop on Windows. On gcc platforms, we strip the release binary and create a separate
// debug library, but Windows already separates debug symbols into a .pdb file.
ext.debugStripSetup = { }
// This is a noop on Windows. The def file already implicilty checks for the symbols
ext.checkNativeSymbols = { getSymbolFunc ->
}