From a8aacd365775895557982b49b25c3eb7149bcfa7 Mon Sep 17 00:00:00 2001 From: Thad House Date: Sat, 27 Oct 2018 00:19:38 -0700 Subject: [PATCH] Update build setup for raspbian and debug binaries (#1384) - Build both debug and release binaries - Append "d" to debug libraries in the style of opencv - Split shared and static classifiers - Add raspbian support --- azure-pipelines.yml | 21 +++ build.gradle | 12 +- buildSrc/src/main/groovy/MultiBuilds.groovy | 95 ++++++++++++++ .../src/main/groovy/SingleNativeBuild.groovy | 5 +- cameraserver/CMakeLists.txt | 1 + cscore/CMakeLists.txt | 122 +++++++++--------- cscore/build.gradle | 21 +-- .../java/edu/wpi/cscore/CameraServerJNI.java | 2 +- hal/CMakeLists.txt | 118 +++++++++-------- hal/build.gradle | 63 ++++++--- .../java/edu/wpi/first/hal/JNIWrapper.java | 2 +- myRobot/build.gradle | 2 + ntcore/CMakeLists.txt | 75 ++++++----- ntcore/build.gradle | 20 --- .../first/networktables/NetworkTablesJNI.java | 2 +- shared/config.gradle | 117 +++++++++++++---- shared/googletest.gradle | 2 +- shared/java/javacommon.gradle | 2 +- shared/javacpp/publish.gradle | 11 +- shared/javacpp/setupBuild.gradle | 4 +- shared/jni/publish.gradle | 13 +- shared/jni/setupBuild.gradle | 70 +++++++--- shared/nilibraries.gradle | 4 +- shared/opencv.gradle | 8 +- shared/plugins/publish.gradle | 11 +- shared/plugins/setupBuild.gradle | 18 ++- simulation/frc_gazebo_plugins/build.gradle | 1 + .../build.gradle | 21 +-- .../publish.gradle | 12 +- simulation/halsim_ds_socket/build.gradle | 2 +- .../src/main/native/cpp/DSCommPacket.cpp | 6 +- simulation/lowfi_simulation/build.gradle | 3 +- simulation/lowfi_simulation/publish.gradle | 12 +- wpilibc/CMakeLists.txt | 1 + wpilibc/build.gradle | 4 +- wpilibc/publish.gradle | 12 +- wpilibcExamples/build.gradle | 2 + wpilibcIntegrationTests/build.gradle | 4 + wpilibj/build.gradle | 5 + wpiutil/CMakeLists.txt | 1 + wpiutil/build.gradle | 1 + 41 files changed, 565 insertions(+), 343 deletions(-) create mode 100644 buildSrc/src/main/groovy/MultiBuilds.groovy diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 914a02efd5..c1d6e3f8f5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,6 +7,8 @@ resources: containers: - container: wpilib2019 image: wpilib/roborio-cross-ubuntu:2019-18.04 + - container: raspbian + image: wpilib/raspbian-cross-ubuntu:18.04 jobs: - job: Linux_Arm @@ -28,6 +30,25 @@ jobs: # checkStyleRunAnalysis: true # pmdRunAnalysis: true + - job: Linux_Raspbian + pool: + vmImage: 'Ubuntu 16.04' + + container: raspbian + + steps: + - task: Gradle@2 + inputs: + workingDirectory: '' + gradleWrapperFile: 'gradlew' + gradleOptions: '-Xmx3072m' + publishJUnitResults: true + testResultsFiles: '**/TEST-*.xml' + tasks: 'build' + options: '-PonlyRaspbian' + # checkStyleRunAnalysis: true + # pmdRunAnalysis: true + - job: Linux pool: vmImage: 'Ubuntu 16.04' diff --git a/build.gradle b/build.gradle index 9ae5ce0570..2d0d56a4b9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,9 +1,9 @@ plugins { id 'base' id 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin' version '2.2' - id 'edu.wpi.first.NativeUtils' version '1.7.7' - id 'edu.wpi.first.GradleJni' version '0.3.0' - id 'edu.wpi.first.GradleVsCode' version '0.4.2' + id 'edu.wpi.first.NativeUtils' version '2.0.1' + id 'edu.wpi.first.GradleJni' version '0.3.1' + id 'edu.wpi.first.GradleVsCode' version '0.6.1' id 'idea' id 'com.gradle.build-scan' version '1.15.1' id 'net.ltgt.errorprone' version '0.6' apply false @@ -77,6 +77,12 @@ subprojects { apply plugin: 'eclipse' apply plugin: 'idea' + def subproj = it + + plugins.withType(NativeComponentPlugin) { + subproj.apply plugin: MultiBuilds + } + apply from: "${rootDir}/shared/java/javastyle.gradle" repositories { diff --git a/buildSrc/src/main/groovy/MultiBuilds.groovy b/buildSrc/src/main/groovy/MultiBuilds.groovy new file mode 100644 index 0000000000..aa1a225e16 --- /dev/null +++ b/buildSrc/src/main/groovy/MultiBuilds.groovy @@ -0,0 +1,95 @@ + +import org.gradle.api.GradleException; +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.Task; +import org.gradle.api.file.FileTree; +import org.gradle.api.tasks.compile.JavaCompile; +import org.gradle.language.base.internal.ProjectLayout; +import org.gradle.language.base.plugins.ComponentModelBasePlugin; +import org.gradle.language.nativeplatform.tasks.AbstractNativeSourceCompileTask; +import org.gradle.model.ModelMap; +import org.gradle.model.Mutate; +import org.gradle.nativeplatform.test.googletest.GoogleTestTestSuiteBinarySpec; +import org.gradle.model.RuleSource; +import org.gradle.model.Validate; +import org.gradle.nativeplatform.NativeExecutableBinarySpec +import org.gradle.nativeplatform.NativeBinarySpec; +import org.gradle.nativeplatform.NativeComponentSpec; +import org.gradle.nativeplatform.NativeLibrarySpec; +import org.gradle.nativeplatform.SharedLibraryBinarySpec; +import org.gradle.nativeplatform.StaticLibraryBinarySpec; +import org.gradle.nativeplatform.platform.internal.NativePlatformInternal; +import org.gradle.nativeplatform.toolchain.NativeToolChain; +import org.gradle.nativeplatform.toolchain.NativeToolChainRegistry; +import org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider; +import org.gradle.nativeplatform.toolchain.internal.ToolType; +import org.gradle.nativeplatform.toolchain.internal.gcc.AbstractGccCompatibleToolChain; +import org.gradle.nativeplatform.toolchain.internal.msvcpp.VisualCppToolChain; +import org.gradle.nativeplatform.toolchain.internal.tools.ToolRegistry; +import org.gradle.platform.base.BinarySpec; +import org.gradle.platform.base.ComponentSpec; +import org.gradle.platform.base.ComponentSpecContainer; +import org.gradle.platform.base.BinaryContainer; +import org.gradle.platform.base.ComponentType; +import org.gradle.platform.base.TypeBuilder; +import org.gradle.nativeplatform.tasks.ObjectFilesToBinary; +import groovy.transform.CompileStatic; +import groovy.transform.CompileDynamic +import org.gradle.nativeplatform.BuildTypeContainer + +@CompileStatic +class MultiBuilds implements Plugin { + @CompileStatic + public void apply(Project project) { + + } + + @CompileStatic + static class Rules extends RuleSource { + @Mutate + void setupBuildTypes(BuildTypeContainer buildTypes, ProjectLayout projectLayout) { + def project = (Project) projectLayout.projectIdentifier + if (project.hasProperty('releaseBuild')) { + buildTypes.create('debug') + } else { + buildTypes.create('release') + } + } + + @CompileDynamic + private static void setBuildableFalseDynamically(NativeBinarySpec binary) { + binary.buildable = false + } + + @Mutate + @CompileStatic + void disableReleaseGoogleTest(BinaryContainer binaries, ProjectLayout projectLayout) { + def project = (Project) projectLayout.projectIdentifier + if (project.hasProperty('testRelease')) { + return + } + binaries.withType(GoogleTestTestSuiteBinarySpec) { oSpec -> + GoogleTestTestSuiteBinarySpec spec = (GoogleTestTestSuiteBinarySpec) oSpec + if (spec.buildType.name == 'release') { + Rules.setBuildableFalseDynamically(spec) + } + } + // def crossCompileConfigs = [] + // for (BuildConfig config : configs) { + // if (!BuildConfigRulesBase.isCrossCompile(config)) { + // continue + // } + // crossCompileConfigs << config.architecture + // } + // if (!crossCompileConfigs.empty) { + // binaries.withType(GoogleTestTestSuiteBinarySpec) { oSpec -> + // GoogleTestTestSuiteBinarySpec spec = (GoogleTestTestSuiteBinarySpec) oSpec + // if (crossCompileConfigs.contains(spec.targetPlatform.architecture.name)) { + // setBuildableFalseDynamically(spec) + // } + // } + // } + } + } +} diff --git a/buildSrc/src/main/groovy/SingleNativeBuild.groovy b/buildSrc/src/main/groovy/SingleNativeBuild.groovy index 07db326787..0f2a287d91 100644 --- a/buildSrc/src/main/groovy/SingleNativeBuild.groovy +++ b/buildSrc/src/main/groovy/SingleNativeBuild.groovy @@ -62,7 +62,7 @@ class SingleNativeBuild implements Plugin { components.each { component -> if (component.name == "${nativeName}Base") { base = (NativeLibrarySpec) component - } else if (component.name == "${nativeName}" || component.name == "${nativeName}JNI") { + } else if (component.name == "${nativeName}") { subs << component } } @@ -79,7 +79,8 @@ class SingleNativeBuild implements Plugin { } def tmpBaseBin = (NativeBinarySpec) oTmpBaseBin if (tmpBaseBin.targetPlatform.operatingSystem.name == binary.targetPlatform.operatingSystem.name && - tmpBaseBin.targetPlatform.architecture.name == binary.targetPlatform.architecture.name) { + tmpBaseBin.targetPlatform.architecture.name == binary.targetPlatform.architecture.name && + tmpBaseBin.buildType == binary.buildType) { baseBin = tmpBaseBin } } diff --git a/cameraserver/CMakeLists.txt b/cameraserver/CMakeLists.txt index 5d5e9c69cf..a2fd0ba95b 100644 --- a/cameraserver/CMakeLists.txt +++ b/cameraserver/CMakeLists.txt @@ -28,6 +28,7 @@ endif() file(GLOB_RECURSE cameraserver_native_src src/main/native/cpp/*.cpp) add_library(cameraserver ${cameraserver_native_src}) +set_target_properties(cameraserver PROPERTIES DEBUG_POSTFIX "d") target_include_directories(cameraserver PUBLIC $ $) diff --git a/cscore/CMakeLists.txt b/cscore/CMakeLists.txt index 31fb2f27f6..f01f4f6880 100644 --- a/cscore/CMakeLists.txt +++ b/cscore/CMakeLists.txt @@ -4,6 +4,57 @@ include(SubDirList) find_package( OpenCV REQUIRED ) +file(GLOB + cscore_native_src src/main/native/cpp/*.cpp) +file(GLOB cscore_linux_src src/main/native/linux/*.cpp) +file(GLOB cscore_osx_src src/main/native/osx/*.cpp) +file(GLOB cscore_windows_src src/main/native/windows/*.cpp) + +add_library(cscore ${cscore_native_src}) +set_target_properties(cscore PROPERTIES DEBUG_POSTFIX "d") + +if(NOT MSVC) + if (APPLE) + target_sources(cscore PRIVATE ${cscore_osx_src}) + else() + target_sources(cscore PRIVATE ${cscore_linux_src}) + endif() + target_compile_options(cscore PRIVATE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE) +else() + target_sources(cscore PRIVATE ${cscore_windows_src}) + target_compile_options(cscore PUBLIC -DNOMINMAX) + target_compile_options(cscore PRIVATE -D_CRT_SECURE_NO_WARNINGS) +endif() + +target_include_directories(cscore PUBLIC + $ + $) +target_include_directories(cscore PRIVATE src/main/native/cpp) +target_link_libraries(cscore PUBLIC wpiutil ${OpenCV_LIBS}) + +set_property(TARGET cscore PROPERTY FOLDER "libraries") + +install(TARGETS cscore EXPORT cscore DESTINATION "${main_lib_dest}") +install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/cscore") + +if (MSVC) + set (cscore_config_dir ${wpilib_dest}) +else() + set (cscore_config_dir share/cscore) +endif() + +install(FILES cscore-config.cmake DESTINATION ${cscore_config_dir}) +install(EXPORT cscore DESTINATION ${cscore_config_dir}) + +SUBDIR_LIST(cscore_examples "${CMAKE_CURRENT_SOURCE_DIR}/examples") +foreach(example ${cscore_examples}) + file(GLOB cscore_example_src examples/${example}/*.cpp) + if(cscore_example_src) + add_executable(cscore_${example} ${cscore_example_src}) + target_link_libraries(cscore_${example} cscore) + endif() +endforeach() + # Java bindings if (NOT WITHOUT_JAVA) find_package(Java REQUIRED) @@ -50,68 +101,23 @@ if (NOT WITHOUT_JAVA) set_property(TARGET cscore_jar PROPERTY FOLDER "java") -endif() + add_library(cscorejni ${cscore_jni_src}) + target_link_libraries(cscorejni PUBLIC cscore wpiutil ${OpenCV_LIBS}) -file(GLOB - cscore_native_src src/main/native/cpp/*.cpp) -file(GLOB cscore_linux_src src/main/native/linux/*.cpp) -file(GLOB cscore_osx_src src/main/native/osx/*.cpp) -file(GLOB cscore_windows_src src/main/native/windows/*.cpp) + set_property(TARGET cscorejni PROPERTY FOLDER "libraries") -add_library(cscore ${cscore_native_src} ${cscore_jni_src}) - -if(NOT MSVC) - if (APPLE) - target_sources(cscore PRIVATE ${cscore_osx_src}) - else() - target_sources(cscore PRIVATE ${cscore_linux_src}) - endif() - target_compile_options(cscore PRIVATE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE) -else() - target_sources(cscore PRIVATE ${cscore_windows_src}) - target_compile_options(cscore PUBLIC -DNOMINMAX) - target_compile_options(cscore PRIVATE -D_CRT_SECURE_NO_WARNINGS) -endif() - -target_include_directories(cscore PUBLIC - $ - $) -target_include_directories(cscore PRIVATE src/main/native/cpp) -target_link_libraries(cscore PUBLIC wpiutil ${OpenCV_LIBS}) - -set_property(TARGET cscore PROPERTY FOLDER "libraries") - -if (NOT WITHOUT_JAVA) if(${CMAKE_VERSION} VERSION_LESS "3.11.0") - target_include_directories(cscore PRIVATE ${JNI_INCLUDE_DIRS}) - target_include_directories(cscore PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/jniheaders") + target_include_directories(cscorejni PRIVATE ${JNI_INCLUDE_DIRS}) + target_include_directories(cscorejni PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/jniheaders") else() - target_link_libraries(cscore PRIVATE cscore_jni_headers) + target_link_libraries(cscorejni PRIVATE cscore_jni_headers) endif() - add_dependencies(cscore cscore_jar) -endif() + add_dependencies(cscorejni cscore_jar) -install(TARGETS cscore EXPORT cscore DESTINATION "${main_lib_dest}") -install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/cscore") - -if (NOT WITHOUT_JAVA AND MSVC) - install(TARGETS cscore RUNTIME DESTINATION "${jni_lib_dest}" COMPONENT Runtime) -endif() - -if (MSVC) - set (cscore_config_dir ${wpilib_dest}) -else() - set (cscore_config_dir share/cscore) -endif() - -install(FILES cscore-config.cmake DESTINATION ${cscore_config_dir}) -install(EXPORT cscore DESTINATION ${cscore_config_dir}) - -SUBDIR_LIST(cscore_examples "${CMAKE_CURRENT_SOURCE_DIR}/examples") -foreach(example ${cscore_examples}) - file(GLOB cscore_example_src examples/${example}/*.cpp) - if(cscore_example_src) - add_executable(cscore_${example} ${cscore_example_src}) - target_link_libraries(cscore_${example} cscore) + if (MSVC) + install(TARGETS cscorejni RUNTIME DESTINATION "${jni_lib_dest}" COMPONENT Runtime) endif() -endforeach() + + install(TARGETS cscorejni EXPORT cscorejni DESTINATION "${main_lib_dest}") + +endif() diff --git a/cscore/build.gradle b/cscore/build.gradle index 6dda16ea3e..da49ac1ab0 100644 --- a/cscore/build.gradle +++ b/cscore/build.gradle @@ -102,30 +102,11 @@ model { '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', '_TI5?AVfailure'] } - cscoreJNI(ExportsConfig) { - x86SymbolFilter = { symbols -> - def retList = [] - symbols.each { symbol -> - if (symbol.startsWith('CS_') || symbol.startsWith('Java_') || symbol.startsWith('JNI_')) { - retList << symbol - } - } - return retList - } - x64SymbolFilter = { symbols -> - def retList = [] - symbols.each { symbol -> - if (symbol.startsWith('CS_') || symbol.startsWith('Java_') || symbol.startsWith('JNI_')) { - retList << symbol - } - } - return retList - } - } } components { examplesMap.each { key, value -> "${key}"(NativeExecutableSpec) { + targetBuildTypes 'debug' binaries.all { lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' lib library: 'cscore', linkage: 'shared' diff --git a/cscore/src/main/java/edu/wpi/cscore/CameraServerJNI.java b/cscore/src/main/java/edu/wpi/cscore/CameraServerJNI.java index 2d67f3dee4..4408f52ae0 100644 --- a/cscore/src/main/java/edu/wpi/cscore/CameraServerJNI.java +++ b/cscore/src/main/java/edu/wpi/cscore/CameraServerJNI.java @@ -24,7 +24,7 @@ public class CameraServerJNI { static { if (!libraryLoaded) { try { - loader = new RuntimeLoader<>("cscore", RuntimeLoader.getDefaultExtractionRoot(), CameraServerJNI.class); + loader = new RuntimeLoader<>("cscorejni", RuntimeLoader.getDefaultExtractionRoot(), CameraServerJNI.class); loader.loadLibrary(); } catch (IOException ex) { ex.printStackTrace(); diff --git a/hal/CMakeLists.txt b/hal/CMakeLists.txt index d43888a2d5..7213c238de 100644 --- a/hal/CMakeLists.txt +++ b/hal/CMakeLists.txt @@ -22,6 +22,47 @@ endforeach() string(REPLACE ";" "\n" usage_reporting_types_cpp "${usage_reporting_types_cpp}") string(REPLACE ";" "\n" usage_reporting_instances_cpp "${usage_reporting_instances_cpp}") +file(GLOB + hal_shared_native_src src/main/native/cpp/cpp/*.cpp + hal_shared_native_src src/main/native/cpp/handles/*.cpp + hal_sim_native_src src/main/native/sim/*.cpp + hal_sim_native_src src/main/native/sim/MockData/*.cpp) +add_library(hal ${hal_shared_native_src}) +set_target_properties(hal PROPERTIES DEBUG_POSTFIX "d") + +if(USE_EXTERNAL_HAL) + include(${EXTERNAL_HAL_FILE}) +else() + target_sources(hal PRIVATE ${hal_sim_native_src} ${hal_sim_jni_src}) +endif() + +configure_file(src/generate/FRCUsageReporting.h.in gen/hal/FRCUsageReporting.h) + +set_target_properties(hal PROPERTIES OUTPUT_NAME "wpiHal") + +target_include_directories(hal PUBLIC + $ + $) + +target_include_directories(hal PUBLIC + $ + $) +target_link_libraries(hal PUBLIC wpiutil) + +set_property(TARGET hal PROPERTY FOLDER "libraries") + +install(TARGETS hal EXPORT hal DESTINATION "${main_lib_dest}") +install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/hal") +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gen DESTINATION "${include_dest}/hal") + +if (MSVC) + set (hal_config_dir ${wpilib_dest}) +else() + set (hal_config_dir share/hal) +endif() + +install(FILES hal-config.cmake DESTINATION ${hal_config_dir}) +install(EXPORT hal DESTINATION ${hal_config_dir}) # Java bindings if (NOT WITHOUT_JAVA) @@ -53,59 +94,32 @@ if (NOT WITHOUT_JAVA) set_property(TARGET hal_jar PROPERTY FOLDER "java") -endif() + add_library(haljni ${hal_shared_jni_src}) -file(GLOB - hal_shared_native_src src/main/native/cpp/cpp/*.cpp - hal_shared_native_src src/main/native/cpp/handles/*.cpp - hal_sim_native_src src/main/native/sim/*.cpp - hal_sim_native_src src/main/native/sim/MockData/*.cpp) -add_library(hal ${hal_shared_native_src} ${hal_shared_jni_src}) - -if(USE_EXTERNAL_HAL) - include(${EXTERNAL_HAL_FILE}) -else() - target_sources(hal PRIVATE ${hal_sim_native_src} ${hal_sim_jni_src}) -endif() - -configure_file(src/generate/FRCUsageReporting.h.in gen/hal/FRCUsageReporting.h) - -set_target_properties(hal PROPERTIES OUTPUT_NAME "wpiHal") - -target_include_directories(hal PUBLIC - $ - $) - -target_include_directories(hal PUBLIC - $ - $) -target_link_libraries(hal PUBLIC wpiutil) - -set_property(TARGET hal PROPERTY FOLDER "libraries") - -if (NOT WITHOUT_JAVA) - if(${CMAKE_VERSION} VERSION_LESS "3.11.0") - target_include_directories(hal PRIVATE ${JNI_INCLUDE_DIRS}) - target_include_directories(hal PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/jniheaders") + if(USE_EXTERNAL_HAL) + include(${EXTERNAL_HAL_FILE}) else() - target_link_libraries(hal PRIVATE hal_jni_headers) + target_sources(haljni PRIVATE ${hal_sim_jni_src}) endif() - add_dependencies(hal hal_jar) + + set_target_properties(haljni PROPERTIES OUTPUT_NAME "wpiHaljni") + + target_link_libraries(haljni PUBLIC hal wpiutil) + + set_property(TARGET haljni PROPERTY FOLDER "libraries") + + if(${CMAKE_VERSION} VERSION_LESS "3.11.0") + target_include_directories(haljni PRIVATE ${JNI_INCLUDE_DIRS}) + target_include_directories(haljni PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/jniheaders") + else() + target_link_libraries(haljni PRIVATE hal_jni_headers) + endif() + add_dependencies(haljni hal_jar) + + if (MSVC) + install(TARGETS haljni RUNTIME DESTINATION "${jni_lib_dest}" COMPONENT Runtime) + endif() + + install(TARGETS haljni EXPORT haljni DESTINATION "${main_lib_dest}") + endif() - -install(TARGETS hal EXPORT hal DESTINATION "${main_lib_dest}") -install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/hal") -install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gen DESTINATION "${include_dest}/hal") - -if (NOT WITHOUT_JAVA AND MSVC) - install(TARGETS hal RUNTIME DESTINATION "${jni_lib_dest}" COMPONENT Runtime) -endif() - -if (MSVC) - set (hal_config_dir ${wpilib_dest}) -else() - set (hal_config_dir share/hal) -endif() - -install(FILES hal-config.cmake DESTINATION ${hal_config_dir}) -install(EXPORT hal DESTINATION ${hal_config_dir}) diff --git a/hal/build.gradle b/hal/build.gradle index 824c704e5a..af681a9b97 100644 --- a/hal/build.gradle +++ b/hal/build.gradle @@ -51,11 +51,50 @@ ext { binary.lib project: ':hal', library: 'hal', linkage: shared } + addHalJniDependency = { binary-> + binary.tasks.withType(AbstractNativeSourceCompileTask) { + it.dependsOn generateUsageReporting + } + binary.lib project: ':hal', library: 'halJNIShared', linkage: 'shared' + } + nativeName = 'hal' setBaseName = 'wpiHal' devMain = 'DevMain' niLibraries = true generatedHeaders = "$buildDir/generated/headers" + jniSplitSetup = { + it.tasks.withType(AbstractNativeSourceCompileTask) { + it.dependsOn generateUsageReporting + } + if (it.targetPlatform.architecture.name == 'athena') { + it.sources { + athenaJniCpp(CppSourceSet) { + source { + srcDirs = ["${rootDir}/shared/singlelib", "$buildDir/generated/cpp"] + include '**/*.cpp' + } + exportedHeaders { + srcDir 'src/main/native/include' + srcDir generatedHeaders + } + } + } + } else { + it.sources { + simJniCpp(CppSourceSet) { + source { + srcDirs 'src/main/native/sim' + include '**/jni/*.cpp' + } + exportedHeaders { + srcDir 'src/main/native/include' + srcDir generatedHeaders + } + } + } + } + } splitSetup = { it.tasks.withType(AbstractNativeSourceCompileTask) { it.dependsOn generateUsageReporting @@ -64,8 +103,9 @@ ext { it.sources { athenaCpp(CppSourceSet) { source { - srcDirs = ['src/main/native/athena', "$buildDir/generated/cpp"] + srcDirs = ['src/main/native/athena'] include '**/*.cpp' + exclude '**/jni/*.cpp' } exportedHeaders { srcDir 'src/main/native/include' @@ -79,6 +119,7 @@ ext { source { srcDirs 'src/main/native/sim' include '**/*.cpp' + exclude '**/jni/*.cpp' } exportedHeaders { srcDir 'src/main/native/include' @@ -138,25 +179,5 @@ model { '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', '_TI5?AVfailure'] } - halJNI(ExportsConfig) { - x86SymbolFilter = { symbols -> - def retList = [] - symbols.each { symbol -> - if (symbol.startsWith('HAL_') || symbol.startsWith('Java_') || symbol.startsWith('JNI_')) { - retList << symbol - } - } - return retList - } - x64SymbolFilter = { symbols -> - def retList = [] - symbols.each { symbol -> - if (symbol.startsWith('HAL_') || symbol.startsWith('Java_') || symbol.startsWith('JNI_')) { - retList << symbol - } - } - return retList - } - } } } diff --git a/hal/src/main/java/edu/wpi/first/hal/JNIWrapper.java b/hal/src/main/java/edu/wpi/first/hal/JNIWrapper.java index 705e65c93b..21342bc9e5 100644 --- a/hal/src/main/java/edu/wpi/first/hal/JNIWrapper.java +++ b/hal/src/main/java/edu/wpi/first/hal/JNIWrapper.java @@ -21,7 +21,7 @@ public class JNIWrapper { static { if (!libraryLoaded) { try { - loader = new RuntimeLoader<>("wpiHal", RuntimeLoader.getDefaultExtractionRoot(), JNIWrapper.class); + loader = new RuntimeLoader<>("wpiHaljni", RuntimeLoader.getDefaultExtractionRoot(), JNIWrapper.class); loader.loadLibrary(); } catch (IOException ex) { ex.printStackTrace(); diff --git a/myRobot/build.gradle b/myRobot/build.gradle index c4fa398058..30dd721924 100644 --- a/myRobot/build.gradle +++ b/myRobot/build.gradle @@ -52,6 +52,7 @@ jar { model { components { myRobotCpp(NativeExecutableSpec) { + targetBuildTypes 'debug' baseName = 'FRCUserProgram' sources { cpp { @@ -75,6 +76,7 @@ model { } } myRobotCppStatic(NativeExecutableSpec) { + targetBuildTypes 'debug' baseName = 'FRCUserProgram' sources { cpp { diff --git a/ntcore/CMakeLists.txt b/ntcore/CMakeLists.txt index b92070fc0b..47e2264012 100644 --- a/ntcore/CMakeLists.txt +++ b/ntcore/CMakeLists.txt @@ -1,5 +1,29 @@ project(ntcore) +file(GLOB + ntcore_native_src src/main/native/cpp/*.cpp + ntcore_native_src src/main/native/cpp/networktables/*.cpp + ntcore_native_src src/main/native/cpp/tables/*.cpp) +add_library(ntcore ${ntcore_native_src}) +set_target_properties(ntcore PROPERTIES DEBUG_POSTFIX "d") +target_include_directories(ntcore PUBLIC + $ + $) +target_link_libraries(ntcore PUBLIC wpiutil) + +set_property(TARGET ntcore PROPERTY FOLDER "libraries") + +install(TARGETS ntcore EXPORT ntcore DESTINATION "${main_lib_dest}") +install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/ntcore") + +if (MSVC) + set (ntcore_config_dir ${wpilib_dest}) +else() + set (ntcore_config_dir share/ntcore) +endif() + +install(FILES ntcore-config.cmake DESTINATION ${ntcore_config_dir}) +install(EXPORT ntcore DESTINATION ${ntcore_config_dir}) # Java bindings if (NOT WITHOUT_JAVA) @@ -26,42 +50,23 @@ if (NOT WITHOUT_JAVA) set_property(TARGET ntcore_jar PROPERTY FOLDER "java") -endif() + add_library(ntcorejni ${ntcore_jni_src}) + target_link_libraries(ntcorejni PUBLIC ntcore wpiutil) -file(GLOB - ntcore_native_src src/main/native/cpp/*.cpp - ntcore_native_src src/main/native/cpp/networktables/*.cpp - ntcore_native_src src/main/native/cpp/tables/*.cpp) -add_library(ntcore ${ntcore_native_src} ${ntcore_jni_src}) -target_include_directories(ntcore PUBLIC - $ - $) -target_link_libraries(ntcore PUBLIC wpiutil) + set_property(TARGET ntcorejni PROPERTY FOLDER "libraries") -set_property(TARGET ntcore PROPERTY FOLDER "libraries") - -if (NOT WITHOUT_JAVA) - if(${CMAKE_VERSION} VERSION_LESS "3.11.0") - target_include_directories(ntcore PRIVATE ${JNI_INCLUDE_DIRS}) - target_include_directories(ntcore PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/jniheaders") - else() - target_link_libraries(ntcore PRIVATE ntcore_jni_headers) + if (MSVC) + install(TARGETS ntcorejni RUNTIME DESTINATION "${jni_lib_dest}" COMPONENT Runtime) endif() - add_dependencies(ntcore ntcore_jar) + + if(${CMAKE_VERSION} VERSION_LESS "3.11.0") + target_include_directories(ntcorejni PRIVATE ${JNI_INCLUDE_DIRS}) + target_include_directories(ntcorejni PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/jniheaders") + else() + target_link_libraries(ntcorejni PRIVATE ntcore_jni_headers) + endif() + add_dependencies(ntcorejni ntcore_jar) + + install(TARGETS ntcorejni EXPORT ntcorejni DESTINATION "${main_lib_dest}") + endif() - -install(TARGETS ntcore EXPORT ntcore DESTINATION "${main_lib_dest}") -install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/ntcore") - -if (NOT WITHOUT_JAVA AND MSVC) - install(TARGETS ntcore RUNTIME DESTINATION "${jni_lib_dest}" COMPONENT Runtime) -endif() - -if (MSVC) - set (ntcore_config_dir ${wpilib_dest}) -else() - set (ntcore_config_dir share/ntcore) -endif() - -install(FILES ntcore-config.cmake DESTINATION ${ntcore_config_dir}) -install(EXPORT ntcore DESTINATION ${ntcore_config_dir}) diff --git a/ntcore/build.gradle b/ntcore/build.gradle index 0d5d0b22f3..0166786861 100644 --- a/ntcore/build.gradle +++ b/ntcore/build.gradle @@ -21,26 +21,6 @@ model { '_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 - } - } } } diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTablesJNI.java b/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTablesJNI.java index 1a3f4fe9d3..1d736fc14d 100644 --- a/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTablesJNI.java +++ b/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTablesJNI.java @@ -19,7 +19,7 @@ public final class NetworkTablesJNI { static { if (!libraryLoaded) { try { - loader = new RuntimeLoader<>("ntcore", RuntimeLoader.getDefaultExtractionRoot(), NetworkTablesJNI.class); + loader = new RuntimeLoader<>("ntcorejni", RuntimeLoader.getDefaultExtractionRoot(), NetworkTablesJNI.class); loader.loadLibrary(); } catch (IOException ex) { ex.printStackTrace(); diff --git a/shared/config.gradle b/shared/config.gradle index 5f4a8cf31d..02c2b68799 100644 --- a/shared/config.gradle +++ b/shared/config.gradle @@ -1,19 +1,29 @@ import edu.wpi.first.nativeutils.* import org.gradle.internal.os.OperatingSystem -def windowsCompilerArgs = ['/EHsc', '/DNOMINMAX', '/Zi', '/FS', '/Zc:inline', '/MT'] -def windowsCCompilerArgs = ['/Zi', '/FS', '/Zc:inline', '/MT'] -def windowsReleaseCompilerArgs = ['/O2'] +def windowsCompilerArgs = ['/EHsc', '/DNOMINMAX', '/Zi', '/FS', '/Zc:inline', '/MP4'] +def windowsCCompilerArgs = ['/Zi', '/FS', '/Zc:inline'] +def windowsReleaseCompilerArgs = ['/O2', '/MD'] +def windowsDebugCompilerArgs = ['/Od', '/MDd'] def windowsLinkerArgs = ['/DEBUG:FULL'] def windowsReleaseLinkerArgs = ['/OPT:REF', '/OPT:ICF'] +def linuxCrossCompilerArgs = ['-std=c++14', '-Wformat=2', '-Wall', '-Wextra', '-Werror', '-pedantic', '-Wno-psabi', '-g', + '-Wno-unused-parameter', '-Wno-error=deprecated-declarations', '-fPIC', '-rdynamic', + '-pthread'] +def linuxCrossCCompilerArgs = ['-Wformat=2', '-Wall', '-Wextra', '-Werror', '-pedantic', '-Wno-psabi', '-g', + '-Wno-unused-parameter', '-fPIC', '-rdynamic', '-pthread'] +def linuxCrossLinkerArgs = ['-rdynamic', '-pthread', '-ldl'] +def linuxCrossReleaseCompilerArgs = ['-O2'] +def linuxCrossDebugCompilerArgs = ['-Og'] + def linuxCompilerArgs = ['-std=c++14', '-Wformat=2', '-Wall', '-Wextra', '-Werror', '-pedantic', '-Wno-psabi', '-g', '-Wno-unused-parameter', '-Wno-error=deprecated-declarations', '-fPIC', '-rdynamic', '-pthread'] def linuxCCompilerArgs = ['-Wformat=2', '-Wall', '-Wextra', '-Werror', '-pedantic', '-Wno-psabi', '-g', '-Wno-unused-parameter', '-fPIC', '-rdynamic', '-pthread'] def linuxLinkerArgs = ['-rdynamic', '-pthread', '-ldl'] -def linuxReleaseCompilerArgs = ['-Og'] +def linuxReleaseCompilerArgs = ['-O2'] def linuxDebugCompilerArgs = ['-O0'] def linux32BitArg = '-m32' @@ -98,26 +108,45 @@ def mac32PlatformDetect = { } } -if (!project.hasProperty('skipAthena')) { +if (!project.hasProperty('skipAthena') && !project.hasProperty('onlyRaspbian')) { model { buildConfigs { roboRio(CrossBuildConfig) { architecture = 'athena' operatingSystem = 'linux' toolChainPrefix = 'arm-frc2019-linux-gnueabi-' - compilerArgs = linuxCompilerArgs - CCompilerArgs = linuxCCompilerArgs - linkerArgs = linuxLinkerArgs - debugCompilerArgs = linuxDebugCompilerArgs - releaseCompilerArgs = linuxReleaseCompilerArgs - releaseStripBinaries = true + compilerArgs = linuxCrossCompilerArgs + CCompilerArgs = linuxCrossCCompilerArgs + linkerArgs = linuxCrossLinkerArgs + debugCompilerArgs = linuxCrossDebugCompilerArgs + releaseCompilerArgs = linuxCrossReleaseCompilerArgs + stripBuildTypes = ['debug', 'release'] compilerFamily = 'Gcc' } } } } -if (!project.hasProperty('onlyAthena')) { +if (!project.hasProperty('skipRaspbian') && !project.hasProperty('onlyAthena')) { + model { + buildConfigs { + raspbian(CrossBuildConfig) { + architecture = 'raspbian' + operatingSystem = 'linux' + toolChainPrefix = 'arm-raspbian9-linux-gnueabihf-' + compilerArgs = linuxCrossCompilerArgs + CCompilerArgs = linuxCrossCCompilerArgs + linkerArgs = linuxCrossLinkerArgs + debugCompilerArgs = linuxCrossDebugCompilerArgs + releaseCompilerArgs = linuxCrossReleaseCompilerArgs + stripBuildTypes = ['debug', 'release'] + compilerFamily = 'Gcc' + } + } + } +} + +if (!project.hasProperty('onlyAthena') && !hasProperty('onlyRaspbian')) { model { buildConfigs { winX86(BuildConfig) { @@ -128,6 +157,7 @@ if (!project.hasProperty('onlyAthena')) { linkerArgs = windowsLinkerArgs releaseCompilerArgs = windowsReleaseCompilerArgs releaseLinkerArgs = windowsReleaseLinkerArgs + debugCompilerArgs = windowsDebugCompilerArgs compilerFamily = 'VisualCpp' detectPlatform = windows32PlatformDetect } @@ -139,6 +169,7 @@ if (!project.hasProperty('onlyAthena')) { linkerArgs = windowsLinkerArgs releaseCompilerArgs = windowsReleaseCompilerArgs releaseLinkerArgs = windowsReleaseLinkerArgs + debugCompilerArgs = windowsDebugCompilerArgs compilerFamily = 'VisualCpp' detectPlatform = windows64PlatformDetect } @@ -150,7 +181,7 @@ if (!project.hasProperty('onlyAthena')) { linkerArgs = linuxLinkerArgs debugCompilerArgs = linuxDebugCompilerArgs releaseCompilerArgs = linuxReleaseCompilerArgs - releaseStripBinaries = true + stripBuildTypes = ['debug', 'release'] compilerFamily = 'Gcc' detectPlatform = linux64IntelPlatformDetect } @@ -182,7 +213,7 @@ if (project.hasProperty('linuxCross')) { linkerArgs = linuxLinkerArgs debugCompilerArgs = linuxDebugCompilerArgs releaseCompilerArgs = linuxReleaseCompilerArgs - releaseStripBinaries = true + stripBuildTypes = ['debug', 'release'] skipByDefault = true compilerFamily = 'Gcc' } @@ -199,7 +230,7 @@ if (project.hasProperty('linuxCross')) { linkerArgs = linuxLinkerArgs debugCompilerArgs = linuxDebugCompilerArgs releaseCompilerArgs = linuxReleaseCompilerArgs - releaseStripBinaries = true + stripBuildTypes = ['debug', 'release'] compilerFamily = 'Gcc' detectPlatform = linuxArmPlatformDetect } @@ -207,20 +238,56 @@ if (project.hasProperty('linuxCross')) { } } -ext.getClassifier = { binary -> - return NativeUtils.getClassifier(binary) +ext.getPublishClassifier = { binary -> + return NativeUtils.getPublishClassifier(binary) } ext.getPlatformPath = { binary -> return NativeUtils.getPlatformPath(binary) } -ext.createComponentZipTasks = { components, name, base, type, project, func -> +ext.appendDebugPathToBinaries = { binaries-> + binaries.withType(StaticLibraryBinarySpec) { + if (it.buildType.name.contains('debug')) { + def staticFileDir = it.staticLibraryFile.parentFile + def staticFileName = it.staticLibraryFile.name + def staticFileExtension = staticFileName.substring(staticFileName.lastIndexOf('.')) + staticFileName = staticFileName.substring(0, staticFileName.lastIndexOf('.')) + staticFileName = staticFileName + 'd' + staticFileExtension + def newStaticFile = new File(staticFileDir, staticFileName) + it.staticLibraryFile = newStaticFile + } + } + binaries.withType(SharedLibraryBinarySpec) { + if (it.buildType.name.contains('debug')) { + def sharedFileDir = it.sharedLibraryFile.parentFile + def sharedFileName = it.sharedLibraryFile.name + def sharedFileExtension = sharedFileName.substring(sharedFileName.lastIndexOf('.')) + sharedFileName = sharedFileName.substring(0, sharedFileName.lastIndexOf('.')) + sharedFileName = sharedFileName + 'd' + sharedFileExtension + def newSharedFile = new File(sharedFileDir, sharedFileName) + + def sharedLinkFileDir = it.sharedLibraryLinkFile.parentFile + def sharedLinkFileName = it.sharedLibraryLinkFile.name + def sharedLinkFileExtension = sharedLinkFileName.substring(sharedLinkFileName.lastIndexOf('.')) + sharedLinkFileName = sharedLinkFileName.substring(0, sharedLinkFileName.lastIndexOf('.')) + sharedLinkFileName = sharedLinkFileName + 'd' + sharedLinkFileExtension + def newLinkFile = new File(sharedLinkFileDir, sharedLinkFileName) + + it.sharedLibraryLinkFile = newLinkFile + it.sharedLibraryFile = newSharedFile + } + } +} + +ext.createComponentZipTasks = { components, names, base, type, project, func -> + def stringNames = names.collect {it.toString()} def configMap = [:] components.each { - if (it in NativeLibrarySpec && it.name == name) { + if (it in NativeLibrarySpec && stringNames.contains(it.name)) { it.binaries.each { - def target = getClassifier(it) + if (!it.buildable) return + def target = getPublishClassifier(it) if (configMap.containsKey(target)) { configMap.get(target).add(it) } else { @@ -260,14 +327,16 @@ ext.createComponentZipTasks = { components, name, base, type, project, func -> ext.createAllCombined = { list, name, base, type, project -> def outputsFolder = file("$project.buildDir/outputs") - def task = project.tasks.create(base + '-all', type) { - description = 'Creates component archive for all classifiers' + + def task = project.tasks.create(base + "-all", type) { + description = "Creates component archive for all classifiers" destinationDir = outputsFolder - classifier = 'all' + classifier = "all" baseName = base duplicatesStrategy = 'exclude' list.each { + if (it.name.endsWith('debug')) return from project.zipTree(it.archivePath) dependsOn it } @@ -303,7 +372,7 @@ ext.includeStandardZipFormat = { task, value -> task.from(binary.sharedLibraryLinkFile) { into getPlatformPath(binary) + '/shared' } - } else if (binary instanceof StaticLibraryBinarySpec) { + } else if (binary instanceof StaticLibraryBinarySpec) { task.dependsOn binary.tasks.createStaticLib task.from(binary.staticLibraryFile) { into getPlatformPath(binary) + '/static' diff --git a/shared/googletest.gradle b/shared/googletest.gradle index 7e11b6dc49..736d886e4c 100644 --- a/shared/googletest.gradle +++ b/shared/googletest.gradle @@ -5,7 +5,7 @@ model { artifactId = 'googletest' headerClassifier = 'headers' ext = 'zip' - version = '1.8.0-1-4e4df22' + version = '1.8.0-4-4e4df22' sharedConfigs = [:] staticConfigs = project.staticGtestConfigs } diff --git a/shared/java/javacommon.gradle b/shared/java/javacommon.gradle index 1830e4d101..abf3c2d20c 100644 --- a/shared/java/javacommon.gradle +++ b/shared/java/javacommon.gradle @@ -87,7 +87,7 @@ test { } } -if (project.hasProperty('onlyAthena')) { +if (project.hasProperty('onlyAthena') || project.hasProperty('onlyRaspbian')) { test.enabled = false } diff --git a/shared/javacpp/publish.gradle b/shared/javacpp/publish.gradle index 1c945229d6..854a99677b 100644 --- a/shared/javacpp/publish.gradle +++ b/shared/javacpp/publish.gradle @@ -53,12 +53,7 @@ addTaskToCopyAllOutputs(cppHeadersZip) model { publishing { - def taskList = createComponentZipTasks($.components, nativeName, zipBaseName, Zip, project, includeStandardZipFormat) - - def allTask - if (!project.hasProperty('jenkinsBuild')) { - allTask = createAllCombined(taskList, nativeName, zipBaseName, Zip, project) - } + def taskList = createComponentZipTasks($.components, [nativeName], zipBaseName, Zip, project, includeStandardZipFormat) publications { cpp(MavenPublication) { @@ -68,10 +63,6 @@ model { artifact cppHeadersZip artifact cppSourcesZip - if (!project.hasProperty('jenkinsBuild')) { - artifact allTask - } - artifactId = "${baseArtifactId}-cpp" groupId artifactGroupId version pubVersion diff --git a/shared/javacpp/setupBuild.gradle b/shared/javacpp/setupBuild.gradle index 89e0ffe10b..d2cdd1d866 100644 --- a/shared/javacpp/setupBuild.gradle +++ b/shared/javacpp/setupBuild.gradle @@ -60,10 +60,12 @@ model { } } } + appendDebugPathToBinaries(binaries) } // By default, a development executable will be generated. This is to help the case of // testing specific functionality of the library. "${nativeName}Dev"(NativeExecutableSpec) { + targetBuildTypes 'debug' sources { cpp { source { @@ -101,7 +103,7 @@ model { } binaries { withType(GoogleTestTestSuiteBinarySpec) { - if (!project.hasProperty('onlyAthena')) { + if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) { lib library: nativeName, linkage: 'shared' } else { it.buildable = false diff --git a/shared/jni/publish.gradle b/shared/jni/publish.gradle index ea041d78d9..a6a1abe11b 100644 --- a/shared/jni/publish.gradle +++ b/shared/jni/publish.gradle @@ -71,14 +71,9 @@ addTaskToCopyAllOutputs(cppHeadersZip) model { publishing { - def taskList = createComponentZipTasks($.components, nativeName, zipBaseName, Zip, project, includeStandardZipFormat) + def taskList = createComponentZipTasks($.components, [nativeName, "${nativeName}JNIShared"], zipBaseName, Zip, project, includeStandardZipFormat) - def allTask - if (!project.hasProperty('jenkinsBuild')) { - allTask = createAllCombined(taskList, nativeName, zipBaseName, Zip, project) - } - - def jniTaskList = createComponentZipTasks($.components, "${nativeName}JNI", jniBaseName, Jar, project, { task, value -> + def jniTaskList = createComponentZipTasks($.components, ["${nativeName}JNI"], jniBaseName, Jar, project, { task, value -> value.each { binary -> if (binary.buildable) { if (binary instanceof SharedLibraryBinarySpec) { @@ -113,10 +108,6 @@ model { artifact cppHeadersZip artifact cppSourcesZip - if (!project.hasProperty('jenkinsBuild')) { - artifact allTask - } - artifactId = "${baseArtifactId}-cpp" groupId artifactGroupId version pubVersion diff --git a/shared/jni/setupBuild.gradle b/shared/jni/setupBuild.gradle index 4a8f6925c9..2549b0bc52 100644 --- a/shared/jni/setupBuild.gradle +++ b/shared/jni/setupBuild.gradle @@ -33,9 +33,9 @@ apply from: "${rootDir}/shared/googletest.gradle" if (project.hasProperty('niLibraries')) { ext { chipObjectComponents = ["$nativeName".toString(), "${nativeName}Dev".toString(), "${nativeName}Base".toString(), - "${nativeName}JNI".toString(), "${nativeName}Test".toString()] + "${nativeName}JNI".toString(), "${nativeName}JNIShared".toString(), "${nativeName}Test".toString()] netCommComponents = ["$nativeName".toString(), "${nativeName}Dev".toString(), "${nativeName}Base".toString(), - "${nativeName}JNI".toString(), "${nativeName}Test".toString()] + "${nativeName}JNI".toString(), "${nativeName}JNIShared".toString(), "${nativeName}Test".toString()] useNiJava = true } @@ -44,17 +44,16 @@ if (project.hasProperty('niLibraries')) { model { components { - "${nativeName}Base"(JniNativeLibrarySpec) { + "${nativeName}Base"(NativeLibrarySpec) { if (project.hasProperty('setBaseName')) { baseName = setBaseName } - javaCompileTasks << compileJava - jniCrossCompileOptions << JniCrossCompileOptions('athena') sources { cpp { source { srcDirs 'src/main/native/cpp' include '**/*.cpp' + exclude '**/jni/*.cpp' } exportedHeaders { srcDir 'src/main/native/include' @@ -75,13 +74,10 @@ model { } } } - "${nativeName}"(JniNativeLibrarySpec) { + "${nativeName}"(NativeLibrarySpec) { if (project.hasProperty('setBaseName')) { baseName = setBaseName } - enableCheckTask true - javaCompileTasks << compileJava - jniCrossCompileOptions << JniCrossCompileOptions('athena') sources { cpp { source { @@ -99,21 +95,23 @@ model { binaries.all { lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' } + appendDebugPathToBinaries(binaries) } - "${nativeName}JNI"(JniNativeLibrarySpec) { + "${nativeName}JNIShared"(JniNativeLibrarySpec) { if (project.hasProperty('setBaseName')) { - baseName = setBaseName + baseName = setBaseName + 'jni' } else { - baseName = nativeName + baseName = nativeName + 'jni' } enableCheckTask true javaCompileTasks << compileJava jniCrossCompileOptions << JniCrossCompileOptions('athena') + jniCrossCompileOptions << JniCrossCompileOptions('raspbian') sources { cpp { source { - srcDirs "${rootDir}/shared/singlelib" - include '**/*.cpp' + srcDirs 'src/main/native/cpp' + include '**/jni/*.cpp' } exportedHeaders { srcDir 'src/main/native/include' @@ -128,12 +126,53 @@ model { it.buildable = false return } + lib library: "${nativeName}", linkage: 'shared' + lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' + if (project.hasProperty('jniSplitSetup')) { + jniSplitSetup(it) + } + } + } + "${nativeName}JNI"(JniNativeLibrarySpec) { + if (project.hasProperty('setBaseName')) { + baseName = setBaseName + 'jni' + } else { + baseName = nativeName + 'jni' + } + enableCheckTask true + javaCompileTasks << compileJava + jniCrossCompileOptions << JniCrossCompileOptions('athena') + jniCrossCompileOptions << JniCrossCompileOptions('raspbian') + sources { + cpp { + source { + srcDirs 'src/main/native/cpp' + include '**/jni/*.cpp' + } + exportedHeaders { + srcDir 'src/main/native/include' + if (project.hasProperty('generatedHeaders')) { + srcDir generatedHeaders + } + } + } + } + binaries.all { + if (it instanceof StaticLibraryBinarySpec) { + it.buildable = false + return + } + lib library: "${nativeName}", linkage: 'static' lib project: ':wpiutil', library: 'wpiutil', linkage: 'static' + if (project.hasProperty('jniSplitSetup')) { + jniSplitSetup(it) + } } } // By default, a development executable will be generated. This is to help the case of // testing specific functionality of the library. "${nativeName}Dev"(NativeExecutableSpec) { + targetBuildTypes 'debug' sources { cpp { @@ -151,6 +190,7 @@ model { } binaries.all { lib library: nativeName, linkage: 'shared' + lib library: "${nativeName}JNIShared", linkage: 'shared' lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' } } @@ -181,7 +221,7 @@ model { } binaries { withType(GoogleTestTestSuiteBinarySpec) { - if (!project.hasProperty('onlyAthena')) { + if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) { lib library: nativeName, linkage: 'shared' lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' } else { diff --git a/shared/nilibraries.gradle b/shared/nilibraries.gradle index 5836a67a16..a72466d46d 100644 --- a/shared/nilibraries.gradle +++ b/shared/nilibraries.gradle @@ -16,7 +16,7 @@ model { artifactId = 'chipobject' headerClassifier = 'headers' ext = 'zip' - version = '2019.4.1' + version = '2019.4.2' sharedConfigs = chipObjectConfigs staticConfigs = [:] compileOnlyShared = true @@ -26,7 +26,7 @@ model { artifactId = 'netcomm' headerClassifier = 'headers' ext = 'zip' - version = '2019.4.1' + version = '2019.4.2' sharedConfigs = netCommLibConfigs staticConfigs = [:] compileOnlyShared = true diff --git a/shared/opencv.gradle b/shared/opencv.gradle index 43b3bdde60..f9f8f055a6 100644 --- a/shared/opencv.gradle +++ b/shared/opencv.gradle @@ -6,7 +6,7 @@ if (project.hasProperty('useCpp') && project.useCpp) { artifactId = 'opencv-cpp' headerClassifier = 'headers' ext = 'zip' - version = '3.4.3-7' + version = '3.4.3-15' sharedConfigs = project.sharedCvConfigs staticConfigs = project.staticCvConfigs linkExcludes = ['**/*java*'] @@ -17,12 +17,12 @@ if (project.hasProperty('useCpp') && project.useCpp) { if (project.hasProperty('useJava') && project.useJava) { dependencies { - compile 'edu.wpi.first.thirdparty.frc2019.opencv:opencv-java:3.4.3-7' + compile 'edu.wpi.first.thirdparty.frc2019.opencv:opencv-java:3.4.3-15' if (!project.hasProperty('skipDev') || !project.skipDev) { - devCompile 'edu.wpi.first.thirdparty.frc2019.opencv:opencv-java:3.4.3-7' + devCompile 'edu.wpi.first.thirdparty.frc2019.opencv:opencv-java:3.4.3-15' } if (project.hasProperty('useDocumentation') && project.useDocumentation) { - javaSource 'edu.wpi.first.thirdparty.frc2019.opencv:opencv-java:3.4.3-7:sources' + javaSource 'edu.wpi.first.thirdparty.frc2019.opencv:opencv-java:3.4.3-15:sources' } } } diff --git a/shared/plugins/publish.gradle b/shared/plugins/publish.gradle index 4c94d1e098..a9ba5384fd 100644 --- a/shared/plugins/publish.gradle +++ b/shared/plugins/publish.gradle @@ -50,7 +50,7 @@ addTaskToCopyAllOutputs(cppHeadersZip) model { publishing { - def pluginTaskList = createComponentZipTasks($.components, pluginName, zipBaseName, Zip, project, { task, value -> + def pluginTaskList = createComponentZipTasks($.components, [pluginName], zipBaseName, Zip, project, { task, value -> value.each { binary -> if (binary.buildable) { if (binary instanceof SharedLibraryBinarySpec) { @@ -63,21 +63,12 @@ model { } }) - def allTask - if (!project.hasProperty('jenkinsBuild')) { - allTask = createAllCombined(pluginTaskList, pluginName, zipBaseName, Zip, project) - } - publications { cpp(MavenPublication) { pluginTaskList.each { artifact it } - if (!project.hasProperty('jenkinsBuild')) { - artifact allTask - } - artifact cppHeadersZip artifact cppSourcesZip diff --git a/shared/plugins/setupBuild.gradle b/shared/plugins/setupBuild.gradle index f79292ecc3..ba4c6f0b65 100644 --- a/shared/plugins/setupBuild.gradle +++ b/shared/plugins/setupBuild.gradle @@ -41,8 +41,10 @@ if (!project.hasProperty('onlyAthena')) { lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' } } + appendDebugPathToBinaries(binaries) } "${pluginName}Dev"(NativeExecutableSpec) { + targetBuildTypes 'debug' sources { cpp { source { @@ -55,12 +57,16 @@ if (!project.hasProperty('onlyAthena')) { } } binaries.all { - project(':hal').addHalDependency(it, 'shared') - lib library: pluginName - if (project.hasProperty('includeNtCore')) { - lib project: ':ntcore', library: 'ntcore', linkage: 'shared' + if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) { + project(':hal').addHalDependency(it, 'shared') + lib library: pluginName + if (project.hasProperty('includeNtCore')) { + lib project: ':ntcore', library: 'ntcore', linkage: 'shared' + } + lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' + } else { + it.buildable = false } - lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' } } } @@ -72,7 +78,7 @@ if (!project.hasProperty('onlyAthena')) { model { tasks { def c = $.components - if (!project.hasProperty('onlyAthena')) { + if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) { project.tasks.create('runCpp', Exec) { group = 'WPILib' description = "Run the ${pluginName}Dev executable" diff --git a/simulation/frc_gazebo_plugins/build.gradle b/simulation/frc_gazebo_plugins/build.gradle index 0e1c8094d3..829c4c778e 100644 --- a/simulation/frc_gazebo_plugins/build.gradle +++ b/simulation/frc_gazebo_plugins/build.gradle @@ -52,6 +52,7 @@ model { servo(NativeLibrarySpec) drive_motor(NativeLibrarySpec) all { component -> + component.targetBuildTypes 'debug' sources { cpp.lib library: "${component.name}", linkage: "static" } diff --git a/simulation/halsim_adx_gyro_accelerometer/build.gradle b/simulation/halsim_adx_gyro_accelerometer/build.gradle index fc6a6fd06e..c9f754dde6 100644 --- a/simulation/halsim_adx_gyro_accelerometer/build.gradle +++ b/simulation/halsim_adx_gyro_accelerometer/build.gradle @@ -100,6 +100,7 @@ if (!project.hasProperty('onlyAthena')) { // By default, a development executable will be generated. This is to help the case of // testing specific functionality of the library. "${nativeName}Dev"(NativeExecutableSpec) { + targetBuildTypes 'debug' sources { cpp { source { @@ -125,13 +126,17 @@ if (!project.hasProperty('onlyAthena')) { } binaries { withType(GoogleTestTestSuiteBinarySpec) { - lib project: ':ntcore', library: 'ntcore', linkage: 'shared' - lib project: ':cscore', library: 'cscore', linkage: 'shared' - project(':hal').addHalDependency(it, 'shared') - lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' - lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared' - lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared' - lib library: nativeName, linkage: 'shared' + if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) { + lib project: ':ntcore', library: 'ntcore', linkage: 'shared' + lib project: ':cscore', library: 'cscore', linkage: 'shared' + project(':hal').addHalDependency(it, 'shared') + lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' + lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared' + lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared' + lib library: nativeName, linkage: 'shared' + } else { + it.buildable = false + } } } } @@ -142,7 +147,7 @@ if (!project.hasProperty('onlyAthena')) { model { testSuites { - if (!project.hasProperty('onlyAthena')) { + if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) { "${nativeName}Test"(GoogleTestTestSuiteSpec) { for(NativeComponentSpec c : $.components) { if (c.name == nativeName) { diff --git a/simulation/halsim_adx_gyro_accelerometer/publish.gradle b/simulation/halsim_adx_gyro_accelerometer/publish.gradle index d292bb72d7..11feda572c 100644 --- a/simulation/halsim_adx_gyro_accelerometer/publish.gradle +++ b/simulation/halsim_adx_gyro_accelerometer/publish.gradle @@ -49,13 +49,7 @@ addTaskToCopyAllOutputs(cppHeadersZip) model { publishing { - def halsim_adx_gyro_accelerometerTaskList = createComponentZipTasks($.components, nativeName, zipBaseName, Zip, project, includeStandardZipFormat) - def allTask - if (!project.hasProperty('jenkinsBuild')) { - allTask = createAllCombined(halsim_adx_gyro_accelerometerTaskList, nativeName, zipBaseName, Zip, project) - } - - + def halsim_adx_gyro_accelerometerTaskList = createComponentZipTasks($.components, [nativeName], zipBaseName, Zip, project, includeStandardZipFormat) publications { cpp(MavenPublication) { @@ -63,10 +57,6 @@ model { artifact it } - if (!project.hasProperty('jenkinsBuild')) { - artifact allTask - } - artifact cppHeadersZip artifact cppSourcesZip diff --git a/simulation/halsim_ds_socket/build.gradle b/simulation/halsim_ds_socket/build.gradle index 9fe7650fb1..0200980c99 100644 --- a/simulation/halsim_ds_socket/build.gradle +++ b/simulation/halsim_ds_socket/build.gradle @@ -21,7 +21,7 @@ apply from: "${rootDir}/shared/plugins/setupBuild.gradle" model { testSuites { def comps = $.components - if (!project.hasProperty('onlyAthena')) { + if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) { "${pluginName}Test"(GoogleTestTestSuiteSpec) { for(NativeComponentSpec c : comps) { if (c.name == pluginName) { diff --git a/simulation/halsim_ds_socket/src/main/native/cpp/DSCommPacket.cpp b/simulation/halsim_ds_socket/src/main/native/cpp/DSCommPacket.cpp index 3007fa79b9..93f7af7019 100644 --- a/simulation/halsim_ds_socket/src/main/native/cpp/DSCommPacket.cpp +++ b/simulation/halsim_ds_socket/src/main/native/cpp/DSCommPacket.cpp @@ -57,7 +57,11 @@ void DSCommPacket::ReadMatchtimeTag(wpi::ArrayRef tagData) { store |= tagData[4] << 8; store |= tagData[5]; - float matchTime = *reinterpret_cast(&store); + static_assert(sizeof(uint32_t) == sizeof(float), "float must be 32 bits"); + + float matchTime = 0; + + std::memcpy(&matchTime, &store, sizeof(float)); m_match_time = matchTime; } diff --git a/simulation/lowfi_simulation/build.gradle b/simulation/lowfi_simulation/build.gradle index 2b6ae428d4..2b97416e54 100644 --- a/simulation/lowfi_simulation/build.gradle +++ b/simulation/lowfi_simulation/build.gradle @@ -105,6 +105,7 @@ if (!project.hasProperty('onlyAthena')) { // By default, a development executable will be generated. This is to help the case of // testing specific functionality of the library. "${nativeName}Dev"(NativeExecutableSpec) { + targetBuildTypes 'debug' sources { cpp { source { @@ -149,7 +150,7 @@ if (!project.hasProperty('onlyAthena')) { model { testSuites { - if (!project.hasProperty('onlyAthena')) { + if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) { "${nativeName}Test"(GoogleTestTestSuiteSpec) { for(NativeComponentSpec c : $.components) { if (c.name == nativeName) { diff --git a/simulation/lowfi_simulation/publish.gradle b/simulation/lowfi_simulation/publish.gradle index cd16178841..4143cd2b97 100644 --- a/simulation/lowfi_simulation/publish.gradle +++ b/simulation/lowfi_simulation/publish.gradle @@ -50,13 +50,7 @@ addTaskToCopyAllOutputs(cppHeadersZip) model { publishing { - def lowfiSimTaskList = createComponentZipTasks($.components, nativeName, zipBaseName, Zip, project, includeStandardZipFormat) - def allTask - if (!project.hasProperty('jenkinsBuild')) { - allTask = createAllCombined(lowfiSimTaskList, nativeName, zipBaseName, Zip, project) - } - - + def lowfiSimTaskList = createComponentZipTasks($.components, [nativeName], zipBaseName, Zip, project, includeStandardZipFormat) publications { cpp(MavenPublication) { @@ -64,10 +58,6 @@ model { artifact it } - if (!project.hasProperty('jenkinsBuild')) { - artifact allTask - } - artifact cppHeadersZip artifact cppSourcesZip diff --git a/wpilibc/CMakeLists.txt b/wpilibc/CMakeLists.txt index 0b8223cb05..da3587188a 100644 --- a/wpilibc/CMakeLists.txt +++ b/wpilibc/CMakeLists.txt @@ -8,6 +8,7 @@ file(GLOB_RECURSE wpilibc_native_src src/main/native/cpp/*.cpp) add_library(wpilibc ${wpilibc_native_src} ${CMAKE_CURRENT_BINARY_DIR}/WPILibVersion.cpp) +set_target_properties(wpilibc PROPERTIES DEBUG_POSTFIX "d") target_include_directories(wpilibc PUBLIC $ diff --git a/wpilibc/build.gradle b/wpilibc/build.gradle index fce31393f6..37ff6bd94c 100644 --- a/wpilibc/build.gradle +++ b/wpilibc/build.gradle @@ -138,10 +138,12 @@ model { lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared' } + appendDebugPathToBinaries(binaries) } // By default, a development executable will be generated. This is to help the case of // testing specific functionality of the library. "${nativeName}Dev"(NativeExecutableSpec) { + targetBuildTypes 'debug' sources { cpp { source { @@ -200,7 +202,7 @@ model { } } withType(GoogleTestTestSuiteBinarySpec) { - if (!project.hasProperty('onlyAthena')) { + if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) { lib project: ':ntcore', library: 'ntcore', linkage: 'shared' lib project: ':cscore', library: 'cscore', linkage: 'shared' project(':hal').addHalDependency(it, 'shared') diff --git a/wpilibc/publish.gradle b/wpilibc/publish.gradle index 7427709d2c..06f88dff32 100644 --- a/wpilibc/publish.gradle +++ b/wpilibc/publish.gradle @@ -54,22 +54,14 @@ addTaskToCopyAllOutputs(cppSourcesZip) model { publishing { - def wpilibCTaskList = createComponentZipTasks($.components, 'wpilibc', zipBaseName, Zip, project, includeStandardZipFormat) - def allTask - if (!project.hasProperty('jenkinsBuild')) { - allTask = createAllCombined(wpilibCTaskList, 'wpilibc', zipBaseName, Zip, project) - } - - + def wpilibCTaskList = createComponentZipTasks($.components, ['wpilibc'], zipBaseName, Zip, project, includeStandardZipFormat) publications { cpp(MavenPublication) { wpilibCTaskList.each { artifact it } - if (!project.hasProperty('jenkinsBuild')) { - artifact allTask - } + artifact cppHeadersZip artifact cppSourcesZip diff --git a/wpilibcExamples/build.gradle b/wpilibcExamples/build.gradle index ae8973b38c..08a1c68f25 100644 --- a/wpilibcExamples/build.gradle +++ b/wpilibcExamples/build.gradle @@ -85,6 +85,7 @@ model { examplesMap.each { key, value -> "${key}"(NativeExecutableSpec) { + targetBuildTypes 'debug' binaries.all { binary -> lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared' lib project: ':ntcore', library: 'ntcore', linkage: 'shared' @@ -115,6 +116,7 @@ model { } templatesMap.each { key, value -> "${key}"(NativeExecutableSpec) { + targetBuildTypes 'debug' binaries.all { binary -> lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared' lib project: ':ntcore', library: 'ntcore', linkage: 'shared' diff --git a/wpilibcIntegrationTests/build.gradle b/wpilibcIntegrationTests/build.gradle index 2ad5863776..0dea400675 100644 --- a/wpilibcIntegrationTests/build.gradle +++ b/wpilibcIntegrationTests/build.gradle @@ -30,6 +30,7 @@ apply from: "${rootDir}/shared/nilibraries.gradle" model { components { wpilibcIntegrationTests(NativeExecutableSpec) { + targetBuildTypes 'debug' baseName = 'FRCUserProgram' binaries.all { binary -> if (binary.targetPlatform.architecture.name == 'athena') { @@ -53,7 +54,10 @@ model { lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared' lib project: ':ntcore', library: 'ntcore', linkage: 'shared' lib project: ':cscore', library: 'cscore', linkage: 'shared' + lib project: ':ntcore', library: 'ntcoreJNIShared', linkage: 'shared' + lib project: ':cscore', library: 'cscoreJNIShared', linkage: 'shared' project(':hal').addHalDependency(binary, 'shared') + project(':hal').addHalJniDependency(binary) lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared' } else { diff --git a/wpilibj/build.gradle b/wpilibj/build.gradle index 1d414b80d8..b3a14b472c 100644 --- a/wpilibj/build.gradle +++ b/wpilibj/build.gradle @@ -96,6 +96,7 @@ apply from: "${rootDir}/shared/opencv.gradle" model { components { wpilibjDev(NativeExecutableSpec) { + targetBuildTypes 'debug' sources { cpp { source { @@ -104,6 +105,9 @@ model { lib project: ':ntcore', library: 'ntcore', linkage: 'shared' lib project: ':cscore', library: 'cscore', linkage: 'shared' lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' + lib project: ':ntcore', library: 'ntcoreJNIShared', linkage: 'shared' + lib project: ':cscore', library: 'cscoreJNIShared', linkage: 'shared' + lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared' } exportedHeaders { @@ -113,6 +117,7 @@ model { } binaries.all { project(':hal').addHalDependency(it, 'shared') + project(':hal').addHalJniDependency(it) } } } diff --git a/wpiutil/CMakeLists.txt b/wpiutil/CMakeLists.txt index 4f44ec6831..cadb5b2aa4 100644 --- a/wpiutil/CMakeLists.txt +++ b/wpiutil/CMakeLists.txt @@ -70,6 +70,7 @@ set(uv_linux_src ) add_library(wpiutil ${wpiutil_native_src} ${uv_native_src}) +set_target_properties(wpiutil PROPERTIES DEBUG_POSTFIX "d") set_property(TARGET wpiutil PROPERTY FOLDER "libraries") diff --git a/wpiutil/build.gradle b/wpiutil/build.gradle index 5d9c1e8d8f..fc73400e58 100644 --- a/wpiutil/build.gradle +++ b/wpiutil/build.gradle @@ -138,6 +138,7 @@ model { components { examplesMap.each { key, value -> "${key}"(NativeExecutableSpec) { + targetBuildTypes 'debug' binaries.all { lib library: 'wpiutil', linkage: 'shared' }