Rename our allwpilib (which is now 2020) to not have 2019 in the name
Change-Id: I3c07f85ed32ab8b97db765a9b43f2a6ce7da964a
diff --git a/simulation/gz_msgs/build.gradle b/simulation/gz_msgs/build.gradle
new file mode 100644
index 0000000..353f4ad
--- /dev/null
+++ b/simulation/gz_msgs/build.gradle
@@ -0,0 +1,95 @@
+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 (!protobuf_version?.trim()) {
+ println "Protobuf is not available. (pkg-config --modversion protobuf failed)"
+ protobuf_version = "+"
+ if (project.hasProperty("makeSim")) {
+ /* Force the build even though we did not find protobuf. */
+ 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"
+ }
+ }
+ }
+ }
+}