mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Adds spotless formatting for Gradle, xml, md, and gitignore files. yml linting is not performed as it requires a dependency on npm.
96 lines
2.8 KiB
Groovy
96 lines
2.8 KiB
Groovy
plugins {
|
|
id 'cpp'
|
|
id 'java'
|
|
id 'com.google.protobuf' version '0.8.8'
|
|
id 'edu.wpi.first.NativeUtils'
|
|
}
|
|
|
|
description = "A C++ and Java library to pass FRC Simulation Messages in and out of Gazebo."
|
|
|
|
/* The simulation does not run on real hardware; so we always skip Athena */
|
|
ext.skiplinuxathena = true
|
|
ext.skiplinuxraspbian = true
|
|
apply from: "${rootDir}/shared/config.gradle"
|
|
|
|
/* Use a sort of poor man's autoconf to find the protobuf development
|
|
files; on Debian, those are supplied by libprotobuf-dev.
|
|
This should get skipped on Windows.
|
|
TODO: Add Windows support for the simulation code */
|
|
|
|
def protobuf_version = ""
|
|
try {
|
|
protobuf_version = "pkg-config --modversion protobuf".execute().text.trim()
|
|
println "Protobuf version is [${protobuf_version}]"
|
|
} catch(Exception ex) {
|
|
}
|
|
|
|
if (project.hasProperty("makeSim")) {
|
|
if (!protobuf_version?.trim()) {
|
|
println "Protobuf is not available. (pkg-config --modversion protobuf failed)"
|
|
println "makeSim set. Forcing build - failure likely."
|
|
}
|
|
} else {
|
|
ext.skip_gz_msgs = true
|
|
println "Skipping gz msgs."
|
|
}
|
|
|
|
tasks.whenTaskAdded { task ->
|
|
task.onlyIf { !project.hasProperty('skip_gz_msgs') }
|
|
}
|
|
|
|
dependencies {
|
|
implementation "com.google.protobuf:protobuf-java:${protobuf_version}"
|
|
implementation "com.google.protobuf:protoc:${protobuf_version}"
|
|
}
|
|
|
|
/* There is a nice gradle plugin for protobuf, and the protoc tool
|
|
is included; using it simplifies our build process.
|
|
The trick is that we have to use the same version as the system
|
|
copy of libprotobuf-dev */
|
|
protobuf {
|
|
protoc {
|
|
artifact = "com.google.protobuf:protoc:${protobuf_version}"
|
|
}
|
|
|
|
generatedFilesBaseDir = "$buildDir/generated"
|
|
generateProtoTasks {
|
|
all().each { task ->
|
|
task.builtins {
|
|
cpp {
|
|
outputSubDir = 'simulation/gz_msgs'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
model {
|
|
components {
|
|
gz_msgs(NativeLibrarySpec) {
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDir "$buildDir/generated/main/simulation/gz_msgs"
|
|
builtBy tasks.generateProto
|
|
}
|
|
exportedHeaders {
|
|
srcDir "src/include"
|
|
srcDir "$buildDir/generated/main"
|
|
}
|
|
}
|
|
}
|
|
/* We must compile with -fPIC to link the static library into an so */
|
|
binaries {
|
|
all {
|
|
cppCompiler.args "-fPIC"
|
|
|
|
// Disable -Wzero-length-array on Clang
|
|
if (it.targetPlatform.operatingSystem.isMacOsX()) {
|
|
it.cppCompiler.args.add('-Wno-error=zero-length-array')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|