GBS Logo HOME Generic Build Support (GBS) - User Manual
The switch.gbs script file Bottom Doc. Button

Contents Bottom Doc. Button Top Document Button Down Section Button Blank

Description
Purpose| General| Calling| Environment Variables| Additional Available Environment Variables| Layout| Notes
Example of a switch.gbs.bat
Example of a switch.gbs.bat| Example of a switch.gbs.sh

Description Bottom Doc. Button Top Document Button Down Section Button Up Section Button

Purpose Bottom Doc. Button Top Document Button Down Section Button Up Section Button Down Chapter Button Blank

The switch.gbs script file is located in the GBS_SYSTEM_PATH directory and is used to define the environment in which the System has to function.
Here all external items must be defined. e.g.:

To edit the file: gbsedit switch.gbs

In GBS the switch.gbs script file and the site.gbs script file are the only files allowed to contain absolute disk-addresses

General Bottom Doc. Button Top Document Button Down Section Button Up Section Button Down Chapter Button Up Chapter Button

Special considerations:

Calling Bottom Doc. Button Top Document Button Down Section Button Up Section Button Down Chapter Button Up Chapter Button

The switch.gbs file is called:
When you enter a System (swr or startup)
GBS_SYSTEM_PATH:switch.gbs is called with parameter entry
When you leave a System (swr)
GBS_SYSTEM_PATH:switch.gbs is called with parameter exit

Environment Variables Bottom Doc. Button Top Document Button Down Section Button Up Section Button Down Chapter Button Up Chapter Button

Environment Variables defined in the switch.gbs file should be in uppercase.
When referring to external data (directories/files) they should be prefixed with GBSEXT_. (Not GBS_EXT_)
When exiting a System, GBS will unset all GBSEXT_ Environment Variables that were set at 'entry'.
This is done before the switch.gbs is called with the 'exit' parameter.
The only sensible thing to do in the 'exit' part is to call a script or program. But this will be extremely rare.
Note that at the moment of invocation all GBS internal Environment Variables for that System have been set.

Additional Available Environment Variables Bottom Doc. Button Top Document Button Down Section Button Up Section Button Down Chapter Button Up Chapter Button

These are defined before execution of the switch.gbs file and can be used to control additional settings.
They should not be changed!
GBS_SITE
Preset by user (Install or gbssettings)
Specifies the site where this user is working
More info in Install Notes
GBS_VERSION
A full numeric value that identifies the current build of GBS
A combination of the GBS version and version_date. E.g.: 6.01
GBS_PLATFORM
Use to distinguish on which platform GBS is running. e.g.:
    linux, MSWin32, etc
GBS_SYSTEM_PARENT
The name of the parent directory (not the path) of the System.
It is used to define a Log-directory dependent on the System. E.g.:
SET GBS_LOG_PATH=%GBSLOG_ROOT%\%GBS_SYSTEM_PARENT%
GBS_IS_INTEGRATOR
0 or 1
Specifies that the user has GBS Integrator privileges
GBS_IS_ADMINISTRATOR
0 or 1
Specifies that the user has GBS Administrator privileges

Layout Bottom Doc. Button Top Document Button Down Section Button Up Section Button Down Chapter Button Up Chapter Button

The file consists of two mayor parts:

Entry

This part is executed when you 'enter' a System (make it current)
It consists of 2 Sections

The ROOT section

This Section is where you have the Site dependent stuff.
Here you will typically set GBSEXT_..._ROOT EnvVars to their Site-dependent locations

As this part remains consistent for the various Systems on your computer (SITE) you can also define the GBSEXT_..._ROOT EnvVars in a separate file site.gbs(.bat/.sh) instead. (described below)

The REL and PATH section

This Section is where you set the GBSEXT_..._REL
And the assembly of GBSEXT_..._ROOT and GBSEXT_..._REL to GBSEXT_..._PATH

In some cases (e.g. svn or git) you can set the GBSEXT_..._PATH to PATH. No GBSEXT_..._REL is needed in this case.

Exit

This part is executed when you 'exit' a System (un-current it)

Notes: Bottom Doc. Button Top Document Button Down Section Button Up Section Button Blank Up Chapter Button

Please note the following:
  1. Do not try to be 'clever' with these files.
  2. Placing any 'clever' stuff in these files may cause GBS to malfunction.
    If not today: definitely in the future.

Example of a switch.gbs.bat: Bottom Doc. Button Top Document Button Down Section Button Up Section Button

Example of a switch.gbs.bat: Bottom Doc. Button Top Document Button Down Section Button Up Section Button Down Chapter Button Blank


@ECHO OFF
::================================================
::  File:        %FILE%
::  Path:        %PATH%
::  System Name: %SYSTEM_NAME%
::================================================
if NOT [%1] == [entry] goto :do_exit
    ::
    ::	ENTRY: set items
    ::

    ::-------------------------------------------
    ::	ROOT Section
    ::	This part can be deleted if <GBS_BASE_PATH>/site.gbs.bat is used
    ::-------------------------------------------
    if NOT [%GBS_SITE%] == [%SITE%] goto :NOT_%SITE%
	::
	::  %SITE%
	::

	::
	::  Version Control
	::
	::set GBSEXT_GIT_ROOT=C:\Program Files\Git

	::set GBSEXT_SVN_ROOT=C:\Program Files\Subversion

	::
	::  Builds
	::
	::set GBSEXT_MSVS2012_ROOT=C:\Program Files (x86)\Microsoft Visual Studio 11.0
	::set GBSEXT_MSVS2012_KIT_ROOT=C:\Program Files (x86)\Windows Kits
	::set GBSEXT_MSBUILD_ROOT=C:\Windows\Microsoft.NET\Framework

	::set GBSEXT_MINGW_ROOT=C:\MinGW

	::
	::  Audits
	::
	::set GBSEXT_QAC_ROOT=C:\MyPrograms\PRQA\QAC

	::set GBSEXT_QACPP_ROOT=C:\MyPrograms\PRQA\QACPP

	::set GBSEXT_PCLINT_ROOT=C:\MyPrograms\PC-Lint

	::set GBSEXT_CPPTEST_ROOT=C:\MyPrograms\Parasoft\C++test

	::
	::  Tools
	::
	::set GBSEXT_DOXYGEN_ROOT=C:\MyPrograms\doxygen

	::
	::  GBS Settings
	::

	goto :end_site
    :NOT_%SITE%
    if NOT [%GBS_SITE%] == [OTHER] goto :NOT_OTHER
	::
	::      OTHER
	::
	goto :end_site
    :NOT_OTHER
	echo *******
	echo **  Unknown site '%GBS_SITE%'
	echo **  Must be one of [ %SITE% OTHER ]
	echo *******
	::false
	goto :error_exit
    :end_site

    ::--------------------------------------------
    ::	REL and PATH Section
    ::-------------------------------------------
    ::
    ::	Version Control
    ::
    ::set GBSEXT_GIT_PATH=PATH

    ::set GBSEXT_SVN_PATH=PATH

    ::
    ::  Builds
    ::
    ::set GBSEXT_MSVS2012_CONS_REL=2012
    ::set GBSEXT_MSVS2012_CONS_PATH=%GBSEXT_MSVS2012_ROOT%
    ::set GBSEXT_MSVS2012_KIT_REL=8.0
    ::set GBSEXT_MSVS2012_KIT_PATH=%GBSEXT_MSVS2012_KIT_ROOT%\%GBSEXT_MSVS2012_KIT_REL%
    ::set GBSEXT_MSBUILD_REL=v4.0.30319
    ::set GBSEXT_MSBUILD_PATH=%GBSEXT_MSBUILD_ROOT%\%GBSEXT_MSBUILD_REL%

    ::set GBSEXT_MINGW_BASE_REL=2013072200
    ::set GBSEXT_MINGW_CPP_PATH=%GBSEXT_MINGW_ROOT%\%GBSEXT_MINGW_BASE_REL%
    ::set GBSEXT_MINGW_CPP_REL=6.3.0

    ::set GBSEXT_MINGW_BASE_REL=2013072200
    ::set GBSEXT_MINGW_GCC_PATH=%GBSEXT_MINGW_ROOT%\%GBSEXT_MINGW_BASE_REL%
    ::set GBSEXT_MINGW_GCC_REL=6.3.0

    ::
    ::  Audits
    ::
    ::set GBSEXT_QAC_REL=8.1-R
    ::set GBSEXT_QAC_PATH=%GBSEXT_QAC_ROOT%\%GBSEXT_QAC_REL%

    ::set GBSEXT_QACPP_REL=3.0-R
    ::set GBSEXT_QACPP_PATH=%GBSEXT_QACPP_ROOT%\%GBSEXT_QACPP_REL%

    ::set GBSEXT_PCLINT_REL=8.00x
    ::set GBSEXT_PCLINT_PATH=%GBSEXT_PCLINT_ROOT%\%GBSEXT_PCLINT_REL%

    ::SET GBSEXT_CPPTEST_REL=9.6
    ::SET GBSEXT_CPPTEST_PATH=%GBSEXT_CPPTEST_ROOT%\%GBSEXT_CPPTEST_REL%
    ::SET GBSEXT_CPPTEST_BUILD=9.6.0.99

    ::
    ::	Tools
    ::
    ::set GBSEXT_DOXYGEN_REL=3.5
    ::set GBSEXT_DOXYGEN_PATH=%GBSEXT_DOXYGEN_ROOT%

    ::
    ::	Audit Tools
    ::
    ::set QAC_REL=%GBSEXT_QAC_REL%
    ::set QACROOT=%GBSEXT_QAC_PATH%

    ::set QACPP_REL=%GBSEXT_QACPP_REL%
    ::set QACPPROOT=%GBSEXT_QACPP_PATH%

    goto end_entry_exit
:do_exit
if NOT [%1] == [exit] goto :no_entry_exit
    ::
    ::	unset items
    ::

    goto :end_entry_exit
:no_entry_exit
    echo *****
    echo ** SYSTEM/switch.gbs: Usage = call switch.gbs.bat [ entry ^| exit ]
    echo *****
    goto :error_exit
:end_entry_exit
:: true
goto :EOF

:error_exit
::
::  Error-exit
::
set GBS_RC=1
goto :EOF

:::EOF:::

Example of a switch.gbs.sh: Bottom Doc. Button Top Document Button Blank Up Section Button Blank Up Chapter Button


#!must_be_sourced
#=================================================
#   File:        %FILE%
#   Path:        %PATH%
#   System Name: %SYSTEM_NAME%
#=================================================
GBS_SWITCH_RC=0
if [[ $1 = "entry" ]]
then
    #
    #	ENTRY: set items
    #

    #--------------------------------------------
    #	ROOT Section
    #	This part can be deleted if <GBS_BASE_PATH>/site.gbs.sh is used
    #--------------------------------------------
    if [[ $GBS_SITE = "%SITE%" ]]
    then
	#
	#   %SITE%
	#

	#
	#   Version Control
	#
	#export GBSEXT_GIT_ROOT=PATH

	#export GBSEXT_SVN_ROOT=PATH

	#
	#   Builds
	#
	#export GBSEXT_LGNU_CPP_ROOT=/usr/lib/gcc/x86_64-linux-gnu
	#export GBSEXT_LGNU_GCC_ROOT=/usr/lib/gcc/x86_64-linux-gnu

	#
	#   Audits
	#
	#export GBSEXT_QAC_ROOT=/apl/cadappl_linux_ia32/qac
	#export GBSEXT_QACPP_ROOT=/apl/cadappl_linux_ia32/qac++

	#
	#   Tools
	#

	#
	#   GBS Settings
	#

	true

    elif [[ $GBS_SITE = "OTHER" ]]
    then
	#
	#   OTHER
	#

	true
    else
	echo "SWITCH.GBS: *****"
	echo "SWITCH.GBS: ** Unknown Site $GBS_SITE"
	echo "SWITCH.GBS: ** Must be one of '%SITE% OTHER'"
	echo "SWITCH.GBS: *****"
	GBS_SWITCH_RC=1
    fi

    #--------------------------------------------
    #	REL and PATH Section
    #--------------------------------------------
    if [[ $GBS_SWITCH_RC = 0 ]]
    then
	#
	#   Version Control
	#
	#export GBSEXT_GIT_PATH=PATH

	#export GBSEXT_SVN_PATH=PATH

	#
	#   Builds
	#
	#export GBSEXT_LGNU_CPP_REL=7
	#export GBSEXT_LGNU_CPP_PATH=$GBSEXT_LGNU_CPP_ROOT/$GBSEXT_LGNU_CPP_REL

	#export GBSEXT_LGNU_GCC_REL=7
	#export GBSEXT_LGNU_GCC_PATH=$GBSEXT_LGNU_GCC_ROOT/$GBSEXT_LGNU_GCC_REL

	#
	#   Audits
	#
	#set GBSEXT_QAC_REL=8.1-R
	#set GBSEXT_QAC_PATH=$GBSEXT_QAC_ROOT-$GBSEXT_QAC_REL

	#set GBSEXT_QACPP_REL=3.0-R
	#set GBSEXT_QACPP_PATH=$GBSEXT_QACPP_ROOT-$GBSEXT_QACPP_REL

	#
	#   Tools
	#

	true
    fi
elif [[ $1 = "exit" ]]
then
    #
    #	EXIT: unset items
    #

    true
else
    echo "SWITCH.GBS: *****"
    echo "SWITCH.GBS: ** switch.gbs.sh: Usage = . switch.gbs.sh [ entry | exit ]"
    echo "SWITCH.GBS: *****"
    GBS_SWITCH_RC=1
fi

[[ $GBS_SWITCH_RC = 1 ]] && export GBS_RC=1
unset GBS_SWITCH_RC

##EOF##

switch.html