Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 1 | description = "A set of C++ plugins to interface the FRC Simulator with Gazebo." |
| 2 | |
| 3 | apply plugin: 'edu.wpi.first.NativeUtils' |
| 4 | apply plugin: 'cpp' |
| 5 | apply plugin: "google-test" |
| 6 | |
| 7 | ext.skiplinuxathena = true |
| 8 | ext.skiplinuxraspbian = true |
| 9 | |
| 10 | apply from: "${rootDir}/shared/config.gradle" |
| 11 | |
| 12 | /* If gz_msgs or gazebo is not available, do not attempt a build */ |
| 13 | def gazebo_version = "" |
| 14 | def gazebo_cppflags = "" |
| 15 | def gazebo_linker_args = "" |
| 16 | |
| 17 | try { |
| 18 | gazebo_version = "pkg-config --modversion gazebo".execute().text.trim() |
| 19 | println "Gazebo version is [${gazebo_version}]" |
| 20 | gazebo_cppflags = "pkg-config --cflags gazebo".execute().text.split() |
| 21 | gazebo_linker_args = "pkg-config --libs gazebo protobuf".execute().text.split() |
| 22 | } catch(Exception ex) { } |
| 23 | |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame^] | 24 | if (project.hasProperty("makeSim")) { |
| 25 | if (!gazebo_version?.trim()) { |
| 26 | println "Gazebo development files are not available. (pkg-config --modversion gazebo failed)" |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 27 | println "makeSim set. Forcing build - failure likely." |
| 28 | } |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame^] | 29 | } else { |
| 30 | ext.skip_frc_plugins = true |
| 31 | println "Skipping FRC Plugins." |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | evaluationDependsOn(":simulation:gz_msgs") |
| 35 | def gz_msgs_project = project(":simulation:gz_msgs") |
| 36 | |
| 37 | tasks.whenTaskAdded { task -> |
| 38 | task.onlyIf { !gz_msgs_project.hasProperty('skip_gz_msgs') && !project.hasProperty('skip_frc_plugins') } |
| 39 | } |
| 40 | |
| 41 | model { |
| 42 | components { |
| 43 | clock(NativeLibrarySpec) |
| 44 | dc_motor(NativeLibrarySpec) |
| 45 | encoder(NativeLibrarySpec) |
| 46 | gyro(NativeLibrarySpec) |
| 47 | limit_switch(NativeLibrarySpec) |
| 48 | potentiometer(NativeLibrarySpec) |
| 49 | pneumatic_piston(NativeLibrarySpec) |
| 50 | rangefinder(NativeLibrarySpec) |
| 51 | servo(NativeLibrarySpec) |
| 52 | drive_motor(NativeLibrarySpec) |
| 53 | all { component -> |
| 54 | component.targetBuildTypes 'debug' |
| 55 | sources { |
| 56 | cpp.lib library: "${component.name}", linkage: "static" |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | } |
| 61 | |
| 62 | /* TODO: Finish writing the test case */ |
| 63 | |
| 64 | /* We pass the name of the .so and a .world file to each test */ |
| 65 | testSuites { |
| 66 | all { test-> |
| 67 | def library_file |
| 68 | testedComponent.binaries.withType(SharedLibraryBinarySpec).each { b-> |
| 69 | library_file = b.sharedLibraryFile |
| 70 | } |
| 71 | |
| 72 | tasks.withType(RunTestExecutable) { |
| 73 | args library_file, file("src/${baseName}/world/${baseName}.world") |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | |
| 79 | binaries { |
| 80 | all { |
| 81 | linker.args gazebo_linker_args |
| 82 | cppCompiler.args gazebo_cppflags |
| 83 | lib project: ":simulation:gz_msgs", library: "gz_msgs", linkage: "static" |
| 84 | } |
| 85 | |
| 86 | /* TODO: build only shared object? Figure out why this doesn't work? */ |
| 87 | withType(StaticLibraryBinarySpec) { |
| 88 | buildable = false |
| 89 | } |
| 90 | |
| 91 | withType(GoogleTestTestSuiteBinarySpec) { |
| 92 | |
| 93 | /* We currently only have a test for the clock plugin */ |
| 94 | /* TODO: learn how to add this back to gmock */ |
| 95 | //if (it.projectScopedName.contains("clockTest")) { |
| 96 | // buildable = true |
| 97 | // project(':gmock').addGmockToLinker(it) |
| 98 | //} |
| 99 | //else { |
| 100 | buildable = false |
| 101 | //} |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | task copyScript(type: Copy, group: "FRC Gazebo", description: "Copy the frcgazebo script to the output directory.") { |
| 107 | from "scripts" |
| 108 | into "$project.buildDir/bin" |
| 109 | fileMode 0755 |
| 110 | } |
| 111 | |
| 112 | build.dependsOn copyScript |
| 113 | |
| 114 | /* TODO: Publish this library */ |