Software Configuration Management Support
Have the following information ready at hand:
- A name that describes your System uniquely (SystemName)
- The name of your first Target
- The main location of that Target's Compiler, Linker, etc
- The name of your first SubSystem
- The name of your first Component
See the sections below on how to decide on the names mentioned above.
Example
For the explanation below a 'Hello world' implementation is used as example:
- SystemName: HelloWorld
- Targets: mingw and mingwd
- SubSystem: main
- Component: main
We will be using the MinGW environment under Windows.
You can obtain MinGW via SourceForge/MinGW
Be sure you install it in a Hard Versioned Directory
e.g: C:\WinGW\2013072200 .
You only need to install Basic Setup: mingw32-base for this exercise.
Creating the GBS-WA
Make sure your 'Site' is defined in GBS
- Create a directory
GBSWA in a convenient place.
cd to that directory
- Create a directory
HelloWorld in that directory.
cd to that directory
- Enter:
swr --add (switch Root)
- Select: 'Use the Current Path (CWD) as Root Path'
- Enter empty line with 'Enter New System Name [HelloWorld]:'
- Select: No_SCMS
- Enter empty line with 'OK? (y/n/q)[y]:'
An empty root is now created.
A GBS-Root needs at least one Target so GBS will now proceed to execute an implicit
swt --new
- Enter mingw with 'Enter new Target-name []:'
- Select: 'Create a Reference to a Target Plugin'
- Select: 'mingw : MINGW: GNU C/C++'
- Enter empty line with 'OK? (y/n/q)[y]:'
The Target is created.
There is still work to be done for that Target, but we will do that when we try to compile a file for the first time.
- Optionally enter gbs to see what you have achieved
We will now proceed to create a SubSystem
Creating a Subsystem
- Enter: sws --new (switch SubSystem)
- Enter the name of the New Subsystem: main
- Keep entering empty lines (defaults) till you get the 'Summary for New SubSys ...'
- Enter empty line with 'OK? (y/n/q)[y]:'
The SubSystem is created.
We will now proceed to create a Component
Creating a Component
- Enter: swc --new (switch Component)
- Enter the name of the New Component: main
- Enter empty line with 'Enter empty line with ' OK? (y/n/q)[y]:'
- Enter empty line with 'Add another Component? (y/n/q)[n]:'
The Component is created.
We will now proceed to create a file and compile it
Getting one file to compile
Setup Editor
You probably want to use your own editor:
- Enter gbssetup
- Select: '2. General Settings (Beeps, Editor, ...)'
- Change the Beeps if you whish
- Change the Editor
- Enter 'e' (end) with 'Change? (y/n/e/q)[n]:'
- Enter empty line in the main-menu (0. Exit)
- Enter 'y' with '*** Implement Changes? (y/n)[n]:'
Create and edit the file
Now we create the file:
- Make sure you are in the src directory
If not: Enter: cdsrc
- Enter: gbsedit hello.c
Enter 'y' when asked 'Create? (y/n/q)[y]:'
Select a Template-File ending with main.c when asked
The file is created in the src directory and opened in your editor
- Edit the file to implement the 'hello world' application
and save the file (keep open in editor)
Adjust the Target-environment
You can try to compile the file with gbsgen hello.c, but that will fail
- Enter: gbswhich to get an overview of building (and auditing)
Note the src_types on top
And the GBSEXT_Paths, which is empty
- Enter: gbswhich .c to get information on .c -files processing
You will get errors on all references to %GBSEXT_MINGW_PATH% because the EnvVar is not set.
GBSEXT_ EnvVars are set in the switch.gbs.bat
- Enter: gbsedit switch.gbs
Note that gbsedit knows where the switch.gbs file resides and that it ends with .bat
It is assumed that MinGW is installed in
Hard Version Directories
- Find the commented line '::set GBSEXT_MINGW_ROOT=C:\MinGW'
Uncomment it (remove '::')
Adjust it to point to the root where you installed MinGW
- Find the commented line '::set GBSEXT_MINGW_REL=2013072200'
Uncomment the first three lines related to MINGW (remove '::')
Adjust the first one to refer to the wanted version-directory
Adjust the third one to refer to the wanted include versions
- Save the file
Now we must re-execute the switch.gbs:
- Enter: swr . (switch-root to current - mind the dot)
- Enter: gbswhich and after that
gbswhich .c and check for errors
- Keep repeating Edit, swr . and
gbswhich untill all errors are gone
Note: In gbswhich: an 'x' before a PATH means that it was not found
Compile the file
Repeat until no more errors:
- Enter: gbsgen hello.c
- Edit hello.c and save
Note: You need not be in the src directory when you execute a gbsgen.
We will now proceed to create the executable
Creating the executable
For linking we need a
.glk file in the src directory
Create the .glk file
- Enter: cdsrc (probably already in src)
- Enter: gbsedit hello.glk
'y' to create the file
- Immediately below the main banner enter:
hello$GBS_BLD_C
- Save the file
Note: During processing the $GBS_BLD_C will be replaced by the the resulting file-type
of a C compilation for this platform (.o)
- Enter: cdtarget
This places you in the output-directory for gbsgen.
Link the .glk file
- Enter gbsgen hello.glk
- Make sure you are the bld-Target directory (with cdtarget)
- Enter hello.exe to run the executable
- If you need to change stuff:
- Stay in the cdtarget.
- Do your edits
- Build with gbsgen .:*.*
Not with gbsgen *.* That will cause Unix globbing to take the files in the cdtarget
- Run with hello.exe
We will now proceed to export the executable
Exporting the executable
For the Export we will need an
export.gbs file in the component.
We will assume that this executable is for a customer called FOO
Export the file
- Enter: gbsexport
- Enter: cdexport and see what has happened (You may want to do this with a GUI)
Generate in the Batch
- Enter gbssysgen
A batch job is started.
When it is done, a Notify popup-box will appear.
- In the popup-box Select: (click) 'View Log & Exit'
- View the logfile
If at a later stage you want to view your gbssysgen logfiles:
- Enter: gbssilo
A page is generated in your browser
- Select: 'Generate/Make (.log)'
- Select: VIEW of the LogFile you want to view
Adding a Target
The previously defined Target will generate our FINAL (non-debug) version.
But we also want a DEBUG version:
- Enter swt --new
- Enter mingwd with 'Enter new Target-name []:'
- Select: 'Create a Reference to a Target Plugin'
- Select: 'mingw : MINGW: GNU C/C++'
- Enter empty line with 'OK? (y/n/q)[y]:'
The new Target is created (but will be equal to mingw).
It is now also the Current Target.
- Enter gbsedit target.gbs
- Set MODE into DEBUG
- Set DEBUGGER to YES
- Set OPT to DEBUG
- Save
We do not want to export the DEBUG version so we have to edit the export.gbs
- Enter gbsedit export.gbs
Select 'Component'
- Append
FOO with a few TABs and then == mingw
This will cause the destination-line and the following source-lines to be
executed only for the mingw Target.
- Save
It is done now.
You can generate single stuff for a single Target with gbsgen and use swt to switch Targets.
Enter gbssysgen and observe how the system is generated for both Targets in parallel.
Creating a non-GBS SubSystem
TBS
Interfacing with the outside-world
System (Root)
This file resides in the $GBS_ROOT_PATH directory.
It is a script that is executed every time GBS makes a System (Root) current.
Its purpose is to define the particularities of the general building environment of the selected System.
e.g.: Here you want to make sure you are using the proper environment for your particular System.
Have a look at the contents of this file.
It is maintained by the GBS Administrator
and must be under SCM control.
Note that at the moment of invocation all environment variables for that Root have been set.
switch.usr(.bat./sh)
This optional file also resides in the $GBS_ROOT_PATH directory.
It is an optional script that is executed every time GBS makes a System current.
And after the switch.gbs mentioned above has been executed.
Its purpose is to enable a developer to (re-) define the particularities of the general building environment of the selected System.
It is maintained by the Developer and must never be under SCM control.
Note: If you change any of these two files you must swr . for them to take effect.
Copyright © Randy Marques of Randy Marques Consultancy - All rights reserved
|