diff options
author | 2015-12-12 14:40:59 +0100 | |
---|---|---|
committer | 2015-12-13 18:18:27 +0100 | |
commit | a0d4a1a6d1b81b132787e382ac3f8487b71cf52c (patch) | |
tree | aabeaa39e8b0e6db087e993c9acecadbf84811b7 /vpp | |
parent | 29726ab117a1fc5b3d92d1afaaaaa08ef7f138eb (diff) |
new version handling
Change-Id: I90983f3df94a3b28199908b29ffd8f827ab0c379
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'vpp')
-rw-r--r-- | vpp/Makefile.am | 22 | ||||
-rw-r--r-- | vpp/Makefile.in | 20 | ||||
-rw-r--r-- | vpp/api/api.c | 6 | ||||
-rw-r--r-- | vpp/api/vpe.api | 4 | ||||
-rw-r--r-- | vpp/app/version.c | 52 |
5 files changed, 77 insertions, 27 deletions
diff --git a/vpp/Makefile.am b/vpp/Makefile.am index eef0ff6fedc..1e3bbf08ebd 100644 --- a/vpp/Makefile.am +++ b/vpp/Makefile.am @@ -49,18 +49,16 @@ nobase_include_HEADERS = \ apidir = $(prefix)/api api_DATA = api/vpe.api -BUILT_SOURCES += api/vpe.api.h app/version.c - -.PHONY: app/version.c - -app/version.c: - @pushd ../../../vpp ; \ - branch=`git rev-parse --abbrev-ref HEAD` ; \ - popd ; \ - if [ x$$GITTAG = "x" ] ; then \ - GITTAG=$$USER-private ; \ - fi ; \ - vppversion -p vpe -b $${branch}@$${GITTAG} -o $@ +BUILT_SOURCES += api/vpe.api.h app/version.h + +.PHONY: app/version.h + +app/version.h: ../build-root/scripts/version + @echo "#define VPP_BUILD_DATE \"$$(date)\"" > $@ + @echo "#define VPP_BUILD_USER \"$$(whoami)\"" >> $@ + @echo "#define VPP_BUILD_HOST \"$$(hostname)\"" >> $@ + @echo "#define VPP_BUILD_TOPDIR \"$$(git rev-parse --show-toplevel)\"" >> $@ + @echo "#define VPP_BUILD_VER \"$$(../../scripts/version)\"" >> $@ vpe_LDADD = -lvlibapi -lvlibmemory -lvlib_unix -lvlib diff --git a/vpp/Makefile.in b/vpp/Makefile.in index 643f41e9158..17f3a8cddf1 100644 --- a/vpp/Makefile.in +++ b/vpp/Makefile.in @@ -368,7 +368,7 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = foreign subdir-objects AM_CFLAGS = -Wall @Q_PLATFORM_DEFINE@ @Q_PLATFORM_PLUGPATH@ @DPDK@ -BUILT_SOURCES = api/vpe.api.h app/version.c +BUILT_SOURCES = api/vpe.api.h app/version.h CLEANFILES = lib_LTLIBRARIES = @@ -1074,17 +1074,17 @@ uninstall-am: uninstall-apiDATA uninstall-binPROGRAMS \ uninstall-binPROGRAMS uninstall-libLTLIBRARIES \ uninstall-nobase_includeHEADERS +.PRECIOUS: Makefile + -.PHONY: app/version.c +.PHONY: app/version.h -app/version.c: - @pushd ../../../vpp ; \ - branch=`git rev-parse --abbrev-ref HEAD` ; \ - popd ; \ - if [ x$$GITTAG = "x" ] ; then \ - GITTAG=$$USER-private ; \ - fi ; \ - vppversion -p vpe -b $${branch}@$${GITTAG} -o $@ +app/version.h: ../build-root/scripts/version + @echo "#define VPP_BUILD_DATE \"$$(date)\"" > $@ + @echo "#define VPP_BUILD_USER \"$$(whoami)\"" >> $@ + @echo "#define VPP_BUILD_HOST \"$$(hostname)\"" >> $@ + @echo "#define VPP_BUILD_TOPDIR \"$$(git rev-parse --show-toplevel)\"" >> $@ + @echo "#define VPP_BUILD_VER \"$$(../../scripts/version)\"" >> $@ %.api.h: %.api @echo " APIGEN " $@ ; \ diff --git a/vpp/api/api.c b/vpp/api/api.c index 57eaa7237f6..a1e7f020e6c 100644 --- a/vpp/api/api.c +++ b/vpp/api/api.c @@ -3915,7 +3915,7 @@ vl_api_show_version_t_handler (vl_api_show_version_t *mp) vl_api_show_version_reply_t *rmp; int rv = 0; char * vpe_api_get_build_directory(void); - char * vpe_api_get_branch(void); + char * vpe_api_get_version(void); char * vpe_api_get_build_date(void); unix_shared_memory_queue_t * q = @@ -3929,8 +3929,8 @@ vl_api_show_version_t_handler (vl_api_show_version_t *mp) strncpy ((char *) rmp->program, "vpe", ARRAY_LEN(rmp->program)-1); strncpy ((char *) rmp->build_directory, vpe_api_get_build_directory(), ARRAY_LEN(rmp->build_directory)-1); - strncpy ((char *) rmp->git_branch, vpe_api_get_branch(), - ARRAY_LEN(rmp->git_branch)-1); + strncpy ((char *) rmp->version, vpe_api_get_version(), + ARRAY_LEN(rmp->version)-1); strncpy ((char *) rmp->build_date, vpe_api_get_build_date(), ARRAY_LEN(rmp->build_date)-1); })); diff --git a/vpp/api/vpe.api b/vpp/api/vpe.api index 4301f549b4c..480558aa4c2 100644 --- a/vpp/api/vpe.api +++ b/vpp/api/vpe.api @@ -1988,14 +1988,14 @@ define show_version { @param context - sender context, to match reply w/ request @param retval - return code for the request @param program - name of the program (vpe) + @param version - version of the program @param build_directory - root of the workspace where the program was built - @param git_branch - the git branch for the workspace */ manual_java define show_version_reply { u32 context; i32 retval; u8 program[32]; - u8 git_branch[32]; + u8 version[32]; u8 build_date[32]; u8 build_directory[256]; }; diff --git a/vpp/app/version.c b/vpp/app/version.c new file mode 100644 index 00000000000..354c0296306 --- /dev/null +++ b/vpp/app/version.c @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include <vlib/vlib.h> +#include <app/version.h> + +static char * vpe_version_string = +"vpp v" VPP_BUILD_VER " built by " VPP_BUILD_USER " on " VPP_BUILD_HOST " at " VPP_BUILD_DATE; +static char * vpe_dir_string = "workspace is " VPP_BUILD_TOPDIR; + +static clib_error_t * +show_vpe_version_command_fn (vlib_main_t * vm, + unformat_input_t * input, + vlib_cli_command_t * cmd) +{ + vlib_cli_output (vm, "%s", vpe_version_string); + if (unformat (input, "verbose")){ + vlib_cli_output (vm, "%s", vpe_dir_string); + } + return 0; +} + +VLIB_CLI_COMMAND (show_vpe_version_command, static) = { + .path = "show version", + .short_help = "show version information", + .function = show_vpe_version_command_fn, +}; + +char * vpe_api_get_build_directory (void) +{ + return VPP_BUILD_TOPDIR; +} + +char * vpe_api_get_version (void) +{ + return VPP_BUILD_VER; +} +char * vpe_api_get_build_date (void) +{ + return VPP_BUILD_DATE; +} |