Create dummy wpiutil library. (#84)

This will allow dependencies such as wpilibc to update to use wpiutil
without breaking "normal" ntcore static library use in the meantime.

This commit also restructures the gradle files by creating a new
(placeholder) wpiutil project, and moving the ntcore project into
a separate gradle file.  Added toolchains/native.gradle (refactored from
ntcore).

Also fixes ntcore skipJava on Windows by providing an alternate .def file
for this case.
This commit is contained in:
Peter Johnson
2016-07-27 22:18:56 -05:00
committed by GitHub
parent a73166a665
commit 30fbfe46e6
18 changed files with 593 additions and 281 deletions

1
.gitignore vendored
View File

@@ -28,6 +28,7 @@
.vs/
*.def
!ntcore.def
!ntcore-jni.def
*.opensdf
*.vcxproj
*.vcxproj.user

View File

@@ -19,6 +19,7 @@ if (!hasProperty('repo')) {
}
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.' +
@@ -52,211 +53,28 @@ ext.getPlatformPath = { binary ->
}
}
def includeJava = !hasProperty('skipJava')
// This is a closure to set up the model for compiling a c++ build. In order to run the tests only on the
// native build, we have two pseudoprojects, native and arm. Native compiles for x86/x64, and arm compiles
// for arm. This closure takes two parameters:
// project - the project to configure
// isArm - whether the project should use arm include files or not.
def setupModel = { project, isArm ->
project.model {
platforms {
if (isArm) {
arm {
architecture 'arm'
operatingSystem 'linux'
}
} else {
x86 {
architecture 'x86'
}
x64 {
architecture 'x86_64'
}
}
}
components {
ntcore(NativeLibrarySpec) {
if (isArm) {
targetPlatform 'arm'
} else {
targetPlatform 'x86'
targetPlatform 'x64'
}
binaries.all {
if (project.hasProperty('debug')) {
project.setupDebugDefines(cppCompiler, linker)
} else {
project.setupReleaseDefines(cppCompiler, linker)
}
}
if (includeJava) {
project.setupJniIncludes(binaries)
}
sources {
cpp {
source {
srcDirs = ['../src']
if (includeJava) {
srcDirs "../java/lib"
}
includes = ['**/*.cpp']
}
exportedHeaders {
srcDirs = ['../include', '../src']
if (includeJava) {
project.jniHeadersNetworkTables.outputs.files.each { file ->
srcDirs file.getPath()
}
}
includes = ['**/*.h']
}
}
}
}
}
ext.setupDefines = { project, binaries ->
binaries.all {
if (project.hasProperty('debug')) {
project.setupDebugDefines(cppCompiler, linker)
} else {
project.setupReleaseDefines(cppCompiler, linker)
}
}
}
def ntcoreZipTask = { project ->
project.ext.ntcoreZip = project.tasks.create("${project.isArm ? 'arm' : 'native'}NtcoreZip", Zip) {
description = 'Creates platform-specific zip of the desktop ntcore libraries.'
group = 'WPILib'
destinationDir = project.buildDir
baseName = 'ntcore'
classifier = "${project.buildPlatform}"
apply from: "ntcore.gradle"
apply from: "wpiutil.gradle"
from(file('include')) {
into 'include'
}
if (!hasProperty('skipJava')) {
project.jniHeadersNetworkTables.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)
}
}
}
}
}
project.build.dependsOn project.ntcoreZip
def releaseTasks = [project.ntcoreZip]
if (includeJava) {
releaseTasks.add(project.jar)
}
project.releaseSetup(releaseTasks)
project.tasks.whenTaskAdded { task ->
def name = task.name.toLowerCase()
if (name.contains("ntcoresharedlibrary") || name.contains("ntcorestaticlibrary") || name.contains("ntcoretest")) {
project.ntcoreZip.dependsOn task
}
}
}
if (buildArm) {
project(':arm') {
apply plugin: 'cpp'
ext.buildPlatform = 'arm'
ext.isArm = true
apply from: '../toolchains/arm.gradle'
if (includeJava) {
apply from: '../java/java.gradle'
}
setupModel(project, true)
ntcoreZipTask(project)
}
}
project(':native') {
apply plugin: 'cpp'
task check
ext.buildPlatform = OperatingSystem.current().getFamilyName()
ext.isArm = false
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()}.")
}
if (!project.hasProperty("withoutTests")) {
apply from: '../test/tests.gradle'
}
if (includeJava) {
apply from: '../java/java.gradle'
}
setupModel(project, false)
ntcoreZipTask(project)
}
task ntcoreSourceZip(type: Zip) {
description = 'Creates a sources-zip of the ntcore source files'
group = 'WPILib'
destinationDir = project.buildDir
baseName = 'ntcore'
classifier = "sources"
from('src') {
into 'src'
}
from('include') {
into 'include'
}
if (includeJava) {
from('java/lib') {
into 'src'
}
project(':native').jniHeadersNetworkTables.outputs.each {
from(it) {
into 'include'
}
}
}
}
// Empty task for build so that ntcoreSourceZip will be build when running ./gradlew build
// Empty task for build so that ntcoreSourceZip and wpiutilSourceZip will be
// built when running ./gradlew build
task build
build.dependsOn ntcoreSourceZip
build.dependsOn wpiutilSourceZip
apply from: 'publish.gradle'
task wrapper(type: Wrapper) {
gradleVersion = '2.14.1'
gradleVersion = '2.14'
}

View File

@@ -11,12 +11,12 @@ configurations.errorprone {
resolutionStrategy.force 'com.google.errorprone:error_prone_core:2.0.9'
}
def generatedJNIHeaderLoc = '../build/include'
def generatedJNIHeaderLoc = "${buildDir}/include"
sourceSets {
main {
java {
srcDirs = ['../java/src']
srcDirs = ["${rootDir}/java/src"]
}
}
}
@@ -111,8 +111,8 @@ ext.setupJniIncludes = { binaries ->
binaries.all {
tasks.withType(CppCompile) {
if (buildPlatform == 'arm') {
cppCompiler.args '-I', file('../java/arm-linux').absolutePath
cppCompiler.args '-I', file('../java/arm-linux/linux').absolutePath
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)

163
ntcore-jni.def Normal file
View File

@@ -0,0 +1,163 @@
LIBRARY NTCORE
EXPORTS
NT_GetEntryValue @1
NT_SetEntryValue @2
NT_SetEntryTypeValue @3
NT_SetEntryFlags @4
NT_GetEntryFlags @5
NT_DeleteEntry @6
NT_DeleteAllEntries @7
NT_GetEntryInfo @8
NT_Flush @9
NT_AddEntryListener @10
NT_RemoveEntryListener @11
NT_AddConnectionListener @12
NT_RemoveConnectionListener @13
NT_SetNetworkIdentity @18
NT_StartServer @19
NT_StopServer @20
NT_StartClient @21
NT_StopClient @22
NT_SetUpdateRate @23
NT_GetConnections @24
NT_SavePersistent @25
NT_LoadPersistent @26
NT_DisposeValue @27
NT_InitValue @28
NT_DisposeString @29
NT_InitString @30
NT_DisposeConnectionInfoArray @31
NT_Now @32
NT_SetLogger @33
NT_CreateRpc @34
NT_CreatePolledRpc @35
NT_PollRpc @36
NT_PostRpcResponse @37
NT_CallRpc @38
NT_GetRpcResult @39
NT_PackRpcDefinition @40
NT_UnpackRpcDefinition @41
NT_PackRpcValues @42
NT_UnpackRpcValues @43
NT_DisposeRpcDefinition @44
NT_DisposeRpcCallInfo @45
NT_GetType @46
NT_AllocateDoubleArray @47
NT_AllocateBooleanArray @48
NT_AllocateStringArray @49
NT_FreeDoubleArray @51
NT_FreeBooleanArray @52
NT_FreeStringArray @53
NT_GetValueType @54
NT_GetValueBoolean @55
NT_GetValueDouble @56
NT_GetValueString @57
NT_GetValueRaw @58
NT_GetValueBooleanArray @59
NT_GetValueDoubleArray @60
NT_GetValueStringArray @61
NT_GetEntryBoolean @62
NT_GetEntryDouble @63
NT_GetEntryString @64
NT_GetEntryRaw @65
NT_GetEntryBooleanArray @66
NT_GetEntryDoubleArray @67
NT_GetEntryStringArray @68
NT_SetEntryDouble @69
NT_SetEntryBoolean @70
NT_SetEntryString @71
NT_SetEntryRaw @72
NT_SetEntryBooleanArray @73
NT_SetEntryDoubleArray @74
NT_SetEntryStringArray @75
NT_DisposeEntryInfoArray @76
NT_AllocateCharArray @77
NT_FreeCharArray @78
NT_NotifierDestroyed @79
NT_StopRpcServer @80
NT_StopNotifier @81
NT_SetListenerOnStart @82
NT_SetListenerOnExit @83
NT_SetRpcServerOnStart @84
NT_SetRpcServerOnExit @85
NT_StartClientMulti @86
NT_SetDefaultEntryValue @87
NT_SetDefaultEntryBoolean @88
NT_SetDefaultEntryDouble @89
NT_SetDefaultEntryString @90
NT_SetDefaultEntryRaw @91
NT_SetDefaultEntryBooleanArray @92
NT_SetDefaultEntryDoubleArray @93
NT_SetDefaultEntryStringArray @94
; JNI functions
JNI_OnLoad
JNI_OnUnload
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_containsKey
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getType
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_putBoolean
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_putDouble
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_putString
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_putRaw__Ljava_lang_String_2_3B
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_putRaw__Ljava_lang_String_2Ljava_nio_ByteBuffer_2I
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_putBooleanArray
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_putDoubleArray
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_putStringArray
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_forcePutBoolean
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_forcePutDouble
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_forcePutString
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_forcePutRaw__Ljava_lang_String_2_3B
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_forcePutRaw__Ljava_lang_String_2Ljava_nio_ByteBuffer_2I
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_forcePutBooleanArray
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_forcePutDoubleArray
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_forcePutStringArray
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getValue__Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getBoolean__Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getDouble__Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getString__Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getRaw__Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getBooleanArray__Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getDoubleArray__Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getStringArray__Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getValue__Ljava_lang_String_2Ljava_lang_Object_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getBoolean__Ljava_lang_String_2Z
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getDouble__Ljava_lang_String_2D
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getString__Ljava_lang_String_2Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getRaw__Ljava_lang_String_2_3B
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getBooleanArray__Ljava_lang_String_2_3Z
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getDoubleArray__Ljava_lang_String_2_3D
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getStringArray__Ljava_lang_String_2_3Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setEntryFlags
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getEntryFlags
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_deleteEntry
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_deleteAllEntries
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getEntries
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_flush
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_addEntryListener
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_removeEntryListener
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_addConnectionListener
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_removeConnectionListener
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getRpc__Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getRpc__Ljava_lang_String_2_3B
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_callRpc__Ljava_lang_String_2_3B
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_callRpc__Ljava_lang_String_2Ljava_nio_ByteBuffer_2I
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setNetworkIdentity
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_startServer
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_stopServer
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_startClient__Ljava_lang_String_2I
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_startClient___3Ljava_lang_String_2_3I
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_stopClient
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setUpdateRate
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getConnections
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_savePersistent
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_loadPersistent
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_now
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setLogger
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setDefaultBoolean
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setDefaultDouble
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setDefaultString
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setDefaultRaw
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setDefaultBooleanArray
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setDefaultDoubleArray
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setDefaultStringArray

View File

@@ -90,74 +90,3 @@ NT_SetDefaultEntryRaw @91
NT_SetDefaultEntryBooleanArray @92
NT_SetDefaultEntryDoubleArray @93
NT_SetDefaultEntryStringArray @94
; JNI functions
JNI_OnLoad
JNI_OnUnload
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_containsKey
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getType
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_putBoolean
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_putDouble
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_putString
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_putRaw__Ljava_lang_String_2_3B
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_putRaw__Ljava_lang_String_2Ljava_nio_ByteBuffer_2I
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_putBooleanArray
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_putDoubleArray
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_putStringArray
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_forcePutBoolean
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_forcePutDouble
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_forcePutString
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_forcePutRaw__Ljava_lang_String_2_3B
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_forcePutRaw__Ljava_lang_String_2Ljava_nio_ByteBuffer_2I
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_forcePutBooleanArray
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_forcePutDoubleArray
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_forcePutStringArray
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getValue__Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getBoolean__Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getDouble__Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getString__Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getRaw__Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getBooleanArray__Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getDoubleArray__Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getStringArray__Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getValue__Ljava_lang_String_2Ljava_lang_Object_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getBoolean__Ljava_lang_String_2Z
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getDouble__Ljava_lang_String_2D
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getString__Ljava_lang_String_2Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getRaw__Ljava_lang_String_2_3B
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getBooleanArray__Ljava_lang_String_2_3Z
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getDoubleArray__Ljava_lang_String_2_3D
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getStringArray__Ljava_lang_String_2_3Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setEntryFlags
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getEntryFlags
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_deleteEntry
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_deleteAllEntries
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getEntries
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_flush
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_addEntryListener
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_removeEntryListener
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_addConnectionListener
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_removeConnectionListener
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getRpc__Ljava_lang_String_2
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getRpc__Ljava_lang_String_2_3B
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_callRpc__Ljava_lang_String_2_3B
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_callRpc__Ljava_lang_String_2Ljava_nio_ByteBuffer_2I
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setNetworkIdentity
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_startServer
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_stopServer
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_startClient__Ljava_lang_String_2I
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_startClient___3Ljava_lang_String_2_3I
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_stopClient
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setUpdateRate
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getConnections
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_savePersistent
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_loadPersistent
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_now
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setLogger
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setDefaultBoolean
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setDefaultDouble
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setDefaultString
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setDefaultRaw
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setDefaultBooleanArray
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setDefaultDoubleArray
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setDefaultStringArray

166
ntcore.gradle Normal file
View File

@@ -0,0 +1,166 @@
def ntcoreSetupModel = { project ->
project.model {
components {
ntcore(NativeLibrarySpec) {
if (project.isArm) {
targetPlatform 'arm'
} else {
targetPlatform 'x86'
targetPlatform 'x64'
}
setupDefines(project, binaries)
if (includeJava) {
project.setupJniIncludes(binaries)
binaries.all {
project.setupDef(linker, "${rootDir}/ntcore-jni.def")
}
} else {
binaries.all {
project.setupDef(linker, "${rootDir}/ntcore.def")
}
}
sources {
cpp {
source {
srcDirs = ["${rootDir}/src"]
if (includeJava) {
srcDirs "${rootDir}/java/lib"
}
includes = ['**/*.cpp']
}
exportedHeaders {
srcDirs = ["${rootDir}/include"]
if (includeJava) {
project.jniHeadersNetworkTables.outputs.files.each { file ->
srcDirs file.getPath()
}
}
includes = ['**/*.h']
}
if (project.isArm) {
lib project: ':arm:wpiutil', library: 'wpiutil', linkage: 'static'
} else {
lib project: ':native:wpiutil', library: 'wpiutil', linkage: 'static'
}
}
}
}
}
}
}
def ntcoreZipTask = { project ->
project.ext.ntcoreZip = project.tasks.create("${project.isArm ? 'arm' : 'native'}NtcoreZip", Zip) {
description = 'Creates platform-specific zip of the desktop ntcore libraries.'
group = 'WPILib'
destinationDir = project.buildDir
baseName = 'ntcore'
classifier = "${project.buildPlatform}"
from(file('include')) {
into 'include'
}
if (!project.hasProperty('skipJava')) {
project.jniHeadersNetworkTables.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)
}
}
}
}
}
project.build.dependsOn project.ntcoreZip
def releaseTasks = [project.ntcoreZip]
if (includeJava) {
releaseTasks.add(project.jar)
}
project.releaseSetup(releaseTasks)
project.tasks.whenTaskAdded { task ->
def name = task.name.toLowerCase()
if (name.contains("ntcoresharedlibrary") || name.contains("ntcorestaticlibrary") || name.contains("ntcoretest")) {
project.ntcoreZip.dependsOn task
}
}
}
if (buildArm) {
project(':arm:ntcore') {
apply plugin: 'cpp'
apply from: "${rootDir}/toolchains/arm.gradle"
if (includeJava) {
apply from: "${rootDir}/java/java.gradle"
}
ntcoreSetupModel(project)
ntcoreZipTask(project)
}
}
project(':native:ntcore') {
apply plugin: 'cpp'
task check
apply from: "${rootDir}/toolchains/native.gradle"
if (!project.hasProperty("withoutTests")) {
apply from: "${rootDir}/test/tests.gradle"
}
if (includeJava) {
apply from: "${rootDir}/java/java.gradle"
}
ntcoreSetupModel(project)
ntcoreZipTask(project)
}
task ntcoreSourceZip(type: Zip) {
description = 'Creates a sources-zip of the ntcore source files'
group = 'WPILib'
destinationDir = project.buildDir
baseName = 'ntcore'
classifier = "sources"
from('src') {
into 'src'
}
from('include') {
into 'include'
}
if (includeJava) {
from('java/lib') {
into 'src'
}
project(':native:ntcore').jniHeadersNetworkTables.outputs.each {
from(it) {
into 'include'
}
}
}
}

View File

@@ -6,14 +6,14 @@ apply plugin: 'maven-publish'
// release. This is set up in the main gradle file.
publishing {
publications {
def nat = project('native')
def nat = project('native:ntcore')
if (!project.hasProperty('skipJava')) {
java(MavenPublication) {
artifact nat.jar
artifact nat.networktablesJavaSource
artifact nat.networktablesJavadoc
if (project.buildArm) {
artifact project('arm').jar
artifact project('arm:ntcore').jar
}
if (project.hasProperty('makeDesktop')) {
@@ -31,7 +31,7 @@ publishing {
artifact nat.ntcoreZip
artifact ntcoreSourceZip
if (project.buildArm) {
artifact project(':arm').ntcoreZip
artifact project(':arm:ntcore').ntcoreZip
}
if (project.hasProperty('makeDesktop')) {
@@ -44,6 +44,23 @@ publishing {
artifactId 'NetworkTables'
version '3.0.0-SNAPSHOT'
}
wpiutil(MavenPublication) {
artifact project(':native:wpiutil').wpiutilZip
artifact wpiutilSourceZip
if (project.buildArm) {
artifact project(':arm:wpiutil').wpiutilZip
}
if (project.hasProperty('makeDesktop')) {
artifact project(':native:wpiutil').wpiutilZip, {
classifier = 'desktop'
}
}
groupId 'edu.wpi.first.wpilib'
artifactId 'wpiutil'
version '1.0.0-SNAPSHOT'
}
}
repositories {

View File

@@ -1,5 +1,8 @@
include 'native', 'gmock'
include 'native:ntcore'
include 'native:wpiutil'
include 'gmock'
if (!hasProperty('skipArm')) {
include 'arm'
include 'arm:ntcore'
include 'arm:wpiutil'
}

View File

@@ -9,11 +9,11 @@ model {
sources {
cpp {
source {
srcDirs = ['../test/unit']
srcDirs = ["${rootDir}/test/unit"]
includes = ['**/*.cpp']
}
exportedHeaders {
srcDirs = ['../include', '../src', '../gmock/include', '../gmock/gtest/include']
srcDirs = ["${rootDir}/include", "${rootDir}/src", "${rootDir}/wpiutil/include", "${rootDir}/gmock/include", "${rootDir}/gmock/gtest/include"]
includes = ['**/*.h']
}
}

View File

@@ -1,5 +1,14 @@
ext.isArm = true
ext.buildPlatform = 'arm'
def compilerPrefix = project.hasProperty('compilerPrefix') ? project.compilerPrefix : 'arm-frc-linux-gnueabi-'
model {
platforms {
arm {
architecture 'arm'
operatingSystem 'linux'
}
}
toolChains {
gcc(Gcc) {
target("arm") {
@@ -65,6 +74,9 @@ ext.setupDebugDefines = { cppCompiler, linker ->
cppCompiler.args '-g', '-O0'
}
// Used only on Windows.
ext.setupDef = { linker, deffile -> }
ext.releaseSetup = { releaseTasks ->
model {
binaries {

View File

@@ -41,6 +41,9 @@ ext.setupDebugDefines = { cppCompiler, linker ->
cppCompiler.args '-g', '-O0'
}
// Used only on Windows.
ext.setupDef = { linker, deffile -> }
ext.releaseSetup = { releaseTasks ->
model {
binaries {

View File

@@ -30,6 +30,9 @@ ext.setupDebugDefines = { cppCompiler, linker ->
cppCompiler.args '-g', '-O0'
}
// Used only on Windows.
ext.setupDef = { linker, deffile -> }
ext.releaseSetup = { releaseTasks ->
model {
binaries {

25
toolchains/native.gradle Normal file
View File

@@ -0,0 +1,25 @@
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

@@ -36,14 +36,17 @@ model {
ext.setupReleaseDefines = { cppCompiler, linker ->
cppCompiler.args '/O2', '/Zi', '/FS'
linker.args '/DEF:../ntcore.def'
}
ext.setupDebugDefines = { cppCompiler, linker ->
cppCompiler.args '/Zi', '/FS'
linker.args '/DEBUG', '/DEF:../ntcore.def'
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.releaseSetup = {}
ext.releaseSetup = { releaseTasks -> }

112
wpiutil.gradle Normal file
View File

@@ -0,0 +1,112 @@
def wpiutilSetupModel = { project ->
project.model {
components {
wpiutil(NativeLibrarySpec) {
if (project.isArm) {
targetPlatform 'arm'
} else {
targetPlatform 'x86'
targetPlatform 'x64'
}
setupDefines(project, binaries)
sources {
cpp {
source {
srcDirs = ["${rootDir}/wpiutil/src"]
includes = ['**/*.cpp']
}
exportedHeaders {
srcDirs = ["${rootDir}/wpiutil/include"]
includes = ['**/*.h']
}
}
}
}
}
}
}
def wpiutilZipTask = { project ->
project.ext.wpiutilZip = project.tasks.create("${project.isArm ? 'arm' : 'native'}WpiutilZip", Zip) {
description = 'Creates platform-specific zip of the desktop wpiutil libraries.'
group = 'WPILib'
destinationDir = project.buildDir
baseName = 'wpiutil'
classifier = "${project.buildPlatform}"
from(file('wpiutil/include')) {
into 'include'
}
project.model {
binaries {
withType(StaticLibraryBinarySpec) { binary ->
from(binary.staticLibraryFile) {
into getPlatformPath(binary)
}
}
withType(SharedLibraryBinarySpec) { binary ->
from(binary.sharedLibraryFile) {
into getPlatformPath(binary)
}
}
}
}
}
project.build.dependsOn project.wpiutilZip
def releaseTasks = [project.wpiutilZip]
project.releaseSetup(releaseTasks)
project.tasks.whenTaskAdded { task ->
def name = task.name.toLowerCase()
if (name.contains("wpiutilsharedlibrary") || name.contains("wpiutilstaticlibrary") || name.contains("wpiutiltest")) {
project.wpiutilZip.dependsOn task
}
}
}
if (buildArm) {
project(':arm:wpiutil') {
apply plugin: 'cpp'
apply from: "${rootDir}/toolchains/arm.gradle"
wpiutilSetupModel(project)
wpiutilZipTask(project)
}
}
project(':native:wpiutil') {
apply plugin: 'cpp'
task check
apply from: "${rootDir}/toolchains/native.gradle"
if (!project.hasProperty("withoutTests")) {
apply from: "${rootDir}/wpiutil/unittest/unittest.gradle"
}
wpiutilSetupModel(project)
wpiutilZipTask(project)
}
task wpiutilSourceZip(type: Zip) {
description = 'Creates a sources-zip of the wpiutil source files'
group = 'WPILib'
destinationDir = project.buildDir
baseName = 'wpiutil'
classifier = "sources"
from('wpiutil/src') {
into 'src'
}
from('wpiutil/include') {
into 'include'
}
}

3
wpiutil/src/dummy.cpp Normal file
View File

@@ -0,0 +1,3 @@
namespace wpi {
void DummyFunction() {}
}

15
wpiutil/unittest/main.cpp Normal file
View File

@@ -0,0 +1,15 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2015. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "gtest/gtest.h"
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
int ret = RUN_ALL_TESTS();
return ret;
}

View File

@@ -0,0 +1,39 @@
apply plugin: 'google-test'
model {
testSuites {
wpiutilTest {
sources {
cpp {
source {
srcDirs = ["${rootDir}/wpiutil/unittest"]
includes = ['**/*.cpp']
}
exportedHeaders {
srcDirs = ["${rootDir}/wpiutil/include", "${rootDir}/gmock/include", "${rootDir}/gmock/gtest/include"]
includes = ['**/*.h']
}
}
}
binaries.all {
lib project: ':gmock', library: 'gmock', linkage: 'static'
lib library: 'wpiutil', linkage: 'static'
}
}
}
}
model {
binaries {
withType(GoogleTestTestSuiteBinarySpec) {
lib project: ':gmock', library: "gmock", linkage: "static"
lib library: 'wpiutil', linkage: 'static'
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'
}
}
}
}