version.cc 2.09 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/utils/version.h"
6

7
#include "include/v8-version-string.h"
8
#include "include/v8-version.h"
9
#include "src/base/strings.h"
10
#include "src/utils/utils.h"
11

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

17 18
namespace v8 {
namespace internal {
19

20 21 22 23
int Version::major_ = V8_MAJOR_VERSION;
int Version::minor_ = V8_MINOR_VERSION;
int Version::build_ = V8_BUILD_NUMBER;
int Version::patch_ = V8_PATCH_LEVEL;
24
const char* Version::embedder_ = V8_EMBEDDER_STRING;
25
bool Version::candidate_ = (V8_IS_CANDIDATE_VERSION != 0);
26
const char* Version::soname_ = SONAME;
27
const char* Version::version_string_ = V8_VERSION_STRING;
28 29

// Calculate the V8 version string.
30
void Version::GetString(base::Vector<char> str) {
31 32
  const char* candidate = IsCandidate() ? " (candidate)" : "";
  if (GetPatch() > 0) {
33 34
    base::SNPrintF(str, "%d.%d.%d.%d%s%s", GetMajor(), GetMinor(), GetBuild(),
                   GetPatch(), GetEmbedder(), candidate);
35
  } else {
36 37
    base::SNPrintF(str, "%d.%d.%d%s%s", GetMajor(), GetMinor(), GetBuild(),
                   GetEmbedder(), candidate);
38 39 40 41
  }
}

// Calculate the SONAME for the V8 shared library.
42
void Version::GetSONAME(base::Vector<char> str) {
43
  if (soname_ == nullptr || *soname_ == '\0') {
44 45 46
    // Generate generic SONAME if no specific SONAME is defined.
    const char* candidate = IsCandidate() ? "-candidate" : "";
    if (GetPatch() > 0) {
47 48
      SNPrintF(str, "libv8-%d.%d.%d.%d%s%s.so", GetMajor(), GetMinor(),
               GetBuild(), GetPatch(), GetEmbedder(), candidate);
49
    } else {
50 51
      SNPrintF(str, "libv8-%d.%d.%d%s%s.so", GetMajor(), GetMinor(), GetBuild(),
               GetEmbedder(), candidate);
52 53 54
    }
  } else {
    // Use specific SONAME.
55
    SNPrintF(str, "%s", soname_);
56 57 58
  }
}

59 60
#undef SONAME

61 62
}  // namespace internal
}  // namespace v8