blob: 7da3216dc6e9e9a09c92e0b210d2de6473992dd4 [file] [log] [blame]
Brian Silverman1a675112016-02-20 20:42:49 -05001import org.apache.tools.ant.taskdefs.condition.Os
2
3 //cmake wrapper tasks
4task setupCmake(type: Exec) {
5 description = 'create build directory for cmake to use'
6 group = 'WPILib Simulation'
7 workingDir '..'
8 commandLine 'mkdir', '-p', 'build'
9}
10
11task cmake(type: Exec, dependsOn: setupCmake) {
12 description = 'run cmake in the build directory to generate makefiles'
13 group = 'WPILib Simulation'
14 workingDir '../build'
15 if (Os.isFamily(Os.FAMILY_WINDOWS)) {
16 commandLine '../configure.bat',
17 "-DNTCORE_INCLUDE_DIR=$netTablesInclude",
18 "-DNTCORE_LIBDIR=$netLibDesktopLocation",
19 "-DSIMULATION_INSTALL_DIR=$simulationInstallDir"
20 }
21 else {
22 commandLine 'cmake', '..',
23 "-DNTCORE_INCLUDE_DIR=$netTablesInclude",
24 "-DNTCORE_LIBDIR=$netLibDesktopLocation",
25 "-DSIMULATION_INSTALL_DIR=$simulationInstallDir"
Brian Silverman26e4e522015-12-17 01:56:40 -050026 }
27}
28
Brian Silverman1a675112016-02-20 20:42:49 -050029task frc_gazebo_plugins(type: Exec, dependsOn: cmake) {
30 description = 'build Gazebo plugins with cmake'
31 group = 'WPILib Simulation'
32 workingDir '../build'
33 if (Os.isFamily(Os.FAMILY_WINDOWS)) {
34 commandLine 'nmake', 'frc_gazebo_plugins'
35 }
36 else {
37 commandLine 'make', 'frc_gazebo_plugins'
38 }
Brian Silverman26e4e522015-12-17 01:56:40 -050039}
Brian Silverman1a675112016-02-20 20:42:49 -050040
41task gz_msgs(type: Exec, dependsOn: cmake) {
42 description = 'build gz_msgs library with cmake'
43 group = 'WPILib Simulation'
44 workingDir '../build'
45 if (Os.isFamily(Os.FAMILY_WINDOWS)) {
46 commandLine 'nmake', 'gz_msgs'
47 }
48 else {
49 commandLine 'make', 'gz_msgs'
50 }
51}
52
53task wpilibcSim(type: Exec, dependsOn: ['cmake', ':unzipNetworkTables']) {
54 description = 'build WPILib C++ for simulation with cmake'
55 group = 'WPILib Simulation'
56 workingDir '../build'
57 if (Os.isFamily(Os.FAMILY_WINDOWS)) {
58 commandLine 'nmake', 'wpilibcSim'
59 }
60 else {
61 commandLine 'make', 'wpilibcSim'
62 }
63}
64
65task allcsim(dependsOn: [wpilibcSim, gz_msgs, frc_gazebo_plugins]){
66 description = 'wrapper task to build all c++ simulation tasks'
67 group = 'WPILib Simulation'
68}
69
70task wpilibcSimCopy(type: Copy, dependsOn: allcsim) {
71 description = 'copy headers and ntcore library to make simulation zip'
72 group = 'WPILib Simulation'
73 into "$simulationInstallDir"
74
75 from ("$netTablesInclude"){
76 into "include"
77 }
78
79 from ("../hal/include"){
80 into "include"
81 }
82
83 from ("simulation/include"){
84 into "include"
85 }
86
87 from ("shared/include"){
88 into "include"
89 }
90
91 from ("$netLibDesktopLocation/libntcore.so") {
92 into "lib"
93 }
94}
95
96build.dependsOn allcsim