-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[datalog] Move all DataLog functionality to new datalog library (#7641)
Currently the major DataLog backend API (reading and writing) is split between wpiutil and glass. In the interest of allowing code that wants to use these APIs to not need to link to glass and declutter wpiutil, all of those APIs are moved to a new library named "datalog". Signed-off-by: Jade Turner <spacey-sooty@proton.me> Co-authored-by: Jade Turner <spacey-sooty@proton.me> Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com>
- Loading branch information
1 parent
ac1705a
commit da47f06
Showing
99 changed files
with
778 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
cppHeaderFileInclude { | ||
\.h$ | ||
} | ||
|
||
cppSrcFileInclude { | ||
\.cpp$ | ||
} | ||
|
||
licenseUpdateExclude { | ||
examples/printlog | ||
} | ||
|
||
modifiableFileExclude { | ||
examples/printlog/datalog\.py$ | ||
} | ||
|
||
repoRootNameOverride { | ||
datalog | ||
} | ||
|
||
includeOtherLibs { | ||
^fmt/ | ||
^gtest/ | ||
^wpi/(?!datalog) | ||
} | ||
|
||
includeProject { | ||
^wpi/datalog/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") | ||
load("@rules_java//java:defs.bzl", "java_binary") | ||
load("@rules_python//python:defs.bzl", "py_binary") | ||
load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test") | ||
load("//shared/bazel/rules:jni_rules.bzl", "wpilib_jni_cc_library", "wpilib_jni_java_library") | ||
|
||
cc_library( | ||
name = "datalog.static", | ||
srcs = glob( | ||
["src/main/native/cpp/**"], | ||
exclude = ["src/main/native/cpp/jni/**"], | ||
), | ||
hdrs = glob(["src/main/native/include/**"]), | ||
includes = [ | ||
"src/main/native/cpp", | ||
"src/main/native/include", | ||
], | ||
strip_include_prefix = "src/main/native/include", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//wpiutil:wpiutil.static", | ||
], | ||
) | ||
|
||
wpilib_jni_cc_library( | ||
name = "datalogjni", | ||
srcs = glob(["src/main/native/cpp/jni/**"]), | ||
java_dep = ":datalog-java", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
":datalog.static", | ||
], | ||
) | ||
|
||
wpilib_jni_java_library( | ||
name = "datalog-java", | ||
srcs = glob(["src/main/java/**/*.java"]), | ||
native_libs = [":datalogjni"], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//wpiutil:wpiutil-java", | ||
"@maven//:us_hebi_quickbuf_quickbuf_runtime", | ||
], | ||
) | ||
|
||
py_binary( | ||
name = "datalog", | ||
srcs = ["examples/printlog/datalog.py"], | ||
tags = ["manual"], | ||
) | ||
|
||
cc_binary( | ||
name = "printlog", | ||
srcs = ["examples/printlog/printlog.cpp"], | ||
deps = [ | ||
":datalog.static", | ||
"//wpiutil:wpiutil.static", | ||
], | ||
) | ||
|
||
cc_binary( | ||
name = "writelog", | ||
srcs = ["examples/writelog/writelog.cpp"], | ||
deps = [ | ||
":datalog.static", | ||
"//wpiutil:wpiutil.static", | ||
], | ||
) | ||
|
||
java_binary( | ||
name = "printlog-java", | ||
srcs = ["src/printlog/java/printlog/PrintLog.java"], | ||
main_class = "printlog.PrintLog", | ||
deps = [ | ||
":datalog-java", | ||
], | ||
) | ||
|
||
cc_test( | ||
name = "datalog-cpp-test", | ||
size = "small", | ||
srcs = glob([ | ||
"src/test/native/**/*.cpp", | ||
"src/test/native/**/*.h", | ||
]), | ||
tags = [ | ||
"exclusive", | ||
"no-asan", | ||
"no-tsan", | ||
], | ||
deps = [ | ||
":datalog.static", | ||
"//thirdparty/googletest:googletest.static", | ||
"//wpiutil:wpiutil-testlib", | ||
], | ||
) | ||
|
||
wpilib_java_junit5_test( | ||
name = "datalog-java-test", | ||
srcs = glob(["src/test/java/**/*.java"]), | ||
tags = ["exclusive"], | ||
deps = [ | ||
":datalog-java", | ||
"//wpiutil:wpiutil-java", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
project(datalog) | ||
|
||
include(CompileWarnings) | ||
|
||
file(GLOB datalog_native_src src/main/native/cpp/*.cpp) | ||
|
||
file(GLOB datalog_jni_src src/main/native/cpp/jni/DataLogJNI.cpp) | ||
list(REMOVE_ITEM datalog_native_src ${datalog_jni_src}) | ||
|
||
add_library(datalog ${datalog_native_src}) | ||
set_target_properties(datalog PROPERTIES DEBUG_POSTFIX "d") | ||
|
||
target_compile_features(datalog PUBLIC cxx_std_20) | ||
if(MSVC) | ||
target_compile_options( | ||
datalog | ||
PUBLIC /permissive- /Zc:preprocessor /Zc:__cplusplus /Zc:throwingNew /MP /bigobj /utf-8 | ||
) | ||
target_compile_definitions(datalog PRIVATE -D_CRT_SECURE_NO_WARNINGS) | ||
endif() | ||
wpilib_target_warnings(datalog) | ||
|
||
target_include_directories( | ||
datalog | ||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include> | ||
) | ||
|
||
target_link_libraries(datalog PRIVATE wpiutil) | ||
|
||
subdir_list(datalog_examples "${CMAKE_CURRENT_SOURCE_DIR}/examples") | ||
foreach(example ${datalog_examples}) | ||
file(GLOB datalog_example_src examples/${example}/*.cpp) | ||
if(datalog_example_src) | ||
add_executable(datalog_${example} ${datalog_example_src}) | ||
wpilib_target_warnings(datalog_${example}) | ||
target_link_libraries(datalog_${example} datalog wpiutil) | ||
set_property(TARGET datalog_${example} PROPERTY FOLDER "examples") | ||
endif() | ||
endforeach() | ||
|
||
# Java bindings | ||
if(WITH_JAVA) | ||
include(UseJava) | ||
|
||
set(CMAKE_JNI_TARGET true) | ||
|
||
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java) | ||
file(GLOB QUICKBUF_JAR ${WPILIB_BINARY_DIR}/wpiutil/thirdparty/quickbuf/*.jar) | ||
|
||
add_jar( | ||
datalog_jar | ||
${JAVA_SOURCES} | ||
# INCLUDE_JARS ${JACKSON_JARS} ${QUICKBUF_JAR} | ||
INCLUDE_JARS wpiutil_jar ${QUICKBUF_JAR} | ||
OUTPUT_NAME datalog | ||
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest} | ||
GENERATE_NATIVE_HEADERS datalog_jni_headers | ||
) | ||
set_property(TARGET datalog_jar PROPERTY FOLDER "java") | ||
|
||
install_jar(datalog_jar DESTINATION ${java_lib_dest}) | ||
install_jar_exports(TARGETS datalog_jar FILE datalog_jar.cmake DESTINATION share/datalog) | ||
|
||
add_library(datalogjni ${datalog_jni_src}) | ||
wpilib_target_warnings(datalogjni) | ||
target_link_libraries(datalogjni PUBLIC datalog wpiutil) | ||
|
||
set_property(TARGET datalogjni PROPERTY FOLDER "libraries") | ||
|
||
target_link_libraries(datalogjni PRIVATE datalog_jni_headers) | ||
add_dependencies(datalogjni datalog_jar) | ||
|
||
install(TARGETS datalogjni EXPORT datalogjni) | ||
export(TARGETS datalogjni FILE datalogjni.cmake NAMESPACE datalogjni::) | ||
endif() | ||
|
||
if(WITH_JAVA_SOURCE) | ||
include(UseJava) | ||
include(CreateSourceJar) | ||
add_source_jar( | ||
datalog_src_jar | ||
BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java | ||
OUTPUT_NAME datalog-sources | ||
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest} | ||
) | ||
set_property(TARGET datalog_src_jar PROPERTY FOLDER "java") | ||
|
||
install_jar(datalog_src_jar DESTINATION ${java_lib_dest}) | ||
endif() | ||
|
||
install(TARGETS datalog EXPORT datalog) | ||
export(TARGETS datalog FILE datalog.cmake NAMESPACE datalog::) | ||
|
||
configure_file(datalog-config.cmake.in ${WPILIB_BINARY_DIR}/datalog-config.cmake) | ||
install(FILES ${WPILIB_BINARY_DIR}/datalog-config.cmake DESTINATION share/datalog) | ||
install(EXPORT datalog DESTINATION share/datalog) | ||
|
||
if(WITH_TESTS) | ||
file(GLOB_RECURSE datalog_testlib_src src/test/native/include/*.h) | ||
add_library(datalog_testlib INTERFACE ${datalog_test_src}) | ||
target_include_directories(datalog_testlib INTERFACE src/test/native/include) | ||
|
||
wpilib_add_test(datalog src/test/native/cpp) | ||
target_link_libraries(datalog_test datalog googletest datalog_testlib wpiutil) | ||
if(MSVC) | ||
target_compile_options(datalog_test PRIVATE /utf-8) | ||
endif() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
ext { | ||
useJava = true | ||
useCpp = true | ||
baseId = 'datalog' | ||
groupId = 'edu.wpi.first.datalog' | ||
|
||
nativeName = 'datalog' | ||
devMain = 'edu.wpi.first.datalog.DevMain' | ||
} | ||
|
||
apply from: "${rootDir}/shared/jni/setupBuild.gradle" | ||
|
||
nativeUtils.exportsConfigs { | ||
datalog { | ||
} | ||
} | ||
|
||
model { | ||
components { | ||
all { | ||
it.sources.each { | ||
it.exportedHeaders { | ||
srcDirs 'src/main/native/include' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
api project(":wpiutil") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@FILENAME_DEP_REPLACE@ | ||
include(${SELF_DIR}/wpiutil.cmake) | ||
if(@WITH_JAVA@) | ||
include(${SELF_DIR}/wpiutil_jar.cmake) | ||
endif() |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package edu.wpi.first.datalog; | ||
|
||
public final class DevMain { | ||
/** Main entry point. */ | ||
public static void main(String[] args) {} | ||
|
||
private DevMain() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
int main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.