blob: d9db2b9591075f56934ace5dbbe80eddeeafabea [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
Austin Schuh1e69f942020-11-14 15:06:14 -080024if (project.hasProperty("makeSim")) {
25 if (!gazebo_version?.trim()) {
26 println "Gazebo development files are not available. (pkg-config --modversion gazebo failed)"
Brian Silverman8fce7482020-01-05 13:18:21 -080027 println "makeSim set. Forcing build - failure likely."
28 }
Austin Schuh1e69f942020-11-14 15:06:14 -080029} else {
30 ext.skip_frc_plugins = true
31 println "Skipping FRC Plugins."
Brian Silverman8fce7482020-01-05 13:18:21 -080032}
33
34evaluationDependsOn(":simulation:gz_msgs")
35def gz_msgs_project = project(":simulation:gz_msgs")
36
37tasks.whenTaskAdded { task ->
38 task.onlyIf { !gz_msgs_project.hasProperty('skip_gz_msgs') && !project.hasProperty('skip_frc_plugins') }
39}
40
41model {
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
106task 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
112build.dependsOn copyScript
113
114/* TODO: Publish this library */