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