FD.io VPP  v18.07-rc0-415-g6c78436
Vector Packet Processing
version.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include <vlib/vlib.h>
16 #include <vppinfra/cpu.h>
17 #include <vpp/app/version.h>
18 
19 /* N.B. Variable is not static to ensure it's visible in core dumps, i.e.,
20  * it doesn't go to rodata segment */
22  "vpp v" VPP_BUILD_VER
23  " built by " VPP_BUILD_USER " on " VPP_BUILD_HOST " at " VPP_BUILD_DATE;
24 
25 static char *vpe_compiler =
26 #if defined(__INTEL_COMPILER)
27 #define __(x) #x
28 #define _(x) __(x)
29  "icc " _(__INTEL_COMPILER) " (" __VERSION__ ")";
30 #undef _
31 #undef __
32 #elif defined(__clang__)
33  "Clang/LLVM " __clang_version__;
34 #elif defined (__GNUC__)
35  "GCC " __VERSION__;
36 #else
37  "unknown compiler";
38 #endif
39 
40 static clib_error_t *
42  unformat_input_t * input,
43  vlib_cli_command_t * cmd)
44 {
45  if (unformat (input, "verbose"))
46  {
47 #define _(a,b,c) vlib_cli_output (vm, "%-25s " b, a ":", c);
48  _("Version", "%s", "v" VPP_BUILD_VER);
49  _("Compiled by", "%s", VPP_BUILD_USER);
50  _("Compile host", "%s", VPP_BUILD_HOST);
51  _("Compile date", "%s", VPP_BUILD_DATE);
52  _("Compile location", "%s", VPP_BUILD_TOPDIR);
53  _("Compiler", "%s", vpe_compiler);
54  _("Current PID", "%d", getpid ());
55 #undef _
56  }
57  else
59  return 0;
60 }
61 
62 /* *INDENT-OFF* */
63 VLIB_CLI_COMMAND (show_vpe_version_command, static) = {
64  .path = "show version",
65  .short_help = "show version information",
66  .function = show_vpe_version_command_fn,
67 };
68 /* *INDENT-ON* */
69 
70 char *
72 {
73  return VPP_BUILD_TOPDIR;
74 }
75 
76 char *
78 {
79  return VPP_BUILD_VER;
80 }
81 
82 char *
84 {
85  return VPP_BUILD_DATE;
86 }
87 
88 /*
89  * fd.io coding-style-patch-verification: ON
90  *
91  * Local Variables:
92  * eval: (c-set-style "gnu")
93  * End:
94  */
static char * vpe_compiler
Definition: version.c:25
char * vpe_version_string
Definition: version.c:21
char * vpe_api_get_version(void)
Definition: version.c:77
struct _unformat_input_t unformat_input_t
vlib_main_t * vm
Definition: buffer.c:294
static clib_error_t * show_vpe_version_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: version.c:41
char * vpe_api_get_build_directory(void)
Definition: version.c:71
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
char * vpe_api_get_build_date(void)
Definition: version.c:83
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:681
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972