Add Cmake wrappers and unzip desktop ntcore builds

the task allcsim will build everything
requires ntcore desktop to be built
also fixed Driverstation to match non-sim C++ API

Conflicts:
	wpilibc/simulation/CMakeLists.txt

Change-Id: Id38141a5b48ed7fe064c7e6c8d2f618481b7e298
This commit is contained in:
Peter_Mitrano
2015-11-29 21:12:12 -05:00
parent 9316933454
commit 0d062fba3a
7 changed files with 108 additions and 75 deletions

View File

@@ -56,4 +56,3 @@ include_directories("build")
add_subdirectory(simulation/gz_msgs)
add_subdirectory(wpilibc/simulation)
add_subdirectory(simulation/frc_gazebo_plugins)
add_subdirectory(ntcore)

View File

@@ -22,6 +22,25 @@ To build a specific subproject, such as wpilibc, you must access the subproject
./gradlew :wpilibc:build
```
If you also want simulation to be build, add -PmakeSim. This requires gazebo_transport. We have tested on 14.04 and 15.05, but any correct install of gazebo should work, even on windows if you build from source. Correct means cmake needs to be able to find gazebo-config.cmake, which you get for free with ubuntu installs.
```bash
./gradlew build -PmakeSim
```
Note that java sim libraries build either way, because they don't depend on gazebo, only on JavaGazebo. C++ simulation tasks (including plugins, gz_msgs, and wpilibcSim) all depend on gazebo_transport. In order for this to build you must have installed gazebo. See [The Gazebo website](https://gazebosim.org/) for installation instructions.
If you prefer to use Cmake directly, the you can still do so.
The common cmake tasks are wpilibcSim, frc_gazebo_plugins, and gz_msgs
```bash
mkdir build
cd build
cmake ..
make
```
The gradlew wrapper only exists in the root of the main project, so be sure to run all commands from there. All of the subprojects have build tasks that can be run. Gradle automatically determines and rebuilds dependencies, so if you make a change to the HAL and then run `:wpilibc:build`, the HAL will be rebuilt, then wpilibc.
There are a few tasks other than `build` available. To see them, run the meta-task `tasks`. This will print a list of all available tasks, with a description of each task.

View File

@@ -19,11 +19,20 @@ niLibraryTree.each { lib ->
}
}
def ntDependency =
def armNtDependency =
project.dependencies.create("edu.wpi.first.wpilib.networktables.cpp:NetworkTables:3.0.0-SNAPSHOT:arm@zip")
def config = project.configurations.detachedConfiguration(ntDependency)
config.setTransitive(false)
def netTables = config.files[0].canonicalFile
def armConfig = project.configurations.detachedConfiguration(armNtDependency)
armConfig.setTransitive(false)
def armNetTables = armConfig.files[0].canonicalFile
def desktopNetTables
if (project.hasProperty('makeSim')){
def desktopNtDependency =
project.dependencies.create("edu.wpi.first.wpilib.networktables.cpp:NetworkTables:3.0.0-SNAPSHOT:desktop@zip")
def desktopConfig = project.configurations.detachedConfiguration(desktopNtDependency)
desktopConfig.setTransitive(false)
desktopNetTables = desktopConfig.files[0].canonicalFile
}
def netTablesUnzipLocation = "$buildDir/networktables"
@@ -31,7 +40,10 @@ def netTablesUnzipLocation = "$buildDir/networktables"
task unzipNetworkTables(type: Copy) {
description = 'Unzips the networktables maven dependency so that the include files and libraries can be used'
group = 'WPILib'
from zipTree(netTables)
if (project.hasProperty('makeSim')){
from zipTree(desktopNetTables)
}
from zipTree(armNetTables)
into netTablesUnzipLocation
}
@@ -47,9 +59,12 @@ subprojects {
ext.defineNetworkTablesProperties = {
ext.netTables = netTablesUnzipLocation
ext.netTablesInclude = "$netTablesUnzipLocation/include"
ext.netLibLocation = "$netTablesUnzipLocation/Linux/arm"
ext.netSharedLib = "$netLibLocation/libntcore.so"
ext.netStaticLib = "$netLibLocation/libntcore.a"
ext.netLibArmLocation = "$netTablesUnzipLocation/Linux/arm"
if (project.hasProperty('makeSim')){
ext.netLibDesktopLocation = "$netTablesUnzipLocation/Linux/amd64"
}
ext.netSharedLib = "$netLibArmLocation/libntcore.so"
ext.netStaticLib = "$netLibArmLocation/libntcore.a"
task addNetworkTablesLibraryLinks() {
description = 'Adds the linker flags for the networktables libraries retreived from maven'

View File

@@ -33,3 +33,6 @@ foreach(PLUGIN ${PLUGINS})
install(TARGETS ${PLUGIN} DESTINATION $ENV{HOME}/wpilib/simulation/plugins)
endforeach()
# create a dummy target the depends on all the plugins
add_custom_target(${PROJECT_NAME} DEPENDS ${PLUGINS})

View File

@@ -1,23 +1,54 @@
publishing {
publications {
wpilibcSim(MavenPublication) {
artifact wpilibcSimZip
groupId 'edu.wpi.first.wpilibc.simulation'
artifactId 'WPILibCSim'
version '0.1.0'
}
}
}
import org.apache.tools.ant.taskdefs.condition.Os
task wpilibcSimZip(type: Zip) {
description 'Creates the include zip file for wpilibc'
group 'WPILib'
baseName 'WPILibCSim'
destinationDir = project.buildDir
into 'sim/include'
from "${simulation}/include"
from "${shared}/include"
from '../build/simulation/gz_msgs/generated'
from netTablesInclude
from '../hal/include'
if (project.hasProperty('makeSim')){
//cmake wrapper tasks
task setupCmake(type: Exec) {
workingDir '..'
commandLine 'mkdir', '-p', 'build'
}
task cmake(type: Exec, dependsOn: setupCmake) {
workingDir '../build'
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine '../configure.bat', "-DNTCORE_INCLUDE_DIR=$netTablesInclude","-DNTCORE_LIBDIR=$netLibDesktopLocation"
}
else {
commandLine 'cmake', '..', "-DNTCORE_INCLUDE_DIR=$netTablesInclude","-DNTCORE_LIBDIR=$netLibDesktopLocation"
}
}
task frc_gazebo_plugins(type: Exec, dependsOn: cmake) {
workingDir '../build'
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
comanndLine 'nmake', 'frc_gazebo_plugins'
}
else {
commandLine 'make', 'frc_gazebo_plugins'
}
}
task gz_msgs(type: Exec, dependsOn: cmake) {
workingDir '../build'
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'nmake', 'gz_msgs'
}
else {
commandLine 'make', 'gz_msgs'
}
}
task wpilibcSim(type: Exec, dependsOn: ['cmake', ':unzipNetworkTables']) {
workingDir '../build'
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'nmake', 'wpilibcSim'
}
else {
commandLine 'make', 'wpilibcSim'
}
}
task allcsim(dependsOn: [wpilibcSim, gz_msgs, frc_gazebo_plugins]){
}
build.dependsOn allcsim
}

View File

@@ -1,60 +1,26 @@
cmake_minimum_required(VERSION 2.8)
project(WPILibSim)
if (WIN32)
#temporary until we build dlls
add_definitions(-DBUILDING_STATIC_LIBS)
# XXX: should be set via CMake variables in configure.bat
set(PTHREAD_INCLUDE_DIR "C:/Users/peter/gz-ws/pthread-w32/include")
set(PTHREAD_LIBRARY "C:/Users/peter/gz-ws/pthread-w32/libs/x64/pthreadVC2.lib")
endif()
cmake_policy(SET CMP0015 NEW)
project(wpilibcSim)
get_filename_component(HAL_API_INCLUDES ../../hal/include REALPATH)
get_filename_component(NWT_API_INCLUDES ../../networktables/cpp/include REALPATH)
# also on windows use sprintf_s instead of snprintf
# TODO: find a more permenenant solution
if (WIN32)
add_definitions(-Dsnprintf=sprintf_s)
endif()
file(GLOB_RECURSE COM_SRC_FILES ../wpilibC++/src/*.cpp)
file(GLOB_RECURSE COM_SRC_FILES ../shared/src/*.cpp
src/*.cpp)
set (INCLUDE_FOLDERS include
../wpilibC++/include
../../networktables/ntcore/include
../shared/include
../../hal/include
${NTCORE_INCLUDE_DIR}
${GZ_MSGS_INCLUDE_DIR}
${Boost_INCLUDE_DIR}
${GAZEBO_INCLUDE_DIRS})
if (WIN32)
#these paths will be fixed when a more permenant windows development solution is found
set(INCLUDE_FOLDERS ${INCLUDE_FOLDERS}
C:/Users/peter/gz-ws/protobuf-2.6.0-win64-vc12/src
C:/Users/peter/gz-ws/sdformat/src/win/tinyxml
C:/Users/peter/gz-ws/FreeImage-vc12-x64-release-debug/Source
C:/Users/peter/gz-ws/tbb43_20141023oss/include
${PTHREAD_INCLUDE_DIR})
endif()
message("inc=${INCLUDE_FOLDERS}")
include_directories(${INCLUDE_FOLDERS})
link_directories(${GAZEBO_LIBRARY_DIRS})
link_directories(${NTCORE_LIBDIR})
if (WIN32)
add_library(WPILibSim ${SRC_FILES} ${COM_SRC_FILES})
else()
add_library(WPILibSim SHARED ${SRC_FILES} ${COM_SRC_FILES})
endif()
add_library(${PROJECT_NAME} SHARED ${SRC_FILES} ${COM_SRC_FILES})
target_link_libraries(WPILibSim gz_msgs ntcore ${PTHREAD_LIBRARY} ${Boost_LIBRARIES} ${GAZEBO_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -fPIC) # NetworkTables
if (WIN32)
set_target_properties(${project} PROPERTIES LINK_FLAGS "/DEBUG")
endif()
#copy to eclipse plugin
target_link_libraries(${PROJECT_NAME} gz_msgs ntcore)

View File

@@ -43,7 +43,7 @@ DriverStation::DriverStation() {
}
// Register that semaphore with the network communications task.
// It will signal when new packet data is available.
HALSetNewDataSem(m_packetDataAvailableCond.native_handle());
HALSetNewDataSem(&m_packetDataAvailableCond);
AddToSingletonList();