Helper class providing functions to access various parts of the version string, as well as functions for composing short and long variants of the version string. More...
#include "version.h"
Static Public Member Functions | |
static std::string | BuildProfile () |
Indicates the type of build that was performed (debug/release/optimized). | |
static std::string | BuildSummary () |
Constructs a string containing the most recent tag and status flags. | |
static std::string | ClosestAncestorTag () |
Returns the closest tag that is attached to a commit that is an ancestor of the current branch head. | |
static std::string | CommitHash () |
Hash of the most recent commit. | |
static bool | DirtyWorkingTree () |
Indicates whether there were uncommitted changes during the build. | |
static std::string | LongVersion () |
Constructs a string containing all of the build details. | |
static uint32_t | Major () |
Major component of the build version. | |
static uint32_t | Minor () |
Minor component of the build version. | |
static uint32_t | Patch () |
Patch component of the build version. | |
static std::string | ReleaseCandidate () |
Release candidate component of the build version. | |
static std::string | ShortVersion () |
Constructs a string containing the ns-3 major and minor version components, and indication of additional commits or dirty status. | |
static uint32_t | TagDistance () |
The number of commits between the current commit and the tag returned by ClosestAncestorTag(). | |
static std::string | VersionTag () |
Returns the ns-3 version tag of the closest ancestor commit. | |
Helper class providing functions to access various parts of the version string, as well as functions for composing short and long variants of the version string.
See CommandLine::PrintVersion() for an example on how to use Version to output a version string. command-line-example has been updated to include CommandLine::PrintVersion() in its output
build-version-example.cc illustrates using each of these functions.
Below is a partial view of a git branch:
Here are the values that will be assigned based on this example branch:
Component | Value | Notes |
---|---|---|
VersionTag | ns-3.32 | |
ClosestAncestorTag | mytag | |
Major | 3 | |
Minor | 32 | |
Patch | 0 | This version tag does not have a patch field |
ReleaseCandidate | "" | This version tag does not have a release candidate field |
TagDistance | 1 | |
CommitHash | g6ad7f05 | g at front of hash indicates a git hash |
DirtyWorkingTree | Variable | Depends on status of git working and stage areas |
BuildProfile | Variable | Depends on the value of –build-profile option of ns3 configure |
|
|
static |
Indicates the type of build that was performed (debug/release/optimized).
This information is set by the –build-profile option of ns3 configure
Definition at line 79 of file version.cc.
Referenced by LongVersion().
|
static |
Constructs a string containing the most recent tag and status flags.
In the case where closest-ancestor-tag == version-tag, the output of this function will be the same as ShortVersion()
The format of the constructed string is <closest-ancestor-tag>[flags]
.
flags
will contain +
when TagDistance() > 0flags
will contain *
when DirtyWorkingTree() == true.[flags] will contain none, one, or both characters depending on the state of the branch
Definition at line 104 of file version.cc.
References ClosestAncestorTag(), DirtyWorkingTree(), and TagDistance().
|
static |
Returns the closest tag that is attached to a commit that is an ancestor of the current branch head.
The value returned by this function may be the same as VersionTag() if the ns-3 version tag is the closest ancestor tag.
Definition at line 31 of file version.cc.
Referenced by BuildSummary(), LongVersion(), and ShortVersion().
|
static |
Hash of the most recent commit.
The hash component is the id of the most recent commit. The returned value is a hexadecimal string with enough data to uniquely identify the commit.
The first character of the string is a letter indicating the type of repository that was in use: g=git
Example of hash output: g6bfb0c9
Definition at line 73 of file version.cc.
Referenced by LongVersion().
|
static |
Indicates whether there were uncommitted changes during the build.
true
if the working tree had uncommitted changes. Definition at line 67 of file version.cc.
Referenced by BuildSummary(), LongVersion(), and ShortVersion().
|
static |
Constructs a string containing all of the build details.
The format of the constructed string is
* ns-<major>.<minor>[.patch][-rc][-closest-tag]-<tag-distance>@<hash>[-dirty]-<build-profile> *
[patch], [rc], [closest-tag], and [dirty] will only be present under certain circumstances:
true
Definition at line 122 of file version.cc.
References BuildProfile(), ClosestAncestorTag(), CommitHash(), DirtyWorkingTree(), TagDistance(), and VersionTag().
Referenced by ns3::CommandLine::GetVersion().
|
static |
Major component of the build version.
The format of the build version string is
ns-<major>.<minor>[.patch][-RC<digit>]
The major component is the number before the first period
Definition at line 37 of file version.cc.
|
static |
Minor component of the build version.
The format of the build version string is
ns-<major>.<minor>[.patch][-RC<digit>]
The minor component is the number after the first period
Definition at line 43 of file version.cc.
|
static |
Patch component of the build version.
A build version with a patch component will have the format
ns-<major>.<minor>.<patch>
The patch component is the number after the second period
Definition at line 49 of file version.cc.
|
static |
Release candidate component of the build version.
A build version with a release candidate will have the format
ns-<major>.<minor>[.patch]-RC<digit>
The string returned by this function will have the format RC<digit>
Definition at line 55 of file version.cc.
|
static |
Constructs a string containing the ns-3 major and minor version components, and indication of additional commits or dirty status.
The format of the constructed string is
ns-<major>.<minor>[.patch][-rc]<flags>
flags
will contain +
when TagDistance() > 0flags
will contain *
when DirtyWorkingTree() == true.[flags] will contain none, one, or both characters depending on the state of the branch
Definition at line 85 of file version.cc.
References ClosestAncestorTag(), DirtyWorkingTree(), TagDistance(), and VersionTag().
|
static |
The number of commits between the current commit and the tag returned by ClosestAncestorTag().
Definition at line 61 of file version.cc.
Referenced by BuildSummary(), LongVersion(), and ShortVersion().
|
static |
Returns the ns-3 version tag of the closest ancestor commit.
The format of the tag is
ns3-<major>.<minor>[.patch]
The patch field is optional and may not be present. The value of patch defaults to 0 if the tag does not have a patch field.
Definition at line 25 of file version.cc.
Referenced by LongVersion(), and ShortVersion().