version.cc 2.56 KB
Newer Older
1
// Copyright 2012 the V8 project authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4

5
#include "src/version.h"
6

7 8 9
#include "include/v8-version.h"
#include "src/utils.h"

10
// Define SONAME to have the build system put a specific SONAME into the
11
// shared library instead the generic SONAME generated from the V8 version
12
// number. This define is mainly used by the build system script.
13 14
#define SONAME            ""

15
#if V8_IS_CANDIDATE_VERSION
16
#define CANDIDATE_STRING " (candidate)"
17
#else
18
#define CANDIDATE_STRING ""
19 20 21 22 23
#endif

#define SX(x) #x
#define S(x) SX(x)

24 25 26 27
#if V8_PATCH_LEVEL > 0
#define VERSION_STRING                                                      \
  S(V8_MAJOR_VERSION) "." S(V8_MINOR_VERSION) "." S(V8_BUILD_NUMBER) "." S( \
      V8_PATCH_LEVEL) CANDIDATE_STRING
28
#else
29 30 31
#define VERSION_STRING                                               \
  S(V8_MAJOR_VERSION) "." S(V8_MINOR_VERSION) "." S(V8_BUILD_NUMBER) \
      CANDIDATE_STRING
32 33
#endif

34 35
namespace v8 {
namespace internal {
36

37 38 39 40 41
int Version::major_ = V8_MAJOR_VERSION;
int Version::minor_ = V8_MINOR_VERSION;
int Version::build_ = V8_BUILD_NUMBER;
int Version::patch_ = V8_PATCH_LEVEL;
bool Version::candidate_ = (V8_IS_CANDIDATE_VERSION != 0);
42
const char* Version::soname_ = SONAME;
43
const char* Version::version_string_ = VERSION_STRING;
44 45 46 47

// Calculate the V8 version string.
void Version::GetString(Vector<char> str) {
  const char* candidate = IsCandidate() ? " (candidate)" : "";
48 49 50 51 52
#ifdef USE_SIMULATOR
  const char* is_simulator = " SIMULATOR";
#else
  const char* is_simulator = "";
#endif  // USE_SIMULATOR
53
  if (GetPatch() > 0) {
54 55 56
    SNPrintF(str, "%d.%d.%d.%d%s%s",
             GetMajor(), GetMinor(), GetBuild(), GetPatch(), candidate,
             is_simulator);
57
  } else {
58 59 60
    SNPrintF(str, "%d.%d.%d%s%s",
             GetMajor(), GetMinor(), GetBuild(), candidate,
             is_simulator);
61 62 63 64 65 66 67 68 69 70
  }
}


// Calculate the SONAME for the V8 shared library.
void Version::GetSONAME(Vector<char> str) {
  if (soname_ == NULL || *soname_ == '\0') {
    // Generate generic SONAME if no specific SONAME is defined.
    const char* candidate = IsCandidate() ? "-candidate" : "";
    if (GetPatch() > 0) {
71 72
      SNPrintF(str, "libv8-%d.%d.%d.%d%s.so",
               GetMajor(), GetMinor(), GetBuild(), GetPatch(), candidate);
73
    } else {
74 75
      SNPrintF(str, "libv8-%d.%d.%d%s.so",
               GetMajor(), GetMinor(), GetBuild(), candidate);
76 77 78
    }
  } else {
    // Use specific SONAME.
79
    SNPrintF(str, "%s", soname_);
80 81 82
  }
}

83 84
}  // namespace internal
}  // namespace v8