Merge "Add DPDK version in "show version verbose" output"
[vpp.git] / vpp / app / version.c
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 <app/version.h>
17 #include <rte_version.h>
18
19 static char * vpe_version_string = 
20     "vpp v" VPP_BUILD_VER 
21     " built by " VPP_BUILD_USER 
22     " on " VPP_BUILD_HOST 
23     " at " VPP_BUILD_DATE;
24 static char * vpe_dir_string = "Built in " VPP_BUILD_TOPDIR;
25
26 static char * vpe_compiler = "Compiled with "
27 #if defined(__INTEL_COMPILER)
28 #define __(x) #x
29 #define _(x) __(x)
30         "icc " _(__INTEL_COMPILER) " (" __VERSION__ ")";
31 #undef _
32 #undef __
33 #elif defined(__clang__)
34         "Clang/LLVM " __clang_version__;
35 #elif defined (__GNUC__)
36         "GCC " __VERSION__;
37 #else
38         "unknown compiler";
39 #endif
40
41 static clib_error_t *
42 show_vpe_version_command_fn (vlib_main_t * vm,
43                  unformat_input_t * input,
44                  vlib_cli_command_t * cmd)
45 {
46   vlib_cli_output (vm, "%s", vpe_version_string);
47   if (unformat (input, "verbose")){
48      vlib_cli_output (vm, "%s", vpe_dir_string);
49      vlib_cli_output (vm, "%s", vpe_compiler);
50      vlib_cli_output (vm, "DPDK version is %s", rte_version());
51   }
52   return 0;
53 }
54
55 VLIB_CLI_COMMAND (show_vpe_version_command, static) = {
56   .path = "show version",
57   .short_help = "show version information",
58   .function = show_vpe_version_command_fn,
59 };
60
61 char * vpe_api_get_build_directory (void) 
62 {
63   return VPP_BUILD_TOPDIR;
64 }
65
66 char * vpe_api_get_version (void) 
67 {
68   return VPP_BUILD_VER;
69 }
70 char * vpe_api_get_build_date (void) 
71 {
72   return VPP_BUILD_DATE;
73 }