[v2,1/4] build: add single source of DPDK version number

Message ID 20190307133502.55321-2-bruce.richardson@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series One versionfile to rule them all... |

Checks

Context Check Description
ci/intel-Performance-Testing success Performance Testing PASS
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Bruce Richardson March 7, 2019, 1:34 p.m. UTC
  Add a new file DPDK_VERSION to hold the current DPDK version number.
Have meson use this file for it's project version, and have make use
it for reporting out "showversion" and "showversionum".

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Luca Boccassi <bluca@debian.org>

---
v2: fix typos and include Luca's ack.
---
 DPDK_VERSION        |  1 +
 meson.build         |  4 +++-
 mk/rte.sdkconfig.mk | 16 ++--------------
 3 files changed, 6 insertions(+), 15 deletions(-)
 create mode 100644 DPDK_VERSION
  

Comments

Thomas Monjalon March 13, 2019, 11:06 a.m. UTC | #1
07/03/2019 14:34, Bruce Richardson:
> Add a new file DPDK_VERSION to hold the current DPDK version number.
> Have meson use this file for it's project version, and have make use
> it for reporting out "showversion" and "showversionum".
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> Acked-by: Luca Boccassi <bluca@debian.org>
[...]
> --- /dev/null
> +++ b/DPDK_VERSION

Why not VERSION ?

[...]
> --- a/mk/rte.sdkconfig.mk
> +++ b/mk/rte.sdkconfig.mk
>  showversion:
> -	@set -- \
> -		$$(sed -rne 's,^#define RTE_VER_[A-Z_]*[[:space:]]+([0-9]+).*,\1,p' \
> -			-e 's,^#define RTE_VER_SUFFIX[[:space:]]+"(.*)",\1,p' \
> -			$(RTE_SRCDIR)/lib/librte_eal/common/include/rte_version.h) ;\
> -		printf '%d.%02d.%d' "$$1" "$$2" "$$3"; \
> -		if [ -z "$$5" ]; then echo; \
> -		else printf '%s' "$$4"; \
> -			if [ $$5 -lt 16 ] ; then echo $$5; \
> -			else echo $$(($$5 - 16)); fi; \
> -		fi
> +	@cat $(RTE_SRCDIR)/DPDK_VERSION

I'm a bit sad about removing this complex command ;)
  
Bruce Richardson March 13, 2019, 11:17 a.m. UTC | #2
On Wed, Mar 13, 2019 at 12:06:38PM +0100, Thomas Monjalon wrote:
> 07/03/2019 14:34, Bruce Richardson:
> > Add a new file DPDK_VERSION to hold the current DPDK version number.
> > Have meson use this file for it's project version, and have make use
> > it for reporting out "showversion" and "showversionum".
> > 
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > Acked-by: Luca Boccassi <bluca@debian.org>
> [...]
> > --- /dev/null
> > +++ b/DPDK_VERSION
> 
> Why not VERSION ?
> 

No particular reason. I just picked a name I thought reasonable, but I'm
fine with just VERSION on its own.

The one advantage of having DPDK in the title is that if one has a clone to
a directory called e.g. "temp", a quick "ls" will show the forgetful what
product it was that they cloned to a directory with such an unhelpful name.

> [...]
> > --- a/mk/rte.sdkconfig.mk
> > +++ b/mk/rte.sdkconfig.mk
> >  showversion:
> > -	@set -- \
> > -		$$(sed -rne 's,^#define RTE_VER_[A-Z_]*[[:space:]]+([0-9]+).*,\1,p' \
> > -			-e 's,^#define RTE_VER_SUFFIX[[:space:]]+"(.*)",\1,p' \
> > -			$(RTE_SRCDIR)/lib/librte_eal/common/include/rte_version.h) ;\
> > -		printf '%d.%02d.%d' "$$1" "$$2" "$$3"; \
> > -		if [ -z "$$5" ]; then echo; \
> > -		else printf '%s' "$$4"; \
> > -			if [ $$5 -lt 16 ] ; then echo $$5; \
> > -			else echo $$(($$5 - 16)); fi; \
> > -		fi
> > +	@cat $(RTE_SRCDIR)/DPDK_VERSION
> 
> I'm a bit sad about removing this complex command ;)
> 
Yes, but don't worry, I'm proposing a bit of an addition of sed and awk
to other makefile commands to compensate, though sadly not quite as
unintelligable to the masses as this. :-)
  
Thomas Monjalon March 13, 2019, 11:23 a.m. UTC | #3
13/03/2019 12:17, Bruce Richardson:
> On Wed, Mar 13, 2019 at 12:06:38PM +0100, Thomas Monjalon wrote:
> > 07/03/2019 14:34, Bruce Richardson:
> > > Add a new file DPDK_VERSION to hold the current DPDK version number.
> > > Have meson use this file for it's project version, and have make use
> > > it for reporting out "showversion" and "showversionum".
> > > 
> > > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > > Acked-by: Luca Boccassi <bluca@debian.org>
> > [...]
> > > --- /dev/null
> > > +++ b/DPDK_VERSION
> > 
> > Why not VERSION ?
> > 
> 
> No particular reason. I just picked a name I thought reasonable, but I'm
> fine with just VERSION on its own.
> 
> The one advantage of having DPDK in the title is that if one has a clone to
> a directory called e.g. "temp", a quick "ls" will show the forgetful what
> product it was that they cloned to a directory with such an unhelpful name.

Good try of justification :)

I think I prefer just VERSION.

> > [...]
> > > --- a/mk/rte.sdkconfig.mk
> > > +++ b/mk/rte.sdkconfig.mk
> > >  showversion:
> > > -	@set -- \
> > > -		$$(sed -rne 's,^#define RTE_VER_[A-Z_]*[[:space:]]+([0-9]+).*,\1,p' \
> > > -			-e 's,^#define RTE_VER_SUFFIX[[:space:]]+"(.*)",\1,p' \
> > > -			$(RTE_SRCDIR)/lib/librte_eal/common/include/rte_version.h) ;\
> > > -		printf '%d.%02d.%d' "$$1" "$$2" "$$3"; \
> > > -		if [ -z "$$5" ]; then echo; \
> > > -		else printf '%s' "$$4"; \
> > > -			if [ $$5 -lt 16 ] ; then echo $$5; \
> > > -			else echo $$(($$5 - 16)); fi; \
> > > -		fi
> > > +	@cat $(RTE_SRCDIR)/DPDK_VERSION
> > 
> > I'm a bit sad about removing this complex command ;)
> > 
> Yes, but don't worry, I'm proposing a bit of an addition of sed and awk
> to other makefile commands to compensate, though sadly not quite as
> unintelligable to the masses as this. :-)

I can teach you :)
  
Bruce Richardson March 13, 2019, 11:27 a.m. UTC | #4
On Wed, Mar 13, 2019 at 12:23:16PM +0100, Thomas Monjalon wrote:
> 13/03/2019 12:17, Bruce Richardson:
> > On Wed, Mar 13, 2019 at 12:06:38PM +0100, Thomas Monjalon wrote:
> > > 07/03/2019 14:34, Bruce Richardson:
> > > > Add a new file DPDK_VERSION to hold the current DPDK version number.
> > > > Have meson use this file for it's project version, and have make use
> > > > it for reporting out "showversion" and "showversionum".
> > > > 
> > > > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > > > Acked-by: Luca Boccassi <bluca@debian.org>
> > > [...]
> > > > --- /dev/null
> > > > +++ b/DPDK_VERSION
> > > 
> > > Why not VERSION ?
> > > 
> > 
> > No particular reason. I just picked a name I thought reasonable, but I'm
> > fine with just VERSION on its own.
> > 
> > The one advantage of having DPDK in the title is that if one has a clone to
> > a directory called e.g. "temp", a quick "ls" will show the forgetful what
> > product it was that they cloned to a directory with such an unhelpful name.
> 
> Good try of justification :)
>
Worth a shot! :-)
 
> I think I prefer just VERSION.
> 
Ok, will change in V2.

> > > [...]
> > > > --- a/mk/rte.sdkconfig.mk
> > > > +++ b/mk/rte.sdkconfig.mk
> > > >  showversion:
> > > > -	@set -- \
> > > > -		$$(sed -rne 's,^#define RTE_VER_[A-Z_]*[[:space:]]+([0-9]+).*,\1,p' \
> > > > -			-e 's,^#define RTE_VER_SUFFIX[[:space:]]+"(.*)",\1,p' \
> > > > -			$(RTE_SRCDIR)/lib/librte_eal/common/include/rte_version.h) ;\
> > > > -		printf '%d.%02d.%d' "$$1" "$$2" "$$3"; \
> > > > -		if [ -z "$$5" ]; then echo; \
> > > > -		else printf '%s' "$$4"; \
> > > > -			if [ $$5 -lt 16 ] ; then echo $$5; \
> > > > -			else echo $$(($$5 - 16)); fi; \
> > > > -		fi
> > > > +	@cat $(RTE_SRCDIR)/DPDK_VERSION
> > > 
> > > I'm a bit sad about removing this complex command ;)
> > > 
> > Yes, but don't worry, I'm proposing a bit of an addition of sed and awk
> > to other makefile commands to compensate, though sadly not quite as
> > unintelligable to the masses as this. :-)
> 
> I can teach you :)
>
Thanks, but I think I'll pass on that opportunity! :-)
  

Patch

diff --git a/DPDK_VERSION b/DPDK_VERSION
new file mode 100644
index 000000000..c4a4cd00b
--- /dev/null
+++ b/DPDK_VERSION
@@ -0,0 +1 @@ 
+19.05.0-rc0
diff --git a/meson.build b/meson.build
index 69833de82..aaa6002ae 100644
--- a/meson.build
+++ b/meson.build
@@ -2,7 +2,9 @@ 
 # Copyright(c) 2017 Intel Corporation
 
 project('DPDK', 'C',
-	version: '19.05.0-rc0',
+	# get version number from file
+	# use "more" rather than "cat" for windows compatibility
+	version: run_command('more', files('DPDK_VERSION')).stdout().strip(),
 	license: 'BSD',
 	default_options: ['buildtype=release', 'default_library=static'],
 	meson_version: '>= 0.47.1'
diff --git a/mk/rte.sdkconfig.mk b/mk/rte.sdkconfig.mk
index fa77331cb..d9c8d53d2 100644
--- a/mk/rte.sdkconfig.mk
+++ b/mk/rte.sdkconfig.mk
@@ -3,23 +3,11 @@ 
 
 .PHONY: showversion
 showversion:
-	@set -- \
-		$$(sed -rne 's,^#define RTE_VER_[A-Z_]*[[:space:]]+([0-9]+).*,\1,p' \
-			-e 's,^#define RTE_VER_SUFFIX[[:space:]]+"(.*)",\1,p' \
-			$(RTE_SRCDIR)/lib/librte_eal/common/include/rte_version.h) ;\
-		printf '%d.%02d.%d' "$$1" "$$2" "$$3"; \
-		if [ -z "$$5" ]; then echo; \
-		else printf '%s' "$$4"; \
-			if [ $$5 -lt 16 ] ; then echo $$5; \
-			else echo $$(($$5 - 16)); fi; \
-		fi
+	@cat $(RTE_SRCDIR)/DPDK_VERSION
 
 .PHONY: showversionum
 showversionum:
-	@set -- \
-		$$(sed -rne 's,^#define RTE_VER_[A-Z_]*[[:space:]]+([0-9]+).*,\1,p' \
-			$(RTE_SRCDIR)/lib/librte_eal/common/include/rte_version.h); \
-		printf '%02d%02d\n' "$$1" "$$2"
+	@cat $(RTE_SRCDIR)/DPDK_VERSION | awk -F '.' '{print $$1$$2}'
 
 INSTALL_CONFIGS := $(sort $(filter-out %~,\
 	$(patsubst $(RTE_SRCDIR)/config/defconfig_%,%,\