[openrtm-commit:00939] r380 - trunk/rtmtools

openrtm @ openrtm.org openrtm @ openrtm.org
2013年 1月 24日 (木) 17:26:37 JST


Author: n-ando
Date: 2013-01-24 17:26:37 +0900 (Thu, 24 Jan 2013)
New Revision: 380

Modified:
   trunk/rtmtools/buildall.sh
Log:
buildall.sh has been updated to set some env.variables automatically.

Modified: trunk/rtmtools/buildall.sh
===================================================================
--- trunk/rtmtools/buildall.sh	2013-01-23 15:38:03 UTC (rev 379)
+++ trunk/rtmtools/buildall.sh	2013-01-24 08:26:37 UTC (rev 380)
@@ -1,32 +1,68 @@
 #!/bin/sh
-#===========================================================================
+#
+# @file buildall.sh
+# @brief rtmtools build script
+# @author Noriaki Ando <n-ando at aist.go.jp>
+#
 # update:
 # cerate:Sep/11/2008
-# 
-# このシェルスクリプトは RTSystemEditor をビルドします。
-#     (以降、"Update"毎に上記に日付、名前、変更内容を記述する)
-# このシェルスクリプトは RTSystemEditor をビルドします。
-# 環境
-#  以下にビルドに必要な環境とインストール方法を簡単に示します。
-#   Eclipse SDK
-#   ant
-#   jdk
-# 
-# 環境変数
-#  ビルドに必要な環境変数を以下に示します。
-#   ECLIPSE_HOME   Eclipse SDK 3.2.x の実行ファイルがあるディレクトリを指定
-#   JAVA_HOME      jdkのディレクトリを指定します。
 #
-#===========================================================================
+# * How to build rtmtools
 #
+# ** Required environment
 #
+# The following development environment and tools are required to
+# build rtmtools.
+#
+# - jdk
+# - ant
+# - Eclipse SDK (3.4 or later is required.)
+#
+# ** Before build tools
+#
+# Please edit "version" text to set version number of the tools. This
+# is a kind of bash script.
+#
+# Example:
+# -------
+# VERSION=1.1.0
+# PROJECT_VERSION=${VERSION}.rc7v$(date +%Y%m%d)
+#
+# ** Environment variables
+#
+# To build rtmtools, some environmental variables can be set. In most
+# case, these variables are automatically set.
+#
+# - ECLIPSE_HOME: A directory path to an Eclipse SDK. Under this
+#                 directory, .eclipseproduct, eclipse.ini, plugins and
+#                 eclipse executable should exist. If this
+#                 env.variable is not set, this script tries to search
+#                 eclipse directory under some directories that is set
+#                 in a env.variable ECLIPSE_DIRS written in the head
+#                 of this script.
+#
+# - JAVA_HOME: A directory JDK installed. If this variable is not set,
+#                 this script tries to estimate JDK directory to
+#                 resolve symbolic link of javac executable.
+#
+# - VERSION: A simple version number for the tools like 1.1.1. This is
+#                 used for actual bundles' version number with
+#                 PROJECT_VERSION number.
+#
+# - PROJECT_VERSION: Project version number is full version string
+#                 with simple version and suffix like
+#                 rc120121212. This version string is used actual jar
+#                 file name.
+#
 
+
 #---------------------------------------------------------------------------
+# Global variables
 #---------------------------------------------------------------------------
+# jar directory
 JARDIR=openrtp_1.1.0
-LIBS="-lib ../lib -lib $ECLIPSE_HOME/plugins"
-
-projects="jp.go.aist.rtm.toolscommon.profiles
+# target projects
+PROJECTS="jp.go.aist.rtm.toolscommon.profiles
     jp.go.aist.rtm.toolscommon.profiles.nl1
     jp.go.aist.rtm.toolscommon
     jp.go.aist.rtm.toolscommon.nl1
@@ -40,36 +76,143 @@
     jp.go.aist.rtm.nameserviceview.nl1
     jp.go.aist.rtm.systemeditor
     jp.go.aist.rtm.systemeditor.nl1"
+PROJECTS="jp.go.aist.rtm.toolscommon.nl1"
+#jp.go.aist.rtm.toolscommon.profiles
+#    jp.go.aist.rtm.toolscommon.profiles.nl1
+#    jp.go.aist.rtm.toolscommon
+#    jp.go.aist.rtm.toolscommon.nl1"
+#    jp.go.aist.rtm.toolscommon"
 
+# Eclipse search directories
+ECLIPSE_DIRS="../ ../../ ../../ $HOME /usr/lib/ /usr/share"
 
-if test -d $JARDIR; then
-    rm -rf $JARDIR
-    mkdir $JARDIR
-else
-    mkdir $JARDIR
-fi
+#============================================================
+# functions
+#============================================================
 
-for project in $projects; do
-    if test -d $project; then
-	echo "-" $project
-	cd $project
+#------------------------------------------------------------
+# find_eclipsehome
+#
+# This function checks ECLIPSE_HOME env variable and if it is
+# not set, it searches an eclipse directory under ECLIPSE_DIRS,
+# and set ECLIPSE_HOME env variable.
+# ------------------------------------------------------------
+find_eclipsehome()
+{
+    if test ! "x$ECLIPSE_HOME" = "x" ; then
+        return 0
+    fi
+    echo "Environment variable ECLIPSE_HOME is not set. Seaching..."
+    for d in $ECLIPSE_DIRS ; do
+        tmp=`find $d -name .eclipseproduct`
+        if test "x$tmp" = "x" ; then
+            continue
+        fi
+        for e in $tmp ; do
+            edir=`dirname $e`
+            if test -f $edir/eclipse.ini && test -d $edir/plugins ; then
+                export ECLIPSE_HOME="$edir"
+                return 0
+            fi
+        done
+    done
+    echo "eclipse not found. Please install eclipse and set ECLIPSE_HOME."
+    exit 1
+}
 
-	ant buildAll $LIBS
-	    
-	if test $? -ne 0; then
-	    echo "build failed: " $project
-	    exit 1
-	fi
-	mv jar/*aist*.jar ../$JARDIR
-	cd ..
+#------------------------------------------------------------
+# find_javahome
+#
+# This function estimate JAVA_HOME from javac, which usually
+# is a symbolic link to $JAVA_HOME/bin/javac.
+#------------------------------------------------------------
+find_javahome()
+{
+    if test ! "x$JAVA_HOME" = "x" ; then
+        return 0
+    fi
+    echo "Environment variable JAVA_HOME is not set. Searching..."
+    tmp=`readlink -e $(which javac)`
+    jdk_path=`dirname $tmp | sed 's/\/bin$//'`
+    if test "x$jdk_path" = "x" ; then
+        echo "JDK not found. Please install JDK and set JAVA_HOME."
+        exit 1
+    fi
+    export JAVA_HOME=$jdk_path
+    return 0
+}
+
+get_version()
+{
+    if test "x$VERSION" = "x" || test "x$PROJECT_VERSION" = "x" ; then
+        echo "Environment variable VERSION/PROJECT_VERSION is not set."
+        echo "Getting from ./version text."
+        . ./version
+    fi
+}
+
+#------------------------------------------------------------
+# cleanup_jardir
+#
+# Cleanup jar directory
+#------------------------------------------------------------
+cleanup_jardir()
+{
+    if test -d $JARDIR; then
+        rm -rf $JARDIR
+        mkdir $JARDIR
     else
-	echo $project "does not exist"
+        mkdir $JARDIR
     fi
-done
+}
 
-if test -f $JARDIR.zip ; then
-    rm $JARDIR.zip
-fi
-zip $JARDIR.zip -r ./$JARDIR
+do_ant_build()
+{
+    for project in $PROJECTS; do
+        if test -d $project; then
+            echo "- Starting ant build of project: $project"
+            cd $project
+            ant buildAll $LIBS
+            if test $? -ne 0; then
+                echo "[ERROR] build failed: " $project
+                echo "Aborting..."
+                exit 1
+            fi
+            echo "Copying created jar file into $JARDIR..."
+            mv jar/*aist*.jar ../$JARDIR
+            cd ..
+        else
+            echo "Project: $project does not exist"
+            echo "Skipping..."
+        fi
+    done
+}
 
+create_zip()
+{
+    if test -f $JARDIR.zip ; then
+        rm $JARDIR.zip
+    fi
+    zip $JARDIR.zip -r ./$JARDIR
+}
 
+#==============================
+# main
+#==============================
+find_eclipsehome
+find_javahome
+get_version
+
+echo "ECLIPSE_HOME: $ECLIPSE_HOME"
+echo "JAVA_HOME: $JAVA_HOME"
+echo "VERSION: $VERSION"
+echo "PROJECT_VERSION: $PROJECT_VERSION"
+
+LIBS="-lib ../lib -lib $ECLIPSE_HOME/plugins"
+cleanup_jardir
+do_ant_build
+create_zip
+
+exit 0
+
+# end of script
\ No newline at end of file



More information about the openrtm-commit mailing list