GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/base/configuration.cpp Lines: 110 130 84.6 %
Date: 2021-09-18 Branches: 119 292 40.8 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Morgan Deters, Aina Niemetz, Mathias Preiner
4
 *
5
 * This file is part of the cvc5 project.
6
 *
7
 * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
8
 * in the top-level source directory and their institutional affiliations.
9
 * All rights reserved.  See the file COPYING in the top-level source
10
 * directory for licensing information.
11
 * ****************************************************************************
12
 *
13
 * Implementation of Configuration class, which provides compile-time
14
 * configuration information about the cvc5 library.
15
 */
16
#include "base/configuration.h"
17
18
#include <stdlib.h>
19
#include <string.h>
20
21
#include <algorithm>
22
#include <sstream>
23
#include <string>
24
25
#include "base/Debug_tags.h"
26
#include "base/Trace_tags.h"
27
#include "base/configuration_private.h"
28
#include "base/cvc5config.h"
29
30
using namespace std;
31
32
namespace cvc5 {
33
34
3
string Configuration::getName() { return CVC5_PACKAGE_NAME; }
35
36
358244
bool Configuration::isDebugBuild() {
37
358244
  return IS_DEBUG_BUILD;
38
}
39
40
2628
bool Configuration::isTracingBuild() {
41
2628
  return IS_TRACING_BUILD;
42
}
43
44
2628
bool Configuration::isDumpingBuild() {
45
2628
  return IS_DUMPING_BUILD && !IS_MUZZLED_BUILD;
46
}
47
48
9005
bool Configuration::isMuzzledBuild() {
49
9005
  return IS_MUZZLED_BUILD;
50
}
51
52
4190648
bool Configuration::isAssertionBuild() {
53
4190648
  return IS_ASSERTIONS_BUILD;
54
}
55
56
2628
bool Configuration::isCoverageBuild() {
57
2628
  return IS_COVERAGE_BUILD;
58
}
59
60
2628
bool Configuration::isProfilingBuild() {
61
2628
  return IS_PROFILING_BUILD;
62
}
63
64
2626
bool Configuration::isAsanBuild() { return IS_ASAN_BUILD; }
65
66
2626
bool Configuration::isUbsanBuild() { return IS_UBSAN_BUILD; }
67
68
2626
bool Configuration::isTsanBuild() { return IS_TSAN_BUILD; }
69
70
2626
bool Configuration::isCompetitionBuild() {
71
2626
  return IS_COMPETITION_BUILD;
72
}
73
74
2629
bool Configuration::isStaticBuild()
75
{
76
#if defined(CVC5_STATIC_BUILD)
77
2629
  return true;
78
#else
79
  return false;
80
#endif
81
}
82
83
2
string Configuration::getPackageName() { return CVC5_PACKAGE_NAME; }
84
85
2629
string Configuration::getVersionString() { return CVC5_RELEASE_STRING; }
86
87
2628
unsigned Configuration::getVersionMajor() { return CVC5_MAJOR; }
88
89
2628
unsigned Configuration::getVersionMinor() { return CVC5_MINOR; }
90
91
2628
unsigned Configuration::getVersionRelease() { return CVC5_RELEASE; }
92
93
std::string Configuration::getVersionExtra() { return CVC5_EXTRAVERSION; }
94
95
2629
std::string Configuration::copyright() {
96
5258
  std::stringstream ss;
97
  ss << "Copyright (c) 2009-2021 by the authors and their institutional\n"
98
2629
     << "affiliations listed at https://cvc5.github.io/people.html\n\n";
99
100
2629
  if (Configuration::licenseIsGpl()) {
101
    ss << "This build of cvc5 uses GPLed libraries, and is thus covered by\n"
102
       << "the GNU General Public License (GPL) version 3.  Versions of cvc5\n"
103
       << "are available that are covered by the (modified) BSD license. If\n"
104
       << "you want to license cvc5 under this license, please configure cvc5\n"
105
2629
       << "with the \"--no-gpl\" option before building from sources.\n\n";
106
  } else {
107
    ss << "cvc5 is open-source and is covered by the BSD license (modified)."
108
       << "\n\n";
109
  }
110
111
  ss << "THIS SOFTWARE IS PROVIDED AS-IS, WITHOUT ANY WARRANTIES.\n"
112
2629
     << "USE AT YOUR OWN RISK.\n\n";
113
114
  ss << "cvc5 incorporates code from ANTLR3 (http://www.antlr.org).\n"
115
     << "See licenses/antlr3-LICENSE for copyright and licensing information."
116
2629
     << "\n\n";
117
118
  ss << "This version of cvc5 is linked against the following non-(L)GPL'ed\n"
119
2629
     << "third party libraries.\n\n";
120
121
  ss << "  CaDiCaL - Simplified Satisfiability Solver\n"
122
     << "  See https://github.com/arminbiere/cadical for copyright "
123
2629
     << "information.\n\n";
124
125
5258
  if (Configuration::isBuiltWithAbc()
126
2629
      || Configuration::isBuiltWithCryptominisat()
127
      || Configuration::isBuiltWithKissat()
128
2629
      || Configuration::isBuiltWithEditline())
129
  {
130
2629
    if (Configuration::isBuiltWithAbc()) {
131
      ss << "  ABC - A System for Sequential Synthesis and Verification\n"
132
         << "  See http://bitbucket.org/alanmi/abc for copyright and\n"
133
         << "  licensing information.\n\n";
134
    }
135
2629
    if (Configuration::isBuiltWithCryptominisat())
136
    {
137
      ss << "  CryptoMiniSat - An Advanced SAT Solver\n"
138
         << "  See https://github.com/msoos/cryptominisat for copyright "
139
2629
         << "information.\n\n";
140
    }
141
2629
    if (Configuration::isBuiltWithKissat())
142
    {
143
      ss << "  Kissat - Simplified Satisfiability Solver\n"
144
         << "  See https://fmv.jku.at/kissat for copyright "
145
         << "information.\n\n";
146
    }
147
2629
    if (Configuration::isBuiltWithEditline())
148
    {
149
      ss << "  Editline Library\n"
150
         << "  See https://thrysoee.dk/editline\n"
151
         << "  for copyright information.\n\n";
152
    }
153
  }
154
155
  ss << "  SymFPU - The Symbolic Floating Point Unit\n"
156
     << "  See https://github.com/martin-cs/symfpu/tree/cvc5 for copyright "
157
2629
     << "information.\n\n";
158
159
2629
  if (Configuration::isBuiltWithGmp() || Configuration::isBuiltWithPoly())
160
  {
161
    ss << "This version of cvc5 is linked against the following third party\n"
162
       << "libraries covered by the LGPLv3 license.\n"
163
2629
       << "See licenses/lgpl-3.0.txt for more information.\n\n";
164
2629
    if (Configuration::isBuiltWithGmp()) {
165
      ss << "  GMP - Gnu Multi Precision Arithmetic Library\n"
166
         << "  See http://gmplib.org for copyright information.\n\n";
167
    }
168
2629
    if (Configuration::isBuiltWithPoly())
169
    {
170
      ss << "  LibPoly polynomial library\n"
171
         << "  See https://github.com/SRI-CSL/libpoly for copyright and\n"
172
2629
         << "  licensing information.\n\n";
173
    }
174
2629
    if (Configuration::isStaticBuild())
175
    {
176
2629
      ss << "cvc5 is statically linked against these libraries. To recompile\n"
177
            "this version of cvc5 with different versions of these libraries\n"
178
            "follow the instructions on "
179
            "https://github.com/cvc5/cvc5/blob/master/INSTALL.md\n\n";
180
    }
181
  }
182
183
5258
  if (Configuration::isBuiltWithCln()
184
2629
      || Configuration::isBuiltWithGlpk ()) {
185
    ss << "This version of cvc5 is linked against the following third party\n"
186
       << "libraries covered by the GPLv3 license.\n"
187
2629
       << "See licenses/gpl-3.0.txt for more information.\n\n";
188
2629
    if (Configuration::isBuiltWithCln()) {
189
      ss << "  CLN - Class Library for Numbers\n"
190
2629
         << "  See http://www.ginac.de/CLN for copyright information.\n\n";
191
    }
192
2629
    if (Configuration::isBuiltWithGlpk()) {
193
      ss << "  glpk-cut-log - a modified version of GPLK, "
194
         << "the GNU Linear Programming Kit\n"
195
         << "  See http://github.com/timothy-king/glpk-cut-log for copyright"
196
         << " information\n\n";
197
    }
198
  }
199
200
  ss << "See the file COPYING (distributed with the source code, and with\n"
201
     << "all binaries) for the full cvc5 copyright, licensing, and (lack of)\n"
202
2629
     << "warranty information.\n";
203
5258
  return ss.str();
204
}
205
206
2629
std::string Configuration::about() {
207
5258
  std::stringstream ss;
208
2629
  ss << "This is cvc5 version " << CVC5_RELEASE_STRING;
209
2629
  if (Configuration::isGitBuild()) {
210
2629
    ss << " [" << Configuration::getGitId() << "]";
211
  }
212
5258
  ss << "\ncompiled with " << Configuration::getCompiler()
213
5258
     << "\non " << Configuration::getCompiledDateTime() << "\n\n";
214
2629
  ss << Configuration::copyright ();
215
5258
  return ss.str();
216
}
217
218
2629
bool Configuration::licenseIsGpl() {
219
2629
  return IS_GPL_BUILD;
220
}
221
222
7884
bool Configuration::isBuiltWithGmp() {
223
7884
  return IS_GMP_BUILD;
224
}
225
226
7884
bool Configuration::isBuiltWithCln() {
227
7884
  return IS_CLN_BUILD;
228
}
229
230
5255
bool Configuration::isBuiltWithGlpk() {
231
5255
  return IS_GLPK_BUILD;
232
}
233
234
7884
bool Configuration::isBuiltWithAbc() {
235
7884
  return IS_ABC_BUILD;
236
}
237
238
7894
bool Configuration::isBuiltWithCryptominisat() {
239
7894
  return IS_CRYPTOMINISAT_BUILD;
240
}
241
242
5255
bool Configuration::isBuiltWithKissat() { return IS_KISSAT_BUILD; }
243
244
5255
bool Configuration::isBuiltWithEditline() { return IS_EDITLINE_BUILD; }
245
246
7884
bool Configuration::isBuiltWithPoly()
247
{
248
7884
  return IS_POLY_BUILD;
249
}
250
251
const std::vector<std::string>& Configuration::getDebugTags()
252
{
253
  return Debug_tags;
254
}
255
256
bool Configuration::isDebugTag(const std::string& tag)
257
{
258
  return std::find(Debug_tags.begin(), Debug_tags.end(), tag)
259
         != Debug_tags.end();
260
}
261
262
const std::vector<std::string>& Configuration::getTraceTags()
263
{
264
  return Trace_tags;
265
}
266
267
bool Configuration::isTraceTag(const std::string& tag)
268
{
269
  return std::find(Trace_tags.begin(), Trace_tags.end(), tag)
270
         != Trace_tags.end();
271
}
272
273
7884
bool Configuration::isGitBuild() {
274
7884
  return IS_GIT_BUILD;
275
}
276
277
5255
const char* Configuration::getGitBranchName() {
278
5255
  return GIT_BRANCH_NAME;
279
}
280
281
5255
const char* Configuration::getGitCommit() {
282
5255
  return GIT_COMMIT;
283
}
284
285
5255
bool Configuration::hasGitModifications() {
286
5255
  return GIT_HAS_MODIFICATIONS;
287
}
288
289
2629
std::string Configuration::getGitId() {
290
2629
  if(! isGitBuild()) {
291
    return "";
292
  }
293
294
2629
  const char* branchName = getGitBranchName();
295
2629
  if(*branchName == '\0') {
296
    branchName = "-";
297
  }
298
299
5258
  stringstream ss;
300
5258
  ss << "git " << branchName << " " << string(getGitCommit()).substr(0, 8)
301
5258
     << (::cvc5::Configuration::hasGitModifications() ? " (with modifications)"
302
7887
                                                      : "");
303
2629
  return ss.str();
304
}
305
306
2629
std::string Configuration::getCompiler() {
307
5258
  stringstream ss;
308
#ifdef __GNUC__
309
2629
  ss << "GCC";
310
#else /* __GNUC__ */
311
  ss << "unknown compiler";
312
#endif /* __GNUC__ */
313
#ifdef __VERSION__
314
2629
  ss << " version " << __VERSION__;
315
#else /* __VERSION__ */
316
  ss << ", unknown version";
317
#endif /* __VERSION__ */
318
5258
  return ss.str();
319
}
320
321
2629
std::string Configuration::getCompiledDateTime() {
322
2629
  return __DATE__ " " __TIME__;
323
}
324
325
29580
}  // namespace cvc5