Ben Murdoch | 692be65 | 2012-01-10 18:47:50 +0000 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 4 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 5 | #include "src/version.h" |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 6 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 7 | #include "include/v8-version.h" |
| 8 | #include "src/utils.h" |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 9 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 10 | // Define SONAME to have the build system put a specific SONAME into the |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 11 | // shared library instead the generic SONAME generated from the V8 version |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 12 | // number. This define is mainly used by the build system script. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 13 | #define SONAME "" |
| 14 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 15 | #if V8_IS_CANDIDATE_VERSION |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 16 | #define CANDIDATE_STRING " (candidate)" |
| 17 | #else |
| 18 | #define CANDIDATE_STRING "" |
| 19 | #endif |
| 20 | |
| 21 | #define SX(x) #x |
| 22 | #define S(x) SX(x) |
| 23 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 24 | #if V8_PATCH_LEVEL > 0 |
| 25 | #define VERSION_STRING \ |
| 26 | S(V8_MAJOR_VERSION) "." S(V8_MINOR_VERSION) "." S(V8_BUILD_NUMBER) "." S( \ |
| 27 | V8_PATCH_LEVEL) CANDIDATE_STRING |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 28 | #else |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 29 | #define VERSION_STRING \ |
| 30 | S(V8_MAJOR_VERSION) "." S(V8_MINOR_VERSION) "." S(V8_BUILD_NUMBER) \ |
| 31 | CANDIDATE_STRING |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 32 | #endif |
| 33 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 34 | namespace v8 { |
| 35 | namespace internal { |
| 36 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 37 | int Version::major_ = V8_MAJOR_VERSION; |
| 38 | int Version::minor_ = V8_MINOR_VERSION; |
| 39 | int Version::build_ = V8_BUILD_NUMBER; |
| 40 | int Version::patch_ = V8_PATCH_LEVEL; |
| 41 | bool Version::candidate_ = (V8_IS_CANDIDATE_VERSION != 0); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 42 | const char* Version::soname_ = SONAME; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 43 | const char* Version::version_string_ = VERSION_STRING; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 44 | |
| 45 | // Calculate the V8 version string. |
| 46 | void Version::GetString(Vector<char> str) { |
| 47 | const char* candidate = IsCandidate() ? " (candidate)" : ""; |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 48 | #ifdef USE_SIMULATOR |
| 49 | const char* is_simulator = " SIMULATOR"; |
| 50 | #else |
| 51 | const char* is_simulator = ""; |
| 52 | #endif // USE_SIMULATOR |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 53 | if (GetPatch() > 0) { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 54 | SNPrintF(str, "%d.%d.%d.%d%s%s", |
| 55 | GetMajor(), GetMinor(), GetBuild(), GetPatch(), candidate, |
| 56 | is_simulator); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 57 | } else { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 58 | SNPrintF(str, "%d.%d.%d%s%s", |
| 59 | GetMajor(), GetMinor(), GetBuild(), candidate, |
| 60 | is_simulator); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 61 | } |
| 62 | } |
| 63 | |
| 64 | |
| 65 | // Calculate the SONAME for the V8 shared library. |
| 66 | void Version::GetSONAME(Vector<char> str) { |
| 67 | if (soname_ == NULL || *soname_ == '\0') { |
| 68 | // Generate generic SONAME if no specific SONAME is defined. |
| 69 | const char* candidate = IsCandidate() ? "-candidate" : ""; |
| 70 | if (GetPatch() > 0) { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 71 | SNPrintF(str, "libv8-%d.%d.%d.%d%s.so", |
| 72 | GetMajor(), GetMinor(), GetBuild(), GetPatch(), candidate); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 73 | } else { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 74 | SNPrintF(str, "libv8-%d.%d.%d%s.so", |
| 75 | GetMajor(), GetMinor(), GetBuild(), candidate); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 76 | } |
| 77 | } else { |
| 78 | // Use specific SONAME. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 79 | SNPrintF(str, "%s", soname_); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 80 | } |
| 81 | } |
| 82 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 83 | } // namespace internal |
| 84 | } // namespace v8 |