description = "A set of C++ plugins to interface the FRC Simulator with Gazebo." apply plugin: 'edu.wpi.first.NativeUtils' apply plugin: 'cpp' apply plugin: "google-test" ext.skiplinuxathena = true ext.skiplinuxarm32 = true apply from: "${rootDir}/shared/config.gradle" /* If gz_msgs or gazebo is not available, do not attempt a build */ def gazebo_version = "" def gazebo_cppflags = "" def gazebo_linker_args = "" try { gazebo_version = "pkg-config --modversion gazebo".execute().text.trim() println "Gazebo version is [${gazebo_version}]" gazebo_cppflags = "pkg-config --cflags gazebo".execute().text.split() gazebo_linker_args = "pkg-config --libs gazebo protobuf".execute().text.split() } catch(Exception ex) { } if (project.hasProperty("forceGazebo")) { if (!gazebo_version?.trim()) { println "Gazebo development files are not available. (pkg-config --modversion gazebo failed)" println "forceGazebo set. Forcing build - failure likely." } } else { ext.skip_frc_plugins = true println "Skipping FRC Plugins." } evaluationDependsOn(":simulation:gz_msgs") def gz_msgs_project = project(":simulation:gz_msgs") tasks.whenTaskAdded { task -> task.onlyIf { !gz_msgs_project.hasProperty('skip_gz_msgs') && !project.hasProperty('skip_frc_plugins') } } model { components { clock(NativeLibrarySpec) dc_motor(NativeLibrarySpec) encoder(NativeLibrarySpec) gyro(NativeLibrarySpec) limit_switch(NativeLibrarySpec) potentiometer(NativeLibrarySpec) pneumatic_piston(NativeLibrarySpec) rangefinder(NativeLibrarySpec) servo(NativeLibrarySpec) drive_motor(NativeLibrarySpec) all { component -> component.targetBuildTypes 'debug' sources { cpp.lib library: "${component.name}", linkage: "static" } } } /* TODO: Finish writing the test case */ /* We pass the name of the .so and a .world file to each test */ testSuites { all { test-> def library_file testedComponent.binaries.withType(SharedLibraryBinarySpec).each { b-> library_file = b.sharedLibraryFile } tasks.withType(RunTestExecutable) { args library_file, file("src/${baseName}/world/${baseName}.world") } } } binaries { all { linker.args gazebo_linker_args cppCompiler.args gazebo_cppflags lib project: ":simulation:gz_msgs", library: "gz_msgs", linkage: "static" } /* TODO: build only shared object? Figure out why this doesn't work? */ withType(StaticLibraryBinarySpec) { buildable = false } withType(GoogleTestTestSuiteBinarySpec) { /* We currently only have a test for the clock plugin */ /* TODO: learn how to add this back to gmock */ //if (it.projectScopedName.contains("clockTest")) { // buildable = true // project(':gmock').addGmockToLinker(it) //} //else { buildable = false //} } } } task copyScript(type: Copy, group: "FRC Gazebo", description: "Copy the frcgazebo script to the output directory.") { from "scripts" into "$project.buildDir/bin" fileMode 0755 } build.dependsOn copyScript /* TODO: Publish this library */