Skip to content

Commit

Permalink
[datalogtool] Add datalogtool
Browse files Browse the repository at this point in the history
This is a support tool for datalog file conversion (and eventually
download/remote datalog file management).
  • Loading branch information
PeterJohnson committed Feb 26, 2022
1 parent 0aefae5 commit 427dfcc
Show file tree
Hide file tree
Showing 29 changed files with 2,176 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ if (WITH_GUI)
add_subdirectory(outlineviewer)
if (LIBSSH_FOUND)
add_subdirectory(roborioteamnumbersetter)
add_subdirectory(datalogtool)
endif()
endif()

Expand Down
29 changes: 29 additions & 0 deletions datalogtool/.styleguide
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
cppHeaderFileInclude {
\.h$
\.inc$
\.inl$
}

cppSrcFileInclude {
\.cpp$
}

generatedFileExclude {
src/main/native/resources/
src/main/native/win/datalogtool.ico
src/main/native/mac/datalogtool.icns
}

repoRootNameOverride {
datalogtool
}

includeOtherLibs {
^GLFW
^fmt/
^glass/
^imgui
^portable-file-dialog
^wpi/
^wpigui
}
29 changes: 29 additions & 0 deletions datalogtool/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
project(datalogtool)

include(CompileWarnings)
include(GenResources)
include(LinkMacOSGUI)

configure_file(src/main/generate/WPILibVersion.cpp.in WPILibVersion.cpp)
GENERATE_RESOURCES(src/main/native/resources generated/main/cpp DLT dlt datalogtool_resources_src)

file(GLOB datalogtool_src src/main/native/cpp/*.cpp ${CMAKE_CURRENT_BINARY_DIR}/WPILibVersion.cpp)

if (WIN32)
set(datalogtool_rc src/main/native/win/datalogtool.rc)
elseif(APPLE)
set(MACOSX_BUNDLE_ICON_FILE datalogtool.icns)
set(APP_ICON_MACOSX src/main/native/mac/datalogtool.icns)
set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
endif()

add_executable(datalogtool ${datalogtool_src} ${datalogtool_resources_src} ${datalogtool_rc} ${APP_ICON_MACOSX})
wpilib_link_macos_gui(datalogtool)
target_link_libraries(datalogtool libglass ${LIBSSH_LIBRARIES})
target_include_directories(datalogtool PRIVATE ${LIBSSH_INCLUDE_DIRS})

if (WIN32)
set_target_properties(datalogtool PROPERTIES WIN32_EXECUTABLE YES)
elseif(APPLE)
set_target_properties(datalogtool PROPERTIES MACOSX_BUNDLE YES OUTPUT_NAME "datalogTool")
endif()
32 changes: 32 additions & 0 deletions datalogtool/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>datalogTool</string>
<key>CFBundleExecutable</key>
<string>datalogtool</string>
<key>CFBundleDisplayName</key>
<string>datalogTool</string>
<key>CFBundleIdentifier</key>
<string>edu.wpi.first.tools.datalogTool</string>
<key>CFBundleIconFile</key>
<string>datalogtool.icns</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleShortVersionString</key>
<string>2021</string>
<key>CFBundleVersion</key>
<string>2021</string>
<key>LSMinimumSystemVersion</key>
<string>10.11</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
134 changes: 134 additions & 0 deletions datalogtool/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import org.gradle.internal.os.OperatingSystem

if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian') && !project.hasProperty('onlylinuxaarch64bionic')) {

description = "roboRIO Team Number Setter"

apply plugin: 'cpp'
apply plugin: 'c'
apply plugin: 'google-test-test-suite'
apply plugin: 'visual-studio'
apply plugin: 'edu.wpi.first.NativeUtils'

if (OperatingSystem.current().isWindows()) {
apply plugin: 'windows-resources'
}

ext {
nativeName = 'datalogtool'
}

apply from: "${rootDir}/shared/resources.gradle"
apply from: "${rootDir}/shared/config.gradle"

def wpilibVersionFileInput = file("src/main/generate/WPILibVersion.cpp.in")
def wpilibVersionFileOutput = file("$buildDir/generated/main/cpp/WPILibVersion.cpp")

nativeUtils {
nativeDependencyContainer {
libssh(getNativeDependencyTypeClass('WPIStaticMavenDependency')) {
groupId = "edu.wpi.first.thirdparty.frc2022"
artifactId = "libssh"
headerClassifier = "headers"
sourceClassifier = "sources"
ext = "zip"
version = '0.95-1'
targetPlatforms.addAll(nativeUtils.wpi.platforms.desktopPlatforms)
}
}
}

task generateCppVersion() {
description = 'Generates the wpilib version class'
group = 'WPILib'

outputs.file wpilibVersionFileOutput
inputs.file wpilibVersionFileInput

if (wpilibVersioning.releaseMode) {
outputs.upToDateWhen { false }
}

// We follow a simple set of checks to determine whether we should generate a new version file:
// 1. If the release type is not development, we generate a new version file
// 2. If there is no generated version number, we generate a new version file
// 3. If there is a generated build number, and the release type is development, then we will
// only generate if the publish task is run.
doLast {
def version = wpilibVersioning.version.get()
println "Writing version ${version} to $wpilibVersionFileOutput"

if (wpilibVersionFileOutput.exists()) {
wpilibVersionFileOutput.delete()
}
def read = wpilibVersionFileInput.text.replace('${wpilib_version}', version)
wpilibVersionFileOutput.write(read)
}
}

gradle.taskGraph.addTaskExecutionGraphListener { graph ->
def willPublish = graph.hasTask(publish)
if (willPublish) {
generateCppVersion.outputs.upToDateWhen { false }
}
}

def generateTask = createGenerateResourcesTask('main', 'DLT', 'dlt', project)

project(':').libraryBuild.dependsOn build
tasks.withType(CppCompile) {
dependsOn generateTask
dependsOn generateCppVersion
}

model {
components {
// By default, a development executable will be generated. This is to help the case of
// testing specific functionality of the library.
"${nativeName}"(NativeExecutableSpec) {
baseName = 'datalogtool'
sources {
cpp {
source {
srcDirs 'src/main/native/cpp', "$buildDir/generated/main/cpp"
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/main/native/include'
}
}
if (OperatingSystem.current().isWindows()) {
rc {
source {
srcDirs 'src/main/native/win'
include '*.rc'
}
}
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.raspbian || it.targetPlatform.name == nativeUtils.wpi.platforms.aarch64bionic) {
it.buildable = false
return
}
it.cppCompiler.define("LIBSSH_STATIC")
lib project: ':glass', library: 'glass', linkage: 'static'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
nativeUtils.useRequiredLibrary(it, 'imgui_static', 'libssh')
if (it.targetPlatform.operatingSystem.isWindows()) {
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
it.linker.args << 'ws2_32.lib' << 'advapi32.lib' << 'crypt32.lib' << 'user32.lib'
} else if (it.targetPlatform.operatingSystem.isMacOsX()) {
it.linker.args << '-framework' << 'Metal' << '-framework' << 'MetalKit' << '-framework' << 'Cocoa' << '-framework' << 'IOKit' << '-framework' << 'CoreFoundation' << '-framework' << 'CoreVideo' << '-framework' << 'QuartzCore'
it.linker.args << '-framework' << 'Kerberos'
} else {
it.linker.args << '-lX11'
}
}
}
}
}

apply from: 'publish.gradle'
}
107 changes: 107 additions & 0 deletions datalogtool/publish.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
apply plugin: 'maven-publish'

def baseArtifactId = 'DataLogTool'
def artifactGroupId = 'edu.wpi.first.tools'
def zipBaseName = '_GROUP_edu_wpi_first_tools_ID_DataLogTool_CLS'

def outputsFolder = file("$project.buildDir/outputs")

model {
tasks {
// Create the run task.
$.components.datalogtool.binaries.each { bin ->
if (bin.buildable && bin.name.toLowerCase().contains("debug")) {
Task run = project.tasks.create("run", Exec) {
commandLine bin.tasks.install.runScriptFile.get().asFile.toString()
}
run.dependsOn bin.tasks.install
}
}
}
publishing {
def dataLogToolTaskList = []
$.components.each { component ->
component.binaries.each { binary ->
if (binary in NativeExecutableBinarySpec && binary.component.name.contains("datalogtool")) {
if (binary.buildable && binary.name.contains("Release")) {
// We are now in the binary that we want.
// This is the default application path for the ZIP task.
def applicationPath = binary.executable.file
def icon = file("$project.projectDir/src/main/native/mac/datalogtool.icns")

// Create the macOS bundle.
def bundleTask = project.tasks.create("bundleDataLogToolOsxApp", Copy) {
description("Creates a macOS application bundle for DataLogTool")
from(file("$project.projectDir/Info.plist"))
into(file("$project.buildDir/outputs/bundles/DataLogTool.app/Contents"))
into("MacOS") { with copySpec { from binary.executable.file } }
into("Resources") { with copySpec { from icon } }

doLast {
if (project.hasProperty("developerID")) {
// Get path to binary.
exec {
workingDir rootDir
def args = [
"sh",
"-c",
"codesign --force --strict --deep " +
"--timestamp --options=runtime " +
"--verbose -s ${project.findProperty("developerID")} " +
"$project.buildDir/outputs/bundles/DataLogTool.app/"
]
commandLine args
}
}
}
}

// Reset the application path if we are creating a bundle.
if (binary.targetPlatform.operatingSystem.isMacOsX()) {
applicationPath = file("$project.buildDir/outputs/bundles")
project.build.dependsOn bundleTask
}

// Create the ZIP.
def task = project.tasks.create("copyDataLogToolExecutable", Zip) {
description("Copies the DataLogTool executable to the outputs directory.")
destinationDirectory = outputsFolder

archiveBaseName = '_M_' + zipBaseName
duplicatesStrategy = 'exclude'
classifier = nativeUtils.getPublishClassifier(binary)

from(licenseFile) {
into '/'
}

from(applicationPath)
into(nativeUtils.getPlatformPath(binary))
}

if (binary.targetPlatform.operatingSystem.isMacOsX()) {
bundleTask.dependsOn binary.tasks.link
task.dependsOn(bundleTask)
}

task.dependsOn binary.tasks.link
dataLogToolTaskList.add(task)
project.build.dependsOn task
project.artifacts { task }
addTaskToCopyAllOutputs(task)
}
}
}
}

publications {
datalogtool(MavenPublication) {
dataLogToolTaskList.each { artifact it }

artifactId = baseArtifactId
groupId = artifactGroupId
version wpilibVersioning.version.get()
}
}
}
}
7 changes: 7 additions & 0 deletions datalogtool/src/main/generate/WPILibVersion.cpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Autogenerated file! Do not manually edit this file. This version is regenerated
* any time the publish task is run, or when this file is deleted.
*/
const char* GetWPILibVersion() {
return "${wpilib_version}";
}
Loading

0 comments on commit 427dfcc

Please sign in to comment.