Remove wpiutil and update to the new build system (#210)

This commit is contained in:
Thad House
2017-08-03 14:14:40 -07:00
committed by Peter Johnson
parent f43675e2bd
commit 5df7463663
168 changed files with 670 additions and 16084 deletions

2
.gitignore vendored
View File

@@ -41,7 +41,7 @@
# Build directories
/.gradle
/build*
/build/
!build.gradle
/native
/arm

View File

@@ -1,5 +0,0 @@
[gerrit]
host=usfirst.collab.net
port=29418
project=ntcore
defaultbranch=master

View File

@@ -7,7 +7,6 @@ matrix:
sudo: required
- os: osx
osx_image: xcode8
env: WPILIB_FLAGS=-PskipArm
addons:
apt:
@@ -19,10 +18,10 @@ before_install:
- .travis-scripts/install.sh
install:
- ./gradlew assemble $WPILIB_FLAGS
- ./gradlew build -PbuildAll
script:
- ./gradlew build $WPILIB_FLAGS
- ./gradlew build -PbuildAll
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock

View File

@@ -1,112 +0,0 @@
cmake_minimum_required(VERSION 2.8)
project(ntcore)
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DNOMINMAX /D_SCL_SECURE_NO_WARNINGS /D_WINSOCK_DEPRECATED_NO_WARNINGS")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++1y -Wformat=2 -Wall -Wextra -Werror -pedantic -Wno-unused-parameter")
endif()
# This must be a macro(), as inside a function string() can only
# update variables in the function scope.
macro(fix_default_compiler_settings_)
if (MSVC)
# For MSVC, CMake sets certain flags to defaults we want to override.
# This replacement code is taken from sample in the CMake Wiki at
# http://www.cmake.org/Wiki/CMake_FAQ#Dynamic_Replace.
foreach (flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if (NOT BUILD_SHARED_LIBS AND NOT gtest_force_shared_crt)
# When Google Test is built as a shared library, it should also use
# shared runtime libraries. Otherwise, it may end up with multiple
# copies of runtime library data in different modules, resulting in
# hard-to-find crashes. When it is built as a static library, it is
# preferable to use CRT as static libraries, as we don't have to rely
# on CRT DLLs being available. CMake always defaults to using shared
# CRT libraries, so we override that default here.
string(REPLACE "/MD" "-MT" ${flag_var} "${${flag_var}}")
endif()
endforeach()
endif()
endmacro()
fix_default_compiler_settings_()
file(GLOB_RECURSE SRC_FILES src/*.cpp)
include_directories(include src wpiutil/include)
# Java bindings
if (NOT WITHOUT_JAVA)
find_package(Java)
find_package(JNI)
include(UseJava)
set(CMAKE_JAVA_COMPILE_FLAGS "-Xlint:unchecked")
include_directories(${JNI_INCLUDE_DIRS})
list(APPEND SRC_FILES java/lib/NetworkTablesJNI.cpp)
file(GLOB_RECURSE JAVA_SOURCES java/src/*.java)
set(CMAKE_JNI_TARGET true)
add_jar(ntcore_jar ${JAVA_SOURCES} OUTPUT_NAME ntcore)
# Generate JNI headers
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/edu_wpi_first_wpilibj_networktables_NetworkTablesJNI.h"
DEPENDS ntcore_jar java/src/edu/wpi/first/wpilibj/networktables/NetworkTablesJNI.java
COMMAND "${Java_JAVAH_EXECUTABLE}"
-jni
-o "${CMAKE_CURRENT_BINARY_DIR}/edu_wpi_first_wpilibj_networktables_NetworkTablesJNI.h"
-classpath "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/ntcore_jar.dir/"
edu.wpi.first.wpilibj.networktables.NetworkTablesJNI
)
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
set_source_files_properties(
java/lib/NetworkTablesJNI.cpp
OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/edu_wpi_first_wpilibj_networktables_NetworkTablesJNI.h"
)
#add_subdirectory(java/test)
endif()
if (WIN32)
if (NOT WITHOUT_JAVA)
add_library(ntcore SHARED ${SRC_FILES} ntcore-jni.def)
else()
add_library(ntcore SHARED ${SRC_FILES} ntcore.def)
endif()
else()
add_library(ntcore SHARED ${SRC_FILES})
endif()
set_target_properties(ntcore PROPERTIES VERSION 1.0.0 SOVERSION 1)
target_link_libraries(ntcore wpiutil)
if (WIN32)
add_library(ntcore_static STATIC ${SRC_FILES})
target_link_libraries(ntcore_static wpiutil)
target_link_libraries(ntcore ws2_32)
target_link_libraries(ntcore_static ws2_32)
endif()
INSTALL(TARGETS ntcore
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib COMPONENT lib)
INSTALL(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT headers)
file(GLOB_RECURSE WPIUTIL_SRC_FILES wpiutil/src/*.cpp)
add_library(wpiutil STATIC ${WPIUTIL_SRC_FILES})
INSTALL(TARGETS wpiutil
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib COMPONENT lib)
INSTALL(DIRECTORY wpiutil/include DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT headers)
# We need thread support
find_package(Threads REQUIRED)
if (NOT WITHOUT_TESTS)
enable_testing()
add_subdirectory(gmock)
include_directories("gmock/include")
include_directories("gmock/gtest/include")
add_subdirectory(test)
endif()

View File

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

View File

@@ -1,74 +1,201 @@
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
buildscript {
repositories {
mavenLocal()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.8'
classpath 'gradle.plugin.edu.wpi.first:native-utils:1.2.9'
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.getPlatformPath = { binary ->
if (binary.targetPlatform.architecture.arm) {
return 'Linux/arm'
} else if (binary.targetPlatform.operatingSystem.linux) {
if (binary.targetPlatform.architecture.amd64) {
return 'Linux/amd64'
} else {
return 'Linux/i386'
ext.getClassifier = { binary->
return NativeUtils.getClassifier(binary)
}
ext.getPlatformPath = { binary->
return NativeUtils.getPlatformPath(binary)
}
ext.getJNIHeadersClass = {
return JNIHeaders
}
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
}
task nativeTestFilesJar(type: Jar) {
destinationDir = project.buildDir
classifier = "nativeTestFiles"
project.model {
binaries {
withType(SharedLibraryBinarySpec) { binary ->
if (binary.component.name == 'ntcoreJNI') {
from(binary.sharedLibraryFile) {
into NativeUtils.getPlatformPath(binary)
}
}
}
}
} else if (binary.targetPlatform.operatingSystem.windows) {
if (binary.targetPlatform.architecture.amd64) {
return 'Windows/amd64'
} else {
return 'Windows/' + binary.targetPlatform.architecture.name
}
} else if (binary.targetPlatform.operatingSystem.macOsX) {
if (binary.targetPlatform.architecture.amd64) {
return 'Mac OS X/x86_64'
} else {
return 'Mac OS X/' + binary.targetPlatform.architecture.name
}
} else {
return binary.targetPlatform.operatingSystem.name + '/' + binary.targetPlatform.architecture.name
}
}
ext.setupDefines = { project, binaries ->
binaries.all {
if (project.hasProperty('debug')) {
project.setupDebugDefines(cppCompiler, linker)
} else {
project.setupReleaseDefines(cppCompiler, linker)
}
}
test.dependsOn nativeTestFilesJar
dependencies {
compile 'edu.wpi.first.wpiutil:wpiutil-java:+'
runtime 'edu.wpi.first.wpiutil:wpiutil-java:+'
testCompile 'junit:junit:4.12'
testRuntime files(project(':').nativeTestFilesJar.archivePath)
}
apply from: "ntcore.gradle"
apply from: "wpiutil.gradle"
// Empty task for build so that ntcoreSourceZip and wpiutilSourceZip will be
// built when running ./gradlew build
task build
build.dependsOn ntcoreSourceZip
build.dependsOn wpiutilSourceZip
model {
jniConfigs {
ntcore(JNIConfig) {
jniDefinitionClasses = [ "edu.wpi.first.wpilibj.networktables.NetworkTablesJNI" ]
jniArmHeaderLocations = [ all: file("${rootDir}/src/arm-linux-jni") ]
sourceSets = [ project.sourceSets.main ]
}
ntcoreJNI(JNIConfig) {
jniDefinitionClasses = [ "edu.wpi.first.wpilibj.networktables.NetworkTablesJNI" ]
jniArmHeaderLocations = [ all: file("${rootDir}/src/arm-linux-jni") ]
sourceSets = [ project.sourceSets.main ]
}
}
exportsConfigs {
ntcore(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' ]
}
ntcoreJNI(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 = [ ntcore: [],
ntcoreExe: [],
ntcoreTestingBaseTest: [] ]
staticConfigs = [ ntcoreJNI: [] ]
}
}
components {
ntcore(NativeLibrarySpec) {
sources {
cpp {
source {
srcDirs 'src/main/native/cpp'
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/main/native/include'
}
}
}
}
ntcoreJNI(NativeLibrarySpec) {
baseName = 'ntcore'
sources {
cpp {
source {
srcDirs 'src/main/native/cpp'
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/main/native/include'
}
}
}
}
if (!project.hasProperty('skipTestExe')) {
ntcoreExe(NativeExecutableSpec) {
sources {
cpp {
lib library: "ntcore"
}
}
}
}
ntcoreTestingBase(NativeLibrarySpec) { }
}
testSuites {
ntcoreTestingBaseTest {
sources {
cpp.source.srcDir 'src/test/native/cpp'
cpp.exportedHeaders.srcDir 'src/test/native/include'
}
}
}
binaries {
withType(StaticLibraryBinarySpec) {
if (it.component.name == 'ntcoreJNI') {
it.buildable = false
}
}
withType(GoogleTestTestSuiteBinarySpec) {
if (it.component.testedComponent.name.contains('TestingBase') && !project.hasProperty('onlyAthena')) {
lib project: ':gmock', library: 'gmock', linkage: 'static'
lib library: 'ntcore', linkage: 'shared'
NativeUtils.setPlatformSpecificIncludeFlag("${rootDir}/src/main/native/cpp".toString(), cppCompiler)
} else {
it.buildable = false
}
}
}
}
apply from: 'publish.gradle'
task wrapper(type: Wrapper) {
gradleVersion = '3.3'
gradleVersion = '4.0.2'
}

226
config.gradle Normal file
View File

@@ -0,0 +1,226 @@
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
}
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,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,6 @@
#Wed Jan 04 18:53:29 PST 2017
#Thu Aug 03 08:44:52 PDT 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
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.2-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 " "
}

View File

@@ -1,180 +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"]
}
}
}
jar {
description = 'Generates NetworkTables jar, with the JNI shared libraries embedded'
baseName = 'ntcore'
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 == 'ntcoreSharedLibrary') jar.dependsOn task
} else {
if (task.name == 'ntcoreX64SharedLibrary' || task.name == 'ntcoreX86SharedLibrary')
jar.dependsOn task
}
}
task networktablesJavaSource(type: Jar, dependsOn: classes) {
description = 'Generates the source jar for NetworkTables java'
group = 'WPILib'
baseName = 'ntcore'
classifier = "sources"
duplicatesStrategy = 'exclude'
from sourceSets.main.allJava
}
task networktablesJavadoc(type: Jar, dependsOn: javadoc) {
description = 'Generates the javadoc jar for NetworkTables java'
group = 'WPILib'
baseName = 'ntcore'
classifier = "javadoc"
duplicatesStrategy = 'exclude'
from javadoc.destinationDir
}
build.dependsOn networktablesJavaSource
build.dependsOn networktablesJavadoc
/**
* Generates the JNI headers
*/
task jniHeadersNetworkTables {
description = 'Generates JNI headers from edu.wpi.first.wpilibj.networktables.*'
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.output.classesDir
args 'edu.wpi.first.wpilibj.networktables.NetworkTablesJNI'
}
}
}
ext.getNativeJNISymbols = {
def symbolsList = []
jniHeadersNetworkTables.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)
}
}
jniHeadersNetworkTables.outputs.files.each { file ->
if (buildPlatform == 'arm') {
cppCompiler.args '-I', file.getPath()
} else {
platformSpecificIncludeFlag(file.getPath(), cppCompiler)
}
}
dependsOn jniHeadersNetworkTables
}
}
}

View File

@@ -1,199 +0,0 @@
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
NT_PollRpcTimeout @95
NT_GetRpcResultTimeout @96
NT_CancelBlockingRpcResult @97
NT_GetStringForTesting @98
NT_GetEntryInfoForTesting @99
NT_FreeEntryInfoForTesting @101
NT_GetConnectionInfoForTesting @102
NT_FreeConnectionInfoForTesting @103
NT_GetValueBooleanForTesting @104
NT_GetValueDoubleForTesting @105
NT_GetValueStringForTesting @106
NT_GetValueRawForTesting @107
NT_GetValueBooleanArrayForTesting @108
NT_GetValueDoubleArrayForTesting @109
NT_GetValueStringArrayForTesting @110
NT_GetRpcParamDefForTesting @111
NT_FreeRpcParamDefForTesting @112
NT_GetRpcResultsDefForTesting @113
NT_FreeRpcResultsDefForTesting @114
NT_GetRpcDefinitionForTesting @115
NT_GetRpcCallInfoForTesting @116
NT_SetServer @117
NT_SetServerMulti @118
NT_StartDSClient @119
NT_StopDSClient @120
NT_StartClientNone @121
NT_GetNetworkMode @122
; 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__
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_setServer__Ljava_lang_String_2I
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_setServer___3Ljava_lang_String_2_3I
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_startDSClient
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_stopDSClient
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
Java_edu_wpi_first_wpilibj_networktables_NetworkTablesJNI_getNetworkMode

View File

@@ -1,122 +0,0 @@
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
NT_PollRpcTimeout @95
NT_GetRpcResultTimeout @96
NT_CancelBlockingRpcResult @97
NT_GetStringForTesting @98
NT_GetEntryInfoForTesting @99
NT_FreeEntryInfoForTesting @101
NT_GetConnectionInfoForTesting @102
NT_FreeConnectionInfoForTesting @103
NT_GetValueBooleanForTesting @104
NT_GetValueDoubleForTesting @105
NT_GetValueStringForTesting @106
NT_GetValueRawForTesting @107
NT_GetValueBooleanArrayForTesting @108
NT_GetValueDoubleArrayForTesting @109
NT_GetValueStringArrayForTesting @110
NT_GetRpcParamDefForTesting @111
NT_FreeRpcParamDefForTesting @112
NT_GetRpcResultsDefForTesting @113
NT_FreeRpcResultsDefForTesting @114
NT_GetRpcDefinitionForTesting @115
NT_GetRpcCallInfoForTesting @116
NT_SetServer @117
NT_SetServerMulti @118
NT_StartDSClient @119
NT_StopDSClient @120
NT_StartClientNone @121
NT_GetNetworkMode @122

View File

@@ -1,173 +0,0 @@
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)
project.checkNativeSymbols(project.getNativeJNISymbols)
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 && project.hasProperty('compilerPrefix')) {
lib project: ':arm:wpiutil', library: 'wpiutil', linkage: 'static'
} else if (project.isArm) {
// If roboRIO, link shared
lib project: ':arm:wpiutil', library: 'wpiutil', linkage: 'shared'
} else {
lib project: ':native:wpiutil', library: 'wpiutil', linkage: 'static'
}
}
}
}
}
}
}
def ntcoreZipTask = { project ->
project.ext.ntcoreZip = project.tasks.create("ntcoreZip", Zip) {
description = 'Creates platform-specific zip of the desktop ntcore libraries.'
group = 'WPILib'
destinationDir = project.buildDir
baseName = 'ntcore'
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.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)
}
from(new File(binary.sharedLibraryFile.absolutePath + ".debug")) {
into getPlatformPath(binary)
}
}
}
}
}
project.build.dependsOn project.ntcoreZip
project.debugStripSetup()
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'
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"
duplicatesStrategy = 'exclude'
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

@@ -1,132 +1,222 @@
import org.gradle.internal.os.OperatingSystem
apply plugin: 'maven-publish'
apply plugin: 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin'
def getVersion = {
if (WPILibVersion.version.contains('-'))
return WPILibVersion.version.substring(WPILibVersion.version.indexOf('-'))
else
return ""
}
if (!hasProperty('releaseType')) {
WPILibVersion {
releaseType = 'dev'
}
}
def ntVersion
def utilVersion
if (project.hasProperty("ntPublishVersion")) {
ntVersion = project.ntPublishVersion
def pubVersion
if (project.hasProperty("publishVersion")) {
pubVersion = project.publishVersion
} else {
ntVersion = WPILibVersion.version
pubVersion = WPILibVersion.version
}
if (project.hasProperty("utilPublishVersion")) {
utilVersion = project.utilPublishVersion
} else {
utilVersion = "1.0.2${-> getVersion()}"
}
def outputsFolder = file("$buildDir/outputs")
def utilFile = file("$buildDir/wpiutil.txt")
def ntcoreFile = file("$buildDir/ntcore.txt")
def versionFile = file("$outputsFolder/version.txt")
task outputVersions() {
description = 'Prints the versions of ntcore and wpiutil to a file for use by the downstream packaging project'
description = 'Prints the versions of ntcore to a file for use by the downstream packaging project'
group = 'Build'
outputs.files(utilFile, ntcoreFile)
outputs.files(versionFile)
doFirst {
buildDir.mkdir()
outputsFolder.mkdir()
}
doLast {
utilFile.write utilVersion
ntcoreFile.write ntVersion
versionFile.write pubVersion
}
}
task clean(type: Delete) {
delete utilFile
delete ntcoreFile
build.dependsOn outputVersions
def baseArtifactId = 'ntcore'
def artifactGroupId = 'edu.wpi.first.ntcore'
def licenseFile = file("$rootDir/license.txt")
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
}
}
}
}
}
outputVersions.mustRunAfter clean
task cppHeadersZip(type: Zip) {
destinationDir = outputsFolder
classifier = "headers"
project(':native:wpiutil').build.dependsOn outputVersions
project(':native:ntcore').build.dependsOn outputVersions
if (project.buildArm) {
project(':arm:wpiutil').build.dependsOn outputVersions
project(':arm:ntcore').build.dependsOn outputVersions
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 ntcoreTaskList = createComponentZipTasks($.components, 'ntcore', 'zipcppntcore', 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'
}
}
}
}
})
def ntcoreJNITaskList = createComponentZipTasks($.components, 'ntcoreJNI', 'jnijnintcore', 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)
}
}
}
}
})
publications {
cpp(MavenPublication) {
ntcoreTaskList.each {
artifact it
}
artifact cppHeadersZip
artifact cppSourcesZip
artifactId = "${baseArtifactId}-cpp"
groupId artifactGroupId
version pubVersion
}
jni(MavenPublication) {
ntcoreJNITaskList.each {
artifact it
}
artifactId = "${baseArtifactId}-jni"
groupId artifactGroupId
version pubVersion
}
}
}
}
// 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:ntcore')
if (!project.hasProperty('skipJava')) {
java(MavenPublication) {
artifact nat.jar
artifact nat.networktablesJavaSource
artifact nat.networktablesJavadoc
if (project.buildArm) {
def natArm = project('arm:ntcore')
artifact natArm.jar
// If the library is not embedded include it in the repo
if (!project.hasProperty('compilerPrefix')) {
artifact natArm.ntcoreZip
}
}
java(MavenPublication) {
artifact jar
artifact sourcesJar
artifact javadocJar
if (project.hasProperty('makeDesktop')) {
artifact nat.jar, {
classifier = 'desktop'
}
}
groupId 'edu.wpi.first.wpilib.networktables.java'
artifactId 'NetworkTables'
version ntVersion
}
}
cpp(MavenPublication) {
artifact nat.ntcoreZip
artifact ntcoreSourceZip
if (project.buildArm) {
artifact project(':arm:ntcore').ntcoreZip
}
if (project.hasProperty('makeDesktop')) {
artifact nat.ntcoreZip, {
classifier = 'desktop'
}
}
groupId 'edu.wpi.first.wpilib.networktables.cpp'
artifactId 'NetworkTables'
version ntVersion
}
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 utilVersion
artifactId = "${baseArtifactId}-java"
groupId artifactGroupId
version pubVersion
}
}
}

View File

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

View File

@@ -0,0 +1,9 @@
#include "ntcore.h"
#include "nt_Value.h"
#include <iostream>
int main() {
nt::SetEntryValue("MyValue", nt::Value::MakeString("Hello World"));
std::cout << nt::GetEntryValue("MyValue")->GetString() << std::endl;
}

View File

@@ -8,6 +8,7 @@ import java.io.OutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import edu.wpi.first.wpiutil.RuntimeDetector;
public class NetworkTablesJNI {
static boolean libraryLoaded = false;
@@ -18,19 +19,7 @@ public class NetworkTablesJNI {
System.loadLibrary("ntcore");
} 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 += "ntcore.dll";
else if (osname.startsWith("Mac"))
resname += "libntcore.dylib";
else
resname += "libntcore.so";
String resname = RuntimeDetector.getLibraryResource("ntcore");
InputStream is = NetworkTablesJNI.class.getResourceAsStream(resname);
if (is != null) {
// create temporary file

View File

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

View File

@@ -1,16 +0,0 @@
add_subdirectory(unit)
if(MSVC)
set(NTCORE_LIB ntcore_static)
else()
set(NTCORE_LIB ntcore)
endif()
add_executable(client client.cpp)
target_link_libraries(client ${NTCORE_LIB} ${CMAKE_THREAD_LIBS_INIT})
add_executable(server server.cpp)
target_link_libraries(server ${NTCORE_LIB} ${CMAKE_THREAD_LIBS_INIT})
add_executable(rpc_local rpc_local.cpp)
target_link_libraries(rpc_local ${NTCORE_LIB} ${CMAKE_THREAD_LIBS_INIT})
add_executable(rpc_speed rpc_speed.cpp)
target_link_libraries(rpc_speed ${NTCORE_LIB} ${CMAKE_THREAD_LIBS_INIT})

View File

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

View File

@@ -1,18 +0,0 @@
file(GLOB SRCS *.cpp)
add_executable(testntcore ${SRCS})
add_test(testntcore testntcore)
if(MSVC)
target_link_libraries(testntcore
ntcore_static
gmock
gtest
)
else()
target_link_libraries(testntcore
ntcore
gmock
gtest
)
endif()

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,33 +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 ->
}

View File

@@ -1,119 +0,0 @@
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("wpiutilZip", Zip) {
description = 'Creates platform-specific zip of the desktop wpiutil libraries.'
group = 'WPILib'
destinationDir = project.buildDir
baseName = 'wpiutil'
if (project.isArm && project.hasProperty('compilerPrefix')
&& project.hasProperty('armSuffix')) {
classifier = "${project.buildPlatform}${project.armSuffix}"
} else {
classifier = "${project.buildPlatform}"
}
duplicatesStrategy = 'exclude'
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)
}
from(new File(binary.sharedLibraryFile.absolutePath + ".debug")) {
into getPlatformPath(binary)
}
}
}
}
}
project.build.dependsOn project.wpiutilZip
project.debugStripSetup()
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'
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"
duplicatesStrategy = 'exclude'
from('wpiutil/src') {
into 'src'
}
from('wpiutil/include') {
into 'include'
}
}

View File

@@ -1,259 +0,0 @@
//===--- AlignOf.h - Portable calculation of type alignment -----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the AlignOf function that computes alignments for
// arbitrary types.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_SUPPORT_ALIGNOF_H
#define LLVM_SUPPORT_ALIGNOF_H
#include "llvm/Compiler.h"
#include <cstddef>
#include <type_traits>
namespace llvm {
namespace detail {
// For everything other than an abstract class we can calulate alignment by
// building a class with a single character and a member of the given type.
template <typename T, bool = std::is_abstract<T>::value>
struct AlignmentCalcImpl {
char x;
#if defined(_MSC_VER)
// Disables "structure was padded due to __declspec(align())" warnings that are
// generated by any class using AlignOf<T> with a manually specified alignment.
// Although the warning is disabled in the LLVM project we need this pragma
// as AlignOf.h is a published support header that's available for use
// out-of-tree, and we would like that to compile cleanly at /W4.
#pragma warning(suppress : 4324)
#endif
T t;
private:
AlignmentCalcImpl() = delete;
};
// Abstract base class helper, this will have the minimal alignment and size
// for any abstract class. We don't even define its destructor because this
// type should never be used in a way that requires it.
struct AlignmentCalcImplBase {
virtual ~AlignmentCalcImplBase() = 0;
};
// When we have an abstract class type, specialize the alignment computation
// engine to create another abstract class that derives from both an empty
// abstract base class and the provided type. This has the same effect as the
// above except that it handles the fact that we can't actually create a member
// of type T.
template <typename T>
struct AlignmentCalcImpl<T, true> : AlignmentCalcImplBase, T {
~AlignmentCalcImpl() override = 0;
};
} // End detail namespace.
/// AlignOf - A templated class that contains an enum value representing
/// the alignment of the template argument. For example,
/// AlignOf<int>::Alignment represents the alignment of type "int". The
/// alignment calculated is the minimum alignment, and not necessarily
/// the "desired" alignment returned by GCC's __alignof__ (for example). Note
/// that because the alignment is an enum value, it can be used as a
/// compile-time constant (e.g., for template instantiation).
template <typename T>
struct AlignOf {
#ifndef _MSC_VER
// Avoid warnings from GCC like:
// comparison between 'enum llvm::AlignOf<X>::<anonymous>' and 'enum
// llvm::AlignOf<Y>::<anonymous>' [-Wenum-compare]
// by using constexpr instead of enum.
// (except on MSVC, since it doesn't support constexpr yet).
static constexpr unsigned Alignment = static_cast<unsigned int>(
sizeof(detail::AlignmentCalcImpl<T>) - sizeof(T));
#else
enum {
Alignment = static_cast<unsigned int>(
sizeof(::llvm::detail::AlignmentCalcImpl<T>) - sizeof(T))
};
#endif
enum { Alignment_GreaterEqual_2Bytes = Alignment >= 2 ? 1 : 0 };
enum { Alignment_GreaterEqual_4Bytes = Alignment >= 4 ? 1 : 0 };
enum { Alignment_GreaterEqual_8Bytes = Alignment >= 8 ? 1 : 0 };
enum { Alignment_GreaterEqual_16Bytes = Alignment >= 16 ? 1 : 0 };
enum { Alignment_LessEqual_2Bytes = Alignment <= 2 ? 1 : 0 };
enum { Alignment_LessEqual_4Bytes = Alignment <= 4 ? 1 : 0 };
enum { Alignment_LessEqual_8Bytes = Alignment <= 8 ? 1 : 0 };
enum { Alignment_LessEqual_16Bytes = Alignment <= 16 ? 1 : 0 };
};
#ifndef _MSC_VER
template <typename T> constexpr unsigned AlignOf<T>::Alignment;
#endif
/// alignOf - A templated function that returns the minimum alignment of
/// of a type. This provides no extra functionality beyond the AlignOf
/// class besides some cosmetic cleanliness. Example usage:
/// alignOf<int>() returns the alignment of an int.
template <typename T>
inline unsigned alignOf() { return AlignOf<T>::Alignment; }
/// \struct AlignedCharArray
/// \brief Helper for building an aligned character array type.
///
/// This template is used to explicitly build up a collection of aligned
/// character array types. We have to build these up using a macro and explicit
/// specialization to cope with old versions of MSVC and GCC where only an
/// integer literal can be used to specify an alignment constraint. Once built
/// up here, we can then begin to indirect between these using normal C++
/// template parameters.
// MSVC requires special handling here.
#ifndef _MSC_VER
#if __has_feature(cxx_alignas)
template<std::size_t Alignment, std::size_t Size>
struct AlignedCharArray {
alignas(Alignment) char buffer[Size];
};
#elif defined(__GNUC__) || defined(__IBM_ATTRIBUTES)
/// \brief Create a type with an aligned char buffer.
template<std::size_t Alignment, std::size_t Size>
struct AlignedCharArray;
#define LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(x) \
template<std::size_t Size> \
struct AlignedCharArray<x, Size> { \
__attribute__((aligned(x))) char buffer[Size]; \
};
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(1)
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(2)
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(4)
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(8)
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(16)
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(32)
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(64)
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(128)
#undef LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT
#else
# error No supported align as directive.
#endif
#else // _MSC_VER
/// \brief Create a type with an aligned char buffer.
template<std::size_t Alignment, std::size_t Size>
struct AlignedCharArray;
// We provide special variations of this template for the most common
// alignments because __declspec(align(...)) doesn't actually work when it is
// a member of a by-value function argument in MSVC, even if the alignment
// request is something reasonably like 8-byte or 16-byte. Note that we can't
// even include the declspec with the union that forces the alignment because
// MSVC warns on the existence of the declspec despite the union member forcing
// proper alignment.
template<std::size_t Size>
struct AlignedCharArray<1, Size> {
union {
char aligned;
char buffer[Size];
};
};
template<std::size_t Size>
struct AlignedCharArray<2, Size> {
union {
short aligned;
char buffer[Size];
};
};
template<std::size_t Size>
struct AlignedCharArray<4, Size> {
union {
int aligned;
char buffer[Size];
};
};
template<std::size_t Size>
struct AlignedCharArray<8, Size> {
union {
double aligned;
char buffer[Size];
};
};
// The rest of these are provided with a __declspec(align(...)) and we simply
// can't pass them by-value as function arguments on MSVC.
#define LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(x) \
template<std::size_t Size> \
struct AlignedCharArray<x, Size> { \
__declspec(align(x)) char buffer[Size]; \
};
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(16)
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(32)
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(64)
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(128)
#undef LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT
#endif // _MSC_VER
namespace detail {
template <typename T1,
typename T2 = char, typename T3 = char, typename T4 = char,
typename T5 = char, typename T6 = char, typename T7 = char,
typename T8 = char, typename T9 = char, typename T10 = char>
class AlignerImpl {
T1 t1; T2 t2; T3 t3; T4 t4; T5 t5; T6 t6; T7 t7; T8 t8; T9 t9; T10 t10;
AlignerImpl() = delete;
};
template <typename T1,
typename T2 = char, typename T3 = char, typename T4 = char,
typename T5 = char, typename T6 = char, typename T7 = char,
typename T8 = char, typename T9 = char, typename T10 = char>
union SizerImpl {
char arr1[sizeof(T1)], arr2[sizeof(T2)], arr3[sizeof(T3)], arr4[sizeof(T4)],
arr5[sizeof(T5)], arr6[sizeof(T6)], arr7[sizeof(T7)], arr8[sizeof(T8)],
arr9[sizeof(T9)], arr10[sizeof(T10)];
};
} // end namespace detail
/// \brief This union template exposes a suitably aligned and sized character
/// array member which can hold elements of any of up to ten types.
///
/// These types may be arrays, structs, or any other types. The goal is to
/// expose a char array buffer member which can be used as suitable storage for
/// a placement new of any of these types. Support for more than ten types can
/// be added at the cost of more boilerplate.
template <typename T1,
typename T2 = char, typename T3 = char, typename T4 = char,
typename T5 = char, typename T6 = char, typename T7 = char,
typename T8 = char, typename T9 = char, typename T10 = char>
struct AlignedCharArrayUnion : llvm::AlignedCharArray<
AlignOf<llvm::detail::AlignerImpl<T1, T2, T3, T4, T5,
T6, T7, T8, T9, T10> >::Alignment,
sizeof(::llvm::detail::SizerImpl<T1, T2, T3, T4, T5,
T6, T7, T8, T9, T10>)> {
};
} // end namespace llvm
#endif // LLVM_SUPPORT_ALIGNOF_H

Some files were not shown because too many files have changed in this diff Show More