Merge "Move rpc handler where it belongs, related cleanup"
[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
18 static char * vpe_version_string = 
19     "vpp v" VPP_BUILD_VER 
20     " built by " VPP_BUILD_USER 
21     " on " VPP_BUILD_HOST 
22     " at " VPP_BUILD_DATE;
23 static char * vpe_dir_string = "Built in " VPP_BUILD_TOPDIR;
24
25 static char * vpe_compiler = "Compiled with "
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 *
41 show_vpe_version_command_fn (vlib_main_t * vm,
42                  unformat_input_t * input,
43                  vlib_cli_command_t * cmd)
44 {
45   vlib_cli_output (vm, "%s", vpe_version_string);
46   if (unformat (input, "verbose")){
47      vlib_cli_output (vm, "%s", vpe_dir_string);
48      vlib_cli_output (vm, "%s", vpe_compiler);
49   }
50   return 0;
51 }
52
53 VLIB_CLI_COMMAND (show_vpe_version_command, static) = {
54   .path = "show version",
55   .short_help = "show version information",
56   .function = show_vpe_version_command_fn,
57 };
58
59 char * vpe_api_get_build_directory (void) 
60 {
61   return VPP_BUILD_TOPDIR;
62 }
63
64 char * vpe_api_get_version (void) 
65 {
66   return VPP_BUILD_VER;
67 }
68 char * vpe_api_get_build_date (void) 
69 {
70   return VPP_BUILD_DATE;
71 }