usertools: script to output version string
PATCH v2 1/1 usertools: script to output version string
--- usertools/dpdk-version.sh | 124 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100755 usertools/dpdk-version.sh
usertools/dpdk-version.sh new file +124 -0
@@ -0,0 +1,124 @@ +#!/bin/bash +# +# BSD LICENSE +# +# Copyright(c) 2017 Intel Corporation. All rights reserved. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# Locate the rte_version.h file and parse out the version strings. +# +# If RTE_SDK is set, then it is used to locate the file. If the +# RTE_SDK variable is not set then the current working directory +# is used. +# +# See usage below for more details. +# + +fname=rte_version.h + +function usage() { + cat <<EOM + Usage: dpdk-version.sh + + Locate the rte_version.h file and parse out the version information. + + If RTE_SDK is set, then it is used to locate the file. If the + RTE_SDK variable is not set then the current working directory + is used. + + The default output of the version is 'DPDK Version: YY.MM.MINOR' + e.g. 'dpdk-version.sh' gives 'DPDK Version: 17.08.0' + + Options: Only one option can be used at a time. + + '-h' prints usage messages + + '-l' prints out the full version string + e.g. 'dpdk-version.sh -l' gives 'DPDK-17.08.0-rc0' + + '-s' prints a shorter version string + e.g. 'dpdk-version.sh -s' gives '17.08.0' + + '-m' prints out information is comma delimited format. + e.g. 'dpdk-version.sh -m' give 'DPDK,17,08,0,-rc0' + + '-p' prints out a Python readable format of the version. + e.g. 'dpdk-version.sh -m' gives + + version = { + 'prefix': 'DPDK', + 'year': '17', + 'month': '08', + 'minor': '0', + 'suffix': '-rc' + } +EOM + exit 1 +} + +if [ -z ${RTE_SDK} ] ; then + echo "*** RTE_SDK is not set, using "${PWD} + sdk=${PWD} +else + sdk=${RTE_SDK} +fi + +fpath=${sdk}/lib/librte_eal/common/include/${fname} + +if [ ! -e ${fpath} ]; then + echo "File not found @ "${fpath} + usage +fi + +PREFIX=`grep "define RTE_VER_PREFIX" ${fpath} | cut -d ' ' -f 3 | sed -e 's/\"//g'` +SUFFIX=`grep "define RTE_VER_SUFFIX" ${fpath} | cut -d ' ' -f 3 | sed -e 's/\"//g'` + +YY=`grep "define RTE_VER_YEAR" ${fpath} | cut -d ' ' -f 3` +MM=`grep "define RTE_VER_MONTH" ${fpath} | cut -d ' ' -f 3` +MINOR=`grep "define RTE_VER_MINOR" ${fpath} | cut -d ' ' -f 3` + +if [ "$1" = "-h" ]; then + usage +elif [ "$1" = "-l" ]; then + echo ${PREFIX}-${YY}.${MM}.${MINOR}${SUFFIX} +elif [ "$1" = '-s' ]; then + echo ${YY}.${MM}.${MINOR} +elif [ "$1" = "-p" ]; then + echo "dpdk_version = {" + echo " 'prefix': '"${PREFIX}"'," + echo " 'year': '"${YY}"'," + echo " 'month': '"${MM}"'," + echo " 'minor': '"${MINOR}"'," + echo " 'suffix': '"${SUFFIX}"'" + echo "}" +elif [ "$1" = "-m" ]; then + echo ""${PREFIX}","${YY}","${MM}","${MINOR}","${SUFFIX}"" +else + echo "DPDK Version: "${YY}.${MM}.${MINOR} +fi
Signature · 1 line
2.11.0
Hi,
06/07/2017 16:56, Keith Wiles:
Quoted 1 line
+# Locate the
rte_version.hfile and parse out the version strings.
I think this script is not needed because we have already something in mk/rte.sdkconfig.mk.
Example:
% make showversion 17.08.0-rc4
Do you need more?
Quoted 13 lines · Thomas Monjalon
Hi,
06/07/2017 16:56, Keith Wiles:
Quoted 1 line
+# Locate the
rte_version.hfile and parse out the version strings.I think this script is not needed because we have already something in
mk/rte.sdkconfig.mk.
Example:% make showversion 17.08.0-rc4
Executing make to find out a version seems to bit of over kill to me and a simple script would be much easier IMO. I do not really see harm in having this script that can output the version into different formats is helpful when running external scripts. Also in the future we are most like going to replace the build system and then we would need to add this support to that build system and having it in a standalone script is easier manage in the long run.
Quoted 2 lines
Do you need more?
Regards,
Keith
07/08/2017 15:17, Wiles, Keith:
Quoted 8 lines
Quoted 8 lines · Thomas Monjalon
Hi,
06/07/2017 16:56, Keith Wiles:
Quoted 1 line
+# Locate the
rte_version.hfile and parse out the version strings.
Quoted 7 lines
Quoted 5 lines
I think this script is not needed because we have already something in
mk/rte.sdkconfig.mk.
Example:% make showversion 17.08.0-rc4Executing make to find out a version seems to bit of over kill to me and a simple script would be much easier IMO. I do not really see harm in having this script that can output the version into different formats is helpful when running external scripts. Also in the future we are most like going to replace the build system and then we would need to add this support to that build system and having it in a standalone script is easier manage in the long run.
"make showversion" is here for several years. Usually we do not implement the same thing in several places without a good reason.
And some users can use the old command.
Especially when talking about versions, it is very convenient to use the same command in every versions.
That's why I insist: why implementing it differently? If it is only about the new build system, it should be part of the build system migration plan (long term).
Quoted 18 lines · Thomas Monjalon
07/08/2017 15:17, Wiles, Keith:
Quoted 14 lines
Quoted 13 lines · Thomas Monjalon
Hi,
06/07/2017 16:56, Keith Wiles:
Quoted 1 line
+# Locate the
rte_version.hfile and parse out the version strings.I think this script is not needed because we have already something in
mk/rte.sdkconfig.mk.
Example:% make showversion 17.08.0-rc4
Quoted 8 lines
Quoted 1 line
Executing make to find out a version seems to bit of over kill to me and a simple script would be much easier IMO. I do not really see harm in having this script that can output the version into different formats is helpful when running external scripts. Also in the future we are most like going to replace the build system and then we would need to add this support to that build system and having it in a standalone script is easier manage in the long run.
"make showversion" is here for several years. Usually we do not implement the same thing in several places without a good reason.
And some users can use the old command.
Especially when talking about versions, it is very convenient to use the same command in every versions.
I grep’d the repo and found couple references to showversion.
./devtools/git-log-fixes.sh:72: make showversion | cut -d'.' -f-2
./doc/guides/conf.py:67:version = subprocess.check_output(['make', '-sRrC', '../../', 'showversion']) ./mk/rte.sdkconfig.mk:32:.PHONY: showversion
./mk/rte.sdkconfig.mk:33:showversion:
./mk/rte.sdkconfig.mk:45:.PHONY: showversionum ./mk/rte.sdkconfig.mk:46:showversionum:./mk/rte.sdkdoc.mk:76: $(MAKE) -rRs showversion && \
./mk/rte.sdkroot.mk:91:.PHONY: config defconfig showconfigs showversion showversionum ./mk/rte.sdkroot.mk:92:config defconfig showconfigs showversion showversionum:
Which means to me this was a completely undocumented feature, which is why I created this shell script. This also means the feature was not used widely. Then I suggest we remove the 'make showversion' and use the script in the usertools dir, which is easier to find and does not require the use of Make or Makefile at all. The script allows you to print the version from any directory as long as RTE_SDK is defined or if you are located in a SDK directory. Also allows the developer/user to execute dpdk-version.sh from the installed location or the RTE_SDK/usertools directory. I have the changes already to install dpdk-version.h tool during build like the other tools, but have not submitted it yet. I can also update the documents to help users find the tool.
Quoted 4 lines
That's why I insist: why implementing it differently? If it is only about the new build system, it should be part of the build system migration plan (long term).
Regards,
Keith
Quoted 39 lines · Keith)
Quoted 17 lines · Thomas Monjalon
07/08/2017 15:17, Wiles, Keith:
Quoted 14 lines
Quoted 13 lines · Thomas Monjalon
Hi,
06/07/2017 16:56, Keith Wiles:
Quoted 1 line
+# Locate the
rte_version.hfile and parse out the version strings.I think this script is not needed because we have already something in
mk/rte.sdkconfig.mk.
Example:% make showversion 17.08.0-rc4Quoted 8 lines
Quoted 1 line
Executing make to find out a version seems to bit of over kill to me and a simple script would be much easier IMO. I do not really see harm in having this script that can output the version into different formats is helpful when running external scripts. Also in the future we are most like going to replace the build system and then we would need to add this support to that build system and having it in a standalone script is easier manage in the long run.
"make showversion" is here for several years. Usually we do not implement the same thing in several places without a good reason.
And some users can use the old command.
Especially when talking about versions, it is very convenient to use the same command in every versions.I grep?d the repo and found couple references to showversion.
./devtools/git-log-fixes.sh:72: make showversion | cut -d'.' -f-2
./doc/guides/conf.py:67:version =subprocess.check_output(['make', '-sRrC', '../../', 'showversion'])./mk/rte.sdkconfig.mk:32:.PHONY: showversion
./mk/rte.sdkconfig.mk:33:showversion:
./mk/rte.sdkconfig.mk:45:.PHONY: showversionum ./mk/rte.sdkconfig.mk:46:showversionum:./mk/rte.sdkdoc.mk:76: $(MAKE) -rRs showversion && \
./mk/rte.sdkroot.mk:91:.PHONY: config defconfig showconfigs showversion showversionum ./mk/rte.sdkroot.mk:92:config defconfig showconfigs showversion showversionum:
Quoted 1 line
Which means to me this was a completely undocumented feature, which is why I created this shell script. This also means the feature was not used widely. Then I suggest we remove the 'make showversion' and use the script in the usertools dir, which is easier to find and does not require the use of Make or
Makefileat all. The script allows you to print the version from any directory as long asRTE_SDKis defined or if you are located in a SDK directory. Also allows the developer/user to executedpdk-version.shfrom the installed location or the RTE_SDK/usertools directory. I have the changes already to installdpdk-version.htool during build like the other tools, but have not submitted it yet. I can also update the documents to help users find the tool.
Hi Keith,
This patch is also sitting in the patchwork for a long time without a decision.
I am not against this script explicitly, but we already has a solution what this script does and I don't see the motivation to replace it.
Perhaps we may need it when switched to meson, I don't know if we have a solution in meson, cc'ed Luca for comment.
Unless there is a demand/need for it, I am for updating it as rejected.
Thanks,
ferruh
Quoted 10 lines
Quoted 5 lines
That's why I insist: why implementing it differently? If it is only about the new build system, it should be part of the build system migration plan (long term).
Regards,
Keith
Quoted 44 lines · Ferruh Yigit
Quoted 39 lines · Keith)
Quoted 17 lines · Thomas Monjalon
07/08/2017 15:17, Wiles, Keith:
Quoted 14 lines
Quoted 13 lines · Thomas Monjalon
Hi,
06/07/2017 16:56, Keith Wiles:
Quoted 1 line
+# Locate the
rte_version.hfile and parse out the version strings.I think this script is not needed because we have already something in
mk/rte.sdkconfig.mk.
Example:% make showversion 17.08.0-rc4Quoted 8 lines
Quoted 1 line
Executing make to find out a version seems to bit of over kill to me and a simple script would be much easier IMO. I do not really see harm in having this script that can output the version into different formats is helpful when running external scripts. Also in the future we are most like going to replace the build system and then we would need to add this support to that build system and having it in a standalone script is easier manage in the long run.
"make showversion" is here for several years. Usually we do not implement the same thing in several places without a good reason.
And some users can use the old command.
Especially when talking about versions, it is very convenient to use the same command in every versions.I grep?d the repo and found couple references to showversion.
./devtools/git-log-fixes.sh:72: make showversion | cut -d'.' -f-2
./doc/guides/conf.py:67:version =subprocess.check_output(['make', '-sRrC', '../../', 'showversion'])./mk/rte.sdkconfig.mk:32:.PHONY: showversion
./mk/rte.sdkconfig.mk:33:showversion:
./mk/rte.sdkconfig.mk:45:.PHONY: showversionum ./mk/rte.sdkconfig.mk:46:showversionum:./mk/rte.sdkdoc.mk:76: $(MAKE) -rRs showversion && \
./mk/rte.sdkroot.mk:91:.PHONY: config defconfig showconfigs showversion showversionum ./mk/rte.sdkroot.mk:92:config defconfig showconfigs showversion showversionum:Quoted 1 line
Which means to me this was a completely undocumented feature, which is why I created this shell script. This also means the feature was not used widely. Then I suggest we remove the 'make showversion' and use the script in the usertools dir, which is easier to find and does not require the use of Make or
Makefileat all. The script allows you to print the version from any directory as long asRTE_SDKis defined or if you are located in a SDK directory. Also allows the developer/user to executedpdk-version.shfrom the installed location or the RTE_SDK/usertools directory. I have the changes already to installdpdk-version.htool during build like the other tools, but have not submitted it yet. I can also update the documents to help users find the tool.Hi Keith,
Quoted 8 lines
This patch is also sitting in the patchwork for a long time without a decision.
I am not against this script explicitly, but we already has a solution what this script does and I don't see the motivation to replace it.
Perhaps we may need it when switched to meson, I don't know if we have a solution in meson, cc'ed Luca for comment.Unless there is a demand/need for it, I am for updating it as rejected.
It seems meson does not have this feature but also it needs to have the version information in root folder meson file, which is easier to implement to grep it and get this information.
This patch can be referenced when it is needed, but for now removed from backlog.
Quoted 15 lines
Thanks,
ferruhQuoted 10 lines
Quoted 5 lines
That's why I insist: why implementing it differently? If it is only about the new build system, it should be part of the build system migration plan (long term).
Regards,
Keith