sbsv2/raptor/bin/sbs_env
author lorewang
Wed, 24 Nov 2010 14:12:23 +0800
changeset 706 5221386d044b
parent 674 37ee82a83d43
permissions -rw-r--r--
external tools cannot specify path.

# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
# All rights reserved.
# This component and the accompanying materials are made available
# under the terms of the License "Eclipse Public License v1.0"
# which accompanies this distribution, and is available
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
#
# Initial Contributors:
# Nokia Corporation - initial contribution.
#
# Contributors:
#
# Description:
# raptor script
# manages common environment settings
#

# Ensure that the host type is set for Raptor:
eval $($SBS_HOME/bin/gethost.sh -e)

if [ -z "$HOSTPLATFORM" ]; then
	echo "Error: HOSTPLATFORM could not be determined." 1>&2
	exit 1
fi

if [ ! -d "$SBS_HOME/$HOSTPLATFORM_DIR" ]; then
cat 1>&2 <<EOERROR
Error: sbs has not been installed with support for your platform: "${HOSTPLATFORM}".

The utilites for your platform should be in "$SBS_HOME/$HOSTPLATFORM_DIR" but sbs
cannot find them there.

sbs is supported on:
	win32
	linux i386 libc2_3 (Redhat 4)

sbs has been known to work (but is not supported) on:
	linux x86_64 libc2_5  (e.g. Centos/Redhat 5.3 64-bit)
	linux i386 libc2_8  (e.g. Fedora 9 32-bit)
	linux x86_64 libc2_10 (e.g. Fedora 11 64-bit)

Even with the appropriate utilities it may be necessary to install 32-bit
compatibility versions of some libraries (e.g. glibc) on these platforms,
particularly for 3rd party tools which are not built natively such as
compilers.

It may be possible to build and install the utilities for your platform by
entering $SBS_HOME/util and running
	make -k
A full development environment is required however.
EOERROR
	exit 1
fi

if [ "$OSTYPE" == "cygwin" ]; then

	SBS_HOME=${SBS_HOME//\\//}

	__MINGW__=${SBS_MINGW:-$SBS_HOME/$HOSTPLATFORM_DIR/mingw}
	__PYTHON__=${SBS_PYTHON:-$SBS_HOME/$HOSTPLATFORM_DIR/python264/python.exe}
	export PYTHONPATH=${SBS_PYTHONPATH:-$SBS_HOME/$HOSTPLATFORM_DIR/python264}
			
	# work out which version of Cygwin to use
	# use SBS_CYGWIN17 if set and assume 1.7,
	# otherwise use SBS_CYGWIN and assume 1.5
	# Tell Cygwin 1.5 not to map unix security attributes to windows to
	# prevent raptor from potentially creating read-only files:
	if [ -z "$SBS_CYGWIN17" ]; then
			__CYGWIN__=$SBS_CYGWIN
			export CYGWIN='nontsec nosmbntsec'
			
	else
			__CYGWIN__=$SBS_CYGWIN17
			export CYGWIN=nodosfilewarning
			__MOUNTOPTIONS__='-o noacl -o user'
			__UMOUNTOPTIONS__=
	fi
    # Command for unifying path strings. For example, "c:\some\path" and
    # "/cygdrive/c/some/path" will both be converted into "c:/some/path".
	u="$__CYGWIN__/bin/cygpath.exe -m"

	__MINGW__=$($u "$__MINGW__")
	
	export SBS_HOME=$($u "$SBS_HOME")

	export PATH=${__MINGW__}/bin:${__CYGWIN__}/bin:$SBS_HOME/$HOSTPLATFORM_DIR/bin:$PATH
	
	# The python and PYTHONPATH used by Raptor are determined by, in order of precedence:
	#  1. the SBS_PYTHON and SBS_PYTHONPATH environment variables (if set)
	#  2. the python shipped locally with Raptor (if present)
	#  3. the python on the system PATH and the PYTHONPATH set in the system environment

	__LOCAL_PYTHON__=$SBS_HOME/win32/python264/python.exe

	if [ -n "$SBS_PYTHON" ]; then
		export __PYTHON__=$SBS_PYTHON
	elif [ -f "$__LOCAL_PYTHON__" ]; then
		export __PYTHON__=$__LOCAL_PYTHON__
		export SBS_PYTHON=$__PYTHON__
		export PYTHONPATH=
	else
		export __PYTHON__=python.exe
	fi
	export __PYTHON__=$($u "$__PYTHON__")		

	if [ -n "$SBS_PYTHONPATH" ]; then
		export PYTHONPATH=$($u "$SBS_PYTHONPATH")
	fi

else	
	PYDIR=python27 # not exported on purpose
	export PYTHONPATH=${SBS_PYTHONPATH:-$SBS_HOME/$HOSTPLATFORM_DIR/$PYDIR/lib}
	PATH=$SBS_HOME/$HOSTPLATFORM_DIR/$PYDIR/bin:$SBS_HOME/$HOSTPLATFORM_DIR/bin:$PATH
	LD_LIBRARY_PATH=$SBS_HOME/$HOSTPLATFORM_DIR/$PYDIR/lib:$SBS_HOME/$HOSTPLATFORM_DIR/bv/lib:$LD_LIBRARY_PATH

	export PATH LD_LIBRARY_PATH
	export __PYTHON__=python
fi