FD.io VPP  v17.04.2-2-ga8f93f8
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 static char *vpe_version_string =
20  "vpp v" VPP_BUILD_VER
21  " built by " VPP_BUILD_USER " on " VPP_BUILD_HOST " at " VPP_BUILD_DATE;
22 
23 static char *vpe_compiler =
24 #if defined(__INTEL_COMPILER)
25 #define __(x) #x
26 #define _(x) __(x)
27  "icc " _(__INTEL_COMPILER) " (" __VERSION__ ")";
28 #undef _
29 #undef __
30 #elif defined(__clang__)
31  "Clang/LLVM " __clang_version__;
32 #elif defined (__GNUC__)
33  "GCC " __VERSION__;
34 #else
35  "unknown compiler";
36 #endif
37 
38 static clib_error_t *
40  unformat_input_t * input,
41  vlib_cli_command_t * cmd)
42 {
43  if (unformat (input, "verbose"))
44  {
45 #define _(a,b,c) vlib_cli_output (vm, "%-25s " b, a ":", c);
46  _("Version", "%s", "v" VPP_BUILD_VER);
47  _("Compiled by", "%s", VPP_BUILD_USER);
48  _("Compile host", "%s", VPP_BUILD_HOST);
49  _("Compile date", "%s", VPP_BUILD_DATE);
50  _("Compile location", "%s", VPP_BUILD_TOPDIR);
51  _("Compiler", "%s", vpe_compiler);
52  _("Current PID", "%d", getpid ());
53 #undef _
54  }
55  else
57  return 0;
58 }
59 
60 /* *INDENT-OFF* */
61 VLIB_CLI_COMMAND (show_vpe_version_command, static) = {
62  .path = "show version",
63  .short_help = "show version information",
64  .function = show_vpe_version_command_fn,
65 };
66 /* *INDENT-ON* */
67 
68 char *
70 {
71  return VPP_BUILD_TOPDIR;
72 }
73 
74 char *
76 {
77  return VPP_BUILD_VER;
78 }
79 
80 char *
82 {
83  return VPP_BUILD_DATE;
84 }
85 
86 /*
87  * fd.io coding-style-patch-verification: ON
88  *
89  * Local Variables:
90  * eval: (c-set-style "gnu")
91  * End:
92  */
static char * vpe_compiler
Definition: version.c:23
static char * vpe_version_string
Definition: version.c:19
char * vpe_api_get_version(void)
Definition: version.c:75
struct _unformat_input_t unformat_input_t
vlib_main_t * vm
Definition: buffer.c:276
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:39
char * vpe_api_get_build_directory(void)
Definition: version.c:69
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
char * vpe_api_get_build_date(void)
Definition: version.c:81
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:577
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:971