A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
version.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Lawrence Livermore National Laboratory
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Mathew Bielejeski <bielejeski1@llnl.gov>
7 */
8
9#include "version.h"
10
11#include "ns3/version-defines.h"
12
13#include <sstream>
14
15/**
16 * \file
17 * \ingroup buildversion
18 * ns3::Version implementation
19 */
20
21namespace ns3
22{
23
24std::string
26{
27 return NS3_VERSION_TAG;
28}
29
30std::string
32{
33 return NS3_VERSION_CLOSEST_TAG;
34}
35
38{
39 return NS3_VERSION_MAJOR;
40}
41
44{
45 return NS3_VERSION_MINOR;
46}
47
50{
51 return NS3_VERSION_PATCH;
52}
53
54std::string
56{
57 return std::string{NS3_VERSION_RELEASE_CANDIDATE};
58}
59
62{
63 return NS3_VERSION_TAG_DISTANCE;
64}
65
66bool
68{
69 return static_cast<bool>(NS3_VERSION_DIRTY_FLAG);
70}
71
72std::string
74{
75 return std::string{NS3_VERSION_COMMIT_HASH};
76}
77
78std::string
80{
81 return std::string{NS3_VERSION_BUILD_PROFILE};
82}
83
84std::string
86{
87 std::ostringstream ostream;
88 ostream << VersionTag();
89
90 auto ancestorTag = ClosestAncestorTag();
91 if ((!ancestorTag.empty() && (ancestorTag != VersionTag())) || TagDistance() > 0)
92 {
93 ostream << "+";
94 }
95 if (DirtyWorkingTree())
96 {
97 ostream << "*";
98 }
99
100 return ostream.str();
101}
102
103std::string
105{
106 std::ostringstream ostream;
107 ostream << ClosestAncestorTag();
108
109 if (TagDistance() > 0)
110 {
111 ostream << "+";
112 }
113 if (DirtyWorkingTree())
114 {
115 ostream << "*";
116 }
117
118 return ostream.str();
119}
120
121std::string
123{
124 std::ostringstream ostream;
125 ostream << VersionTag();
126
127 auto ancestorTag = ClosestAncestorTag();
128 if (!ancestorTag.empty() && (ancestorTag != VersionTag()))
129 {
130 ostream << '+' << ancestorTag;
131 }
132
133 auto tagDistance = TagDistance();
134
135 if (tagDistance > 0)
136 {
137 ostream << '+' << tagDistance;
138 }
139
140 ostream << '@' << CommitHash();
141
142 if (DirtyWorkingTree())
143 {
144 ostream << "-dirty";
145 }
146
147 ostream << '-' << BuildProfile();
148
149 return ostream.str();
150}
151
152} // namespace ns3
static uint32_t Patch()
Patch component of the build version.
Definition version.cc:49
static std::string CommitHash()
Hash of the most recent commit.
Definition version.cc:73
static uint32_t Major()
Major component of the build version.
Definition version.cc:37
static uint32_t TagDistance()
The number of commits between the current commit and the tag returned by ClosestAncestorTag().
Definition version.cc:61
static std::string BuildProfile()
Indicates the type of build that was performed (debug/release/optimized).
Definition version.cc:79
static std::string ReleaseCandidate()
Release candidate component of the build version.
Definition version.cc:55
static uint32_t Minor()
Minor component of the build version.
Definition version.cc:43
static std::string BuildSummary()
Constructs a string containing the most recent tag and status flags.
Definition version.cc:104
static bool DirtyWorkingTree()
Indicates whether there were uncommitted changes during the build.
Definition version.cc:67
static std::string ShortVersion()
Constructs a string containing the ns-3 major and minor version components, and indication of additio...
Definition version.cc:85
static std::string LongVersion()
Constructs a string containing all of the build details.
Definition version.cc:122
static std::string VersionTag()
Returns the ns-3 version tag of the closest ancestor commit.
Definition version.cc:25
static std::string ClosestAncestorTag()
Returns the closest tag that is attached to a commit that is an ancestor of the current branch head.
Definition version.cc:31
Every class exported by the ns3 library is enclosed in the ns3 namespace.
class ns3::Version definition