Thank you for using Generic Build Support (GBS), the generic build environment created by Randy Marques, Netherlands. Generic Build Support is a way of setting up a directory structure combined with generic scripts to accommodate Build Automation for almost any kind of software project. Building information is kept in dedicated files enabling automatic generation of make files, independent of platform or SCMS. The key aspect of GBS is the directory structure. Its strict[1] nature makes sure that everything has its place so that it can be easily retrieved and it is assured that any GBS command will run on any SubSystem created according to the GBS Directory Structure rules. This directory structure makes it possible to swap and/or share software between projects (interchange ability) and ensures an unified way of working. And yes: where needed there is all the freedom you need! You can run GBS parallel on Windows 10, Windows 10 WSL and Linux systems, sharing the same physical directory structure. GBS depends only on Perl (Version 5.16.3 or later, preferably with PerlTkx). No extra packages are required when using ActiveState Perl This version was developed on Windows 10 using Perl 5.16.3 from ActiveState (with PerlTkx) It was tested on Windows 10, Windows 10 WSL 1 and Ubuntu 22.04 - GNOME. (On VirtualBox 7.0) Many thanks to Martin Smiths of the Netherlands who did the beta-testing on Manjaro 18.04 - Xfce. Although not tested: There is no reason why GBS should not run on Unix or Windows 7 No clue if it works on Windows 11. For a simple project you can start using GBS quickly and keep in mind that everything has its place. I strongly suggest reading the 'Getting Started' part of the documentation. Following the instructions in Create a GBS-WA/System will quickly set you on track. The power of GBS lies in its concept. So on the long run this means that in order for you to use GBS to its full extent, you must understand the concept of GBS and use it as intended. Rest assured: it is very simple. Understand GBS by:
GBS is OpenSource under the MIT License and as such free to use:
Note: The free and OpenSource versions of GBS are not compatible with pre version 2.00 releases Before you start using GBS, please take a moment to read the Terms and Conditions
[1]
Strict really means that no deviations are allowed.
ImportantThis document is just what it is named. A User Manual.It does not describe the background, concepts or philosophy of GBS. It therefore cannot be used to determine whether GBS is usable in a particular environment or project. It certainly cannot be used to assess the full potential and usability of GBS. For above purposes the interested user should read the GBS Concepts (PDF). Features
DocumentationGeneralGBS Release Notes GBS FAQ Installation NotesWindows and Linux |
ContentsDescriptionEnvironment| Install| Setup| Startup| Getting Started| Commands| General notes on the GBS command-line environment
DescriptionEnvironmentOS / ShellGBS runs on:
WSL ConsiderationsYou will need:
Linux considerationsOn some Linux distributions some necessary bash commands are not installed. You will need:
PerlGBS is based on Perl-scripts.Perl must be installed and the perl command must be either in the PATH or
specified via an Environment-Variable (GBS_PERL_PATH).You need at least Perl version 5.16.3. More information on installing Perl for GBS can be found in Install Notes→Environment InstallGBS can be installed in two ways:
If you need to install GBS yourself:
SetupTo setup GBS:If setup was not executed by Install:
StartupStartup GBSUse the 'GBS Startup [cur]' shortcut to startup GBS.It may be on your Desktop and/or the Programs Folder. If it is not present (maybe you do not have a desktop or deleted it...):
Enter: gbs The general GBS command line interface is started. The first time you startup GBS you may need to give its some additional information: Just answer the questions. Define your own editorIn GBS you use the gbsedit command to edit (GBS) files. Sometimes other GBS functions may invoke the editorThe gbsedit command has a lot of builtin knowledge of .gbs files. It will also aid you in editing your code. By default GBS uses Notepad on Win32 and gedit on Linux. You may want to change that to your favourite editor: gbssettings → Change Config settings → Edit EditorMake sure you use an editor that startup fast after multiple invocations (or stays alive). Use a different Terminal typeBy default GBS uses CMD Console on Win32 and xterm on Linux.To change the current Terminal: gbssettings → Change Config settings → Edit TerminalSupported Terminals:
GBS Manual PageTo obtain current information on all implemented GBS commands enter: gbsmanGBS HelpTo obtain extensive Help in HTML format (including this page) enter: gbshelpGetting StartedOrganising your GBS-WAs / SystemsYou can place a GBS-WA/System anywhere you want. You can also have them all on totally different locations. They do not need to be grouped in one directory, although that is a good idea.The default for the GBS WorkArea Path is:
SystemName and SystemIdThe SystemName is the generic name of your project.The SystemId is the parent-directory of your GBS WorkArea. It is important that SystemId reflects the SystemName:
Remember that GBS does not like spaces in directory and filenames and that they are case sensitive! Yes, also on Win32! Connect to an existing GBS System (--add)
Create a new GBS-WA/System (--new)You enter swr --new.Creating a new GBS-WA is serious business. You can find out how to do it in Create a GBS-WA/System A good understanding of the concept and principles of GBS is needed. Once done however, things get extremely simple, convenient and fast. CommandsUse GBS to navigate through your directoriesAfter you have once set them GBS 'remembers' the following 'currencies'
Displaying CurrenciesTo display your currencies just enter: gbsCurrency commandsswr Switch System: set/change the current System (and SubSystem (and Component))sws Switch SubSystem: set/change the current SubSystem (and Component) swc Switch Component: To set/change the current Component. This command ends with an explicit cdsrc swb Switch Build: set/change the current Build Basic commandsgbsedit Create/Edit a file (you can define your own editor with gbssettings )gbsbuild Compile, Link, etc. one or more files gbssysbuild Compile, Link, etc. the whole System (Runs in batch - with logfile) Navigation commands
Other GBS commandsNote that all GBS-commands accept --h for short help and --help for long helpgbsbuild, gbssysbuildCommands to compile, link, etc directlygbsmake, gbssysmakeCommands to compile, link, etc using 'make'gbsaudit, gbssysauditCommands to run Audit programs like QAC and QAC++gbsmaintThis command enables you to select and execute a number of GBS maintenance functions.Like:
gbssettingsThis command enables you to define your customizations. (Beeps on/off, Define Editor, etc.)gbsscmThis command enables you to select and execute SCM-related functions in GBS.There are a lot more command in GBS. They can be found at All Commands. General notes on the GBS command-line environmentIn a prompt, possible values are embedded in parenthesise.g.: GBS: Are you sure? (y/n):
In a prompt, the default value is embedded in square brackets e.g.: GBS: Are you sure? (y/n)[y]:
Entering a single '!' will quit the script. Entering a single '?' will give you some additional help (if available) In general, options for GBS-commands start with -- (double hyphens). This is to be able to discern options for GBS and options for applications (like QAC) All GBS-commands accept --h for short help and --help for long help More in The Command-line Interface |
ContentsRelease Notes for GBS 6.00Interface changes since 5.00| Build RMC-06.02: 2024-04-29| Build 06.01: 2021-03-20| Build 6.00: 2020-03-05
Release Notes for Previous ReleasesRelease Notes for GBS 6.00Interface changes since 5.00The following major changes were implemented:
When you run gbsmaint 7 9 (Upgrade), all your files will be updated accordingly Build RMC-06.02: 2024-04-29New/Changed Functionality
Problems solvedBuild 06.01: 2021-03-20New/Changed Functionality
Problems solved
Build 6.00: 2020-03-05New/Changed Functionality
Problems solved
Release Notes for Previous ReleasesPlease note that not all links may work correctly |
ContentsDescriptionDescriptionEnvironmentOS / ShellGBS runs on:
WSL ConsiderationsGeneralFile locationsIn WSL bash you can access Windows directories/files.In Windows you cannot access WSL bash local directories/files (e.g.: ~/). Therefore all GBS directories/files must be placed at a location accessible by Windows. e.g.: MyDocuments or D:\Work Install GBS on WindowsBefore starting GBS on WSL you need to install it on Windows.GBS will use the same physical installation for both Windows and WSL. So you will need WSL 1. You need to install Perl AND GBS on Windows. For more info on installing Perl and GBS look below. Install WSLDocumentation can be found at: WSL Installation Guide for Windows 10
Install X ServerDocumentation can be found at: Running Graphical Programs on Windows Subsystem on Linux
Install commands using X server
Additional bash commandsRefer to the Linux Considerations below for additional bash commands.Linux considerationsOn some Linux distributions some necessary bash commands are not installed.xtermOpen a 'Terminal'Note: A 'Terminal' is not always an xterm To try: enter xterm -h To install: enter sudo apt install xterm atOpen a 'Terminal'To try: enter at -h To install: enter sudo apt install at Make sure the atd daemon runs: enter sudo atd Install PerlGBS is based on Perl-scripts.Perl must be installed and the perl command must be either in the PATH or
specified via an Environment-Variable (GBS_PERL_PATH).You need at least Perl version 5.16.3 If Perl (or the proper Perl version) is not in the PATH, define an environment variable GBS_PERL_PATH to point to the top-level directory where the proper Perl is installed. e.g.: export GBS_PERL_PATH=/opt/ActivePerl-5.26 Perl can be obtained for free via
InstallAfter download From ActiveState:
Note: There is a bug in core Perl on Windows that doesn't set up @INC correctly if Perl is installed into a directory that starts with the letter '5'. Your problem should go away if you install into something like C:\MyPrograms\perl\v5.10 instead. This bug is at least 10 years old and somewhat related to finding additional site_lib directories when you are using the versioned directory layout scheme where multiple Perl versions share site_lib directories. Found in Perl Monks Missing Perl ModulesMissing Perl modules can be installed via CPAN. More info: How to install CPAN modulesInstall GBSPre-InstalledIf GBS is pre-installed (local or on a network drive) your GBS Administrator will be able to tell you where GBS is installed.You will then only need to do the Setup as explained below. Where to InstallSeveral versions of GBS can be installed in a GBS_SCRIPTS_ROOT directory.They are installed using the Hard versioned directories method. The latest build of a version is always installed under the plain version> directory. E.g: RMC-06.02 This is called the Current Build of a version. It will be overwritten with every install of the same version. Specific Builds are installed under version_build directory. E.g.: GBS can be installed in two ways:
The Install scripts only installs GBS (possibly on a central location). To be able to use GBS, each user must 'Setup' GBS as explained below. This tells GBS which of the versions to use. During the Install you have the option to execute the setup immediately after the install (not with Multi-User). Prerequisites:
How to Install'Install' command syntax hereInstructions for Install:
After the Install there will be:
SetupGeneralTo setup GBS:
|
ContentsDescriptionBefore you start| Creating the GBS-WA| Defining a Build| Creating a Subsystem| Creating a Component| Getting one file to compile| Creating the executable| Creating automated testing| Using 'make'| Exporting the executable| Generate in the Batch| Adding a Build (Debug)| Creating a non-GBS SubSystem| Try the GUI| Interfacing with the outside-world
DescriptionCreating a new GBS-WA is serious business.A good understanding of the concept and principles of GBS is needed. Once done however, things get extremely simple, convenient and fast. This document will guide you to setup a simple non SCM-controlled 'Hello World' project to give you a taste of GBS. Before you startInstall GBSRead:PrepareAfter Install it really helps if you have read: If you get stuck, read:The projectFor the explanation below a 'Hello world' implementation is used as example:
Windows: We will be using the MinGW toolchain
Startup GBS
Setup EditorNow is a good time to setup your editor if you have not yet done so. (Not required):gbssettings → Change Config settings → Edit Editor More info: Define your own editor Use a different Terminal typeYou may also want to use a different Terminal type.gbssettings → Change Config settings → Edit Terminal More info: Use a different Terminal type Creating the GBS-WAMake sure your 'Site' is defined in GBS
Defining a Build
Creating a Subsystem
Creating a Component
Getting one file to compileSetup EditorIf you have not setup your own editor, now is really the time to do so. (But you do not have to):gbssettings → Change Profile settings → Program SettingsMore info: Define your own editor Create and edit the fileNow we create the file:
Adjust the Build-environment (if necessary)Try to compile the file with gbsbuild hello.cIt should compile, but if it fails that is probably because the GBSEXT_ EnvVars are not properly set:
Compile the fileEnter: gbsbuild hello.cRepeat until no more errors:
We will now proceed to create the executable Where am I?At any time you can enter gbs on the commandline. It will show you all currencies.Creating the executableFor linking we need a .glk file in the src directoryCreate the .glk file
Link and run the .glk file
Creating automated testingFor testing we need a .glt file in the src directoryCreate the .glt file
Run the .glt file
Using 'make'Until now we have used gbsbuild to generate the code, specifying explicitly the file(s) we want to 'build'.Of course GBS offers a 'make' facility ('incremental build', 'selective build', 'dependency build'): gbsmake. Before you run gbsmake
for the first time you have to run gbsmakemake
to create a Component and Build specific make-file.
Enter: gbsmake
If you have not done so, this is a good time to read Generating Code.
More info: Generating Libraries & Executables and Testing Exporting the executableFor the Export we will need an export.gbs file in the component.Create export.gbs fileWe will assume that this executable is for a customer called FOO
Export the file
Generate in the Batch
Adding a Build (Debug)The previously defined Build will generate our FINAL (non-debug) version.But we also want a DEBUG version:
Enter: gbssysbuild and observe how the system is generated for both Builds in parallel. Creating a non-GBS SubSystemCreate a 'make' Subsystem
Try the GUIYou will need Perl Tkx installed.Interfacing with the outside-worldSystemswitch.gbs(.bat/.sh)This file resides in the $GBS_SYSTEM_PATH directory.It is a script that is executed every time GBS makes a System 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 System have been set. The file consists of two parts:
|
ContentsGeneralHow to create a new Component| How to create a new SubSystem| How to create a new System| How to add an existing System to my Systems-list| How to remove a System from my Systems-list
GeneralHow to create a new ComponentEnter: swc --newHow to create a new SubSystemEnter: sws --newHow to create a new SystemEnter: swr --newHow to add an existing System to my Systems-listEnter: swr --addHow to remove a System from my Systems-listEnter: swr --remove |
DescriptionSOFTWARE LICENSEBEFORE YOU USE GBS, CAREFULLY READ THE TERMS AND CONDITIONS OF THIS AGREEMENT.BY INSTALLING AND USING THE SOFTWARE YOU ARE CONSENTING TO BE BOUND BY AND ARE BECOMING A PARTY TO THIS AGREEMENT. IF YOU DO NOT AGREE TO ALL OF THE TERMS OF THIS AGREEMENT, DO NOT INSTALL OR USE THE SOFTWARE.
As the code is written in Perl you are not allowed to modify any released code. MIT License
Generic Build Support (GBS)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
|
ContentsDescriptionDescriptionDefinitionsGeneric Build Support (GBS)The process of building according to strict rules and a strict predefined directory structure.This makes building an easy process to use and to handle. Make-files can be generated because the directory structure is fixed for all SubSystems. RMCRandy Marques Consultancy. The originator of GBS.GBS VersionIn older GBS releases the GBS version syntax was R.VV and R.VV_YY-MM-DD.Where R stands for Release, VV stands for Version and YY-MM-DD for ReleaseDate
With the move of GBS to OpenSource the need to identify the 'Releaser' arises: Given a Release/Version,
you would want to identify who built the Release/Version.
Proj-RR.VV and
GBS-WA or SystemA single, whole GBS directory tree.Contains SubSystems. GBS-WAs or Systems are identified by their SystemName You can have as many GBS-WAs as you want. Even multiple occurrences of the same. A GBS-WA will always correspond with a total SCM work area. SubSystemAn independent generation-unit within GBSA directory-structure with files that, during generation, produce software that can be delivered (released) to other SubSystems and/or end-customers. A GBS SubSystem is not per se an architectural SubSystem. SubSystems can contain one or more Components The number of SubSystems should be limited Most Systems will have only one SubSystem ComponentA files-container within a GBS SubSystem.The lowest level directory-tree in GBS Here the source and object files reside. A GBS Component is not per se an architectural Component GBS Component may very well contain more than one architectural Component and/or parts of architectural Components. Files in Components cannot refer to files in Components of other SubSystems DeliverableThe set of files produced by a SubSystem for use in another SubSystem or as final product. Generally speaking the deliverables of a SubSystem will consist of one or more libraries with one or more header-files. In a broader sense, any file that has to be made available to another SubSystem is a deliverable. (final executables, test-scripts, etc)You can also have internal deliverables. A SubSystem may 'deliver; to another Subsystem. Build or BuildStreamA sequence of compilations for a specific build, with a specific compiler toolchain, using the same set of compile-options, possibly followed by linking, resulting in a deliverable.AuditingActions performed on the code that do not generate executable code.Think of Source Code Analysers (SCAs) like PCLint, C++Test or QAC Auditing runs on file level, just like compilers Note: Doxygen runs on System level. It is therefore not considered an Auditing tool but a System Tool ArchivingThe process of placing one or more object files into an object libraryGBS AdministratorPerson responsible for the infrastructure of a GBS-WA. Typical GBS responsibilities:
GBS IntegratorPerson responsible for the execution of Generic functions in a GBS-WA. Typical GBS responsibilities:
Hard versioned directoriesA method to store multiple versions of something (programs, files, etc.) so that all are available at the same time. This in contrast to Soft versioned directories that are stored inside SCM repositories and need to be checkout before they can be accessed.All versions reside under the ROOT directory. The versions are called REL. And the actual location is called PATH. 3 Environment Variables are used to define the actual location:
This assures that when you want to switch to another version you only need to change the app_REL This method is used heavily throughout GBS BuilderIn the context of this document a Builder is a program or script that takes care of one step of the build-process of a deliverable. Typical builders are compilers, library-archivers and linkers.Acronyms
|
DescriptionThe strict nature of the GBS directory structure allows interchange ability between Systems and SubSystems.GBS will generate the directory-structure automatically making sure all directories are properly named and added to any specified SCM System. General overviewFor the build process three areas can be distinguished:
Reserved (fixed) directory names are specified in a blue background. The 'res' directory contains directories with the deliverables of the various SubSystems. The 'dev' directory contains the top-level directories of the various SubSystems. The 'ext' directory contains the top-level directories of the various external systems. In a project that consists of a single Subsystem (i.e. where the SubSystem is the System) still this top-level directory structure is used. The basicsSoftware is developed in the SubSystems.SubSystems contain, amongst others: sources, header-files, make-files and their resulting objects, libraries and executables. If, for generation purposes, a SubSystem needs items from another SubSystem (like header-files or libraries), these items must be copied from the other SubSystem in the 'res' area. (How is explained later).
Note that most (small) Systems will have only one SubSystem. On a Software-Architectural level, SubSystems will have a hierarchy, defining the order in which SubSystems must be built. In GBS this hierarchy is not reflected in the directory structure. All SubSystems reside on the same directory level. The same applies to Software Components within SubSystems. During the total generation of the system, first the lowest level SubSystem will be built. Using the GBS 'gbsexport' command, its deliverable(s) (e.g. library and header-files) will then be exported into the 'res' area and so made available to the next SubSystem(s). Then the next SubSystem in the Software hierarchy can be built, gradually moving 'up' the scope, generating and incorporating the other SubSystems. DirectoriesThe System directoryThis is the top-level directory for the whole projectIn the rest of the document this directory will be referred to as the SYSTEM directory.
The 'dev' directoryThis directory contains the top-level directories of the various SubSystems.
The 'res' directoryThis directory contains matching SubSystem directories that are used for interfacing between SubSystems.'res' stands for 'result' i.e. deliverables generated by the SubSystems.
The 'ext' directoryThis directory contains 'static' parts of the project. i.e. those parts that are not generated for the project, are used 'as-is' and are not covered by another version-controlled repository.
Other DirectoriesAlthough not mentioned before, there are also a number of other top-level directories like 'sys', 'sysbuild', 'sysaudit', 'systool', 'silo' and 'tmp'Their usage is described in Full-GBS Directory Structure Additional top-level directoriesAll top-level directories are mandatory.Additional directories may be placed at this top-level. Names are free except for the following:
The SubSystem top directoryGBS allows Subsystems to be either Full-GBS or Non-GBS compliant.Full-GBS SubSystemsFull-GBS Subsystems adhere completely to the GBS way of working.The generation of the SubSystem is completely taken care of by GBS Non-GBS SubSystemsThis allows for 'alien' SubSystems to be incorporated in the generation-process.Non-GBS SubSystems may have any directory-structure and/or generation process. Non-GBS SubSystems require a number of predefined scripts that will be called by the GBS Top-level functions like: gbssysbuild, gbssysmake, gbssysaudit and cleanup. The gbsexport functionality to fill res and/.or export directories is also available. Continue readingFull Directory Structure |
DescriptionReserved (fixed) directory names are specified in a blue background.ToplevelThe following diagram gives an overview of the Toplevel GBS directory structure.For a full description: Top Level Directory Structure Systemlevel (full)The following diagram gives an total overview of the top part of GBS directory structure.Full Compliant GBSThe following diagram gives an overview of the Full-GBS compliant directory structure.Non Complient GBSThe following diagram gives an overview of the Non-GBS Complient directory structure.Directory creationPlease note that GBS maintains it's own directory structure, assuring consistency.Never create GBS directories yourself. Let the GBS commands take care of that. The System directoryGBS_SYSTEM_PATHThis is the base of the whole directory structure. It contains all that is necessary to build a multi-SubSystem system. Nine directories are mandatory for GBS: res, dev, ext, sys, sysbuild, sysaudit, systool, silo and tmp. More directories may be added. E.g. doc for documentation, etc. The 'res' directoryGBS_SYSTEM_PATH/resThe functionality of this directory is explained in Top Level Directory Structure → res. It is used to control the exchange of deliverables between SubSystems. The 'dev' directoryGBS_SYSTEM_PATH/devThis directory contains all and only SubSystems. The 'ext' directoryGBS_SYSTEM_PATH/extThis directory contains the directories of all 3-rd party software that is to be used by all or most of the SubSystems. The 'silo' directoryGBS_SYSTEM_PATH/siloHere data is stored that is generated outside the Component structure and should be kept. E.g. Doxygen output. Each Tool has its own directory. The command gbssilo will display any content in HTML format in a browser The 'sys' directoryGBS_SYSTEM_PATH/sysThis directory contains all common items (scripts, tables, etc) for sysbuild, sysaudit and systool e.g.: steps.gbs It also contains a mandatory templates directory to hold user defined File Templates. (Templates) The 'sysbuild' directoryGBS_SYSTEM_PATH/sysbuildThis directory contains all items (scripts, tables, etc) for Building e.g.: gcc, mingw, etc It also contains a mandatory makemake_stubs directory, with subdirectories per Build, to hold stubs for external files to satisfy gbsmakemake. The 'sysaudit' directoryGBS_SYSTEM_PATH/sysauditThis directory contains all items (scripts, tables, etc) for Auditing (SCA) e.g.: qac, qac++, pclint, cpptest, etc The 'systool' directoryGBS_SYSTEM_PATH/systoolThis directory contains all items (scripts, tables, etc) for additional Tooling (e.g. Doxygen) The 'tmp' directoryGBS_SYSTEM_PATH/tmpHere GBS places its temporary files. When something goes wrong GBS will not delete its tmp files, so you can check what went wrong. After 7 days they will be deleted when you make this System current. It is always safe to cleanup this directory when no generations are running. There is an entry in gbsmaint that will do that. The SubSystem directoryThere are 2 basic types of SubSystems:
GBS_SYSTEM_PATH/dev/GBS_SUBSYS This is the top of a basic generation-unit. The SubSystem directory may have any number of Sub-Directories and files. The directories audit, export, build and tool are mandatory for all types of SubSystems. The directory comp is mandatory for Full-GBS SubSystems. The directories app and opts are mandatory for Non-Full-GBS SubSystems. The following names are reserved for all SubSystems: import, gbs*.* and *.gbs. The 'export' directoryGBS_SYSTEM_PATH/dev/GBS_SUBSYS/exportGBS_SYSTEM_PATH/dev/GBS_SUBSYS/export/GBS_BUILD After the build of the SubSystem, this directory will contain the files and directories that are the end-deliverables of this SubSystem. Items in the export directory are always generated/copied items, so they can be deleted at any time. The 'import' directoryGBS_SYSTEM_PATH/dev/GBS_SUBSYS/importThis directory contains directories that hold deliverables from outside the System. This is usually 3-rd party software only used by this SubSystem. It is used rarely. The 'build' directoryGBS_SYSTEM_PATH/dev/GBS_SUBSYS/buildGBS_SYSTEM_PATH/dev/GBS_SUBSYS/build/GBS_BUILD This directory contains information for the generation of the SubSystem. For each BuildStream that this SubSystem generates a sub-directory of the Build-name is required. Else this SubSystem will not generate for that particular BuildStream. These directories may contain a number of files that give information on SubSystem level. These include:
The 'audit' directoryGBS_SYSTEM_PATH/dev/GBS_SUBSYS/auditGBS_SYSTEM_PATH/dev/GBS_SUBSYS/audit/GBS_AUDIT/GBS_BUILD This directory contains information for the Auditing of the SubSystem. For each Audit & Build combination that this SubSystem generates a sub-directory of the Audit-name/Build-name is required. Else this SubSystem will not audit for that particular Audit & Build combination. All files and directories in these directories reside under the responsibility of the GBS Administrator in co-ordination with the architect(s) responsible for the SubSystem. They are the only ones allowed to modify these files. The 'tool' directoryGBS_SYSTEM_PATH/dev/GBS_SUBSYS/toolThis directory contains information for the Step-Command execution. For each Step-Command Tool that this SubSystem runs a sub-directory of the Tool-name is required. Else that particular Step-Command Tool will not run for this SubSystem. All files and directories in these directories reside under the responsibility of the GBS Administrator in co-ordination with the architect(s) responsible for the SubSystem. They are the only ones allowed to modify these files. The Full GBS directories (Components)The 'comp' directoryGBS_SYSTEM_PATH/dev/GBS_SUBSYS/compFull GBS only. This directory contains all and only Component directories. The name is reserved and is used only for Full GBS SubSystems. The only directories it contains are the Component directories that are to be recognised as under control of GBS. GBS_SYSTEM_PATH/dev/GBS_SUBSYS/comp/GBS_COMPONENT These directories contain the Component-Subdirectories. No other directories than the Sub-Directories specified below are allowed here. As far as GBS is concerned, Component names are free, except for ALL, EXPORT and RES. The project however, will impose rules on names here. You can have as many Components as you wish. They also contain a number of files that give information on Component level:
The 'src' sub-directoryGBS_SYSTEM_PATH/dev/GBS_SUBSYS/comp/GBS_COMPONENT/srcIt contains all files that will lead to the generation of corresponding files in a 'bld' Build-directory. Files in this directory form the basis of the generation process. This means that the presence of a file in the src directory indicates that a step of the build-process must be executed with that file as main input. As a result of this all files that have to be compiled (or processed) must reside in this directory. If a file is not placed in this directory it will not be a part of the build process (compiled). Note that header-files are not compiled. They are included. Rules:
The 'inc' sub-directoryGBS_SYSTEM_PATH/dev/GBS_SUBSYS/comp/GBS_COMPONENT/incIt contains the files that are needed in the generation process but do not belong in the 'src' directory because their presence does not lead to the invocation of a processor (compiler, linker) in the build-process (and do not lead to a file with the same name in the 'bld' Sub-Directories). Files in this directory will be accessible from other Components. (#include) This means that all 'included' files like global header-files or API header-files must be placed in this directory. Rules:
The 'loc' sub-directoryGBS_SYSTEM_PATH/dev/GBS_SUBSYS/comp/GBS_COMPONENT/locIt contains the files that are needed in the generation process but do not belong in the 'src' directory because their presence does not lead to the invocation of a processor (compiler, linker) in the build-process (and do not lead to a file with the same name in the 'bld' Sub-Directories). Files in this directory will not be accessible from other Components This means that all 'included' files like local header-files must be placed in this directory. Rules:
The 'aud' sub-directory with Audit/Build-directoriesGBS_SYSTEM_PATH/dev/GBS_SUBSYS/comp/GBS_COMPONENT/audGBS_SYSTEM_PATH/dev/GBS_SUBSYS/comp/GBS_COMPONENT/aud/GBS_AUDIT/GBS_BUILD The 'aud' directory acts a placeholder for the Audit-directories. The Audit/Build-directories contain the resulting files of Audits triggered by files in the 'src' directory. This means that these directories will contain any derived files. Rules for Audit/Build-directories:
The 'opt' sub-directory with optional Build-directoriesGBS_SYSTEM_PATH/dev/GBS_SUBSYS/comp/GBS_COMPONENT/optGBS_SYSTEM_PATH/dev/GBS_SUBSYS/comp/GBS_COMPONENT/opt/GBS_BUILD This directory contains information for the generation of the Component. For each BuildStream that this Component generates a sub-directory of the Build-name can be present to specify exceptions. These directories contain a number of files that give information on Component level:
The 'dat' sub-directoryGBS_SYSTEM_PATH/dev/GBS_SUBSYS/comp/GBS_COMPONENT/datIt contains all other (developer) files that do not fit in any of the Sub-directories mentioned before. Examples are:
The 'sav' sub-directoryGBS_SYSTEM_PATH/dev/GBS_SUBSYS/comp/GBS_COMPONENT/savContains files that in no way perform a role in the build process, but still have to be kept (saved). This is the place to keep obsolete files like test-files that are not maintained anymore. The NON Full GBS directories (make, MSVS, Other)The 'app' directoryGBS_SYSTEM_PATH/dev/GBS_SUBSYS/appNon-Full GBS only. This directory contains the top of the Non-GBS projects/applications directories. The name is reserved and is used only for Non-Full GBS SubSystems. The 'opts' sub-directory with optional Build-directoriesGBS_SYSTEM_PATH/dev/GBS_SUBSYS/optsGBS_SYSTEM_PATH/dev/GBS_SUBSYS/opts/GBS_BUILD This directory contains information for the generation of the application. For each BuildStream that this Component generates a sub-directory of the Build-name can be present to specify exceptions. These directories contain a number of files that give information on SubSys level:
|
DescriptionSubSystemsGBS recognises a number of SubSystem types that can be either Full GBS or Non-Full GBS.
In general:
MSVS SubSystemYou should create/copy your main project of solution file directly in the 'app' directory.You will already have a subsys.gbs.bat file appropriate for MSVS, with lots of comments. Run 'gbsedit subsys.gbs' to change to the wanted functionality. make SubSystemYou should create/copy your 'make' code tree directly in the 'app' directory.Your main 'make' file should be either in the SubSystem directory or the 'app' directory. You will already have a subsys.gbs.bat|.sh file appropriate for 'make', with lots of comments. Run 'gbsedit subsys.gbs' to change to the wanted functionality. Other SubSystemYou should create/copy your code tree directly in the 'app' directory.You will already have a generic subsys.gbs.bat|.sh file, with lots of comments. Run 'gbsedit subsys.gbs' to change to the wanted functionality. StepsBy default SubSystems are handled (gen, make, audit) in Alphabetical order.With the definition of Steps in steps.gbs this order can be changed. It is also possible to make selections of SubSystems optional in various ways. It is also possible to define non-SubSystem steps, called 'Commands' that will allow you to execute commands to e.g.: Copy end-results to a specific directory outside then GBS tree, run Doxygen on the whole GBS tree, etc More information in steps.gbs. |
ContentsDescriptionStart-up the GBS environment| Navigating the directory structure| Switch System| Switch Subsystem| Switch Component| Switch Build| Switch Audit| Switch Tool| Building| Compiling| Building Libraries (Archiving)| Linking| Testing| Generation by means of 'make'| Exporting deliverables| Build-streams| Builders and File-types
DescriptionIn this section the essentials of some GBS procedures are described.This is in no way a specification, final document or manual. It shows the basic idea of what is possible in GBS. Start-up the GBS environmentThe 'gbs' command sets up the GBS environment.The first time it is called, it will prompt the user for things like System Path and a SubSystem name. This information is remembered between logins. Some main Environment Variables are defined:
All GBS actions involve the currencies as indicated by these Environment Variables. GBS maintains the contents of these variables. Never change these Environment Variables yourself. Use the GBS commands to do that. Navigating the directory structureGBS is based on a system of currencies: current-System, current-SubSystem, current-Component, current-Build. etc. Whenever you make another System, SubSystem, Component or Build current (switch) the appropriate Environment Variables are set accordingly.Builds (and Audits and Tools) are always current for a whole System. Switch SystemTo switch to another System enter:swr System-path or, if you do not know the path of the System enter: swr and you will be presented a list of Systems to choose from. GBS_SYSTEM_PATH and additional Environment Variables needed for this System will be set. Switch SubsystemTo switch to another Subsystem enter: sws SubSystem-name or, if you do not know the name of the SubSystem enter: sws and you will be presented a list of SubSystems to choose from.GBS_SUBSYS and additional Environment Variables will be set. Switch ComponentTo switch to another Component enter:swc Component-name or, if you do not know the name of the Component enter: swc and you will be presented a list of Components to choose from. GBS_COMPONENT and additional Environment Variables will be set Switch BuildTo switch to another build enterswb Build-name or, if you do not know the name of the Build enter: swb and you will be presented a list of Builds to choose from. GBS_BUILD and additional Environment Variables will be set Switch AuditTo switch to another Audit enterswb Audit-name or, if you do not know the name of the Audit enter: swb and you will be presented a list of Audit to choose from. GBS_AUDIT and additional Environment Variables will be set Switch ToolTo switch to another Tool enterswb Tool-name or, if you do not know the name of the Tool enter: swb and you will be presented a list of Tools to choose from. GBS_TOOL and additional Environment Variables will be set BuildingBuilding is the process of generating one or more items from a file in the 'src' directory to one or more files in the 'bld/build' directories.Typical builds are: compilation, creating a library (archiving), linking. The file-extension specifies the type of build that is required. (e.g.: *.c →C-compile) The building process of a single file goes via specific, generic rules:
Typical Build (Generation) commands are: gbsbuild files-list gbssysbuild SubSystem-list CompilingCompiling goes straightforward according to the rules specified above.To compile a single file, enter: gbsbuild file.c More info: Generating Code (Building) Building Libraries (Archiving)For building a library, a 'glb-file' acts as the 'src' representative for the 'bld' library.The glb-file contains a list of all object-files that will make up the library. The glb-file also gives a name to the library. E.g.: name.glb → name.lib
Using the rules as mentioned above, a script generates the library-build command needed to create the library, taking the object-files as specified in the glb-file.A #include statement allows grouping of object-file-names. The search-path is the same as for other #includes Note that the glb-file may also contain specific archiver options. More info: glb/glk/glt Files and Generating Code (Building) LinkingFor linking, a 'glk-file' acts as the 'src' representative for the 'bld' executable.The glk-file contains a list of all objects and libraries that will make up the executable. The glk-file also gives a name to the executable. E.g.: name.glk → name.exe
Using the rules as mentioned above, a script generates the link command needed to link the executable, taking the object-files as specified in the glk-file.A #include statement allows grouping of file-names. The search-path is the same as for other #includes Note that the glk-file may also contain linker-options like -L. More info: glb/glk/glt Files and Generating Code (Building) TestingFor (unit-)testing, a 'glt-file' acts as the 'src' representative for the test.The glt-file contains the command-line with the name of the test-executable. Results go to a log-file in the 'bld' The glt-file also gives a name to the log-file. E.g.: name.glt → name.log
Using the rules as mentioned above, a script generates the test command needed to run the executable, taking the executable name as specified in the glt-file.Note that the glt-file may also contain execution options More info: glb/glk/glt Files and Generating Code (Building) Generation by means of 'make'With the information as supplied above 'make' files can now be generated and executed.Typical commands are: gbsmakemake gbsmake build-file-name-list and gbssysmake SubSystem-list To generate a single executable with 'make', enter: gbsmake myfile.exe or, if the .glk file is in a different Component than the current-Component: gbsmake other_component:myfile.exe For more information see: Generating Code (Building) Exporting deliverablesEach Component has an optional export.gbs file in the Component-directory.It specifies for each file in the Component that has to be exported, to which export directory it has to be exported, relative to the 'export'-directory and/or the 'res/SubSystem'-directory. The command is: gbsexport Build-streamsCode may be generated for more than one build: Simulator testing and one or more build platforms.Sometimes a single source-file generates for more than one build A sequence of compilations for a specific build, with a specific compiler using the same set of compile-options, possibly followed by linking, resulting in a set of deliverables is called a stream or build-stream. A total generation of the software-system requires the generation of all streams. Streams can run in parallel and can so reduce generation throughput time. Builders and File-typesTwo mechanisms are used in order to prevent name-clashes (and overwriting of objects/executables):
|
DescriptionGBS works independently from a Software Configuration Management System (SCMS). To ensure however, that GBS-managed files and directories are properly added to the SCMS, GBS provides support for a number of SCMSs: SCMSs supported
Combining an SCMS with GBSDuring System creation (swr --new), one of the above (or 'None') may be selected. Note that gbsmaint offers a function to check and possibly add GBS-managed
files and directories to the selected SCMS. How it FitsTerms UsedREPOSITORY:--SCMS_ROOT------+ +--ext-- \ / DISK:--------GBS_PARENT_PATH--+--SYSTEM--+---dev-- \ DISK:<-------GBS_SYSTEM_PATH--------------> +--res-- Overview
SubVersioNCreate a local repository
Create a workspace
Create GBS System
GitTBS... but somewhat similar to SVN |
DescriptionGeneralAll commands have the format: command [args | gbs-options]...gbs-options always start with: -- (hyphen hyphen) General options (always available):
General Syntax DescriptionRefer to The Command Line InterfaceIndexInstall.bat ,
_gbssetup.bat ,
bgpids ,
detab ,
filerep ,
fixeol ,
gbs ,
gbsaudit ,
gbsbash ,
gbsbg ,
gbsbldcheck ,
gbsbuild ,
gbsdebug ,
gbsedit ,
gbsexit ,
gbsexport ,
gbsgui ,
gbshelp ,
gbsinit ,
gbslocate ,
gbsmaint ,
gbsmake ,
gbsmakemake ,
gbsman ,
gbsmanage ,
gbsnav ,
gbsscm ,
gbssettings ,
gbsshow ,
gbssilo ,
gbsstart ,
gbsstart_here ,
gbsstats ,
gbssudo ,
gbsswa ,
gbsswb ,
gbsswc ,
gbsswr ,
gbssws ,
gbsswt ,
gbssysall ,
gbssysaudit ,
gbssysbuild ,
gbssysmake ,
gbssystool ,
gbswhich ,
gbswsl ,
gbsxref ,
grep ,
pgrep ,
proto ,
swa ,
swb ,
swc ,
swr ,
sws ,
swt ,
tail ,
touch ,
win2unix ,
wordrep ,
wsudo
bgpids (Non-GBS - Linux only)Purpose:Show and/or kill background processesSyntax:
Semantics:
gbsThe gbs command will either startup GBS if not started or show the GBS currenciesgbsinit (gbs - Before GBS is started )Purpose:Startup GBSSyntax:
Semantics:
Note:Alias for this command is 'gbs'. Exists only when GBS was not yet startedgbsauditPurpose:Perform an AUDIT on one or more filesSyntax:
Semantics:
Environment Variables:
Note:Summary files are written to $GBS_LOG_PATH. View with gbssilogbsbash (gbswsl)Purpose:The gbsbash command opens a new WSL bash windowOnly available on Windows Syntax:
Semantics:NonegbsbldcheckPurpose:Check if all files have generatedSyntax:
Semantics:
gbsbgPurpose:Allow user to handle Background Jobs1. Show Jobs 2. View Cur Logfile 3, Tail Cur Logfile 4. Cleanup List 5. View Logfile ... 9. Kill Job Syntax:
Semantics:
gbsdebugPurpose:Enable and Disable Debug1. Enable Debug 2. Disable Debug Syntax:
Semantics:
gbseditPurpose:Create/edit GBS-files and user-files. GBS-files end with .gbsThe switch.gbs, subsys.gbs and site.gbs batch files are also considered GBS-files Source, Include and glkbt-files are considered user-files Relevant templates will be used with file-creation On GBS files, where possible, a syntax check is performed after the edit. Syntax:
Semantics:
gbsexitPurpose:Cleanup and exit the GBS environmentSyntax:
Semantics:
Constraints:The following combinations are not allowed:
gbsexportPurpose:Fill the export and/or res directories from the Components and/or Gen or SubSystem by BuildSyntax:
Semantics:
Environment Variables:
gbsbuildPurpose:Generate one or more filesSyntax:
Semantics:
Environment Variables:
gbsguiPurpose:Startup the GBS GUISyntax:
Semantics:
gbshelpPurpose:Present help on GBS in HTML browserSyntax:
Semantics:NonegbslocatePurpose:Locate a file according to include-settings and assigns the location to a specified Environment VariableSyntax:
Semantics:
gbsmaintPurpose:Allow user to execute General Maintenance functions1. Audits Handling 2. Cleanup 3. Map Network Drives (Linux<->Windows) 5. User Tools 6. Integrator Tools 7. Administrator Tools 8. Check/Fix GBS Directory Structure 9. Owners-file Maintenance Syntax:
Semantics:
gbsmakePurpose:'make' one or more filesSyntax:
Semantics:
Environment Variables:
gbsmakemakePurpose:Make make-file(s) for the current SubSystemSyntax:
Semantics:
gbsmanPurpose:The gbsman command gives a 'more' list of all GBS commandsSyntax:
Semantics:NonegbsnavPurpose:Startup the Navigator in the current or specified directorySyntax:
Semantics:
gbsscm (scm)Purpose:Execute basic SCM commands using the current SCMSSyntax:
Semantics:
Note:infostate <file-dir>... co <file-dir>... ci <file-dir>... unco <file-dir>... mkdir <dir>... mktxt <file>... add <file-dir>... get_ignore <dir> set_ignore <dir> <ignore_list>... remove <file-dir>... import <from-dir> [<to-dir>] connect select gbssetupThis command has been replaced by gbssettingsgbssettings (gbssettings.bat or gbssettings.sh)Purpose:Setup/Maintain Basic GBS settings (Profile(EnvVars) and Config).Syntax:
Semantics:
gbsmanage (gbsmanage.bat or gbsmanage.sh)Purpose:Unsetup/Uninstall GBS version(s).Cannot execute in GBS context Syntax:
Semantics:
gbsshow (gbs)Purpose:Show GBS currenciesSyntax:
Semantics:
gbssiloPurpose:Generate silo index and show in HTML browserSyntax:
Semantics:
Constraints:The following combinations are not allowed:
gbssysauditPurpose:Perform an AUDIT on part of or whole SystemSyntax:
Semantics:
Constraints:The following combinations are not allowed:
Environment Variables:
Note:Summary files are written to $GBS_SILO_PATH/audits. View with gbssiloSee also: The gbssys... commands Use gbsbg command to View and/or Kill a Job gbssysbuildPurpose:Generate part of or whole SystemSyntax:
Semantics:
Constraints:The following combinations are not allowed:
Environment Variables:
Use gbsbg command to View and/or Kill a Job gbssysmakePurpose:Generate part of or whole System using 'make'Syntax:
Semantics:
Constraints:The following combinations are not allowed:
Environment Variables:
Use gbsbg command to View and/or Kill a Job gbssystoolPurpose:Perform TOOL on part of or whole SystemSyntax:
Semantics:
Constraints:The following combinations are not allowed:
Environment Variables:
Note:Output files (Summary files) are written to $GBS_SILO_PATH/audits. View with gbssiloSee also: The gbssys... commands Use gbsbg command to View and/or Kill a Job gbssysallPurpose:Execute gbssysbuild/gbssysmake, gbssysaudit and gbssystool commandsSyntax:
Semantics:
Constraints:The following combinations are not allowed:
Environment Variables:
Note:Commands are only executed if applicableSee also: The gbssys... commands Use gbsbg command to View and/or Kill a Job gbsstart (%GBS_BOOT_PATH%\gbsstart.bat or $GBS_BOOT_PATH/gbsstart.sh)Purpose:Startup GBS and execute a (GBS) command. To be used for integration of GBS in other toolsSyntax:
Semantics:
Constraints:The following combinations are not allowed:
More info:For Tools integration purposes, use the replacing gbsstart_here command.gbsstart_here (%GBS_BOOT_PATH%\gbsstart_here.bat or $GBS_BOOT_PATH/gbsstart_here.sh)Purpose:Startup GBS and execute a (GBS) command, using the CWD.To be used for integration of GBS in other Development Tools / Editors. Replaces 'gbsstart' in most situations Syntax:
Semantics:
More info:Integration with other ToolsgbsstatsPurpose:Show GBS System StatisticsSyntax:
Semantics:
swc (gbsswc)Purpose:Set and/or Create new Current ComponentSyntax:
Semantics:
Constraints:The following combinations are not allowed:
swr (gbsswr)Purpose:Set a current System or- Create a new one - Add / Remove one from the Systems-List - Delete one - Show the Systems-List Syntax:
Semantics:
Constraints:The following combinations are not allowed:
Note:You can only '--add' a System if it was originally created by 'swr --new'sws (gbssws)Purpose:Set and/or Create new Current SubSystemSyntax:
Semantics:
Constraints:The following combinations are not allowed:
swb (gbsswb)Purpose:Set and/or Create new Current BuildSyntax:
Semantics:
Constraints:The following combinations are not allowed:
swa (gbsswa)Purpose:Set and/or Create new Current AuditSyntax:
Semantics:
Constraints:The following combinations are not allowed:
swt (gbsswt)Purpose:Set and/or Create new Current ToolSyntax:
Semantics:
Constraints:The following combinations are not allowed:
gbssudoPurpose:Execute a GBS command in Elevated Mode (SuperUser/Administrator)Syntax:
Semantics:
Note:edit <file_name>manage <menu_entries>... gbswhichPurpose:Show Build and Audit data. Lookup header-files, sub-filesSyntax:
Semantics:
Environment Variables:
Note:subsyscomponent build build <src_file_type> build <bld_file_type> build .glkb audit audit <src_file_type> tool find <include_file> <find_method> search <source_file> search <subdir>/<file> gbsxrefPurpose:Show cross-references using makefiles and/or scope-files LauncherSyntax:
Semantics:
Install.bat & Install.shPurpose:Install GBS (and possibly setup GBS).Syntax:
Semantics:
NoteThis command resides in the $GBS_SCRIPTS_PATH/Install/gbs directoryMore info:Install_gbssetup.bat & _gbssetup.shPurpose:Setup GBS (After Install).Syntax:
Semantics:
NoteThis command resides in the $GBS_SCRIPTS_PATH directoryMore info:Setupdetab (Non-GBS)Purpose:Replace TABs by spaces in filesSyntax:
Semantics:
fixeol (Non-GBS)Purpose:Fix EndOfLine characters of specified file(s) according to the invoking Operating SystemSyntax:
Semantics:
filerep (Non-GBS)Purpose:Rename/Delete filesSyntax:
Semantics:
Note:Directory/Files starting with '.' are skippedNote:No check-out is performed on file(s)pgrep (Non-GBS)Purpose:Find strings in files, using Perl regular expressionsSyntax:
Semantics:
Note:Directory/Files starting with '.' are skippedproto (Non-GBS)Purpose:Generate function-prototypes for C, C++ and PerlSyntax:
Semantics:
win2unix (Non-GBS - Linux Only)Purpose:The win2unix command will convert Files from Windows-format to Unix-formatSyntax:
Semantics:
wordrep (Non-GBS)Purpose:Replace words/strings in filesSyntax:
Semantics:
Note:Directory/Files starting with '.' are skippedNote:No check-out is performed on file(s)wsudo (Non-GBS - Windows Only)Purpose:Run a command in Elevated Mode ('as Administrator')Somewhat like Linux: sudo But the command is run in a separate window Syntax:
Semantics:
grep tail touch and more... (Non-GBS - Windows Only)Purpose:How any programmer can survive without 'grep' is beyond my understanding...Gratefully copied from Karl M. Syring 's UnxUtils (now OpenSource) and (partly) delivered as part of GBS. Please read the Standard Disclaimer. Some extra help can be found UnxUtils Home Page. Note that not all commands are distributed with GBS. Feel free to request additions. The executables are located in '%GBS_SCRIPTS_PATH%/win2utils'. You may consider adding the win32utils directory in your PATH. In switch.gbs.bat add:
IF "%WIN32UTILS_IN_PATH%"=="" THEN PATH=%GBS_SCRIPTS_PATH%\win2util;%PATH%
Syntax and Help:On Command Line the following commands are predefined (DosKey):
In GBS 'make' or via '%GBS_SCRIPTS_PATH%/win2utils' you can use:
|
Descriptiongbssysbuild, gbssysmake, gbssysaudit, gbssystool and gbssysallThe gbssys... commands are used to perform actions involving more than one SubSystem.
These commands will perform their functions over various SubSystems in the appropriate order and allows extra steps to be executed. Usage
LOG files.log filesLog files are written to $GBS_LOG_PATH, which unless defined in switch.gbs points to $GBS_LOG_ROOT/$GBS_SYSTEM_PARENT.For each run 2 to 3 files will be generated:
The logfile_namegbssys-command_build-or-tool_audit-or-hyphen_packed-num-date-timepacked-num-date-time := YYYYMMDD-hhmmss E.g.: gbssysaudit_mingw_pclint_20150214-12:00:00 The .log.sum fileThis file contains a summary of the .log file.It is a fixed-format file. One item per line. Its layout will never change. Although new items may be added at the end, before the <<EOF>>. This file can be used for your own tooling to extract information from the run.
.html filesThese are the Summary files resulting from gbsaudit and not from gbssysaudit |
ContentsDescriptionBuilding basics| The difference between GBSBUILD and GBSMAKE| Specifying Files in GBSBUILD, GBSMAKE and GBSAUDIT| Specifying FLAGS (-D)| Specifying Derived Filetypes (.o)| Specifying Search Paths (for -I and -L)
DescriptionBuilding basicsThere are two commands to be used for building (generating code): gbsbuild and gbsmake.Each command is used for all aspects of building: compile, archive, link, test. They are almost alike for the difference see the next chapter below. gbsbuild is straightforward. gbsmake requires some explanation. gbsmakegbsmake needs a 'make'-file.The gbsmakemake command creates a make-file per SubSystem and Build. You only need to run gbsmakemake when your include-structure changes. Note that the system-wide gbssysbuild and gbssysmake will always create new make-files (implicit makemake). gbsmakemakegbsmakemake will parse all the Component src-files in a SubSystem to detect dependencies and create one (big) make-file per Component with no macros at all. This makes 'make' super-fast.To be able to do this, gbsmakemake needs to know where the compiler gets its include-files. All other include-paths are derived from the GBS file-structure. The compiler include-files are found via GBSEXT_plugin>_PATH which is a combination of GBSEXT_plugin>_ROOT and GBSEXT_plugin>_REL. A wrong '_REL.' may cause gbsmakemake to fail. gbsmakemake has no knowledge of conditional includes (speed). Sometimes the include file may not be available (i.e. because of platform dependency). If all fails, you can put dummy files (stubs) in the makemake_stubs directory in sysbuild to satisfy gbsmakemake. The difference between GBSBUILD and GBSMAKEgbsbuild
gbsmake
Specifying Files in GBSBUILD, GBSMAKE and GBSAUDITSyntaxThe generic syntax to specify files in GBSBUILD, GBSMAKE and GBSAUDIT is:
gbsbuild, gbsauditoptions1 if present, will be passed to all file-generations options2 if present, will be passed to all file-generations preceding the options2 gbsmakeoptions1 if present, will be passed to 'make' options2 cannot be present in gbsmake. Use the GBS_FLAGS_type to specify options with gbsmake. Typical use of GBSBUILD:
gbsbuild my_file.c -DTEST comp1.c comp2:test.c -DTEST2
This results in:
Specifying FLAGS (-D)There are predefined FLAGS for Debug-Mode, Debugger, Optimizer and Map-files
Flags will be placed behind the generation scripts own flags in the following order
Specifying Derived Filetypes (.o)For 'make', GLKBT,
gbsexport and script files a platform/tool independent notation is used. Specifying Search Paths (for -I and -L)Include Paths are passed to the generation scripts in the following order
Note that the contents of the incs_TYPE.gbs files must refer to directories outside the current (Sub)System. Do not prefix directories (with -I or -L) |
DescriptionArchiving Object-files to LibrariesThe glb extensions are used to build libraries from object files. Linking Object-files and Libraries to ExecutablesThe .glk extensions are used to build executables from object files and libraries. Testing ExecutablesThe .glt extensions are used to test executables. GLT directivesAt this moment there is only 1 GLT directive:
Description of the glt files can be found here. |
DescriptionThe gbsexport commandThe gbsexport command is used to copy files from Components and/or Gen or SubSystem to the export-directories:
The presence of an export directory determines copy to export. The presence of a res/SubSystem directory determines the copy to res. Components not containing a bld/$GBS_BUILD directory will be skipped. During copy the file dates are preserved. The creation of (msi) install programs is also supported in this command The syntax of the command can be found here. The description of the export.gbs file can be found here. |
ContentsDescriptionPredefined Audits DescriptiongbsauditThe gbsaudit command will run an audit for one or more files in a Component. The syntax of the gbsaudit command can be found here. Notes:An Audit will only run for SubSystems that
Predefined audits can be installed with the gbsmaint command. gbssysauditExecutes the audit on all files in one or more or all SubSystems in a System (provided the SubSystem is enabled for the audit) The syntax of the gbssysaudit command can be found here. Predefined AuditsQACAudit name:qac Required:
Include-file handlingSame way as for C-compilation Handling of compile time optionsSame way as for C compilations General Notes:
QAC++Audit name:qacpp Required:
Include-file handlingSame way as for C++-compilation Handling of compile time optionsSame way as for C++ compilations General Notes:
PCLintAudit name:pclint Required:
Include-file handlingSame way as for C and C++-compilation Handling of compile time optionsSame way as for C and C++ compilations General Notes:
C++testAudit name:cpptest Required:
Include-file handlingSame way as for C and C++-compilation Handling of compile time optionsSame way as for C and C++ compilations General Notes:
|
ContentsDescriptionDescriptionThese customisations give (extra) control over the gbsaudit, gbsbuild and gbsmake commands (and to some extent: gbssystool).The following EnvVars can be set: There are 4 levels of session-control:
GBS_DEBUGGERName:GBS_DEBUGGERPurpose:To predefine the GBS_DEBUGGER (include debugging information) setting during a sessionPossible Values:YES NODefine:
GBS_MAPName:GBS_MAPPurpose:To predefine the GBS_MAP (generate memory-map) setting during a sessionPossible Values:YES NODefine:
GBS_MODEName:GBS_MODEPurpose:To predefine the GBS_MODE settings during a sessionPossible Values:FINAL ASSERT DEBUG PROFILINGDefine:
GBS_OPTName:GBS_OPTPurpose:To predefine the GBS_OPT (optimisation) settings during a sessionPossible Values:YES SPEED SIZE DEBUG NODefine:
GBS_FLAGS_typeName:GBS_FLAGS_typePurpose:To predefine flags (-options) for a specific type (E.g.: .c or .glk).Specify the type without the '.' (dot) Possible Values:Depend on builder / auditDefine:
GBS_APP_anynameName:GBS_APP_anynamePurpose:To define an EnvVar that is used by a specific Application (audit, build or tool) to change its behaviour, not defined by FLAGs.Possible Values:Anything valid in the SHELL and of interest of the called Application, except GBS_APP_PATH.GBS_APP_PATH is used for the 'app' directory in non-GBS SubSystems Define:
|
ContentsDescriptionDescriptionGBS has a few user customisation possibilities.Most are set by the gbssettings command Index Perl Directory (GBS_PERL_PATH)Name:GBS_PERL_PATHPurpose:Define an specific directory to find the Perl executableTo be used when (the wanted) perl is not in the PATHSpecifies the top-directory of the Perl installation (the directory containing 'bin') Default:Empty (Find Perl via PATH)Where:In Registry (Windows) My Computer → Properties → Advanced → Environment Variablesor ~/.profile or ~/.bash_profile Define:
gbssettings commandWith the gbssettings command you can set/change:
Site-IDGBS_SITEPurpose:To identify the location where the user worksIt is used in the switch.gbs to cater for different IT infrastructures (e.g. different locations of compilers, network drives, etc) You will only really need it if people work from different site-locations on the same code. A good name is an abbreviation of the town or site. Just make sure it is unique for the future. Keep the name short and in uppercase. Consider using the 3-letter IATA Airport Code of a nearby airport. Default:MAINLogRootGBS_LOG_ROOTPurpose:To define the location of the logfile-directories per SystemGBS_LOG_PATH=$GBS_LOG_ROOT/$GBS_SYSTEM_PARENT Defaults:
HomeGBS_HOME_PATHPurpose:Set the CWD when no current System and Default Root for GBS user directoriesDefault:
BeepsGBS_BEEBSPurpose:To switch the 'beep' on the command-line on or offDefault:
CompanyGenericPurpose:To identify your Company and/or ProjectIt is shown in the login-banner, logfile-banner and in the top of generated HTML-files like gbssilo. You can put any text, even your own name here. Default:My CompanyIgnoresGenericPurpose:TBSDefault:NoneNotifyPer PlatformPurpose:To provide a different default for the --n (notify) option in the gbssys* functionsDefault:
EditorPer PlatformPurpose:Define a text-editor (for gbsedit and gbsmaint 9 ('Owners-file' Maintenance)Defaults:
BrowserPer PlatformPurpose:Define a HTML Browser (for gbshelp and gbsaudit)Defaults:
NavigatorPer PlatformPurpose:Define a program to navigate directory structureUsed by gbsgui Defaults:
ViewerPer PlatformPurpose:Define a text-viewer (for viewing batch log-files)Defaults:
TerminalTERMINALPurpose:Define Terminal settings for when a new Terminal window is openedYou can set:
Default:
AdministratorADMINISTRATORPurpose:Define/Remove the current user as Administrator for this SystemAdministrator privilege is required for all changes to the infrastructure. E.g.: create a new component. It is just a token privilege. You will be warned every time you try to do a privileged action. You can always override. This is a safety issue, warning you that you are changing something special for which you probably need permission of the System / Code Architect. Default:
IntegratorINTEGRATORPurpose:Define/Remove the current user as Integrator for this SystemIntegrator privilege is required for the execution of some special functions ad defined in gbsmaint 6:
This is a safety issue, warning you that you are doing something irreversible. Default:
GBS Command Prompt Window (gbscmd.bat / .sh)You can customize your GBS Command Prompt DOS-box/xterm by placing shell commands in a private startup file: 'gbscmd.bat / .sh' in your GBS_BASE_PATH directory:Please note the following:
|
ContentsDescriptionUser File Templates (GBS_TEMPLATES_PATH)| SCM binary home directory (GBSEXT_scm_PATH)| Make (GBS_MAKE)| Background Processing Invocation (GBS_SUBMIT)| Foreground Processing Invocation (GBS_SUBWIN)| Batch Processing Invocation (GBS_BATCH)| Notify Submit, Start and End of gbssys...-job execution (GBS_BG_NOTIFIER)
DescriptionThese Customisation must only be set by the GBS Administrator!Index User File Templates (GBS_TEMPLATES_PATH)TemplatesWhen gbsedit creates a file, a template-file (template) is used.Standard templates are defined in GBS for GBS-internal files (*.gbs & gbs script files). There are also templates for most common User files (.c, .glk, etc). As you can use gbsedit also outside GBS (outside the GBS Work Area) these come in two tastes:
Template-files are named gbs.file_type or
gbs_name.file_type or
any.file_type or
any_name.file_type .E.g.: any.c, gbs.glk , any_myname.c Search-order is:
See below for the customisable items in a template-file. gbsmaint 7 2 provides functions to:
Comments in filesAssociated to a file-type are comment-characters:
Whenever you add a file with gbsedit, and the file-type is not known, you will be prompted for the comment-characters. They are saved in a file called 'comment_chars.gbs' in the User Templates directory. Not happy?Suggestions? Your favourite missing? Let me know!Name:GBS_TEMPLATES_PATHPurpose:To define a directory containing external project file-templatesDefault:
Where:In the switch.gbs file or the site.gbs file.Define:
Semantics:Template-files are namedany.file_type or any_name.file_type .
E.g.: any.c, any.glk , any_myname.c Search-order is GBS_SYS_PATH/templates (User), GBS_TEMPLATES_PATH (Share), Internal_GBS_directory (GBS). The following tokens used within the Template will be replaced during file-creation by GBS:
SCM binary home directory (GBSEXT_scm_PATH)Name:GBSEXT_scm_PATHPurpose:To define the home directory of the specific SCM execution binaryThis prevents being depended on the individual PATH settings Default:
Where:In the switch.gbs file or the site.gbs file.Define:
Semantics:The following EnvVars will be recognised by GBS:
Make (GBS_MAKE)Name:GBS_MAKE and/orGBS_MAKE_gbs_build Purpose:Define a alternate make command and/or specify make-options for Non-GBS makefilesCareful: Incorrect use can damage the build-system! Default:
Where:In the switch.gbs file or the site.gbs file.Define:
Background Processing Invocation (GBS_SUBMIT)Name:GBS_SUBMIT and/orGBS_SUBMIT_gbs_build Purpose:Define a general script to be executed after submitting a job to the background batch and before the job is executed (for implementing things like LSF)The batch-job will be executed within the context of this general script Affected commands: gbssysbuild, gbssysmake, gbssysaudit. Careful: Incorrect use can damage the build-system! Default:
Where:In the switch.gbs file or the site.gbs file.Define:
Foreground Processing Invocation (GBS_SUBWIN)Name:GBS_SUBWIN and/orGBS_SUBWIN_gbs_build Purpose:Define a general script to be executed after submitting a job for foreground executing in a separate window and before the job is executed (for implementing things like LSF)The batch-job will be executed within the context of this general script Affected commands: gbssysbuild, gbssysmake, gbssysaudit (with --fg )Careful: Incorrect use can damage the build-system! Default:
Where:In the switch.gbs file or the site.gbs file.Define:
Batch Processing Invocation (GBS_BATCH)Name:GBS_BATCH and/orGBS_BATCH_gbs_build Purpose:Define a general script to be executed after submitting a batch job and before the job is executed (for implementing things like LSF)The batch-job will be executed within the context of this general script Affected commands: gbsbuild, gbsmake, gbsaudit Careful: Incorrect use can damage the build-system! Default:
Where:In the switch.gbs file or the site.gbs file.Define:
Notify Submit, Start and End of gbssys...-job execution (GBS_BG_NOTIFIER)Name:GBS_BG_NOTIFIER and/orGBS_BG_NOTIFIER_gbs-build Purpose:Define a command to be executed at submit, beginning and at termination of a gbssysbuild, gbssysmake or gbssysaudit job (Used by tools like SoftFab, Hudson, BuildForge and CruiseControl)The command will be appended with the following information:
Note that for one submit all jobname and datetime will be the same Where:In the switch.gbs file or the site.gbs file.Define:
Note:As the GBS_BG_NOTIFIER will be executed from different processes, no assumption can be made on the order in which they are executed! |
ContentsDescriptionThe gbsstart_here Command| The gbsstart Command| Crimson Editor| Eclipse| Gedit| Notepad++| MS Visual Studio
DescriptionIt is possible to integrate the execution of GBS commands in development tooling like editors, IDEs and buildmanagers.The command that makes this possible is gbsstart_here. It is a simplified version of the gbsstart command. Typical commands are
The gbsstart_here CommandThe purpose of the gbsstart_here command is to be able to execute a GBS command outside of a GBS context.For this 2 things are needed:
The gbsstart CommandWhen gbsstart_here cannot be used (because you do not have a CWD), the more complex gbsstart command can be used.The purpose of the gbsstart command is to be able to execute a GBS command outside of a GBS context. For this 2 things are needed:
Specify '.' to take current (default) Specify '-' to take none The first parameter also allows for the special '!' and '!!' GBS_SYSTEM_PATH settings, giving the following possibilities:
The --exec parameter specifies the command that is to be executed. No spaces are allowed here so you must use the special space notation ($_, %_ or %20). Because GBS is now invoked from outside a GBS context the gbsstart command must be invoked from the generic GBS startup directory GBS_BOOT_PATH.
Crimson EditorLocation:Tools → Conf.User Tools...Command definitions:Tools On Windows GBS_BOOT_PATH points to %APPDATA%\.gbsBe sure to mark: Capture output and Save before execute
NotesNoneEclipseLocation:Only System-wide commands can be defined hereWindow → Show View → Make Builds Add Make Build Command definitions:In Add Make Build Window:
Notes:NoneGeditEnable:Edit → Preferences → PluginsEnable 'External Tools' Location:Tools → External ToolsCommand definitions:Tools → Manage External ToolsThe 'External Tools Manager' is started For a new command click on the 'New' icon, in the lower left corner, just above the 'Help'
Notepad++InstallFirst you have to install the NppExec pluginPlugins → Plugin Admin... Install NppExec Command definitions:Plugins → NppExec → Execute... or press F6In the 'Command(s)' window add and Save... the following commands:
Press Ctrl+F6 to immediately execute the last selected command. You can also place the commands in the Macro list with Plugins → NppExec → Execute... Notes:NoneMS Visual StudioAs a Visual Studio project will be in a non-compliant GBS SubSystem, we cannot use the gbsbuild, gbsaudit and gbsmake commands.If you are using Visual Studio only as an editor in a Full GBS SubSystem, you can use these commands. Location:ToolsCommand definitions:Tools → External Tools...On Windows GBS_BOOT_PATH points to %APPDATA%\.gbs Be sure to mark: Use Output window
Notes:None |
DescriptionSupported plugins.GBS Administrator only!! Build (gen) PluginsBuild Plugins are selected with gbsswb --new Supported Build Plugins:
Audit PluginsAudit Plugins are selected and updated with gbsmaint 7 1 Supported Audit Plugins: See also audit.gbsTool PluginsTool Plugins are selected and updated with gbsmaint 7 1 Supported Tool Plugins: See also tool.gbsDoxygenPurposeRun Doxygen for all SubSystemsRunIn steps.gbs:STEP doxygen_api TOOL = doxygen_api BUILD = NO AUDIT = NO STEP doxygen TOOL = doxygen EXEC = SPECIFY BUILD = NO AUDIT = NO RequiresDoxygen via GBSEXT_DOXYGEN_PATH and GBSEXT_DOXYGEN_RELand optionally Dot (Graphviz) via PATH NotesUse gbssilo to view resultsOther PluginsSupported Other Plugins:
Copy_ExportPurposeCopy the contents of one or more GBS EXPORT directories to a directory outside the GBS WorkAreaUsageRun in steps.gbsSyntaxcopy_export >copy_export/bin/copy_export.pl subsys_comma_list export_path to_path
ExampleSTEP copy_export COMMAND = >copy_export/bin/copy_export.pl superglo $GBS_BUILD $GBSEXT_GBSSHARE/$GBS_BUILD AUDIT = NO RequiresNoneNotesNone |
DescriptionGBS relies heavily on Environment Variables (EnvVars)They are all controlled by GBS. There is a lot of inter dependency between the GBS EnvVars and they must be set as a group. Some EnvVars (most) are intrinsically set by GBS, others (a few) may be set by the User and that has to be done by using the proper GBS functionality that supports that. Changing EnvVars by just setting them may lead to unexpected results and may cause GBS to crash or loose integrity All GBS EnvVar are prefixed by either GBS_, GBSEXT_
Index GBS_ EnvVarsNote that the following table is sortable by the items in the top row.
GBSEXT_ EnvVars For SCMSThe value must be either the directory where the SCMS is installed or PATH if the SCMS command(s) are in the PATH.Note that the following table is sortable by the items in the top row.
GBSEXT_ EnvVars For PluginsGBSEXT_... EnvVars define the location of external stuff (Plugins and External Data).Usually 3 EnvVars are defined (Hard versioned directories):
Note that the following table is sortable by the items in the top row.
|
ContentsDescriptionExample of a glb file Example of a glk file Example of a glt file DescriptionThe glkbt files (.glb, .glk, .glt and others) are located in the src, loc and/or inc directories and are used to specify the behaviour of builders that traditionally do not have 'source'-files, like Linkers and Archivers. GeneralGeneral considerations:
Syntax
Lines can be appended with a Build Selector enabling skipping of the
line dependent on the current Build.
Any line can be appended with a Build selector enabling skipping of the line dependent on the current Build. Refer to GBS-files: General for explanation of the build-line-selection mechanism. Semantics:
Notes:NoneExample of a glb file:#====================================== # Src-File: software.glb # Component: software # SubSys: product_s #====================================== main$GBS_BLD_C #====================================== # Other Components #====================================== otv_arm:arm1$GBS_BLD_C otv_arm:arm2$GBS_BLD_C ###EOF### Example of a glk file:#====================================== # Src-File: total_cze.glk # Component: software # SubSys: product_s #====================================== main$GBS_BLD_C main_country_cze$GBS_BLD_C rom_cze_gnu$GBS_BLD_C = gnu rom_cze_arm$GBS_BLD_C = arm software.lib #====================================== # Other Components #====================================== obs:occ$GBS_BLD_C obs:saoc$GBS_BLD_GLK #====================================== # Externals #====================================== .include total_libs.glk +rmgr_upc$GBS_BLD_GLB +country_czech$GBS_BLD_C +caxxconfiguration_cze$GBS_BLD_C +dvbst_stub$GBS_BLD_GLB ###EOF### Example of a glt file:#======================================== # File: hello.glt # Component: test # SubSystem: superglo # System: SuperGlo_OK #======================================== .builds=mingw,mingwd ^timeout=3 hello$GBS_BLD_GLK -par1 +PAR2 ##EOF## |
ContentsGeneralDirectives Common Elements GeneralUsage
The .gbs files form together with the directory structure the backbone of GBS. General Syntax
End-Of-Line CommentsThe usage of End-Of-Line Comments can be enabled and disabled by means of the .eol_comment directive.Enabling the EOL Comments slows down parsing and should therefore be enabled with care. It works similar as C and C++ // comments. Syntax:
Semantics:
Example
build-line-selectionThe build-line-selection mechanism allows lines to be skipped depending on the current Build.This mechanism is not enabled for all .gbs files. Syntax:
Semantics:
Example
NoteIt is practice to align the Build selections to the right of the lines.Order of actions
Directives.plugin .include .eol_comment .builds .exit .end.pluginPurpose:To define the plugin. Syntax:
Semantics:
.includePurpose:To include text from another .gbs file Syntax:
Semantics:
.eol_commentPurpose:To enable/disable EOL (End-Of-Line) Comments Syntax:
Semantics:
.buildsPurpose:To exclude generation of SRC files depending on the current Build Syntax:
Semantics:
.exitPurpose:To prematurely exit from a (included) file Syntax:
Semantics:
.endPurpose:To prematurely exit from a (included) file Syntax:
Semantics:
Common ElementsCOMMANDCOMMANDPurposeUsed to execute a script, executable or builtin command.Available in the plugin descriptors: audit.gbs, build.gbs and tool.gbs. Syntax:
Semantics:
|
ContentsDescriptionPurpose| General| Contents| SETUP Definition| INIT Definition| SRC Definitions| SUMMARY Definition| MAINT Definition| Notes
Examples of audit.gbs filesDescriptionPurposeThe audit.gbs files are located in the GBS_SYSAUDIT_PATH/audit directories and are
used to associate file-extensions with audit-plugins (QAC, QAC++ etc) for a specific audit. GeneralPlease refer to .gbs files: General informationAdditional for this file:
ContentsSETUP definitionINIT definition SRC definitions (multiple) ... SUMMARY definition MAINT definition SETUP DefinitionPurpose:To define general stuff, valid for the whole definition set. Syntax:
Semantics:
INIT DefinitionPurpose:To perform general initialisation. Syntax:
Semantics:
SRC DefinitionsPurpose:To associate a file-extensions with an audit program (like SCA) and provide the necessary information in order to be able to execute that audit program (executable or script). Syntax:
Semantics:
SUMMARY DefinitionPurpose:To provide information on how to run the summary program (executable or script) Syntax:
Semantics:
MAINT DefinitionPurpose:To provide the interface of an audit-related program that can be executed from the gbsmaint command Syntax:
Semantics:
Notes:NoneExamples of audit.gbs files:File 1 (Basic reference)#======================================================== # [qac] audit.gbs #======================================================== .plugin qac .include <audit.gbs> ##EOF## File 2 (Full specification)#======================================================== # [qacpp] audit.gbs #======================================================== SETUP NICE_NAME = QAC++ VIA_FORMAT = -via %s INIT SET_W = QAC_EXEC => qacpp SET_X = QAC_EXEC => qac++ SET = QACPPHELPFILES => $GBSEXT_QACPP_PATH/help PACKAGE = qac::prqa BIN_DIR = SRC .cpp OUT_TYPES = .gout .met .err INC_FORMAT = -I %s SYSINC_FORMAT = -SI %s FLAG_FORMAT = -D %s SYSFLAG_FORMAT = FILE -SD %s COMMAND = 0,1 ; \ $GBSEXT_QACPP_BIN_PATH/$QAC_EXEC $GBS_INCS $GBS_SYSINCS $GBS_AUDIT_FLAGS $GBS_SYSFLAGS $GBS_FLAGS \ $2 $GBS_QACPP_FLAGS $* -outputpath $4 -n 1599 COMMAND = exists $GBS_SYSTEM_PATH/sysaudit/$GBS_AUDIT/style_ALL.nrf; ; \ $GBSEXT_QACPP_BIN_PATH/pal qacpp $2 $GBS_PAL_FLAGS -outputpath $4 COMMAND = exists $GBS_SYSTEM_PATH/sysaudit/$GBS_AUDIT/user_checks$GBS_SHELL_FILETYPE ; ; \ $GBS_SYSTEM_PATH/sysaudit/$GBS_AUDIT/user_checks$GBS_SHELL_FILETYPE qacpp $2 \ $GBS_INCS $GBS_SYSINCS $GBS_AUDIT_FLAGS $GBS_SYSFLAGS $GBS_FLAGS $* COMMAND = 0,1-9,99; \ $GBSEXT_QACPP_BIN_PATH/errdsp qacpp $2 $GBS_ERRDSP_FLAGS -outputpath $4 -file $2$5 SUMMARY COMMAND = ECHO SCA MAINT COMMAND = >qac/bin/prqamaint.pl QACPP ##EOF## |
ContentsDescriptionExample of a broadcast.gbs DescriptionPurposeShow a (GBS related) text when an interactive GBS session is started. It is located in GBS_SCRIPTS_ROOT directory To edit the file: Notes:Useful with multi-user install of GBS Example of a broadcast.gbs:
#================================================= # File: broadcast.gbs # Path: D:/Work/Development/GBS/WA #================================================= # # Place your broadcast here # Lines starting with '#' will not be broadcast # #Release date set to2020-12-01 Release date delayed till 2021-02-14 # ###EOF### |
ContentsDescriptionPurpose| General| Contents| SETUP Definition| DEFAULTS definition| INIT definition| SRC definition| Notes
Examples of build.gbs filesDescriptionPurposeThe build.gbs files are located in the GBS_SYSBUILD_PATH/build directories and is
used to associate file-extensions with builders (compilers, linkers, etc) for a specific build. GeneralPlease refer to .gbs files: General informationAdditional for this file:
ContentsSETUP definitionDEFAULTS definition INIT definition SRC definitions (multiple) ... SETUP DefinitionPurpose:To define general stuff, valid for the whole definition set. Syntax:
Semantics:
DEFAULTS definitionPurpose:To set Build dependent defaults, overriding the GBS defaults Syntax:
Semantics:Refer to SRC semantics below.INIT definitionPurpose:To perform general initialisation. Syntax:
Semantics:
SRC definitionPurpose:To associate a file-extensions with a builder and provide the necessary information in order to be able to execute the builder. Syntax:
Semantics:
Notes:NoneExamples of build.gbs files:File 1 (final build)#======================================================== # [mingw] build.gbs #======================================================== SETUP NICE_NAME = MinGW_cpp INIT SET_W = TEST => WIN32 SET_X = TEST => LINUX BIN_DIR = bin SETPATH = PATH => GBSEXT_MINGW_CPP_BIN_PATH% PATH SRC .c TYPE = c ORDER = 1 INC_TYPES = .h OUT_TYPES = .o INCLUDE_BLD = 1 INC_FORMAT = -I%s INC_SEARCH_STYLE = UNIX FLAG_FORMAT = -D%s MODE = ASSERT => -DASSERT MODE = DEBUG => -DDEBUG MODE = PROFILING => -DPROFILING DEBUGGER = YES => -g OPT = NO => -O0 OPT = SIZE => -Os OPT = SPEED YES => -O3 COMMAND = GBSEXT_MINGW_CPP_BIN_PATH%\gcc -c -Wall -ansi %GBS_INCS% %GBS_FLAGS% %* %2 -o %3 SRC .cpp TYPE = c ORDER = 1 INC_TYPES = .hpp OUT_TYPES = .o INCLUDE_BLD = 0 INC_FORMAT = -I%s INC_SEARCH_STYLE = UNIX FLAG_FORMAT = -D%s MODE = ASSERT => -DASSERT MODE = DEBUG => -DDEBUG MODE = PROFILING => -DPROFILING DEBUGGER = YES => -g DEBUGGER = NO => OPT = NO => -O0 OPT = SIZE => -Os OPT = SPEED YES => -O3 COMMAND = call GBSEXT_MINGW_CPP_BIN_PATH%\g++ -c -Wall %GBS_INCS% %GBS_FLAGS% %* %2 -o %3 SRC .s TYPE = asm ^\.include\s+(")(.*?)" ^\s*#.* ORDER = 1 INC_TYPES = .inc OUT_TYPES = .o INC_FORMAT = -I%s FLAG_FORMAT = -D%s COMMAND = call GBSEXT_MINGW_CPP_BIN_PATH%\as --warn --fatal-warnings %GBS_INCS% %GBS_FLAGS% %* %2 -o %3 SRC .glb TYPE = glb ORDER = 2 INC_TYPES = .glb OUT_TYPES = .a GLKB = LIST COMMAND = call GBSEXT_MINGW_CPP_BIN_PATH%\ar -rvs %* %3 %GBS_GLKB% SRC .glk TYPE = glk ORDER = 4 INC_TYPES = .glk OUT_TYPES = .exe GLKB = LIST UNIXLIB INC_FORMAT = -L%s MAP = YES => -Wl,-Map -Wl,%1 # DEBUGGER = NO => "Wl,-s" COMMAND = @mingw_glk.bat SRC .glt TYPE = glt ORDER = 5 INC_TYPES = .glt OUT_TYPES = .log COMMAND = >ALL/gbstest.pl ##EOF## File 2 (debug build)#======================================================== # [mingwd] build.gbs #======================================================== .plugin mingw_gcc .include <build.gbs> DEFAULTS MODE = DEBUG DEBUGGER = YES OPT = DEBUG ##EOF## |
ContentsDescriptionExample of an export.gbs Example of an export.gbs using INSTALL DescriptionPurposeThe export.gbs files are used to fill the res/subsys and subsys/export directories.They (the export.gbs files) can reside in 2 locations:
The export.gbs files located in the GBS_COMPONENT_PATH directories are used to specify which files of the Component are to be exported to a relative directory in RES/$GBS_SUBSYS and/or EXPORT when using the gbsexport command. The export.gbs files located in the GBS_SUBSYS_PATH directories are used to specify which files of the SubSystem, any RES and/or EXT are to be exported to a relative directory in RES/$SUBSYS and/or EXPORT when using the gbsexport command. Files can be exported to $GBS_RES_PATH/$GBS_SUBSYS and/or to $GBS_EXPORT_PATH depending on the existence of these directories or selective by means if the to_base prefix. Besides copying files it is also possible to create (msi) install programs. By default: GeneralPlease refer to .gbs files: General informationAdditional for this file:
Contents:Syntax:
Destination lines (to_path) can be appended with a Build Selector enabling skipping of the
whole destination_set dependent on the current Build. Semantics:
Notes:
Example of an export.gbs:#=============================== # [otv_al_s:ocs] export.gbs #=============================== RESSUB:inc/$GBS_BUILD == mingw inc/http_init.h inc/lsm.h inc/oco.h inc/ocs.h inc/ocs_cfg.h RESSUB:lib/$GBS_BUILD == mingw bld/$GBS_BUILD/ocs$GBS_BLD_GLB EXPORT:bin == mingw bld/$GBS_BUILD/ocs$GBS_BLD_GLBK |ugo:x ## EOF ## Example of an export.gbs using INSTALL:#======================================================== # [profielsw] export.gbs #======================================================== base base/bin app\Task24Profiel\bin\Release\Task24Profiel.exe base/bin/DUT data\bin\DUT\_NL%20Profiel%20Leesmij.txt data\bin\DUT\CV%20TemplateB.dotm data\bin\DUT\leegcv.ini data\bin\DUT\wizard.ini base/bin/ENG data\bin\ENG\_English%20Profile%20ReadMe.txt data\bin\ENG\CV%20TemplateB.dotm data\bin\ENG\leegcv.ini data\bin\ENG\wizard.ini base/Doc data\Doc\Help.html data\Doc\userguide.doc base/Doc/Images data\Doc\Images\Balkknop.jpg data\Doc\Images\CVWizardMain.jpg data\Doc\Images\image002.jpg data\Doc\Images\TASK24.ico install INSTALL:%GBSEXT_ADVANCED_INSTALLER_PATH%\AdvancedInstaller.com /build Task24Profiel.aip setup.msi ###EOF### |
ContentsDescriptionExample of a flags_*.gbs DescriptionPurposeThe flags_type.gbs files are used to specify builder-specific flags. The flags_type.gbs files may be placed in the following locations:
GeneralPlease refer to .gbs files: General informationAdditional for this file:
Contents:Syntax:One flag per lineA line containing spaces will be quoted unless the line also contains quotes (") To prevent this, place elements on separate lines Notes:Flags may not be include-paths like -I and/or -LThese should be specified in the incs_*.gbs files. Example of a flags_*.gbs:#======================================================== # [superglo::test]FLAGS_C.GBS #======================================================== -DTESTFLAG=1 ###EOF### |
ContentsDescriptionExample of a subsys.gbs.bat DescriptionPurposeThe subsys.gbs script file is used only for Non-GBS SubSystems, is located in the GBS_SUBSYS_PATH
directory and is used for the building or auditing of these Subsystems. GeneralSpecial considerations:
CallingThe subsys.gbs file is called:
Environment VariablesBefore execution a vast amount of EnvVars is set so you can make your proper selections.Some EnvVars will be dependent on the SubSystem type. Refer to example below. Each GBS_BUILD_type EnvVar contains the Command to execute for that filetype for the current Build It is taken from the build.gbs file and contains all settings until the first % or $ argument. Same analogy for GBS_AUDIT_type LayoutFor every Non-GBS SubSystem type there is a slightly different subsys.gbs file.The 'switch' on action (cleanup_bld, gen, make, cleanup_aud or audit) is the same for all, but the contents of the 'cases' will differ. Refer to example below. Notes:NoneExample of a subsys.gbs.bat:@ECHO OFF ::============================================================================= :: [%SUBSYS%] subsys.gbs.bat :: Requires 1 parameter: action :: Called to cleanup, gen, make or audit a non-GBS SubSystem :: For 'make' SubSystems ::============================================================================= :: :: Currently in $GBS_SYSTEM_PATH/dev/$GBS_SUBSYS :: Applicable EnvVars: :: GBS_BUILD :: GBS_BUILD_PLUGIN :: GBS_BUILD_PLUGIN_PATH ('make' or 'Other') :: GBS_BUILD_PLUGIN_BIN_PATH ('make' or 'Other') :: GBS_BUILD_src_type ('make' or 'Other') :: GBS_AUDIT_PLUGIN (for Audit only) :: GBS_AUDIT_PLUGIN_PATH (for Audit only) ('make' or 'Other') :: GBS_AUDIT_PLUGIN_BIN_PATH (for Audit only) ('make' or 'Other') :: GBS_AUDIT_src_type (for Audit only) ('make' or 'Other') :: :: Available EnvVars: :: GBS_SYSTEM_PATH :: GBS_SUBSYS :: GBS_SUBSYS_PATH :: GBS_AUDIT_PATH :: GBS_BUILD_PATH :: GBS_APP_PATH :: :: GBS_MAKE make_command :: GBS_IGNORE_ERRORS 0 | 1 :: GBS_MODE FINAL | ASSERT | DEBUG | PROFILING :: GBS_OPT YES | SPEED | SIZE | DEBUG | NO :: GBS_DEBUGGER NO | YES :: GBS_MAP NO | YES :: :: GBS_BLD_src_type primary_output_type> :: GBS_SYSFLAGS_src_type :: GBS_FLAGS_src_type also contains flags resulting from MODE, OPT, DEBUGGER and MAP :: GBS_SYSINCS_src_type :: GBS_INCS_src_type :: :: GBS_MAKE_FLAGS '-i' if GBS_IGNORE_ERRORS == TRUE :: ::============================================================================= setlocal set rc=0 set action=%1 :: :: Adjust for proper actions :: Just one to a few lines per action. Keep it simple. Do not try to be clever. :: Do not forget to set rc to proper exit value (0=success, >0=fail) :: if [%action%] == [cleanup_bld] goto CASE_CLEANUP_BLD if [%action%] == [gen] goto CASE_GEN if [%action%] == [make] goto CASE_MAKE if [%action%] == [cleanup_aud] goto CASE_CLEANUP_AUD if [%action%] == [audit] goto CASE_AUDIT goto CASE_DEFAULT :: :: CLEANUP_BLD :: :CASE_CLEANUP_BLD echo SUBSYS.GBS_: ** SubSys=%GBS_SUBSYS% - Build=%GBS_BUILD% - Action=%action% :: <== add your command(s) to execute the bld_cleanup here and remove these lines. :: Do not forget to set rc to proper exit value (0=success, >0=fail) :: <== Probably something like: %GBS_MAKE% clean -f Makefile.mk -i set rc=%ERRORLEVEL% goto CASE_END :CASE_GEN :: :: GEN :: echo SUBSYS.GBS_: ** SubSys=%GBS_SUBSYS% - Build=%GBS_BUILD% - Action=%action% :: <== add your command(s) to execute the gen here and remove these lines. :: Do not execute the 'clean' in this command. :: Do not forget to set rc to proper exit value (0=success, >0=fail) :: <== Probably something like: %GBS_MAKE% -f Makefile.mk -B -k %GBS_MAKE_FLAGS% set rc=%ERRORLEVEL% goto CASE_END :CASE_MAKE :: :: MAKE :: echo SUBSYS.GBS_: ** SubSys=%GBS_SUBSYS% - Build=%GBS_BUILD% - Action=%action% :: <== add your command(s) to execute the make here and remove these lines. :: Do not forget to set rc to proper exit value (0=success, >0=fail) :: <== Probably something like: %GBS_MAKE% -f Makefile.mk %GBS_MAKE_FLAGS% set rc=%ERRORLEVEL% goto CASE_END :CASE_CLEANUP_AUD :: :: CLEANUP_AUD :: echo SUBSYS.GBS_: ** SubSys=%GBS_SUBSYS% - Build=%GBS_BUILD% - Audit=%GBS_AUDIT% - Action=%action% :: <== add your command(s) to execute the audit_cleanup here and remove these lines. :: Do not forget to set rc to proper exit value (0=success, >0=fail) :: <== Probably something like: %GBS_MAKE% clean -f Makefile_aud.mk -i set rc=%ERRORLEVEL% goto CASE_END :CASE_AUDIT :: :: AUDIT :: echo SUBSYS.GBS_: ** SubSys=%GBS_SUBSYS% - Build=%GBS_BUILD% - Audit=%GBS_AUDIT% - Action=%action% :: <== add your command(s) to execute the gbssubaudit.bat here and :: remove these lines. :: Do not forget to set rc to proper exit value (0=success, >0=fail) :: <== Probably something like: :: %GBS_MAKE% -f Makefile_aud.mk -B -k %GBS_MAKE_FLAGS% echo SUBSYS.GBS_: No audits for non-GBS SubSystems set rc=%ERRORLEVEL% goto CASE_END :CASE_DEFAULT :: :: DEFAULT :: echo SUBSYS.GBS_: ***FATAL ERROR*** echo - Invalid action '%action%'. Must be one of (cleaunp_bld gen make cleanup_aud audit) set rc=9 goto CASE_END :CASE_END endlocal & set rc=%rc% exit /B %rc% :::EOF::: |
ContentsDescriptionExample of a incs_*.gbs DescriptionPurposeThe incs_type.gbs files are used to extend the search paths for builders beyond the Components.
The incs_type.gbs files may be placed in the following locations:
GeneralPlease refer to .gbs files: General informationAdditional for this file:
Contents:Syntax:One directory per line.Notes:NoneExample of a incs_*.gbs:#======================================================== # [superglo]INCS_C.GBS #======================================================== $GBSEXT_DMF_PATH/include $GBSEXT_MARAP_PATH/inc ###EOF### |
ContentsDescriptionExample of a owners.gbs DescriptionPurposeThe owners.gbs file is located in the GBS_SYS_PATH directory is used to maintains 'owners' of SubSystems
and Components. It has a specific internal structure and editing of the file is done via gbsmaint 9: 'Owners-file' Maintenance Notes:Example of a owners.gbs:
* UserId Email Phone Owner-Name + uida1179 Paul.Lieverse@siemens.com +31-40-1234567 Paul Lieverse + uida1393 Leon.Bouwmeester@SiemensVDO.com +31-40-1234567 Leon Bouwmeester + uida1473 Datta.Inamdar@siemensvdo.com +31-40-1234567 Datta Inamdar + uida1641 Marcel.vanderVelden@siemensvdo.com +31-40-1234567 Marcel van der Velden + uida1667 Reinier.Kleefman@siemensvdo.com +31-40-1234567 Reinier Kleefman + uida1685 Martin.Smits.ext@siemens.com +31-40-1234567 Martin Smits * * SubSystem Component UserId = booter drv_flash uida1641 = booter - uida1641 = booter booter uida1641 = booter i_infolog uida1641 = main - uida1667 = main c_trusted_device_database uida1667 = main test_trace_mgr uida1685 = main most_fb_bluetooth_gateway uida1667 = main drv_iis uida1641 = main i_tracer uida1641 = main i_infolog uida1641 = main test_booter uida1641 = main c_phonebook_manager uida1667 = main a_ec_nr uida1179 = main zzz_comp2 uida1685 = main appl_p2er5 uida1685 = main a_mediarecorder uida1179 = main test_src uida1179 = main a_audiorouter uida1179 = main test_logger uida1641 = main c_bluetooth_phone uida1667 = main hal uida1641 = main base uida1393 = main i_logger uida1641 = main a_speechrecognition_lib uida1179 = main i_xtp uida1641 = main most_fb_speechrecognition uida1179 = main most_fb_linkcontrol uida1179 = main i_rtp uida1641 = main drv_sport uida1641 = main c_bluetooth_transfer_manager uida1667 = main test_autotests uida1473 = main test_most_stack uida1641 = main bsp_bf532dev uida1641 = main i_lifesign uida1641 = main a_speechrecognition uida1179 = main a_ec_nr_lib uida1179 = main i_ffs uida1641 = main h_flash_mgr uida1473 = main a_mediaplayer uida1179 = main most_fb_lifecycle uida1641 = main dq_mgr uida1641 = main zzz_comp1 uida1685 |
ContentsDescriptionExample of a sca_*.gbs DescriptionPurposeThe sca_*.gbs files are used to define the behaviour of SCA Audits.
The sca_*.gbs files can be placed in the following locations:
If not found it is searched in the SYSAUDIT directory GeneralPlease refer to .gbs files: General informationAdditional for this file:
Contents:Syntax:
The file is basically a 'flags' file. Flags are switched on and off by placing a '+' or '-' in front One flag per line Possible flags are: E F Q T Only the E flag can be disabled all others must be preceded by a '+' Semantics:
Notes:NoneExample of a sca_*.gbs:#======================================================== # [SYSAUDIT:pclint[mingw]] sca_mingw.gbs #======================================================== .include sca_ALL.gbs ###EOF###and... #======================================================== # [SYSAUDIT:pclint[ALL]] sca_ALL.gbs #======================================================== -E ALL +E 1* 2* 3* # Enable all messages starting with 1 2 or 3 +E 537 # Repeated include file name -E 1042 # At least one class-like operand is required with operator |
ContentsDescriptionExample of a scope.gbs DescriptionPurposeThe scope.gbs files are located in the GBS_COMPONENT_PATH directories and are used to specify which Components are in scope. GeneralPlease refer to .gbs files: General informationAdditional for this file:
Contents:Syntax:component_name [ build-line-selection ]Semantics:
Notes:NoneExample of a scope.gbs:#======================================================== # [OMS::test_no_unix:main]SCOPE.GBS #======================================================== superglo test_all = gnu ###EOF### |
ContentsDescriptionExample of a site.gbs.bat DescriptionPurposeThis file can be used instead of the 'Site' section in the switch.gbs(.bat/.sh) files.As the Site section in all your switch.gbs(.bat/.sh) files contains the locations of all your plugins on your computer - hence contains the same info -, we can have the definitions in one central place - not inside a System. The site.gbs script file is located in your $GBS_BASE_PATH directory and it is called by swr before the switch.gbs script file with entry parameter. To edit the file: gbsedit site.gbs Notes:Please note the following:
Example of a site.gbs.bat:Example of a site.gbs.bat:@ECHO OFF ::================================================ :: File: %FILE% :: Path: %PATH% ::================================================ echo GBSSITE_: Setup GBS Development environment *** :: :: The following settings define where the roots of your plugins are located on this PC :: This file is called before the switch.gbs.bat :: When you use this file there is no need for the 'ROOT' or 'SITE' section in the switch.gbs.bat file :: Only GBSEXT_*_ROOT EnvVars in this file! :: :: :: 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 :: :: My Settings :: :: Place your stuff here... ::: EOF ::: Example of a site.gbs.sh:#!must_be_sourced #================================================= # File: %FILE% # Path: %PATH% #================================================= echo "GBSSITE_: Setup GBS Development environment ***" # # The following settings define where the roots of your plugins are located on this PC # This file is called before the switch.gbs.sh # When you use this file there is no need for the 'ROOT' or 'SITE' section in the switch.gbs.sh file # Only GBSEXT_*_ROOT EnvVars in this file! # # # Version Control # #export GBSEXT_GIT_ROOT=/usr/lib/git-core #export GBSEXT_SVN_ROOT=/usr/lib/svn # # 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 # # # My Settings # # Place your stuff here... ### EOF ### |
ContentsDescriptionExample of a steps.gbs DescriptionPurposeThe steps.gbs file is located in the GBS_SYS_PATH directory is used to define the
order in which SubSystems are built or audited, Commands are executed or Tools are run. Non-SubSystem steps, called 'Commands' allow you to execute commands to e.g.: Tools run on the whole GBS tree and are not dependent on Audit or Build. E.g.: Doxygen, etc. GeneralPlease refer to .gbs files: General informationAdditional for this file:
DefinitionsSTEP ALIASSTEP-definitionPurpose:To define the order in which SubSystems must be generated Syntax:
Semantics:The order in which the STEP definitions appear specifies the order in which the steps must be executed. Cyclic references are not possible.
ALIAS-definitionPurpose:To group step_names and optionally associate a BuildSyntax:
Semantics
Notes:NoneExample of a steps.gbs:# # STEPS.GBS # # # STEPS # STEP begin COMMAND = @begin AUDIT = NO STEP superglo STEP bart STEP non_gbs STEP visualstudio STEP copy_export COMMAND = >copy_export/bin/copy_export.pl superglo $GBS_BUILD $GBSEXT_GBSSHARE/$GBS_BUILD AUDIT = NO STEP prqa EXEC = SPECIFY STEP doxygen TOOL = >doxygen/bin/doxygen.pl full BUILD = NO AUDIT = NO STEP doxygen_api TOOL = >doxygen/bin/doxygen.pl api EXEC = SPECIFY BUILD = NO AUDIT = NO # # ALIASES # ALIAS SUBSET STEPS = superglo bart ALIAS PRQA STEPS = prqa ALIAS FULL STEPS = superglo bart prqa ALIAS ALL STEPS = begin - doxygen_api ALIAS LGCC BUILD = lgcc ALIAS MINGW BUILD = mingw ##EOF## |
ContentsDescriptionPurpose| General| Calling| Environment Variables| Additional Available Environment Variables| Special Environment Variables| Layout| Notes
Example of a switch.gbs.batDescriptionPurposeThe 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.
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 GeneralSpecial considerations:
CallingThe switch.gbs file is called:
Environment VariablesEnvironment 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 VariablesThese are defined before execution of the switch.gbs file and can be used to control additional settings.They may never be changed!
Special Environment VariablesYou can specify 'special' EnvVars that give extra control the execution of gbsaudit, gbsbuild and gbsmake.These are:
LayoutThe file consists of two mayor parts:
EntryThis part is executed when you 'enter' a System (make it current)It consists of 2 Sections The ROOT sectionThis 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 sectionThis Section is where you set the GBSEXT_..._RELAnd 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. ExitThis part is executed when you 'exit' a System (un-current it)Notes:Please note the following:
Example of a switch.gbs.bat:Example of a switch.gbs.bat:@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:#!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## |
ContentsDescriptionExample of a system.gbs DescriptionPurposeThe system.gbs file is located in the GBS_SYSTEM_PATH directory is used to define primary settings for a System. It is a very delicate file and any manual modifications should be left to a GBS specialist. Notes:Example of a system.gbs:# # SYSTEM.GBS # id=system system_name=SuperGlo root_version=2.04 build_start=202061212 build_end= scms-MSWin32=SubVersioN scms-linux=No_SCMS scms_data=trunk scms_repository-linux= scms_repository-MSWin32=svn://vhvfsnt10/SuperGlo builds-MSWin32=dos builds-MSWin32=dosd builds-MSWin32=mingw builds-MSWin32=mingwd builds-MSWin32=mvs builds-MSWin32=mvsd builds-linux=lgcc ###EOF### |
ContentsDescriptionPurpose| General| Contents| SETUP Definition| DEFAULTS definition| INIT definition| RUN Definition| Notes
Example of a tool.gbsFile 1 (Basic reference - implicit default)| File 2 (Basic reference - explicit default)| File 3 (Full specification)
DescriptionPurposeThe tool.gbs files are located in the GBS_SYSTOOLS_PATH/tool directories and are used to define the particularities of a Tool. GeneralPlease refer to .gbs files: General informationAdditional for this file:
ContentsSETUP definitionDEFAULTS definition INIT definition RUN definition SETUP DefinitionPurpose:To define general stuff, valid for the whole definition set. Syntax:
Semantics:
DEFAULTS definitionPurpose:To set Tool dependent defaults, overriding the GBS defaults Syntax:
Semantics:Refer to RUN semantics below.INIT definitionPurpose:To perform general initialisation. Syntax:
Semantics:
RUN DefinitionPurpose:To provide information on how to run the Tool program (executable or script) Syntax:
Semantics:
Notes:NoneExample of a tool.gbs:File 1 (Basic reference - implicit default)#======================================================== # doxygen_api [doxygen] tool.gbs #======================================================== .plugin doxygen .include <tool.gbs> ###EOF### File 2 (Basic reference - explicit default)#======================================================== # [doxygen] tool.gbs #======================================================== .plugin doxygen .include <tool.gbs> DEFAULTS ACTION = FULL ###EOF### File 3 (Full specification)#======================================================== # %TOOL% [doxygen] tool.gbs #======================================================== SETUP NICE_NAME = DoxyGen INIT BIN_DIR = bin RUN ACTION = API => api ACTION = FULL => full COMMAND = >doxygen/bin/doxygen.pl %1 %2 %3 %4 ##EOF## |
ContentsDescriptionDescriptionThis section describes some basic development aspects of GBS.Choice of LanguageGBS is written in Perl.I needed a language that will execute exactly the same on various computers (at that time Windows and UNIX), without being depended on installed libraries. When I started developing GBS in 2001 the best choice was Perl. Should I start developing now I would probably chose Python. Quality AssuranceperlcriticRunning perlcritic yields the following results for this version:---- 335 files. 5,603 subroutines/methods. 80,795 statements. 139,611 lines, consisting of: 15,423 blank lines. 36,049 comment lines. 68 data lines. 85,725 lines of Perl code. 2,346 lines of POD. Average McCabe score of subroutines was 3.25. 0 violations. Violations per file was 0.000. Violations per statement was 0.000. Violations per line of code was 0.000. ---- I do use function prototypes, but only with $ and @. Never with \. ChecksSome proprietary programs (perlxref and perlcheck) are used to detect:
HelpCommand help (--help) and Help File All Commands are created directly from the code so there is no mismatch.Design Considerations
|
ContentsHistory1985 Pre-GBS at Philips Medical Systems| 2001 Start GBS at Origin / Atos Origin| 2008 GBS at Task24 / Nspyre| 2011 GBS at Randy Marques Consultancy| 2021 GBS Open Source at SourceForge
About Randy MarquesHistoryGBS was conceived, designed and developed by Randy Marques from Eindhoven, The Netherlands.1985 Pre-GBS at Philips Medical SystemsGBS is based on experiences with 'CCS', the Code Control System developed at Philips Medical Systems, Best, Netherlands in 1985. Designed and developed by Randy Marques.Used for over 15 years by a variety of small and large projects and still in use for maintenance projects It was written for VAX/VMS in DCL. 2001 Start GBS at Origin / Atos OriginGBS development started in 2001 on WinXp and later on UnixWritten mainly in Perl to ensure exact same functionality on all platforms. Only dependent on Perl. No special privileges required. Same concept, modern technology. 2008 GBS at Task24 / NspyreAvailable for Windows 7 Unix and Linux.'Consultancy-ware' Experimental GUI 2011 GBS at Randy Marques ConsultancyAvailable for Windows 10, WSL and Linux.'Consultancy-ware' Improved User-Interface (Almost) full functioning GUI 2021 GBS Open Source at SourceForgeAbout Randy MarquesLiving in Eindhoven - The Netherlands, from Curaçao - South Caribbean
|
ContentsMetrics OverviewFunction-Based Metrics File-Based Metrics Class-Based Metrics Project-Wide Metrics General Metrics OverviewThe Calculation of MetricsQAC calculates metrics in three groups. QAC++ calculates metrics in three groups. All metrics, except LIN and TPP, ignore code that is disabled on
evaluation of pre-processor directives. For example: #define A 10 #if 0 #include <stdio.h> /* Ignored by all except LIN, TPP */ int i; /* Ignored by all except LIN, TPP */ #else long i; #endif Function-Based Metrics OverviewThese metrics are all calculated for the source code of an individual function. Some metrics are used in the definition of others, but there is no obvious sequence. They are described here in alphabetical order, for ease of reference. The complete list is as follows:
File-Based Metrics OverviewThese metrics are all calculated for the source code in a complete translation unit (TU). They are listed alphabetically here for convenience. They are not calculated in this sequence. because of their derivation from each other:
Class-Based Metrics OverviewThese metrics are calculated for the classes in your source code. To calculate some of these metrics you must also have run the relevant cross-module analysis program. See Cross-Module Analysis in Chapter 4: Analysing Source Code. Class-based metrics are described here in alphabetical order for ease of reference:
Project-Wide Metrics OverviewThese metrics are calculated once per complete project. The complete list is as follows:
Function-Based MetricsAKI - Akiyama's CriterionFunction-Based Metric This metric is the sum of the Cyclomatic complexity (CYC) and the number of function calls (SUB). Although this is not an independent metric, it is included on account of its use in documented case histories. See Akiyama[1] and Shooman[2] for more details. The metric is calculated as: [1] Akiyama, F. (1971) An Example of Software System Debugging, Proc. IFIP Congress 1971, Lbujlana, Yugoslavia, American Federation of information Processing Societies, Montvale, New Jersey. [2] Shooman, M.L. (1983) Software Engineering, McGraw-Hill, Singapore. AV1 - Average Size of Statement in FunctionAV2 - Average Size of Statement in FunctionAV3 - Average Size of Statement in FunctionAVx - Average Size of Statement in FunctionFunction-Based Metrics These metrics (AV1, AV2, and AV3) measure the average number of operands and operators per statement in the body of the function. They are calculated using Halstead's[1] calculations as follows: AVx = (N1 + N2) / number of statements in the function where: The AVx metrics are computed using ST1, ST2 and ST3 to represent the number of statements in a function. Hence there are three variants: AV1, AV2 and AV3 relating to the respective statement count metrics. This metric is used to detect components with long statements. Statements comprising a large number of textual elements (operators and operands) require more effort by the reader in order to understand them. This metric is a good indicator of the program's readability. Metric values are computed as follows: AV1 = (FN1 + FN2) / ST1 [1] Halstead, Maurice H. (1977). Elements of Software Science. BAK - Number of Backward JumpsFunction-Based Metric Jumps are never recommended and backward jumps are particularly undesirable. If possible, the code should be redesigned to use structured control constructs such as while or for instead of goto. Examplemain() { Backward: switch (n) { case 0: printf( stdout, "zero\n"); break; case 1: printf( stdout, "one\n"); goto Backward; /* 1 */ break; case 2: printf( stdout, "two\n"); break; default: printf( stdout, "many\n"); break; } } The above code sample has a BAK value of 1. CAL - Number of Functions Called from FunctionFunction-Based Metric This metric counts the number of function calls in a function. It differs from the metric SUB, in that only distinct functions are counted (multiple instances of calls to a particular function are counted as one call), and also that functions called via pointers are not counted. CYC - Cyclomatic ComplexityFunction-Based Metric Cyclomatic complexity is calculated as the number of decisions plus 1. High cyclomatic complexity indicates inadequate modularization or too much logic in one function. Software metric research has indicated that functions with a cyclomatic complexity greater than 10 tend to have problems related to their complexity. McCabe[1] gives an essential discussion of this issue as well as introducing the metric. Example 1int divide( int x, int y) { if (y != 0) /* 1 */ { return x / y; } else if (x == 0) /* 2 */ { return 1; } else { printf( "div by zero\n"); return 0; } } The above code sample has a cyclomatic complexity of 3 as there are two decisions made by the function. Note that correctly-indented code does not always reflect the nesting structure of the code. In particular, the use of the construct 'else if' always increases the level of nesting, but it is conventionally written without additional indentation and so the nesting is not visually apparent. Example 2void how_many(int n) { switch (n) { case 0: printf( "zero"); /* 1 */ break; case 1: printf( "one"); /* 2 */ break; case 2: printf( "two"); /* 3 */ break; default: printf( "many"); break; } } The above code sample has a cyclomatic complexity of 4, as a switch statement is equivalent to a series of decisions. Some metrication tools include use of the ternary operator ? : when calculating cyclomatic complexity. It could also be argued that use of the && and || operators should be included. Instead, CYC calculation is based on statements alone. CYC is one of the three standard metrics used by QAC for demographic analysis. [1] McCabe, T. J. (1976) A Complexity Measure, IEEE Transactions on Software Engineering, SE-2, pp. 308-320. ELF - Number of Dangling Else-IfsFunction-Based Metric This is the number of if-else-if constructs that do not end in an else clause. This metric is calculated by counting all if statements that do not have a corresponding else and for which QAC issues a warning 2004. ELF provides a quick reference allowing monitoring of these warnings. The code sample below has an ELF value of 1. Exampleint divide(int x, int y) { if (y != 0) { return x/y; } else if (x == 0) { return 1; } } FN1 - Number of Operator Occurrences in FunctionFunction-Based Metric This metric is Halstead's[1] operator count on a function basis (N1). FN1 is related to OPT and M21: all of these metrics count 'operators', the difference is summarized as:
See OPT for the definition of an operator. [1] Halstead, Maurice H. (1977). Elements of Software Science. FN2 - Number of Operand Occurrences in FunctionFunction-Based Metric This metric is Halstead's[1] operand count on a function basis (N2). FN2 is related to OPN and M20: all of these metrics count 'operands', the difference is summarized as:
See OPN for the definition of an operand. [1] Halstead, Maurice H. (1977). Elements of Software Science. GTO - Number of Goto statementsFunction-Based Metric Some occurrences of goto simplify error handling. However, they should be avoided whenever possible. According to the Plum Hall Guidelines, goto should not be used. HLB - Number of Halstead's delivered bugs (B)Function-Based Metric The metric is an estimate for the number of errors in the implementation.
Function Volume V = N * log2(n)
N - the number of all operators and operands within function n - the number of distinct operators and operands within function Exampleint foo( int i) /* Violation: B = 0.09 */ { int a; int b; a = i + (2 * (i + 1)) + (3 * (i + 2)); b = (i + (2 * (i + 1)) + (3 * (i + 2))) * 2; if (i >= 3) return a; if (i >= 2) return b; } [1] Halstead, Maurice H. (1977). Elements of Software Science. KDN - Knot DensityFunction-Based Metric This is the number of knots per executable line of code. The metric is calculated as: The value is computed as zero when XLN is zero. KNT - Knot CountFunction-Based Metric This is the number of knots in a function. A knot is a crossing of control structures, caused by an explicit jump out of a control structure either by break, continue, goto, or return. KNT is undefined for functions with unreachable code. This metric measures knots, not by counting control structure crossings, but by counting the following keywords:
The function below has an KNT value of 1. Examplevoid fn( int n, int array[], int key ) { while ( array[ n ] != key ) { if ( array[ n ] == 999 ) { break; } else { ++n; } } } LCT - Number of Local Variables DeclaredFunction-Based Metric This is the number of local variables of storage class auto, register, or static declared in a function. These are variables that have no linkage. The function below has an LCT value of 2. Exampleint other_result; extern int result; int test() { int x; /* 1 */ int y; /* 2 */ return (x + y + other_result); } LIN - Number of Code LinesFunction-Based Metric This is the total number of lines, including blank and comment lines, in a function definition between (but excluding) the opening and closing brace of the function body. It is computed on raw code. LIN is undefined for functions which have #include'd code or macros which include braces in their definition. The function below has an LIN value of 5. Exampleint fn() { int x; /* 1 */ int y; /* 2 */ /* 3 */ return (x + y); /* 4 */ /* Comment Here */ /* 5 */ } Long functions are difficult to read, as they do not fit on one screen or one listing page. An upper limit of 200 is recommended. LOP - Number of Logical OperatorsFunction-Based Metric This is the total number of logical operators (&&, ||) in the conditions of do-while, for, if, switch, or while statements in a function. The example function below has a LOP value of 2. Examplevoid fn( int n, int array[], int key ) { while (( array[n] != key ) && ( n > 0 )) { if (( array[n] == 999) || ( array[n] == 1000 )) { break; } else { ++n; } } } M07 - Essential Cyclomatic ComplexityFunction-Based Metric The essential cyclomatic complexity is obtained in the same way as the cyclomatic complexity but is based on a 'reduced' control flow graph. The purpose of reducing a graph is to check that the component complies with the rules of structured programming. A control graph that can be reduced to a graph whose cyclomatic complexity is 1 is said to be structured. Otherwise reduction will show elements of the control graph which do not comply with the rules of structured programming. The principle of control graph reduction is to simplify the most deeply nested control subgraphs into a single reduced subgraph. A subgraph is a sequence of nodes on the control flow graph which has only one entry and exit point. Four cases are identified by McCabe[1] which result in an unstructured control graph. These are:
However, if a subgraph possesses multiple entry or exit points then it cannot be reduced. The use of multiple entry and exit points breaks the most fundamental rule of structured programming. The example below has a M07 value of 4. Examplevoid g( int n, int pos, int force ) /* M07 = 4 Cannot reduce control graph to Cyclomatic Complexity of 1 */ { int nlines = 0; while ( --n >= 0 ) { pos = back_line( pos ); if ( pos == 0 ) { if ( ! force ) { break; } ++nlines; } } } [1] McCabe, T. J. (1976) A Complexity Measure, IEEE Transactions on Software Engineering, SE-2, pp. 308-320. M19 - Number of Exit PointsFunction-Based Metric This metric is a measure of the number of exit points in a software component and is calculated by counting the number of return statements. A function that has no return statements will have an M19 value of zero even though it will exit when falling through the last statement. This is regardless of whether the function is declared to have a return value or not (i.e. returns void). Calls to non-returning functions such as exit() or abort() are ignored by this metric. The example below has an M19 value of 3. Examplevoid f( int a ) { return; /* 1 */ if ( a ) return; /* 2 */ a++; return; /* 3 */ } M29 - Number of Functions Calling this FunctionFunction-Based Metric This metric is defined as the number of functions calling the designated function. The number of calls to a function is an indicator of criticality. The more a function is called, the more critical it is and, therefore, the more reliable it should be. MCC - Myer's IntervalFunction-Based Metric This is an extension to the cyclomatic complexity metric. It is expressed as a pair of numbers, conventionally separated by a colon. Myer's Interval is defined as CYC : CYC + L Cyclomatic complexity (CYC) is a measure of the number of decisions in the control flow of a function. L is the value of the QAC LOP metric which is a measure of the number of logical operators (&&, ||) in the conditional expressions of a function. A high value of L indicates that there are many compound decisions, which makes the code more difficult to understand. A Myer's interval of 10 is considered very high. The example below has a MCC value of 3:4 because the cyclomatic complexity is 3 and there is one connective (&&) used in the conditions. Exampleint divide( int x, int y) { if (y != 0) /* Condition 1 */ { return x / y; } else if (x == 0 && y > 2) /* Condition 2 */ /* Conditional expr 1 */ { return 1; } else { printf( "div by zero\n"); return 0; } } Note: In the calculation of MCC, the ternary operator (?:) is ignored. When exporting metric values or displaying in the Metrics Browser, rather than attempting to display a value pair, the value of L is chosen for MCC. MIF - Deepest Level of NestingFunction-Based Metric This metric is a measure of the maximum control flow nesting in your source code. You can reduce the value of this metric by turning your nesting into separate functions. This will improve the readability of the code by reducing both the nesting and the average cyclomatic complexity per function. The code example below has an MIF value of 3. Exampleint divide( int x, int y) { if (y != 0) /* 1 */ { return (x/y); } else if (x == 0) /* 2 */ { return 1; } else { printf( "Divide by zero\n"); while (x > 1) /* 3 */ printf( "x = %i", x); return 0; } } MIF is incremented in switch, do, while, if and for statements. The nesting level of code is not always visually apparent from the indentation of the code. In particular, an else if construct increases the level of nesting in the control flow structure but is conventionally written without additional indentation. MIF is one of the three standard metrics used by QAC for demographic analysis. PAR - Number of Function ParametersFunction-Based Metric This metric counts the number of declared parameters in the function argument list. Note that ellipsis parameters are ignored. PBG - Residual Bugs (PTH-based est.)Function-Based Metric Hopkins, in Hatton & Hopkins[1] investigated software with a known audit history and observed a correlation between Static Path Count (PTH) and the number of bugs that had been found. This relationship is expressed as PBG. PBG = log10 ( PTH ) [1] Hatton, L., Hopkins, T.R., (1989) Experiences With Flint, a Software Metrication Tool for Fortran 77, Symposium on Software Tools, Napier Polytechnic, Edinburgh, Scotland. PDN - Path DensityFunction-Based Metric This is a measure of the number of paths relative to the number of executable lines of code. PDN = PTH / XLN PTH - Estimated Static Program PathsFunction-Based Metric This is similar to Nejmeh's[1] NPATH statistic and gives an upper bound on the number of possible paths in the control flow of a function. It is the number of non-cyclic execution paths in a function. The NPATH value for a sequence of statements at the same nesting level is the product of the NPATH values for each statement and for the nested structures. NPATH is the product of:
Note: else and default are counted whether they are present or not. In switch statements, multiple case options on the same branch of the switch statement body are counted once for each independent branch only. For example: Exampleswitch( n ) { case 0: break; /* NPATH of this branch is 1 */ case 1: case 2: break; /* NPATH for case 1 & case 2 combined is 1 */ default: break; /* NPATH for this default is 1 */ } Since NPATH cannot be reliably computed if there are goto statements in the function, they are ignored by QAC for the purposes of calculating NPATH. The following code example has a static path count of 26. Exampleint n; if ( n ) { } /* block 1, paths 1 */ else if ( n ) { if ( n ) { } /* block 2, paths 1 */ else { } /* block 3, paths 1 */ /* block 4, paths block2+block3 = 2 */ switch ( n ) { case 1 : break; case 2 : break; case 3 : break; case 4 : break; default: break; } /* block 5, paths = 5 */ } /* block 6, paths block4*block5 = 10 */ else { if ( n ) { } /* block 7, paths 1 */ else { } /* block 8, paths 1 */ } /* block 9, paths block7+block8 = 2 */ /* block 10, paths block1+block6+block9 = 13 */ if ( n ) { } /* block 11, paths 1 */ else { } /* block 12, paths 1 */ /* block 13, paths block11+block12 = 2 */ /* outer block, paths block10*block13 = 26 */ Each condition is treated as disjoint. In other words, no conclusions are drawn about a condition that is tested more than once. The true path count through a function usually obeys the inequality: cyclomatic complexity <= true path count <= static path count Static path count is one of the three standard metrics used by QAC for demographic analysis. [1] Nejmeh, B.A. (1988), NPATH: A Measure of Execution Path Complexity and its Applications, Comm ACM, 31, (2), p. 188-200. RET - Number of Return Points in FunctionFunction-Based Metric RET is the count of the reachable return statements in the function, plus one if there exists a reachable implicit return at the } that terminates the function. The following example shows an implicit return: Examplevoid foo( int x, int y ) { printf( "x=%d, y=%d\n", x, y ); /* Here with implicit return. Hence RET = 1*/ } Structured Programming requires that every function should have exactly one entry and one exit. This is indicated by a RET value of 1. RET is useful when the programmer wants to concentrate on the functions that do not follow the Structured Programming paradigm. For example, those with switch statements with returns in many or every branch. ST1 - Number of Statements in FunctionST2 - Number of Statements in FunctionST3 - Number of Statements in FunctionSTx - Number of Statements in FunctionFunction-Based Metrics These metrics count the number of statements in the function body. There are 3 variants on the metric: ST1 is the base definition and counts all statements tabulated below. The following chart shows the statements counted by the STST metrics:
The following example shows statements counted by ST1, which for this function yields a value of 10: Examplevoid stst( void ) { int i; /* 1 */ label_1: /* 2 */ label_2: /* 3 */ switch ( 1 ) /* 4 */ { /* 5 */ case 0: /* 6 */ case 1: /* 7 */ case 2: /* 8 */ default: /* 9 */ break; /* 10 */ } } This metric indicates the maintainability of the function. Number of statements also correlates with most of the metrics defined by Halstead. The greater the number of statements contained in a function, the greater the number of operands and operators, and hence the greater the effort required to understand the function. Functions with high statement counts should be limited. Restructuring into smaller sub-functions is often appropriate. SUB - Number of Function CallsFunction-Based Metric The number of function calls within a function. Functions with a large number of function calls are more difficult to understand because their functionality is spread across several components. Note that the calculation of SUB is based on the number of function calls and not the number of distinct functions that are called, see CAL. A large SUB value may be an indication of poor design; for example, a calling tree that spreads too
rapidly. The following code example has an SUB value of 4. Exampleextern dothis(int); extern dothat(int); extern dotheother(int); void test() { int a, b; a = 1; b = 0; if (a == 1) { dothis(a); /* 1 */ } else { dothat(a); /* 2 */ } if (b == 1) { dothis(b); /* 3 */ } else { dotheother(b); /* 4 */ } } [1] Brandl, D.L. (1990), Quality Measures in Design, ACM Sigsoft Software Engineering Notes, vol 15, 1.
[x] Halstead, Maurice H. (1977). Elements of Software Science. UNR - Number of Unreachable StatementsFunction-Based Metric This metric is the count of all statements within the function body that are guaranteed never to be executed. UNR uses the same method for identifying statements as metric ST1. Hence UNR counts the following as statements if unreachable.
Statement Kind Counted
block simple statement followed by ; empty statement declaration statement label break continue do for goto if return switch while Example yielding UNR = 4 Examplevoid stunr( unsigned i ) { if ( i >= 0 ) { if ( i >= 0 ) { while ( i >= 0 ) return; } else /* unreachable */ { while ( i >= 0 ) return; } } return; /* unreachable */ } UNV - Unused or Non-Reused VariablesFunction-Based Metric An unused variable is one that has been defined but which is never referenced. A non-reused variable is a variable that has a value by assignment but which is never used subsequently. Such variables are generally clutter and are often evidence of 'software ageing', which is the effect of a number of programmers making changes. The code below has an UNV value of 2. Exampleint other_result; extern int result; int test() { int y; /* Unused */ int z; z = 1; /* Non-Reused */ return (result + other_result); } XLN - Number of Executable LinesFunction-Based Metric This is a count of lines in a function body that have code tokens. Comments, braces, and all tokens of declarations are not treated as code tokens. The function below has an XLN value of 9. Examplevoid fn( int n ) { int x; int y; if ( x ) /* 1 */ { x++; /* 2 */ for (;;) /* 3 */ /* Ignore comments */ /* Ignore braces */ { switch ( n ) /* 4 */ { case 1 : break; /* 5 */ case 2 : /* 6 */ case 3 : /* 7 */ break /* 8 */ ; /* 9 */ } } } } This metric is used in the computation of the KDN and PDN metrics.
File-Based MetricsBMO - Organic Programmer MonthsBMS - Semi-detached Programmer MonthsBME - Embedded Programmer MonthsFile-Based Metrics The COCOMO metrics are produced for each source code file. You can display an estimate of development costs for a whole project by choosing the COCOMO Cost Model option from the Reports menu. See Chapter 6: Reports for a discussion of the COCOMO cost model and an explanation of the three programming modes: Organic, Semi-detached, and Embedded. These metrics estimate the number of programmer-months required to create the source code in the respective environments. BME = 3.6 * ( TPP / 1000 ) 1.20 BUG - Residual Bugs (token-based estimate)File-Based Metric BUG = 0.001 * EFF2/3 This is an estimate of the number of bugs in the file, based on the number of estimated tokens. Its value would normally be lower than the sum of the function-based PBG values. For a more detailed discussion of software bug estimates, see Hatton and Hopkins,[1]. [1] Hatton, L., Hopkins, T.R., (1989) Experiences With Flint, a Software Metrication Tool for Fortran 77, Symposium on Software Tools, Napier Polytechnic, Edinburgh, Scotland. CDN - Comment to Code RatioFunction-Based Metric This metric is defined to be the number of visible characters in comments, divided by the number of visible characters outside comments. Comment delimiters are ignored. Whitespace characters in strings are treated as visible characters. A large value of CDN indicates that there may be too many comments, which can make a module difficult to read. A small value indicates that there may not be enough comments, which can make a module difficult to understand. The code below has 28 visible characters in comments and 33 visible characters in the code. The resulting CDN value is 0.85. Exampleint test() /* This is a test */ { int x; int y; /* This is another test */ return (x + y); } The value of CDN is affected by how QAC counts the comments. QAC can count comments in three possible ways:
DEV - Estimated Development (programmer-days)Function-Based Metric This is an estimate of the number of programmer days required to develop the source file. Unlike COCOMO statistics, which are based solely on the number of lines of code, this estimate is derived from the file's difficulty factor. It is a more accurate measure of the development time, especially after the scaling factor has been adjusted for a particular software environment. DEV = EFF / dev_scaling where dev_scaling is a scaling factor defined in qac.cfg. The default is 6000. DIF - Program DifficultyFunction-Based Metric This is a measure of the difficulty of a translation unit. An average C program has a difficulty of around 12. Anything significantly above this has a rich vocabulary and is potentially difficult to understand. DIF = VOL / ( (2 + VAR) * log2 (2 + VAR) ) ECT - Number of External Variables DeclaredFunction-Based Metric This is a measure of the number of data objects (not including functions) declared with external linkage. It is an indication of the amount of global data being passed between modules. It is always desirable to reduce dependence on global data to a minimum. Exampleextern int result; int other_result; main() { result = 20 + 30; other_result = result * 2; } The above code sample has an ECT value of 2. EFF - Programmer EffortFunction-Based Metric This metric is a measure of the programmer effort involved in the production of a translation unit. It is used to produce a development time estimate. FNC - Number of Functions in FileFunction-Based Metric This metric is a count of the number of function definitions in the file. FCO - Estimated Function CouplingFunction-Based Metric See Brandl[1]. Since the actual value of Brandl's metric requires a full, well-structured calling tree, FCO can only be an estimate. A high figure indicates a large change of complexity between levels of the calling tree. The metric is computed from FNC and the SUB values of the component functions in the translation unit: The code example below has an FCO value of 1 (2 - 2 + 1). ExampleBOOL isActive(CHANNEL c); BOOL okToRead(TEXTCHANNEL c) { return !isActive(c); } BOOL okToPrint(PRINTCHANNEL c) { return !isActive(c); } [1] Brandl, D.L. (1990), Quality Measures in Design, ACM Sigsoft Software Engineering Notes, vol 15, 1. HAL - Halstead Prediction of TOTFunction-Based Metric This metric and also ZIP are predictions derived from the vocabulary analysis metrics OPN and OPT of what the value of TOT should be. If they differ from TOT by more than a factor of 2, it is an indication of an unusual vocabulary. This usually means that either the source code contains sections of rather repetitive code or it has an unusually rich vocabulary. The two metrics are computed as follows: ZIP = ( OPN + OPT ) * ( 0.5772 + ln (OPN + OPT) ) M20 - Number of Operand OccurrencesFunction-Based Metric This metric is the number of operands in a software component and is one of the Halstead vocabulary analysis metrics. Halstead considered that a component is a series of tokens that can be defined as either operators or operands. Unlike OPN, this metric is the count of every instance of an operand in a file, regardless of whether or not it is distinct. OPN only counts the operands that are distinct. The code example below has a M20 value of 8. Examplevoid f( int a ) /* 1,2 -> f, a */ { if ( a > 1 ) /* 3,4 -> a, 1 */ { ++a; /* 5 -> a */ while ( a > 1 ) /* 6,7 -> a, 1 */ { --a; /* 8 -> a */ } } }
[x] Halstead, Maurice H. (1977). Elements of Software Science. M21 - Number of Operator OccurrencesFunction-Based Metric This metric is the number of operators in a software component and is one of the Halstead vocabulary analysis metrics. Halstead considered that a component is a series of tokens that can be defined as either operators or operands. Unlike OPT, this metric is the count of every instance of an operator in a file, regardless of whether or not it is distinct. OPT only counts the operators that are distinct. The code example below has a M21 value of 22. Examplevoid f( int a ) /* 1,2,3,4 -> void, (, int, ) */ { /* 5 -> { */ if ( a > 1) /* 6,7,8,9 -> if, (, >, ) */ { /* 10 ->{ */ ++a; /* 11,12 -> ++, ; */ while (a > 1) /* 13,14,15,16 -> while, (, >, ) */ { /* 17 -> { */ --a; /* 18,19 -> --, ; */ } /* 20 -> } */ } /* 21 -> } */ } /* 22 -> } */
[x] Halstead, Maurice H. (1977). Elements of Software Science. M22 - Number of StatementsFunction-Based Metric This metric is the number of statements in a software component. This is a count of semicolons in a file except for the following instances:
The code example below has a M22 value of 5. Examplevoid f( int a ) { struct { int i; int j; } ij; /* 1 */ a = 1; /* 2 */ a = 1; a = 2; /* 3,4 */ if ( a > 1 ) { return; /* 5 */ } } M28 - Number of Non-Header CommentsFunction-Based Metric This metric is a count of the occurrences of C or C++ style comments in a source file except for those that are within the header of a file. A file header is defined as tokens preceding the first code token or preprocessor directive token. M28 is based on the method used to compute CDN but differs from CDN in that CDN counts the visible characters within comments, whereas M28 counts the occurrences of comments. The code example below has a M28 value of 2. Example/* Header comment 1 Count = 0 */ /* Header comment 2 Count = 0 */ /* Last header comment Count = 0 code follows */ #define CENT 100 /* Non header comment Count = 1 */ void f( int a ) { /* Block scope comment Count = 2 */ a = CENT; return; } M33 - Number of Internal CommentsFunction-Based Metric This metric is a count of C style or C++ comments in a source file that are within functions or annotate a line of code at file scope. Comments within functions are all comments at block scope. Comments that annotate code are ones that start or end on the same line as code. M33 is based on the method used to compute CDN but differs from CDN in that CDN counts the visible characters within comments, whereas M33 counts the occurrences of comments. The code example below has a M33 value of 5. Example/* Header comment 1 Count = 0 */ /* Header comment 2 Count = 0 */ /* Last header comment Count = 0 code follows */ #define CENT 100 /* Annotating comment M33 = 1 */ int /* Annotating comment M33 = 2 */ i; /* Annotating comment M33 = 3 */ int j; /* Annotating comment M33 = 4 */ /* Non internal comment M33 = 0 */ void f( int a ) { /* Block scope comment M33 = 5 */ a = CENT; return; } OPN - Number of Distinct OperandsFunction-Based Metric This is the number of distinct operands used in the file. Distinct operands are defined as unique identifiers and each occurrence of a literal. Most literals, except 0 and 1, are usually distinct within a program. Since macros are usually used for fixed success and failure values (such as TRUE and FALSE), the differences in counting strategies are fairly minimal. The code below has an OPN value of 11. Exampleextern int result; /* 1 -> result */ static int other_result; /* 2 -> other_result */ main() /* 3 -> main */ { int x; /* 4 -> x */ int y; /* 5 -> y */ int z; /* 6 -> z */ x = 45; /* 7 -> 45 */ y = 45; /* 8 -> 45 */ z = 1; /* 9 -> 1 */ result = 1; /* 10 -> 1 */ other_result = 0; /* 11 -> 0 */ return (x + other_result); } OPT - Number of Distinct OperatorsFunction-Based Metric This covers any source code tokens not supplied by the user, such as keywords, operators, and punctuation. OPT is used in the calculation of a number of other metrics. The code below has an OPT value of 11. Exampleextern int result; /* 1,2,3 -> extern, int, ; */ static int other_result; /* 4 -> static */ main() /* 5,6 -> ()*/ { /* 7 -> { */ int x; int y; int z; x = 45; /* 8 -> = */ y = 45; z = 1; result = 1; other_result = 0; return (x + other_result); /* 9,10 -> return, + */ } /* 11 -> } */ SCT - Number of Static Variables DeclaredFunction-Based Metric This metric is computed as the number of variables and functions declared static at file scope. The code example below has an SCT value of 2. Examplestatic int other_result; /* 1 */ int result; static int test() /* 2 */ { int x; int y; int z; z = 1; return (x + other_result); } SHN - Shannon Information ContentFile-Based Metric Also known as the "entropy" H, this metric is a widely recognized algorithm for estimating the program space required to encode the functions in a source file. SHN is measured in bits and is calculated as follows: SHN = ZIP * log2 (√(OPN + OPT) + ln (OPN + OPT)) TDE - Embedded Total MonthsTDO - Organic Total MonthsTDS - Semi-detached Total MonthsFile-Based Metrics The COCOMO metrics are produced for each source code file. You can display an accurate estimate of development costs for a whole project by choosing the COCOMO Cost Model option from the Reports menu. Refer to Chapter 6: Reports for a discussion of the COCOMO cost model and an explanation of the three programming modes: Organic, Semi-detached, and Embedded. These metrics are a measure of elapsed time in months required to develop the source code in the respective environments. TDE = 2.5 * BME 0.32 TLN - Total Preprocessed Code LinesFile-Based Metric This metric is a count of the total number of source lines in the file after pre-processing. The pre-processed
file will reflect the processing of include files, pre-processor directives and the stripping of comment lines. See also TPP TOT - Total Number of Tokens UsedFile-Based Metric This metric is the total number of tokens, not distinct tokens, in the source file. The code example below has an TOT value of 19. Exampleint test() /* 1,2,3,4 */ { /* 5 */ int x; /* 6,7,8 int y; /* 9,10,11 */ /*Excluded Comment*/ return (x + y); /* 12,13,14,15,16,17,18 */ } /* 19 */ TPP - Total Unpreprocessed Code LinesFile-Based Metric This metric is a count of the total number of source lines in the file before pre-processing. See also TLN VAR - Total Number of VariablesFile-Based Metric The metric represents the total number of distinct identifiers. The code below has an VAR value of 5. Exampleint other_result; /* 1 */ extern int result; /* 2 */ int test() /* 3 */ { int x; /* 4 */ int y; /* 5 */ return (x + y + other_result); } VOL - Program VolumeFile-Based Metric This is a measure of the number of bits required for a uniform binary encoding of the program text. It is used to calculate various Halstead vocabulary metrics. The following is the calculation for the program volume: VOL = TOT * log 2 ( OPN + OPT )
[x] Halstead, Maurice H. (1977). Elements of Software Science. ZIP - Zipf Prediction of TOTFile-Based Metric ZIP = ( OPN + OPT ) * ( 0.5772 + ln (OPN + OPT) ) See HAL. CCA - Total Number of CharactersFile-Based Metric This metric is the total number of characters in the file. Only visible characters are counted, except in string or character literals, in which case all characters are counted and tabs are treated as one character. When counting comment characters, the comment delimiter characters are counted. CCB - Total Number of Code CharactersFile-Based Metric This metric is the total number of code characters in the file. Only visible characters are counted, except in string or character literals, in which case all characters are counted and tabs are treated as one character. Characters comprising comments are not counted, this includes the comment delimiter characters. CCC - Total Number of Comment CharactersFile-Based Metric This metric is the total number of visible comment characters in the file. The comment delimiter characters are not
counted.
Class-Based MetricsCBO - Coupling between objectsClass-Based Metric This is a count of the number of methods (member functions) or member objects of other classes accessed by a class. Only classes outside the inheritance hierarchy are considered because you would expect interaction with base and derived classes. Coupling to classes outside the inheritance tree should be viewed with suspicion as it makes the class less independent and less re-usable. This is one of Chidamber & Kemerer's[1] suite of object oriented metrics. [1] Chidamber, S.R. and Kemerer, C.F. (1991). Towards a Metrics Suite for Object Oriented Design, Proceedings of OOPSLA, '91, Sigplan notices, vol.26, no. 11, ACM Press. DIT - Deepest level of inheritanceClass-Based Metric This represents the number of derivations from the furthest base class down to this class. A high figure may indicate that the class depends on accumulated functionality, which makes understanding the class potentially difficult. This is one of the metrics defined by Chidamber & Kemerer. LCM - Lack of cohesion of methods within a classClass-Based Metric Methods within a class are partitioned into sets that access independent sets of member objects. The LCM metric is a count of sets of unrelated members for a type. For example (default): Exampleclass cohesive { private: int i1; int i2; int i3; public: void m1(int a) { i1 = a + i2; } void m2(int a) { i2 = a; } void m3(int a) { if (a > i3) ++i3; } }; This above code sample has a LCM value of 2 because methods m1 and m2 access the set of member objects i1 and i2. Method m3 accesses only i3 and can be viewed as independent of m1 and m2. (m3 is not cohesive with the other two methods). Similarly, where one method calls another, the set used for inclusion in LCM is the union of the sets from each method. Variations of the calculation of LCM may explicitly exclude constructors, so the default behavior of CMA is that constructors are excluded when calculating this metric. To include constructors, enable the configuration option "-ProdOption LCM::include_constructor". If constructors are included, and the constructor for such a type initializes all the members, then the value of LCM is guaranteed to be '1'. This is one of the metrics defined by Chidamber & Kemerer. MTH - Number of methods declared in classClass-Based Metric The number of methods declared within a class. This does not include methods declared in base classes. Classes with a large number of methods will be difficult to understand. NOC - Number of immediate childrenClass-Based Metric This is the number of classes for which this class is an immediate base class. A high figure for this metric indicates greater dependence on the functionality of this class, and more potential knock-on effects from changes to it. This is one of the metrics defined by Chidamber & Kemerer. NOP - Number of immediate parentsClass-Based Metric This metric indicates the number of inheritances for a class. Root base classes have a value of 0 while classes derived with a single inheritance have a value of 1. Classes that have multiple inheritance are prohibited by some programming standards. RFC - Response for classClass-Based Metric This indicates how functions can potentially be called directly from the class. The response set is calculated as the number of distinct class methods and functions called from the definitions of those methods. This is one of the metrics defined by Chidamber & Kemerer. WMC - Weighted methods per classClass-Based Metric This is the sum of cyclomatic complexities (See Cyclomatic complexity (CYC) in Function-Based
Metrics section of this document) for all the methods in the class. In the same way that cyclomatic complexity gives an
indication of the amount of testing required for an individual function, this metric gives an indication of the amount
of testing required for a whole class. This is one of the metrics defined by Chidamber & Kemerer.
Project-Wide MetricsNRA - Number of Recursions Across ProjectProject-Wide Metric This metric is defined to be the number of recursive paths in the call graph of the project's functions. A recursive path can be for one or more functions. The minimum, and often desirable, value of this metric is zero. Values greater than zero indicate the number of distinct loops in the call graph. NEA - Number of Entry points Across ProjectProject-Wide Metric This metric is the number of functions that are not called in the project. It is the number of nodes in the call graph which are not themselves called. For example, main() is not called; hence the minimum (build) value of 1. NFA - Number of Functions Across ProjectProject-Wide Metric This metric is the number of function definitions in the project. Note that this metric is the sum of QAC's FNC metric values for each source file included in the project. CYA - Cyclomatic Complexity Across ProjectProject-Wide Metric This metric is the sum of cyclomatic complexity values for each function definition in the project.
Note that this metric is the sum of QAC CYC metric values for each source file included in the
project.
GeneralThe Components of Function StructureFunction structure diagrams show the control flow structures within source code. Decisions (if, switch, and the condition part of a loop) are displayed as forks in the structure. The corresponding join, further to the right, indicates where the paths rejoin. Backward arcs, caused by loops, are shown as dotted lines. The function structure diagrams show the following code structures:
Each component progresses from the left to the right as the control flow would progress through the source code. Straight codestatic int code = 0; void funcStraight( void) { code = 1; } There is only one path through this particular function, which is represented as lying along the x-axis. Ifstatic int code = 0; void funcIf( void) { if (code > 0) { code = 1; } } This function has two paths. The first path is through the if statement and is shown by the raised line. The second path is where the if condition is false and is represented by the x-axis. If-Elsevoid funcIfElse( void) { if (code > 0) { code = 3; } else { code = 4; } } This function has two execution paths. The first path is the if sub-statement represented by the raised line. The second path is the else sub-statement represented by the x-axis. Note that the body of this structure is longer than the body of the if statement. If the two arms of the if-else were not straight line code, the body of the if branch would appear at the left hand end of the raised line and the body of the else branch would appear to the right of the lower line. Switchstatic int code = 0; void funcSwitch( void) { switch (code) { case 1: if (code == 1) { /* block of code */ } break; case 2: break; case 3: if (code == 3) { /* block of code */ } break; default: break; } } In the switch statement, the x-axis represents the default action, and each case statement is shown by a raised line. The two briefly raised lines represent the if statements within case 1 and case 3. The diagram shows how the if statements are staggered. The if of case 1 is shown on the left and the if of case 3 is shown on the right. While loopstatic int code = 0; void funcWhile( void) { while (code > 0) { --code; } } In the while loop, the x-axis represents the path straight through the function as though the while loop had not been executed. The solid raised line shows the path of the while body. The dotted line shows the loop to the beginning of the while statement. For loopstatic int code = 0; void doSomethingWith(int); void funcFor( void) { int i; for (i = 0; i > code; ++i) { doSomethingWith( i); } } The for loop is similar to the while loop as for loops can be rewritten as while loops. For example, funcFor in the above example could be written as: void funcFor( void) { int i = 0; while (i > code) { /* body */ ++i; } } Nested Structuresstatic int code = 0; void funcWhileIfElse( void) { while (code > 0) { if (code == 1) { code = 0; } else { code--; } } } This is an if-else contained within a while loop. The first solid raised line represents the while loop while the inner raised solid line represents the if-else loop. Other function structure components can be similarly nested. Break in a loopstatic int code = 0; void funcWhileIfBreak( void) { while (code > 0) { if (code == 3) { break; } code--; } if (code == 0) { code++; } } The break jumps to the end of the while statement and causes a knot. A knot is where the control flow crosses the boundary of another statement block and indicates unstructured code. In this case, break jumps to the end of the while statement and the next part of the program, the if statement, is executed. Return in a loopstatic int code = 0; void funcWhileIfReturn( void) { while (code > 0) { if (code == 3) { return; } code--; } if (code == 0) { code++; } } The return statement causes the program to jump to the end of the function. This jump breaks the control flow and causes a knot in the code. Continue in a loopstatic int code = 0; void funcWhileIfContinue( void) { while (code > 0) { if (code == 3) { continue; } code--; } if (code == 0) { code++; } } The continue statement causes the program to jump back to the beginning of the while loop. Unreachable code
static void funcUnReach( int i)
{
if (i)
{
i = 1;
}
goto Bad;
if (i)
{
i = 2;
}
Bad:
if (i)
{
i = 3;
}
return;
}
The raised red section represents code that is unreachable. The structure and approximate position of the unreachable code is shown. It occurs after the first if condition and before the last if condition. Its position above the main structure shows that the control flow misses the middle if condition. |
All Manual Pages |