blob: 2bc2c4f62ccd1650cd8e229c42dd8f9ad2f402a2 [file] [log] [blame]
Brian Silvermanf7f267a2017-02-04 16:16:08 -08001import 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 "-DWPIUTIL_INCLUDE_DIR=$wpiUtilInclude",
20 "-DWPIUTIL_LIBDIR=$wpiUtilLibDesktopLocation",
21 "-DSIMULATION_INSTALL_DIR=$simulationInstallDir"
22 }
23 else {
24 commandLine 'cmake', '..',
25 "-DNTCORE_INCLUDE_DIR=$netTablesInclude",
26 "-DNTCORE_LIBDIR=$netLibDesktopLocation",
27 "-DWPIUTIL_INCLUDE_DIR=$wpiUtilInclude",
28 "-DWPIUTIL_LIBDIR=$wpiUtilLibDesktopLocation",
29 "-DSIMULATION_INSTALL_DIR=$simulationInstallDir"
30 }
31}
32
33task frc_gazebo_plugins(type: Exec, dependsOn: cmake) {
34 description = 'build Gazebo plugins with cmake'
35 group = 'WPILib Simulation'
36 workingDir '../build'
37 if (Os.isFamily(Os.FAMILY_WINDOWS)) {
38 commandLine 'nmake', 'frc_gazebo_plugins'
39 }
40 else {
41 commandLine 'make', 'frc_gazebo_plugins'
42 }
43}
44
45task gz_msgs(type: Exec, dependsOn: cmake) {
46 description = 'build gz_msgs library with cmake'
47 group = 'WPILib Simulation'
48 workingDir '../build'
49 if (Os.isFamily(Os.FAMILY_WINDOWS)) {
50 commandLine 'nmake', 'gz_msgs'
51 }
52 else {
53 commandLine 'make', 'gz_msgs'
54 }
55}
56
57task wpilibcSim(type: Exec, dependsOn: ['cmake', ':downloadNetworkTables', ':downloadWpiutil', 'generateCppVersion']) {
58 description = 'build WPILib C++ for simulation with cmake'
59 group = 'WPILib Simulation'
60 workingDir '../build'
61 if (Os.isFamily(Os.FAMILY_WINDOWS)) {
62 commandLine 'nmake', 'wpilibcSim'
63 }
64 else {
65 commandLine 'make', 'wpilibcSim'
66 }
67}
68
69task allcsim(dependsOn: [wpilibcSim, gz_msgs, frc_gazebo_plugins]){
70 description = 'wrapper task to build all c++ simulation tasks'
71 group = 'WPILib Simulation'
72}
73
74task wpilibcSimCopy(type: Copy, dependsOn: allcsim) {
75 description = 'copy headers and ntcore library to make simulation zip'
76 group = 'WPILib Simulation'
77 into "$simulationInstallDir"
78
79 from ("$netTablesInclude"){
80 into "include"
81 }
82
83 from ("$wpiUtilInclude"){
84 into "include"
85 }
86
87 from ("../hal/include"){
88 into "include"
89 }
90
91 from ("sim/include"){
92 into "include"
93 }
94
95 from ("shared/include"){
96 into "include"
97 }
98
99 from ("$netLibDesktopLocation/libntcore.so") {
100 into "lib"
101 }
102
103 from ("$wpiUtilLibDesktopLocation/libwpiutil.so") {
104 into "lib"
105 }
106}
107
108build.dependsOn allcsim