print SVN revision in log output
authorsvnhieber <svnhieber@f8795833-4959-0410-8ae9-8bcb0cfab428>
Thu, 2 Dec 2010 17:21:31 +0000 (17:21 +0000)
committersvnhieber <svnhieber@f8795833-4959-0410-8ae9-8bcb0cfab428>
Thu, 2 Dec 2010 17:21:31 +0000 (17:21 +0000)
git-svn-id: https://svn.itm.uni-luebeck.de/wisebed/wiselib/trunk/pc_apps/roomba_tests@3674 f8795833-4959-0410-8ae9-8bcb0cfab428

Makefile
main.cc
svnrevision.sh [new file with mode: 0755]

index 463fe55..63e8b19 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,16 +1,26 @@
-export TARGET=roomba_test
-export SOURCES=main.cc
-export CXXFLAGS=-I/usr/include/qt4 -I/usr/include/qt4/QtCore \
-       -I/usr/include/qt4/QtGui -lQtGui \
-       -I/usr/include/ -I/usr/include/QtCore \
-       -I/usr/include/QtGui -lQtGui 
+WISELIB_PATH=../..
+WISELIB_STABLE=$(WISELIB_PATH)/wiselib.stable
+WISELIB_TESTING=$(WISELIB_PATH)/wiselib.testing
+QTCXXFLAGS=-I/usr/include/qt4 -I/usr/include/qt4/QtCore \
+       -I/usr/include/qt4/QtGui -I/usr/include/QtCore -I/usr/include/QtGui \
+       -lQtGui
+
+CXX=g++
+LD=ld
+CXXFLAGS=-I$(WISELIB_STABLE) -I$(WISELIB_TESTING) -lpthread
+LDFLAGS=
 
 all: roomba_test battery_test
 clean:
-       rm -f battery_test $(TARGET)
+       rm -f roomba_test battery_test svnrevision.h
+
+svnrevision.h:
+       ./svnrevision.sh
 
-include ../Makefile.base
+roomba_test: main.cc svnrevision.h
+       $(CXX) $(CXXFLAGS) $< -o $@ $(QTCXXFLAGS)
 
 battery_test: battery_test.cc
-       $(CXX) -I$(WISELIB_STABLE) -I$(WISELIB_TESTING) -lpthread -o battery_test battery_test.cc
+       $(CXX) $(CXXFLAGS) $< -o $@
 
+# vim: noexpandtab :
diff --git a/main.cc b/main.cc
index ffe54bb..2363146 100644 (file)
--- a/main.cc
+++ b/main.cc
  * THE SOFTWARE.
  */
 
-//#include "main.h"
+#include "svnrevision.h"
 #include <iostream>
 #include <stdint.h>
-//#include <unistd.h>
-//#include "util/standalone_math.h"
-//#include "util/delegates/delegate.hpp"
 #include <external_interface/pc/pc_os_model.h>
 #include <external_interface/pc/pc_com_uart.h>
 #include <external_interface/pc/pc_timer.h>
@@ -136,14 +133,15 @@ void drive(Roomba& roomba, ControlledMotion& ctrl_motion) {
         + "Input travelled distance on y axis in mm:", deviation_y,
         numeric_limits<int>::min(), numeric_limits<int>::max(), 1, &ok);
       if(ok) {
-        cout << "input_distance=" << input_distance << " velocity=" << velocity
-          << " internal_distance=" << roomba.distance() << " deviation_x="
-          << deviation_x << " deviation_y=" << deviation_y
-          << " encoder_ticks_left=" << sensor_data.left_encoder_counts
-          << " encoder_ticks_right=" << sensor_data.right_encoder_counts
-          << " batt_charge=" << sensor_data.charge << " batt_capacity="
-          << sensor_data.capacity << " batt_voltage=" << sensor_data.voltage
-          << " batt_current=" << sensor_data.current << endl;
+        cout << "svn=" << SVNREVISION << " input_distance=" << input_distance
+          << " velocity=" << velocity << " internal_distance="
+          << roomba.distance() << " deviation_x=" << deviation_x
+          << " deviation_y=" << deviation_y << " encoder_ticks_left="
+          << sensor_data.left_encoder_counts << " encoder_ticks_right="
+          << sensor_data.right_encoder_counts << " batt_charge="
+          << sensor_data.charge << " batt_capacity=" << sensor_data.capacity
+          << " batt_voltage=" << sensor_data.voltage << " batt_current="
+          << sensor_data.current << endl;
       } else {
         break;
       }
diff --git a/svnrevision.sh b/svnrevision.sh
new file mode 100755 (executable)
index 0000000..67b03a2
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+revision=$(svn info|grep Revision|sed 's/Revision: //')
+
+if [ -n "$(svn status|grep '^M')" ]; then
+  status=" with local changes"
+else
+  status=""
+fi;
+
+echo '// This file is created automatically, your changes will be lost.' > svnrevision.h
+echo '#define SVNREVISION "r'$revision$status'"'  >> svnrevision.h
+
This page took 0.054357 seconds and 4 git commands to generate.