import org.apache.tools.ant.taskdefs.condition.Os //cmake wrapper tasks task setupCmake(type: Exec) { description = 'create build directory for cmake to use' group = 'WPILib Simulation' workingDir '..' commandLine 'mkdir', '-p', 'build' } task cmake(type: Exec, dependsOn: setupCmake) { description = 'run cmake in the build directory to generate makefiles' group = 'WPILib Simulation' workingDir '../build' if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine '../configure.bat', "-DNTCORE_INCLUDE_DIR=$netTablesInclude", "-DNTCORE_LIBDIR=$netLibDesktopLocation", "-DSIMULATION_INSTALL_DIR=$simulationInstallDir" } else { commandLine 'cmake', '..', "-DNTCORE_INCLUDE_DIR=$netTablesInclude", "-DNTCORE_LIBDIR=$netLibDesktopLocation", "-DSIMULATION_INSTALL_DIR=$simulationInstallDir" } } task frc_gazebo_plugins(type: Exec, dependsOn: cmake) { description = 'build Gazebo plugins with cmake' group = 'WPILib Simulation' workingDir '../build' if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine 'nmake', 'frc_gazebo_plugins' } else { commandLine 'make', 'frc_gazebo_plugins' } } task gz_msgs(type: Exec, dependsOn: cmake) { description = 'build gz_msgs library with cmake' group = 'WPILib Simulation' workingDir '../build' if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine 'nmake', 'gz_msgs' } else { commandLine 'make', 'gz_msgs' } } task wpilibcSim(type: Exec, dependsOn: ['cmake', ':unzipNetworkTables']) { description = 'build WPILib C++ for simulation with cmake' group = 'WPILib Simulation' workingDir '../build' if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine 'nmake', 'wpilibcSim' } else { commandLine 'make', 'wpilibcSim' } } task allcsim(dependsOn: [wpilibcSim, gz_msgs, frc_gazebo_plugins]){ description = 'wrapper task to build all c++ simulation tasks' group = 'WPILib Simulation' } task wpilibcSimCopy(type: Copy, dependsOn: allcsim) { description = 'copy headers and ntcore library to make simulation zip' group = 'WPILib Simulation' into "$simulationInstallDir" from ("$netTablesInclude"){ into "include" } from ("../hal/include"){ into "include" } from ("sim/include"){ into "include" } from ("shared/include"){ into "include" } from ("$netLibDesktopLocation/libntcore.so") { into "lib" } } build.dependsOn allcsim