Purpose
The switch.gbs batch file is located in the GBS_ROOT_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.:
- Compiler-locations
- 3rd party software located outside the Root
- etc
In GBS the switch.gbs file is the only file allowed to contain absolute disk-addresses
General
Special considerations:
- These files are operating-system dependent batch files and have the appropriate file-extension
for that particular operating-system. e.g.:
- switch.gbs.sh and switch.usr.sh for Unix-type operating-systems
- switch.gbs.bat and switch.usr.bat for MSWindows operating-systems
- If a file exists with the same name and with extension .usr instead of .gbs then that file will be
taken after execution on the .gbs file.
Never, ever check-in a .usr file.
Calling
The switch.gbs file is called:
- When you enter a System (swr or startup)
- GBS_ROOT_PATH:switch.gbs is called with parameter entry
- When you leave a System (swr)
- GBS_ROOT_PATH:switch.gbs is called with parameter exit
Environment Variables
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 Root (System) GBS will unset all Environment Variables starting with GBSEXT_.
This is done before the switch.gbs is called with the 'exit' parameter.
Note that at the moment of invocation all GBS internal Environment Variables for that Root have been set.
Additional Available Environment Variables
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 gbssetup)
- Specifies the site where this user is working
- More info in Install Notes
- GBS_BUILD
- A full numeric value that identifies the current build of GBS
- A combination of the GBS version and version_date
- GBS_PLATFORM
- Use to distinguish on which platform GBS is running. e.g.:
- solaris, linux, MSWin32, etc
- GBS_ROOT_PARENT
- The name of the parent directory (not the path) of the Root.
- It can be used to define a Log-directory dependent on the Root. E.g.:
SET GBS_LOG_PATH=\%GBS_ROOT_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
The file consists of two mayor parts:
- Entry: The part that is executed with parameter 'entry'
- The Root / Site sub-part
- The general sub-part
- Exit: The part that is executed with parameter 'exit;
Entry
This part is executed when you 'enter' a Root / System (make it current)
It consists of 2 sub-parts
Root / Site sub-part
This sub-part is where you have the Site dependent stuff.
Here you will typically set GBSEXT_..._ROOT EnvVars to their Site-dependent locations
General sub-part
This sub-part is where you set the GBSEXT_..._REL
And the assembly of GBSEXT_..._ROOT and GBSEXT_..._REL to GBSEXT_..._PATH
Exit
This part is executed when you 'exit' a Root / System (un-current it)
Here you cleanup all non GBSEXT_ stuff
Notes:
None
Example of a switch.gbs.bat:
|
|
@ECHO OFF
::========================================
:: %FILE% [%SYSTEM_NAME%]
::========================================
if NOT [%1] == [entry] goto :exit
::
:: set items
::
if NOT [%GBS_SITE%] == [%SITE%] goto :NOT_%SITE%
::
:: %SITE%
::
::
:: Targets
::
::set GBSEXT_MSVS2012_ROOT=C:\Program Files (x86)\Microsoft Visual Studio 11.0
::set GBSEXT_MSVS2012_SDK_ROOT=C:\Program Files (x86)\Microsoft SDKs\Windows
::set GBSEXT_MINGW_ROOT=C:\MinGW
::set GBSEXT_GHSBF_ROOT=C:\Tools\GHSBF
::
:: Audits
::
:: set GBSEXT_QAC_ROOT=C:\MyPrograms\PRQA\QAC
:: set QAC_CUST_ROOT=D:\GBSEXT\qac_pdsl
:: set GBSEXT_QACPP_ROOT=C:\MyPrograms\PRQA\QACPP
:: set QACPP_CUST_ROOT=D:\GBSEXT\qacpp_pdsl
:: set GBSEXT_PCLINT_ROOT=C:\MyPrograms\PCLint
::
:: GBS Settings
::
::set GBS_BG_NOTIFIER=echo BG_NOTIFIER:
goto :end_site
:NOT_%SITE%
if NOT [%GBS_SITE%] == [OTHER] goto :NOT_OTHER
::
:: OTHER
::
goto :end_site
:NOT_OTHER
echo SWITCH.GBS: *******
echo SWITCH.GBS: ** Unknown site '%GBS_SITE%'
echo SWITCH.GBS: ** Must be one of [ %SITE% OTHER ]
echo SWITCH.GBS: *******
::false
goto :error_exit
:end_site
::
:: Targets
::
::set GBSEXT_MSVS2012_REL=2012
::set GBSEXT_MSVS2012_PATH=%GBSEXT_MSVS2012_ROOT%
::set GBSEXT_MSVS2012_SDK_REL=v7.1A
::set GBSEXT_MSVS2012_SDK_PATH=%GBSEXT_MSVS2012_SDK_ROOT%\%GBSEXT_MSVS2012_SDK_REL%
::set GBSEXT_MINGW_REL=2013072200
::set GBSEXT_MINGW_PATH=%GBSEXT_MINGW_ROOT%\%GBSEXT_MINGW_REL%
::set GBSEXT_MINGW_GCC_REL=4.8.1
::set GBSEXT_MINGW_CPP_REL=4.8.1
::set GBSEXT_GHSBF_REL=rel
::set GBSEXT_GHSBF_PATH=%GBSEXT_GHSBF_ROOT\%BF_REL%\win32
::
:: Audits
::
::set GBSEXT_QAC_REL=7.1.1
::set GBSEXT_QAC_PATH=%GBSEXT_QAC_ROOT%-%GBSEXT_QAC_REL%
::set GBSEXT_QACPP_REL=2.4.1
::set GBSEXT_QACPP_PATH=%GBSEXT_QACPP_ROOT%-%GBSEXT_QACPP_REL%
::SET GBSEXT_PCLINT_REL=8.00x
::SET GBSEXT_PCLINT_PATH=%GBSEXT_PCLINT_ROOT%
::
:: Audit Tools
::
::set QAC_REL=%GBSEXT_QAC_REL%
::set QACROOT=%GBSEXT_QAC_PATH%
::set QAC_CUST_DIR=%QAC_CUST_ROOT%\%QAC_REL%
::set QAC_PDSL_DIR=%QAC_CUST_DIR%
::doskey qaccust=%QAC_PDSL_DIR%\qaccust.bat $*
::set QACPP_REL=%GBSEXT_QACPP_REL%
::set QACPPROOT=%GBSEXT_QACPP_PATH%
::set QACPP_CUST_DIR=%QACPP_CUST_ROOT%\%QACPP_REL%
::set QACPP_PDSL_DIR=%QACPP_CUST_DIR%
::doskey qacppcust=%QACPP_PDSL_DIR%\qacppcust.bat $*
goto :end_entry_exit
:exit
if NOT [%1] == [exit] goto :no_entry_exit
::
:: Unset items
:: (GBSEXT_... are all unset by GBS)
::
::set QAC_ROOT=
::set QAC_REL=
::set QACROOT=
::set QAC_CUST_DIR=
::doskey qaccust=
::set QACPP_ROOT=
::set QACPP_REL=
::set QACPPROOT=
::set QACPP_CUST_DIR=
::set QACPP_MSVC98_DIR=
::doskey qacppcust=
goto :end_entry_exit
:no_entry_exit
echo SWITCH.GBS: *****
echo SWITCH.GBS: ** switch.gbs.bat: Usage = call switch.gbs.bat [ entry ^| exit ]
echo SWITCH.GBS: *****
goto :error_exit
:end_entry_exit
:: true
goto :EOF
:error_exit
::
:: Error-exit
::
set GBS_RC=1
goto :EOF
:::EOF:::
Copyright © Randy Marques of Randy Marques Consultancy - All rights reserved