Automatic SO downloading & updating

--HG--
extra : source : 11f8cf1c8ac2a81610ae086b440b6f5ca844377f
This commit is contained in:
Patrick Plenefisch
2014-04-05 02:48:17 -04:00
parent 69d9ad70ab
commit c0222d4e2d
7 changed files with 226 additions and 40 deletions

View File

@@ -10,3 +10,168 @@ get_filename_component(NWT_API_INCLUDES networktables/cpp/include REALPATH)
add_subdirectory(hal)
add_subdirectory(networktables/cpp)
add_subdirectory(wpilibc)
set(CPACK_PACKAGE_NAME "WPILib")
set(CPACK_PACKAGE_VENDOR "Worcester Polytechnic Institute")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "WPILib, NetworkTables and HAL for RoboRIO target
.
This package contains the shared objects for WPILib, NetworkTables, and HAL for the 2015 target on the RoboRIO")
if (NOT DEFINED CPACK_PACKAGE_VERSION)
set(CPACK_PACKAGE_VERSION "2014.9999.DEV")
endif (NOT DEFINED CPACK_PACKAGE_VERSION)
SET(DEBIAN_ARCHITECTURE armv7a-vfp)
SET(CPACK_PACKAGE_CONTACT "Brad Miller at WPI")
# Compute the md5sums file by doing a recursion of directory: `DIRECTORY`
MACRO(COMPUTE_MD5SUMS DIRECTORY OUTPUT_FILE)
# Super ugly and barely readable but you need that in order to
# work around a deficiency in EXECUTE_PROCESS which does not have dependencie scanning
# TODO: look at this more
FILE(WRITE ${CMAKE_BINARY_DIR}/md5sum.cmake "
FILE(GLOB_RECURSE MD5SUM_INPUT_FILES ${DIRECTORY}/*)
EXECUTE_PROCESS(
COMMAND ${CMAKE_COMMAND} -E md5sum \${MD5SUM_INPUT_FILES}
WORKING_DIRECTORY ${DIRECTORY}
OUTPUT_VARIABLE md5sum_VAR
RESULT_VARIABLE md5sum_RES
)
STRING(REPLACE ${DIRECTORY}/
\"\" md5sum_VAR_clean
\${md5sum_VAR})
FILE(WRITE ${CMAKE_BINARY_DIR}/md5sums \${md5sum_VAR_clean})
")
ADD_CUSTOM_COMMAND(
OUTPUT ${OUTPUT_FILE}
COMMAND cmake
ARGS -P ${CMAKE_BINARY_DIR}/md5sum.cmake
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
DEPENDS ${DIRECTORY} ${CMAKE_BINARY_DIR}/md5sum.cmake
COMMENT "Generating md5sums"
)
ENDMACRO(COMPUTE_MD5SUMS)
IF (NOT CMAKE_AR)
MESSAGE(FATAL_ERROR "ar is required but could not be found. If it is in a non-standard location, use -DCMAKE_AR=path/to/ar")
ELSE (NOT CMAKE_AR)
IF (NOT DEFINED "CPACK_PACKAGE_NAME")
MESSAGE(FATAL_ERROR "Package name was not set, please set the package name")
ENDIF (NOT DEFINED "CPACK_PACKAGE_NAME")
# debian policy enforce lower case for package name
STRING(TOLOWER ${CPACK_PACKAGE_NAME} DEBIAN_PACKAGE_NAME)
IF(NOT DEBIAN_PACKAGE_DEPENDS)
SET(DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.11.1-r7), libgcc1 (>= 4.4.1)")
ENDIF(NOT DEBIAN_PACKAGE_DEPENDS)
IF(NOT DEBIAN_PACKAGE_VERSION)
SET(DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
ENDIF(NOT DEBIAN_PACKAGE_VERSION)
IF(NOT DEBIAN_PACKAGE_SECTION)
SET(DEBIAN_PACKAGE_SECTION devel)
ENDIF(NOT DEBIAN_PACKAGE_SECTION)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_BINARY_DIR}/debian-binary
COMMAND ${CMAKE_COMMAND}
ARGS -E echo "2.0" > ${CMAKE_BINARY_DIR}/debian-binary
COMMENT "Generating debian-binary"
VERBATIM)
FILE(WRITE ${CMAKE_BINARY_DIR}/control
"Package: ${DEBIAN_PACKAGE_NAME}
Version: ${CPACK_PACKAGE_VERSION}
Section: ${DEBIAN_PACKAGE_SECTION}
Priority: optional
Architecture: ${DEBIAN_ARCHITECTURE}
Depends: ${DEBIAN_PACKAGE_DEPENDS}
Maintainer: ${CPACK_PACKAGE_CONTACT}
Description: ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}
")
FILE(WRITE ${CMAKE_BINARY_DIR}/postrm "#! /bin/sh
ldconfig
")
FILE(WRITE ${CMAKE_BINARY_DIR}/postinst "#! /bin/sh
ldconfig
")
# let's create a temp directory to call 'DESTDIR=... make install' into:
# cleanup
FILE(REMOVE ${CMAKE_BINARY_DIR}/debian_package)
# make dir:
FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/debian_package)
# calling cmake -P cmake_install.cmake is the same as calling make install:
ADD_CUSTOM_TARGET(deb_destdir_install
COMMAND DESTDIR=${CMAKE_BINARY_DIR}/debian_package ${CMAKE_COMMAND} -DCOMPONENT=lib -P cmake_install.cmake
DEPENDS ${CMAKE_BINARY_DIR}/cmake_install.cmake WPILibAthena NetworkTables HALAthena
COMMENT "Building debian_package directory with DESTDIR"
)
ADD_DEPENDENCIES(deb_destdir_install all)
ADD_CUSTOM_TARGET(control_perms
COMMAND chmod +x ${CMAKE_BINARY_DIR}/postinst ${CMAKE_BINARY_DIR}/postrm
DEPENDS ${CMAKE_BINARY_DIR}/postinst ${CMAKE_BINARY_DIR}/postrm
COMMENT "Setting executable permissions"
)
# create data.tar.gz from the make install stuff
# all files starts with: ./usr
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_BINARY_DIR}/data.tar.gz
COMMAND cmake -E tar
ARGS cfz ${CMAKE_BINARY_DIR}/data.tar.gz .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/debian_package
DEPENDS ${CMAKE_BINARY_DIR}/debian_package
COMMENT "Generating data.tar.gz"
)
# get all the files to be installed:
COMPUTE_MD5SUMS(
${CMAKE_BINARY_DIR}/debian_package
${CMAKE_BINARY_DIR}/md5sums
)
# create a tarball (control.tar.gz) of control and md5sums
# files need to be in relative path: ./md5sums ./control ...
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_BINARY_DIR}/control.tar.gz
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND cmake -E tar
ARGS cfz ${CMAKE_BINARY_DIR}/control.tar.gz control md5sums postinst postrm
DEPENDS ${CMAKE_BINARY_DIR}/control ${CMAKE_BINARY_DIR}/md5sums ${CMAKE_BINARY_DIR}/postinst ${CMAKE_BINARY_DIR}/postrm control_perms
COMMENT "Generating control.tar.gz"
)
# Warning order is important:
# ar -r your-package-name.deb debian-binary control.tar.gz data.tar.gz
# eg: cmake_2.4.5-1_i386.deb
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_BINARY_DIR}/${DEBIAN_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${DEBIAN_ARCHITECTURE}.deb
COMMAND ${CMAKE_AR}
ARGS -r ${CMAKE_BINARY_DIR}/${DEBIAN_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${DEBIAN_ARCHITECTURE}.deb
${CMAKE_BINARY_DIR}/debian-binary
${CMAKE_BINARY_DIR}/control.tar.gz ${CMAKE_BINARY_DIR}/data.tar.gz
DEPENDS ${CMAKE_BINARY_DIR}/debian-binary ${CMAKE_BINARY_DIR}/control.tar.gz ${CMAKE_BINARY_DIR}/data.tar.gz
COMMENT "Generating deb package"
)
# the final target:
ADD_CUSTOM_TARGET(package
DEPENDS ${CMAKE_BINARY_DIR}/${DEBIAN_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${DEBIAN_ARCHITECTURE}.deb
)
ADD_DEPENDENCIES(package deb_destdir_install)
# BUG: debian_package is not removed during a 'make clean':
SET_DIRECTORY_PROPERTIES(PROPERTIES
ADDITIONAL_MAKE_CLEAN_FILES "debian-binary;control;md5sums;debian_package;")
ENDIF (NOT CMAKE_AR)

View File

@@ -24,7 +24,8 @@
<configuration>
<options>
<option>-DCMAKE_TOOLCHAIN_FILE=../../../arm-toolchain.cmake</option>
<option>-DCMAKE_INSTALL_PREFIX=target-root</option>
<option>-DCMAKE_INSTALL_PREFIX=/usr/local/frc/</option>
<option>-DCPACK_PACKAGE_VERSION=${version-info}</option>
</options>
</configuration>
</execution>
@@ -34,6 +35,28 @@
<goals>
<goal>compile</goal>
</goals>
<configuration>
<target>package</target>
</configuration>
</execution>
<execution>
<id>cmake3</id>
<phase>generate-resources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<options>
<option>-DCMAKE_INSTALL_PREFIX=target-root</option>
</options>
</configuration>
</execution>
<execution>
<id>cmake4</id>
<phase>generate-resources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<target>install</target>
</configuration>
@@ -65,7 +88,7 @@
<format property="timestamp" pattern="yyyy/MM/dd HH:mm:ss z"/>
</tstamp>
<tstamp>
<format property="version-info" pattern="yyyy.MM"/>
<format property="version-info" pattern="yyyy.MMdd.HHmmss"/>
</tstamp>
<property name="version" value="${version-info}.${build-number}"/>
</target>
@@ -81,7 +104,10 @@
</goals>
<configuration>
<target>
<echo file="${project.build.directory}/cmake/target-root/so.properties">cpp-sos=${version-info}</echo>
<move file="${project.build.directory}/cmake/wpilib_${version-info}_armv7a-vfp.deb" todir="${project.build.directory}/cmake/target-root" />
<zip destfile="${project.build.directory}/cpp-root-1.0.0.jar" basedir="${project.build.directory}/cmake/target-root" />
<move file="${project.build.directory}/cmake/target-root/wpilib_${version-info}_armv7a-vfp.deb" todir="${project.build.directory}/cmake/" />
</target>
</configuration>
</execution>

View File

@@ -2,6 +2,8 @@
<project name="athena-project-build" default="deploy">
<property file="${wpilib.ant.dir}/../so.properties"/>
<!-- Load Tasks -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
@@ -25,36 +27,6 @@
<echo>Target IP: ${target}</echo>
</target>
<!-- <target name="compile" description="Compile the source code."> -->
<!-- <mkdir dir="${build.dir}"/> -->
<!-- <echo>[athena-compile] Compiling ${src.dir} with classpath=${classpath} to ${build.dir}</echo> -->
<!-- <javac srcdir="${src.dir}" -->
<!-- destdir="${build.dir}" -->
<!-- includeAntRuntime="no" -->
<!-- includeJavaRuntime="no" -->
<!-- classpath="${classpath}" -->
<!-- target="1.7" -->
<!-- source="1.7" -->
<!-- debug="true"> -->
<!-- </javac> -->
<!-- </target> -->
<!-- <target name="jar" depends="compile"> -->
<!-- <echo>[athena-jar] Making jar ${dist.jar}.</echo> -->
<!-- <mkdir dir="${dist.dir}" /> -->
<!-- <jar destfile="${dist.jar}" update="false"> -->
<!-- <manifest> -->
<!-- <attribute name="Main-Class" value="${main}"/> -->
<!-- <attribute name="Class-Path" value="."/> -->
<!-- </manifest> -->
<!-- <fileset dir="${build.dir}" includes="**"/> -->
<!-- <zipgroupfileset file="${networktables.jar}" /> -->
<!-- </jar> -->
<!-- </target> -->
<target name="deploy" depends="get-target-ip" description="Deploy the progam and start it running.">
<echo>[athena-deploy] Killing running program</echo>
<sshexec host="${target}"
@@ -65,6 +37,29 @@
<echo>[athena-deploy] Copying code over.</echo>
<scp file="${out.exe}" todir="${username}@${target}:${deploy.dir}"
password="${password}" trust="true"/>
<sshexec host="${target}"
username="${username}"
password="${password}"
trust="true"
command="opkg info wpilib |grep Version | awk '{printf $2}'"
outputproperty="installedWpilibSo"/>
<if>
<equals arg1="${installedWpilibSo}" arg2="${cpp-sos}" />
<then>
<echo>Found version of WPILib: ${installedWpilibSo} (latest)</echo>
</then>
<else>
<echo>Found version of WPILib: ${installedWpilibSo}</echo>
<echo>Upgrading WPILib to ${cpp-sos}...</echo>
<scp file="${wpilib.ant.dir}/../wpilib_${cpp-sos}_armv7a-vfp.deb" todir="${username}@${target}:/tmp"
password="${password}" trust="true"/>
<sshexec host="${target}"
username="${username}"
password="${password}"
trust="true"
command="opkg install /tmp/wpilib_${cpp-sos}_armv7a-vfp.deb; sh -c 'rm -rf /tmp/wpilib*.deb'"/>
</else>
</if>
<scp file="${wpilib.ant.dir}/runcppprogram" todir="${username}@${target}:${deploy.dir}"
password="${password}" trust="true"/>
<scp file="${wpilib.ant.dir}/runjavaprogram" todir="${username}@${target}:${deploy.dir}"

View File

@@ -3,4 +3,4 @@ killall java
killall FRCUserProgram
sleep 1
chmod +x ./FRCUserProgram
nohup ./FRCUserProgram
./FRCUserProgram

View File

@@ -5,9 +5,9 @@ file(GLOB_RECURSE SRC_FILES lib/Athena/*.cpp)
include_directories(lib/Athena include)
add_library(HALAthena SHARED ${SRC_FILES})
target_link_libraries(HALAthena ${NI_LIBS})
INSTALL(TARGETS HALAthena LIBRARY DESTINATION lib)
INSTALL(FILES ${NI_LIBS} DESTINATION lib)
INSTALL(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX})
INSTALL(TARGETS HALAthena LIBRARY DESTINATION lib COMPONENT lib)
INSTALL(FILES ${NI_LIBS} DESTINATION lib COMPONENT ni_lib)
INSTALL(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT headers)
# lib/ c m gcc_s ld-linux
# usr/lib stdc++
# FRC_NetworkCommunication FRC_FPGA_ChipObject RoboRIO_FRC_ChipObject

View File

@@ -6,8 +6,8 @@ file(GLOB_RECURSE SRC_SHARE_FILES lib/share/*.cpp)
include_directories(include)
add_library(NetworkTables SHARED ${SRC_SHARE_FILES} ${SRC_TARGET_FILES})
target_link_libraries(NetworkTables ${NI_LIBS})
INSTALL(TARGETS NetworkTables LIBRARY DESTINATION lib)
INSTALL(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX})
INSTALL(TARGETS NetworkTables LIBRARY DESTINATION lib COMPONENT lib)
INSTALL(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT headers)
# lib/ c gcc_s ld-linux
# usr/lib stdc++
# NiRioSrv

View File

@@ -5,8 +5,8 @@ file(GLOB_RECURSE SRC_FILES lib/*.cpp)
include_directories(include/ ${HAL_API_INCLUDES} ${NWT_API_INCLUDES})
add_library(WPILibAthena SHARED ${SRC_FILES})
target_link_libraries(WPILibAthena HALAthena NetworkTables ${NI_LIBS})
INSTALL(TARGETS WPILibAthena LIBRARY DESTINATION lib)
INSTALL(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX})
INSTALL(TARGETS WPILibAthena LIBRARY DESTINATION lib COMPONENT lib)
INSTALL(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT headers)
# lib/ c m gcc_s ld-linux
# usr/lib stdc++
# ni_emb