Skip to contentSkip to conversation

One versionfile to rule them all...

RFC PATCH Superseded Bruce Richardson 5 participants 32 messages Mar 7, 2019 – Mar 27, 2019 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover One versionfile to rule them all...

Right now with DPDK we have two sources of version information - the rte_version.h header file containing macros for C use, and the project version number in the project definition in meson.build. This is not optimal, so this patchset aims to provide a single source for the DPDK version. The options considered are:

* Keep version info in rte_version.h only. The two reasons this was not chosen were:
1) parsing the version number from the header is awkward, as seen in the rte.sdkconfig.mk file, and a script to do so would be needed to integrate that into the meson build project definition.
2) rte_version.h is not in an obvious location inside the project when a user clones from git. It's hidden away in the "lib/librte_eal/common/include" folder. Ideally the version number should be evident at the top level of the DPDK tree.

* Keep version info in meson.build file only. This seemed a better option than keeping the info in rte_version.h, but it still had disadvantages:
1) For make, using grep on meson.build to extract the version seemed a bit awkward, though doable. Splitting the version was tricky too, but managable with a small amount of scripting.
2) There was no easy way to have users access the version number when "make showversion" was deprecated with the make build system.

* Store the version number in a new version file at the root level of the repo.
* This did have the advantage of being easily discoverable on clone
* Still had the disadvantage of needing some parsing to generate the defines from rte_version.h

Since the last option seemed best, that is what is implemented in this set. The file DPDK_VERSION is added to store the version number, and make and meson both use that as their source of version info. For C code, the rte_version.h header remains, except that the basic definitions of the release YEAR, MONTH, MINOR etc. are moved to be automatically generated as part of rte_config.h. For make builds, this is done via using the preprocessor to insert the values when it generates the config. For meson builds, this is done by just adding the values to the dpdk_conf configuration object.

Bruce Richardson (4):
build: add single source of DPDK version number
build: use version number from config file
build: move meson version handling to config directory
eal: remove unneeded version logic

 DPDK_VERSION                                |  1 +
 config/common_base                          | 14 ++++++++
 config/meson.build                          | 26 +++++++++++++++
 config/rte_config.h                         |  5 +++
 lib/librte_eal/common/include/rte_version.h | 36 +--------------------
 meson.build                                 | 14 +-------
 mk/rte.sdkconfig.mk                         | 18 +++--------
 7 files changed, 52 insertions(+), 62 deletions(-)
 create mode 100644 DPDK_VERSION
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/4 build: add single source of DPDK version number

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".

---
 DPDK_VERSION        |  1 +
 meson.build         |  2 +-
 mk/rte.sdkconfig.mk | 16 ++--------------
 3 files changed, 4 insertions(+), 15 deletions(-)
 create mode 100644 DPDK_VERSION
DPDK_VERSION new file +1 -0
new file mode 100644
index 000000000..c4a4cd00b
@@ -0,0 +1 @@
+19.05.0-rc0
meson.build +3 -1
index 69833de82..757618144 100644
@@ -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 compatiblity
+	version: run_command('more', files('DPDK_VERSION')).stdout().strip(),
 	license: 'BSD',
 	default_options: ['buildtype=release', 'default_library=static'],
 	meson_version: '>= 0.47.1'
mk/rte.sdkconfig.mk +2 -14
index fa77331cb..8dc31d7cf 100644
@@ -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_%,%,\
Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH 1/4] build: add single source of DPDK version number

Quoted 24 lines · 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".

---
 DPDK_VERSION        |  1 +
 meson.build         |  2 +-
 mk/rte.sdkconfig.mk | 16 ++--------------
 3 files changed, 4 insertions(+), 15 deletions(-)
 create mode 100644 DPDK_VERSION
DPDK_VERSION new file +1 -0
new file mode 100644
index 000000000..c4a4cd00b
@@ -0,0 +1 @@
+19.05.0-rc0
meson.build +0 -0
index 69833de82..757618144 100644

meson.build line 7

Quoted 7 lines
meson.build +2 -1
@@ -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 compatiblity
 

compatibility

+ version: run_command('more',

Quoted 35 lines
meson.build +0 -0
 files('DPDK_VERSION')).stdout().strip(),
        license: 'BSD',
        default_options: ['buildtype=release', 'default_library=static'],
        meson_version: '>= 0.47.1'
mk/rte.sdkconfig.mk +1 -13
index fa77331cb..8dc31d7cf 100644
@@ -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); \

mk/rte.sdkconfig.mk line 10

Quoted 2 lines
mk/rte.sdkconfig.mk +1 -1
-               printf '%02d%02d\n' "$$1" "$$2"
+       @cat ${RTE_SRCDIR}/DPDK_VERSION | awk -F '.' '{print $$1$$2}'

s/{RTE_SRCDIR}/(RTE_SRCDIR)/

Quoted 4 lines
 INSTALL_CONFIGS := $(sort $(filter-out %~,\
        $(patsubst $(RTE_SRCDIR)/config/defconfig_%,%,\
Signature · 1 line
David Marchand
#3 lore raw

PATCH 2/4 build: use version number from config file

In reply to Bruce Richardson

Since we have the version number in a separate file at the root level, we should not need to duplicate this in rte_version.h too. Best approach here is to move the macros for specifying the year/month/etc. parts from the version header file to the build config file - leaving the other utility macros for e.g. printing the version string, where they are.

For make this is done by having a little bit of awk parse the version file and pass the results through to the preprocessor for the config generation stage.

For meson, this is done by parsing the version and adding it to the standard dpdk_conf object.

---
 DPDK_VERSION                                |  2 +-
 config/common_base                          | 14 +++++++++
 config/rte_config.h                         |  5 ++++
 lib/librte_eal/common/include/rte_version.h | 32 ---------------------
 meson.build                                 | 14 +++++++++
 mk/rte.sdkconfig.mk                         |  2 ++
 6 files changed, 36 insertions(+), 33 deletions(-)
DPDK_VERSION +1 -1
index c4a4cd00b..e013b54dd 100644
@@ -1 +1 @@
-19.05.0-rc0
+19.05.1
config/common_base +14 -0
index 0b09a9348..6292bc4af 100644
@@ -1,6 +1,20 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2010-2017 Intel Corporation
 
+#
+# String that appears before the version number
+#
+CONFIG_RTE_VER_PREFIX="DPDK"
+
+#
+# Version information completed when this file is processed for a build
+#
+CONFIG_RTE_VER_YEAR=__YEAR
+CONFIG_RTE_VER_MONTH=__MONTH
+CONFIG_RTE_VER_MINOR=__MINOR
+CONFIG_RTE_VER_SUFFIX=__SUFFIX
+CONFIG_RTE_VER_RELEASE=__RELEASE
+
 #
 # define executive environment
 # RTE_EXEC_ENV values are the directories in mk/exec-env/
config/rte_config.h +5 -0
index 7606f5d7b..5f1749dbb 100644
@@ -18,6 +18,11 @@
 
 #include <rte_build_config.h>
 
+/**
+ * String that appears before the version number
+ */
+#define RTE_VER_PREFIX "DPDK"
+
 /****** library defines ********/
 
 /* compat defines */
lib/librte_eal/common/include/rte_version.h +0 -32
index a7eed7ab7..50867ea81 100644
@@ -19,38 +19,6 @@ extern "C" {
 #include <stdio.h>
 #include <rte_common.h>
 
-/**
- * String that appears before the version number
- */
-#define RTE_VER_PREFIX "DPDK"
-
-/**
- * Major version/year number i.e. the yy in yy.mm.z
- */
-#define RTE_VER_YEAR 19
-
-/**
- * Minor version/month number i.e. the mm in yy.mm.z
- */
-#define RTE_VER_MONTH 5
-
-/**
- * Patch level number i.e. the z in yy.mm.z
- */
-#define RTE_VER_MINOR 0
-
-/**
- * Extra string to be appended to version number
- */
-#define RTE_VER_SUFFIX "-rc"
-
-/**
- * Patch release number
- *   0-15 = release candidates
- *   16   = release
- */
-#define RTE_VER_RELEASE 0
-
 /**
  * Macro to compute a version number usable for comparisons
  */
meson.build +14 -0
index 757618144..9d5320395 100644
@@ -22,6 +22,20 @@ dpdk_app_link_libraries = []
 pver = meson.project_version().split('.')
 major_version = '@0@.@1@'.format(pver.get(0), pver.get(1))
 
+# extract all version information into the build configuration
+dpdk_conf.set('RTE_VER_YEAR', pver.get(0))
+dpdk_conf.set('RTE_VER_MONTH', pver.get(1))
+if pver.get(2).contains('-rc')
+	rc_ver = pver.get(2).split('-rc')
+	dpdk_conf.set('RTE_VER_MINOR', rc_ver.get(0))
+	dpdk_conf.set_quoted('RTE_VER_SUFFIX', '-rc')
+	dpdk_conf.set('RTE_VER_RELEASE', rc_ver.get(1))
+else
+	dpdk_conf.set('RTE_VER_MINOR', pver.get(2))
+	dpdk_conf.set_quoted('RTE_VER_SUFFIX', '')
+	dpdk_conf.set('RTE_VER_RELEASE', 0)
+endif
+
 pmd_subdir_opt = get_option('drivers_install_subdir')
 if pmd_subdir_opt.contains('<VERSION>')
 	pmd_subdir_opt = major_version.join(pmd_subdir_opt.split('<VERSION>'))
mk/rte.sdkconfig.mk +2 -0
index 8dc31d7cf..bbfa24dee 100644
@@ -76,6 +76,8 @@ else
 $(RTE_OUTPUT)/.config: $(RTE_CONFIG_TEMPLATE) FORCE | $(RTE_OUTPUT)
 	$(Q)if [ "$(RTE_CONFIG_TEMPLATE)" != "" -a -f "$(RTE_CONFIG_TEMPLATE)" ]; then \
 		$(CPP) -undef -P -x assembler-with-cpp \
+		`cat $(RTE_SRCDIR)/DPDK_VERSION | sed -e 's/-rc/.-rc./' | \
+		awk -F '.' '{print "-D__YEAR="$$1, "-D__MONTH="$$2, "-D__MINOR="$$3, "-D__SUFFIX=\""$$4"\"", "-D__RELEASE="int($$5)}'` \
 		-ffreestanding \
 		-o $(RTE_OUTPUT)/.config_tmp $(RTE_CONFIG_TEMPLATE) ; \
 		config=$$(cat $(RTE_OUTPUT)/.config_tmp) ; \
Signature · 1 line
2.20.1
#4 lore raw

Re: [PATCH 2/4] build: use version number from config file

Quoted 30 lines · Bruce Richardson

Since we have the version number in a separate file at the root level, we should not need to duplicate this in rte_version.h too. Best approach here is to move the macros for specifying the year/month/etc. parts from the version header file to the build config file - leaving the other utility macros for e.g. printing the version string, where they are.

For make this is done by having a little bit of awk parse the version file and pass the results through to the preprocessor for the config generation stage.

For meson, this is done by parsing the version and adding it to the standard dpdk_conf object.

---
 DPDK_VERSION                                |  2 +-
 config/common_base                          | 14 +++++++++
 config/rte_config.h                         |  5 ++++
 lib/librte_eal/common/include/rte_version.h | 32 ---------------------
 meson.build                                 | 14 +++++++++
 mk/rte.sdkconfig.mk                         |  2 ++
 6 files changed, 36 insertions(+), 33 deletions(-)
DPDK_VERSION +0 -0
index c4a4cd00b..e013b54dd 100644

DPDK_VERSION line 1

Quoted 2 lines
DPDK_VERSION +1 -1
@@ -1 +1 @@
-19.05.0-rc0
+19.05.1

Might be a bit early for the stable while the 19.05 is still being cooked :-)

config/common_base +0 -0
Quoted 12 lines

index 0b09a9348..6292bc4af 100644

config/common_base +5 -0
@@ -1,6 +1,20 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2010-2017 Intel Corporation
 
+#
+# String that appears before the version number
+#
+CONFIG_RTE_VER_PREFIX="DPDK"
+

config/common_base line 18

Quoted 10 lines
config/common_base +9 -0
+#
+# Version information completed when this file is processed for a build
+#
+CONFIG_RTE_VER_YEAR=__YEAR
+CONFIG_RTE_VER_MONTH=__MONTH
+CONFIG_RTE_VER_MINOR=__MINOR
+CONFIG_RTE_VER_SUFFIX=__SUFFIX
+CONFIG_RTE_VER_RELEASE=__RELEASE
+
 

?
I think you broke make support.

== Build lib/librte_eal/linuxapp/eal
CC eal.o
In file included from /home/dmarchan/git/pub/dpdk/lib/librte_eal/linuxapp/eal/eal.c:49:0:
/home/dmarchan/git/pub/dpdk/master/include/rte_version.h: In function ‘rte_version’:
/home/dmarchan/git/pub/dpdk/master/include/rte_version.h:47:13: error:
‘RTE_VER_SUFFIX’ undeclared (first use in this function)
if (strlen(RTE_VER_SUFFIX) == 0)

             ^

/home/dmarchan/git/pub/dpdk/master/include/rte_version.h:47:13: note: each undeclared identifier is reported only once for each function it appears in /home/dmarchan/git/pub/dpdk/master/include/rte_version.h:49:4: error:
‘RTE_VER_PREFIX’ undeclared (first use in this function)

    RTE_VER_PREFIX,
    ^
/home/dmarchan/git/pub/dpdk/master/include/rte_version.h:50:4: error:
‘RTE_VER_YEAR’ undeclared (first use in this function)
    RTE_VER_YEAR,
    ^
/home/dmarchan/git/pub/dpdk/master/include/rte_version.h:51:4: error:
‘RTE_VER_MONTH’ undeclared (first use in this function)
    RTE_VER_MONTH,
    ^
/home/dmarchan/git/pub/dpdk/master/include/rte_version.h:52:4: error:
‘RTE_VER_MINOR’ undeclared (first use in this function)
    RTE_VER_MINOR);
    ^
/home/dmarchan/git/pub/dpdk/master/include/rte_version.h:60:4: error:
‘RTE_VER_RELEASE’ undeclared (first use in this function)
    RTE_VER_RELEASE);
    ^

make[5]: *** [eal.o] Error 1 make[4]: *** [eal] Error 2 make[3]: *** [linuxapp] Error 2 make[2]: *** [librte_eal] Error 2 make[1]: *** [lib] Error 2
make: *** [all] Error 2

#

Quoted 93 lines
config/common_base +0 -0
 # define executive environment
 # RTE_EXEC_ENV values are the directories in mk/exec-env/
config/rte_config.h +5 -0
index 7606f5d7b..5f1749dbb 100644
@@ -18,6 +18,11 @@
 
 #include <rte_build_config.h>
 
+/**
+ * String that appears before the version number
+ */
+#define RTE_VER_PREFIX "DPDK"
+
 /****** library defines ********/
 
 /* compat defines */
lib/librte_eal/common/include/rte_version.h +0 -32
index a7eed7ab7..50867ea81 100644
@@ -19,38 +19,6 @@ extern "C" {
 #include <stdio.h>
 #include <rte_common.h>
 
-/**
- * String that appears before the version number
- */
-#define RTE_VER_PREFIX "DPDK"
-
-/**
- * Major version/year number i.e. the yy in yy.mm.z
- */
-#define RTE_VER_YEAR 19
-
-/**
- * Minor version/month number i.e. the mm in yy.mm.z
- */
-#define RTE_VER_MONTH 5
-
-/**
- * Patch level number i.e. the z in yy.mm.z
- */
-#define RTE_VER_MINOR 0
-
-/**
- * Extra string to be appended to version number
- */
-#define RTE_VER_SUFFIX "-rc"
-
-/**
- * Patch release number
- *   0-15 = release candidates
- *   16   = release
- */
-#define RTE_VER_RELEASE 0
-
 /**
  * Macro to compute a version number usable for comparisons
  */
meson.build +14 -0
index 757618144..9d5320395 100644
@@ -22,6 +22,20 @@ dpdk_app_link_libraries = []
 pver = meson.project_version().split('.')
 major_version = '@0@.@1@'.format(pver.get(0), pver.get(1))
 
+# extract all version information into the build configuration
+dpdk_conf.set('RTE_VER_YEAR', pver.get(0))
+dpdk_conf.set('RTE_VER_MONTH', pver.get(1))
+if pver.get(2).contains('-rc')
+       rc_ver = pver.get(2).split('-rc')
+       dpdk_conf.set('RTE_VER_MINOR', rc_ver.get(0))
+       dpdk_conf.set_quoted('RTE_VER_SUFFIX', '-rc')
+       dpdk_conf.set('RTE_VER_RELEASE', rc_ver.get(1))
+else
+       dpdk_conf.set('RTE_VER_MINOR', pver.get(2))
+       dpdk_conf.set_quoted('RTE_VER_SUFFIX', '')
+       dpdk_conf.set('RTE_VER_RELEASE', 0)
+endif
+
 pmd_subdir_opt = get_option('drivers_install_subdir')
 if pmd_subdir_opt.contains('<VERSION>')
        pmd_subdir_opt =

major_version.join(pmd_subdir_opt.split('<VERSION>'))

mk/rte.sdkconfig.mk +0 -0
index 8dc31d7cf..bbfa24dee 100644

mk/rte.sdkconfig.mk else · line 83

Quoted 8 lines
mk/rte.sdkconfig.mk +2 -0
@@ -76,6 +76,8 @@ else
 $(RTE_OUTPUT)/.config: $(RTE_CONFIG_TEMPLATE) FORCE | $(RTE_OUTPUT)
        $(Q)if [ "$(RTE_CONFIG_TEMPLATE)" != "" -a -f
 "$(RTE_CONFIG_TEMPLATE)" ]; then \
                $(CPP) -undef -P -x assembler-with-cpp \
+               `cat $(RTE_SRCDIR)/DPDK_VERSION | sed -e 's/-rc/.-rc./' | \
+               awk -F '.' '{print "-D__YEAR="$$1, "-D__MONTH="$$2,
 "-D__MINOR="$$3, "-D__SUFFIX=\""$$4"\"", "-D__RELEASE="int($$5)}'` \
 

Can't we just pass the RTE_VER_XXX as CFLAGS here ?

                -ffreestanding \
Quoted 6 lines
                -o $(RTE_OUTPUT)/.config_tmp $(RTE_CONFIG_TEMPLATE) ; \
                config=$$(cat $(RTE_OUTPUT)/.config_tmp) ; \

--
2.20.1

Signature · 1 line
David Marchand
#5 lore raw

Re: [PATCH 2/4] build: use version number from config file

Quoted 207 lines · David Marchand
Quoted 30 lines · Bruce Richardson

Since we have the version number in a separate file at the root level, we should not need to duplicate this in rte_version.h too. Best approach here is to move the macros for specifying the year/month/etc. parts from the version header file to the build config file - leaving the other utility macros for e.g. printing the version string, where they are.

For make this is done by having a little bit of awk parse the version file and pass the results through to the preprocessor for the config generation stage.

For meson, this is done by parsing the version and adding it to the standard dpdk_conf object.

---
 DPDK_VERSION                                |  2 +-
 config/common_base                          | 14 +++++++++
 config/rte_config.h                         |  5 ++++
 lib/librte_eal/common/include/rte_version.h | 32 ---------------------
 meson.build                                 | 14 +++++++++
 mk/rte.sdkconfig.mk                         |  2 ++
 6 files changed, 36 insertions(+), 33 deletions(-)
DPDK_VERSION +0 -0
index c4a4cd00b..e013b54dd 100644

DPDK_VERSION line 1

Quoted 2 lines
DPDK_VERSION +1 -1
@@ -1 +1 @@
-19.05.0-rc0
+19.05.1

Might be a bit early for the stable while the 19.05 is still being cooked :-)

config/common_base +0 -0
Quoted 12 lines

index 0b09a9348..6292bc4af 100644

config/common_base +5 -0
@@ -1,6 +1,20 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2010-2017 Intel Corporation
 
+#
+# String that appears before the version number
+#
+CONFIG_RTE_VER_PREFIX="DPDK"
+

config/common_base line 18

Quoted 10 lines
config/common_base +9 -0
+#
+# Version information completed when this file is processed for a build
+#
+CONFIG_RTE_VER_YEAR=__YEAR
+CONFIG_RTE_VER_MONTH=__MONTH
+CONFIG_RTE_VER_MINOR=__MINOR
+CONFIG_RTE_VER_SUFFIX=__SUFFIX
+CONFIG_RTE_VER_RELEASE=__RELEASE
+
 

?
I think you broke make support.

== Build lib/librte_eal/linuxapp/eal
CC eal.o
In file included from /home/dmarchan/git/pub/dpdk/lib/librte_eal/linuxapp/eal/eal.c:49:0:
/home/dmarchan/git/pub/dpdk/master/include/rte_version.h: In function ‘rte_version’:
/home/dmarchan/git/pub/dpdk/master/include/rte_version.h:47:13: error:
‘RTE_VER_SUFFIX’ undeclared (first use in this function)
if (strlen(RTE_VER_SUFFIX) == 0)

             ^

/home/dmarchan/git/pub/dpdk/master/include/rte_version.h:47:13: note: each undeclared identifier is reported only once for each function it appears in /home/dmarchan/git/pub/dpdk/master/include/rte_version.h:49:4: error:
‘RTE_VER_PREFIX’ undeclared (first use in this function)

    RTE_VER_PREFIX,
    ^
/home/dmarchan/git/pub/dpdk/master/include/rte_version.h:50:4: error:
‘RTE_VER_YEAR’ undeclared (first use in this function)
    RTE_VER_YEAR,
    ^
/home/dmarchan/git/pub/dpdk/master/include/rte_version.h:51:4: error:
‘RTE_VER_MONTH’ undeclared (first use in this function)
    RTE_VER_MONTH,
    ^
/home/dmarchan/git/pub/dpdk/master/include/rte_version.h:52:4: error:
‘RTE_VER_MINOR’ undeclared (first use in this function)
    RTE_VER_MINOR);
    ^
/home/dmarchan/git/pub/dpdk/master/include/rte_version.h:60:4: error:
‘RTE_VER_RELEASE’ undeclared (first use in this function)
    RTE_VER_RELEASE);
    ^

make[5]: *** [eal.o] Error 1 make[4]: *** [eal] Error 2 make[3]: *** [linuxapp] Error 2 make[2]: *** [librte_eal] Error 2 make[1]: *** [lib] Error 2
make: *** [all] Error 2

#

Quoted 96 lines
config/common_base +0 -0
 # define executive environment
 # RTE_EXEC_ENV values are the directories in mk/exec-env/
config/rte_config.h +5 -0
index 7606f5d7b..5f1749dbb 100644
@@ -18,6 +18,11 @@
 
 #include <rte_build_config.h>
 
+/**
+ * String that appears before the version number
+ */
+#define RTE_VER_PREFIX "DPDK"
+
 /****** library defines ********/
 
 /* compat defines */
lib/librte_eal/common/include/rte_version.h +0 -32
index a7eed7ab7..50867ea81 100644
@@ -19,38 +19,6 @@ extern "C" {
 #include <stdio.h>
 #include <rte_common.h>
 
-/**
- * String that appears before the version number
- */
-#define RTE_VER_PREFIX "DPDK"
-
-/**
- * Major version/year number i.e. the yy in yy.mm.z
- */
-#define RTE_VER_YEAR 19
-
-/**
- * Minor version/month number i.e. the mm in yy.mm.z
- */
-#define RTE_VER_MONTH 5
-
-/**
- * Patch level number i.e. the z in yy.mm.z
- */
-#define RTE_VER_MINOR 0
-
-/**
- * Extra string to be appended to version number
- */
-#define RTE_VER_SUFFIX "-rc"
-
-/**
- * Patch release number
- *   0-15 = release candidates
- *   16   = release
- */
-#define RTE_VER_RELEASE 0
-
 /**
  * Macro to compute a version number usable for comparisons
  */
meson.build +14 -0
index 757618144..9d5320395 100644
@@ -22,6 +22,20 @@ dpdk_app_link_libraries = []
 pver = meson.project_version().split('.')
 major_version = '@0@.@1@'.format(pver.get(0), pver.get(1))
 
+# extract all version information into the build configuration
+dpdk_conf.set('RTE_VER_YEAR', pver.get(0))
+dpdk_conf.set('RTE_VER_MONTH', pver.get(1))
+if pver.get(2).contains('-rc')
+       rc_ver = pver.get(2).split('-rc')
+       dpdk_conf.set('RTE_VER_MINOR', rc_ver.get(0))
+       dpdk_conf.set_quoted('RTE_VER_SUFFIX', '-rc')
+       dpdk_conf.set('RTE_VER_RELEASE', rc_ver.get(1))
+else
+       dpdk_conf.set('RTE_VER_MINOR', pver.get(2))
+       dpdk_conf.set_quoted('RTE_VER_SUFFIX', '')
+       dpdk_conf.set('RTE_VER_RELEASE', 0)
+endif
+
 pmd_subdir_opt = get_option('drivers_install_subdir')
 if pmd_subdir_opt.contains('<VERSION>')
        pmd_subdir_opt =

major_version.join(pmd_subdir_opt.split('<VERSION>'))

mk/rte.sdkconfig.mk +0 -0
index 8dc31d7cf..bbfa24dee 100644
@@ -76,6 +76,8 @@ else
 $(RTE_OUTPUT)/.config: $(RTE_CONFIG_TEMPLATE) FORCE | $(RTE_OUTPUT)
        $(Q)if [ "$(RTE_CONFIG_TEMPLATE)" != "" -a -f
 "$(RTE_CONFIG_TEMPLATE)" ]; then \
Quoted 9 lines

mk/rte.sdkconfig.mk else · line 83

Quoted 6 lines
mk/rte.sdkconfig.mk +2 -0
                $(CPP) -undef -P -x assembler-with-cpp \
+               `cat $(RTE_SRCDIR)/DPDK_VERSION | sed -e 's/-rc/.-rc./' |
 \
+               awk -F '.' '{print "-D__YEAR="$$1, "-D__MONTH="$$2,
 "-D__MINOR="$$3, "-D__SUFFIX=\""$$4"\"", "-D__RELEASE="int($$5)}'` \

Can't we just pass the RTE_VER_XXX as CFLAGS here ?

Argh no, I mean passing RTE_VER_XXX as global CFLAGS.
I am not really a fan of having the version in the config file, but I have no real argument against it.

Signature · 1 line
David Marchand
#6 lore raw

Re: [PATCH 2/4] build: use version number from config file

Quoted 204 lines · David Marchand
   On Thu, Mar 7, 2019 at 1:37 PM David Marchand
   <[1][email protected]> wrote:

   On Thu, Mar 7, 2019 at 12:55 PM Bruce Richardson
   <[2][email protected]> wrote:

     Since we have the version number in a separate file at the root
     level,
     we should not need to duplicate this in rte_version.h too. Best
     approach here is to move the macros for specifying the
     year/month/etc.
     parts from the version header file to the build config file -
     leaving
     the other utility macros for e.g. printing the version string, where
     they
     are.
     For make this is done by having a little bit of awk parse the
     version
     file and pass the results through to the preprocessor for the config
     generation stage.
     For meson, this is done by parsing the version and adding it to the
     standard dpdk_conf object.
     Signed-off-by: Bruce Richardson <[3][email protected]>
     ---
      DPDK_VERSION                                |  2 +-
      config/common_base                          | 14 +++++++++
      config/rte_config.h                         |  5 ++++
      lib/librte_eal/common/include/rte_version.h | 32
     ---------------------
      meson.build                                 | 14 +++++++++
      mk/[4]rte.sdkconfig.mk                         |  2 ++
      6 files changed, 36 insertions(+), 33 deletions(-)
     diff --git a/DPDK_VERSION b/DPDK_VERSION
     index c4a4cd00b..e013b54dd 100644
     --- a/DPDK_VERSION
     +++ b/DPDK_VERSION
     @@ -1 +1 @@
     -19.05.0-rc0
     +19.05.1

   Might be a bit early for the stable while the 19.05 is still being
   cooked :-)

     diff --git a/config/common_base b/config/common_base
     index 0b09a9348..6292bc4af 100644
     --- a/config/common_base
     +++ b/config/common_base
     @@ -1,6 +1,20 @@
      # SPDX-License-Identifier: BSD-3-Clause
      # Copyright(c) 2010-2017 Intel Corporation
     +#
     +# String that appears before the version number
     +#
     +CONFIG_RTE_VER_PREFIX="DPDK"
     +
     +#
     +# Version information completed when this file is processed for a
     build
     +#
     +CONFIG_RTE_VER_YEAR=__YEAR
     +CONFIG_RTE_VER_MONTH=__MONTH
     +CONFIG_RTE_VER_MINOR=__MINOR
     +CONFIG_RTE_VER_SUFFIX=__SUFFIX
     +CONFIG_RTE_VER_RELEASE=__RELEASE
     +

   ?
   I think you broke make support.
   == Build lib/librte_eal/linuxapp/eal
     CC eal.o
   In file included from
   /home/dmarchan/git/pub/dpdk/lib/librte_eal/linuxapp/eal/eal.c:49:0:
   /home/dmarchan/git/pub/dpdk/master/include/rte_version.h: In function
   ‘rte_version’:
   /home/dmarchan/git/pub/dpdk/master/include/rte_version.h:47:13: error:
   ‘RTE_VER_SUFFIX’ undeclared (first use in this function)
     if (strlen(RTE_VER_SUFFIX) == 0)
                ^
   /home/dmarchan/git/pub/dpdk/master/include/rte_version.h:47:13: note:
   each undeclared identifier is reported only once for each function it
   appears in
   /home/dmarchan/git/pub/dpdk/master/include/rte_version.h:49:4: error:
   ‘RTE_VER_PREFIX’ undeclared (first use in this function)
       RTE_VER_PREFIX,
       ^
   /home/dmarchan/git/pub/dpdk/master/include/rte_version.h:50:4: error:
   ‘RTE_VER_YEAR’ undeclared (first use in this function)
       RTE_VER_YEAR,
       ^
   /home/dmarchan/git/pub/dpdk/master/include/rte_version.h:51:4: error:
   ‘RTE_VER_MONTH’ undeclared (first use in this function)
       RTE_VER_MONTH,
       ^
   /home/dmarchan/git/pub/dpdk/master/include/rte_version.h:52:4: error:
   ‘RTE_VER_MINOR’ undeclared (first use in this function)
       RTE_VER_MINOR);
       ^
   /home/dmarchan/git/pub/dpdk/master/include/rte_version.h:60:4: error:
   ‘RTE_VER_RELEASE’ undeclared (first use in this function)
       RTE_VER_RELEASE);
       ^
   make[5]: *** [eal.o] Error 1
   make[4]: *** [eal] Error 2
   make[3]: *** [linuxapp] Error 2
   make[2]: *** [librte_eal] Error 2
   make[1]: *** [lib] Error 2
   make: *** [all] Error 2

      #
      # define executive environment
      # RTE_EXEC_ENV values are the directories in mk/exec-env/
     diff --git a/config/rte_config.h b/config/rte_config.h
     index 7606f5d7b..5f1749dbb 100644
     --- a/config/rte_config.h
     +++ b/config/rte_config.h
     @@ -18,6 +18,11 @@
      #include <rte_build_config.h>
     +/**
     + * String that appears before the version number
     + */
     +#define RTE_VER_PREFIX "DPDK"
     +
      /****** library defines ********/
      /* compat defines */
     diff --git a/lib/librte_eal/common/include/rte_version.h
     b/lib/librte_eal/common/include/rte_version.h
     index a7eed7ab7..50867ea81 100644
     --- a/lib/librte_eal/common/include/rte_version.h
     +++ b/lib/librte_eal/common/include/rte_version.h
     @@ -19,38 +19,6 @@ extern "C" {
      #include <stdio.h>
      #include <rte_common.h>
     -/**
     - * String that appears before the version number
     - */
     -#define RTE_VER_PREFIX "DPDK"
     -
     -/**
     - * Major version/year number i.e. the yy in yy.mm.z
     - */
     -#define RTE_VER_YEAR 19
     -
     -/**
     - * Minor version/month number i.e. the mm in yy.mm.z
     - */
     -#define RTE_VER_MONTH 5
     -
     -/**
     - * Patch level number i.e. the z in yy.mm.z
     - */
     -#define RTE_VER_MINOR 0
     -
     -/**
     - * Extra string to be appended to version number
     - */
     -#define RTE_VER_SUFFIX "-rc"
     -
     -/**
     - * Patch release number
     - *   0-15 = release candidates
     - *   16   = release
     - */
     -#define RTE_VER_RELEASE 0
     -
      /**
       * Macro to compute a version number usable for comparisons
       */
     diff --git a/meson.build b/meson.build
     index 757618144..9d5320395 100644
     --- a/meson.build
     +++ b/meson.build
     @@ -22,6 +22,20 @@ dpdk_app_link_libraries = []
      pver = meson.project_version().split('.')
      major_version = '@0@.@1@'.format(pver.get(0), pver.get(1))
     +# extract all version information into the build configuration
     +dpdk_conf.set('RTE_VER_YEAR', pver.get(0))
     +dpdk_conf.set('RTE_VER_MONTH', pver.get(1))
     +if pver.get(2).contains('-rc')
     +       rc_ver = pver.get(2).split('-rc')
     +       dpdk_conf.set('RTE_VER_MINOR', rc_ver.get(0))
     +       dpdk_conf.set_quoted('RTE_VER_SUFFIX', '-rc')
     +       dpdk_conf.set('RTE_VER_RELEASE', rc_ver.get(1))
     +else
     +       dpdk_conf.set('RTE_VER_MINOR', pver.get(2))
     +       dpdk_conf.set_quoted('RTE_VER_SUFFIX', '')
     +       dpdk_conf.set('RTE_VER_RELEASE', 0)
     +endif
     +
      pmd_subdir_opt = get_option('drivers_install_subdir')
      if pmd_subdir_opt.contains('<VERSION>')
             pmd_subdir_opt =
     major_version.join(pmd_subdir_opt.split('<VERSION>'))
     diff --git a/mk/[5]rte.sdkconfig.mk b/mk/[6]rte.sdkconfig.mk
     index 8dc31d7cf..bbfa24dee 100644
     --- a/mk/[7]rte.sdkconfig.mk
     +++ b/mk/[8]rte.sdkconfig.mk
     @@ -76,6 +76,8 @@ else
      $(RTE_OUTPUT)/.config: $(RTE_CONFIG_TEMPLATE) FORCE | $(RTE_OUTPUT)
             $(Q)if [ "$(RTE_CONFIG_TEMPLATE)" != "" -a -f
     "$(RTE_CONFIG_TEMPLATE)" ]; then \
                     $(CPP) -undef -P -x assembler-with-cpp \
     +               `cat $(RTE_SRCDIR)/DPDK_VERSION | sed -e
     's/-rc/.-rc./' | \
     +               awk -F '.' '{print "-D__YEAR="$$1, "-D__MONTH="$$2,
Quoted 8 lines
     "-D__MINOR="$$3, "-D__SUFFIX=\""$$4"\"", "-D__RELEASE="int($$5)}'` \

   Can't we just pass the RTE_VER_XXX as CFLAGS here ?

   Argh no, I mean passing RTE_VER_XXX as global CFLAGS.
   I am not really a fan of having the version in the config file, but I
   have no real argument against it.
   --

We could do that, but that makes things more awkward for consumers as they need to pass those same flags when compiling up their application. Better to have them placed in the header file along with the other defines.

/Bruce

#7 lore raw

Re: [PATCH 2/4] build: use version number from config file

In reply to David Marchand
Quoted 37 lines · David Marchand

On Thu, Mar 7, 2019 at 12:55 PM Bruce Richardson <[1][email protected]> wrote:

Since we have the version number in a separate file at the root level,
we should not need to duplicate this in rte_version.h too. Best approach here is to move the macros for specifying the year/month/etc.
parts from the version header file to the build config file - leaving
the other utility macros for e.g. printing the version string, where they
are.
For make this is done by having a little bit of awk parse the version
file and pass the results through to the preprocessor for the config generation stage.
For meson, this is done by parsing the version and adding it to the standard dpdk_conf object.

---
DPDK_VERSION | 2 +-
config/common_base | 14 +++++++++
config/rte_config.h | 5 ++++
lib/librte_eal/common/include/rte_version.h | 32
---------------------
meson.build | 14 +++++++++
mk/[3]rte.sdkconfig.mk | 2 ++
6 files changed, 36 insertions(+), 33 deletions(-)
diff --git a/DPDK_VERSION b/DPDK_VERSION index c4a4cd00b..e013b54dd 100644
--- a/DPDK_VERSION
+++ b/DPDK_VERSION
@@ -1 +1 @@
-19.05.0-rc0
+19.05.1

Quoted 3 lines

Might be a bit early for the stable while the 19.05 is still being cooked :-)

Oops, didn't realise that testing change had crept in.

Quoted 23 lines
     diff --git a/config/common_base b/config/common_base
     index 0b09a9348..6292bc4af 100644
     --- a/config/common_base
     +++ b/config/common_base
     @@ -1,6 +1,20 @@
      # SPDX-License-Identifier: BSD-3-Clause
      # Copyright(c) 2010-2017 Intel Corporation
     +#
     +# String that appears before the version number
     +#
     +CONFIG_RTE_VER_PREFIX="DPDK"
     +
     +#
     +# Version information completed when this file is processed for a
     build
     +#
     +CONFIG_RTE_VER_YEAR=__YEAR
     +CONFIG_RTE_VER_MONTH=__MONTH
     +CONFIG_RTE_VER_MINOR=__MINOR
     +CONFIG_RTE_VER_SUFFIX=__SUFFIX
     +CONFIG_RTE_VER_RELEASE=__RELEASE
     +
Quoted 2 lines

?
I think you broke make support.

Well, yes and no. It should be fine if you remove the build directory and recreate it, as the code for generating the build config has changed.

/Bruce

#8 lore raw

PATCH 3/4 build: move meson version handling to config directory

In reply to Bruce Richardson

To keep the top-level meson.build file as clean and clear as possible, we move the version handling - which was originally short but now is a lot longer - to the config/meson.build file, where the rest of the build configuration is already being set up.

---
 config/meson.build | 26 ++++++++++++++++++++++++++
 meson.build        | 26 --------------------------
 2 files changed, 26 insertions(+), 26 deletions(-)
config/meson.build +26 -0
index 0419607d3..bbe17c786 100644
@@ -1,6 +1,32 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
+# set the major version, which might be used by drivers and libraries
+# depending on the configuration options
+pver = meson.project_version().split('.')
+major_version = '@0@.@1@'.format(pver.get(0), pver.get(1))
+
+# extract all version information into the build configuration
+dpdk_conf.set('RTE_VER_YEAR', pver.get(0))
+dpdk_conf.set('RTE_VER_MONTH', pver.get(1))
+if pver.get(2).contains('-rc')
+	rc_ver = pver.get(2).split('-rc')
+	dpdk_conf.set('RTE_VER_MINOR', rc_ver.get(0))
+	dpdk_conf.set_quoted('RTE_VER_SUFFIX', '-rc')
+	dpdk_conf.set('RTE_VER_RELEASE', rc_ver.get(1))
+else
+	dpdk_conf.set('RTE_VER_MINOR', pver.get(2))
+	dpdk_conf.set_quoted('RTE_VER_SUFFIX', '')
+	dpdk_conf.set('RTE_VER_RELEASE', 0)
+endif
+
+pmd_subdir_opt = get_option('drivers_install_subdir')
+if pmd_subdir_opt.contains('<VERSION>')
+	pmd_subdir_opt = major_version.join(pmd_subdir_opt.split('<VERSION>'))
+endif
+driver_install_path = join_paths(get_option('libdir'), pmd_subdir_opt)
+eal_pmd_path = join_paths(get_option('prefix'), driver_install_path)
+
 # set the machine type and cflags for it
 if meson.is_cross_build()
 	machine = host_machine.cpu()
meson.build +0 -26
index 9d5320395..b0151f0c7 100644
@@ -17,32 +17,6 @@ dpdk_drivers = []
 dpdk_extra_ldflags = []
 dpdk_app_link_libraries = []
 
-# set the major version, which might be used by drivers and libraries
-# depending on the configuration options
-pver = meson.project_version().split('.')
-major_version = '@0@.@1@'.format(pver.get(0), pver.get(1))
-
-# extract all version information into the build configuration
-dpdk_conf.set('RTE_VER_YEAR', pver.get(0))
-dpdk_conf.set('RTE_VER_MONTH', pver.get(1))
-if pver.get(2).contains('-rc')
-	rc_ver = pver.get(2).split('-rc')
-	dpdk_conf.set('RTE_VER_MINOR', rc_ver.get(0))
-	dpdk_conf.set_quoted('RTE_VER_SUFFIX', '-rc')
-	dpdk_conf.set('RTE_VER_RELEASE', rc_ver.get(1))
-else
-	dpdk_conf.set('RTE_VER_MINOR', pver.get(2))
-	dpdk_conf.set_quoted('RTE_VER_SUFFIX', '')
-	dpdk_conf.set('RTE_VER_RELEASE', 0)
-endif
-
-pmd_subdir_opt = get_option('drivers_install_subdir')
-if pmd_subdir_opt.contains('<VERSION>')
-	pmd_subdir_opt = major_version.join(pmd_subdir_opt.split('<VERSION>'))
-endif
-driver_install_path = join_paths(get_option('libdir'), pmd_subdir_opt)
-eal_pmd_path = join_paths(get_option('prefix'), driver_install_path)
-
 # configure the build, and make sure configs here and in config folder are
 # able to be included in any file. We also store a global array of include dirs
 # for passing to pmdinfogen scripts
Signature · 1 line
2.20.1
#9 lore raw

PATCH 4/4 eal: remove unneeded version logic

In reply to Bruce Richardson

The version number in the DPDK_VERSION file will never have an offset that needs to be subtracted, so remove that logic from the version string generation.

---
 lib/librte_eal/common/include/rte_version.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
lib/librte_eal/common/include/rte_version.h +1 -3
index 50867ea81..f7a3a1ebc 100644
@@ -57,9 +57,7 @@ rte_version(void)
 			RTE_VER_MONTH,
 			RTE_VER_MINOR,
 			RTE_VER_SUFFIX,
-			RTE_VER_RELEASE < 16 ?
-				RTE_VER_RELEASE :
-				RTE_VER_RELEASE - 16);
+			RTE_VER_RELEASE);
 	return version;
 }
 
Signature · 1 line
2.20.1
#10 lore raw
In reply to Bruce Richardson
Quoted 64 lines · Bruce Richardson

Right now with DPDK we have two sources of version information - the rte_version.h header file containing macros for C use, and the project
version number in the project definition in meson.build. This is not optimal, so this patchset aims to provide a single source for the DPDK
version. The options considered are:

* Keep version info in rte_version.h only. The two reasons this was not
chosen were:
1) parsing the version number from the header is awkward, as seen
in the
rte.sdkconfig.mk file, and a script to do so would be needed to integrate that into the meson build project definition.
2) rte_version.h is not in an obvious location inside the project
when
a user clones from git. It's hidden away in the "lib/librte_eal/common/include" folder. Ideally the version
number
should be evident at the top level of the DPDK tree.

* Keep version info in meson.build file only. This seemed a better option
than keeping the info in rte_version.h, but it still had
disadvantages:
1) For make, using grep on meson.build to extract the version
seemed a
bit awkward, though doable. Splitting the version was tricky
too, but
managable with a small amount of scripting.
2) There was no easy way to have users access the version number
when
"make showversion" was deprecated with the make build system.

* Store the version number in a new version file at the root level of the
repo.
* This did have the advantage of being easily discoverable on clone
* Still had the disadvantage of needing some parsing to generate
the
defines from rte_version.h

Since the last option seemed best, that is what is implemented in this set.
The file DPDK_VERSION is added to store the version number, and make and
meson both use that as their source of version info. For C code, the rte_version.h header remains, except that the basic definitions of the
release YEAR, MONTH, MINOR etc. are moved to be automatically generated as
part of rte_config.h. For make builds, this is done via using the preprocessor to insert the values when it generates the config. For meson
builds, this is done by just adding the values to the dpdk_conf configuration object.

Bruce Richardson (4):
build: add single source of DPDK version number
build: use version number from config file
build: move meson version handling to config directory
eal: remove unneeded version logic

Quoted 10 lines
 DPDK_VERSION                                |  1 +
 config/common_base                          | 14 ++++++++
 config/meson.build                          | 26 +++++++++++++++
 config/rte_config.h                         |  5 +++
 lib/librte_eal/common/include/rte_version.h | 36 +----------------
----
 meson.build                                 | 14 +-------
 mk/rte.sdkconfig.mk                         | 18 +++--------
 7 files changed, 52 insertions(+), 62 deletions(-)
 create mode 100644 DPDK_VERSION

This is a good change, thanks for that. Too bad there's not yet a meson --project-version option - it's been discussed but not implemented:

https://github.com/mesonbuild/meson/issues/3535

Signature · 2 lines
Kind regards,
Luca Boccassi
#11 lore raw
Quoted 52 lines · Luca Boccassi
Quoted 42 lines · Bruce Richardson

Right now with DPDK we have two sources of version information - the rte_version.h header file containing macros for C use, and the project version number in the project definition in meson.build. This is not optimal, so this patchset aims to provide a single source for the DPDK version. The options considered are:

* Keep version info in rte_version.h only. The two reasons this was not chosen were: 1) parsing the version number from the header is awkward, as seen in the rte.sdkconfig.mk file, and a script to do so would be needed to integrate that into the meson build project definition. 2) rte_version.h is not in an obvious location inside the project when a user clones from git. It's hidden away in the "lib/librte_eal/common/include" folder. Ideally the version number should be evident at the top level of the DPDK tree.

* Keep version info in meson.build file only. This seemed a better option than keeping the info in rte_version.h, but it still had
disadvantages: 1) For make, using grep on meson.build to extract the version seemed a bit awkward, though doable. Splitting the version was tricky too, but managable with a small amount of scripting. 2) There was no easy way to have users access the version number when "make showversion" was deprecated with the make build system.

* Store the version number in a new version file at the root level of the repo. * This did have the advantage of being easily discoverable on clone * Still had the disadvantage of needing some parsing to generate the defines from rte_version.h

Since the last option seemed best, that is what is implemented in this set. The file DPDK_VERSION is added to store the version number, and make and meson both use that as their source of version info. For C code, the rte_version.h header remains, except that the basic definitions of the release YEAR, MONTH, MINOR etc. are moved to be automatically generated as part of rte_config.h. For make builds, this is done via using the preprocessor to insert the values when it generates the config. For meson builds, this is done by just adding the values to the dpdk_conf configuration object.

Bruce Richardson (4): build: add single source of DPDK version number
build: use version number from config file build: move meson version handling to config directory eal: remove unneeded version logic

Quoted 8 lines

DPDK_VERSION | 1 + config/common_base

 | 14 ++++++++ config/meson.build                          | 26
 +++++++++++++++ config/rte_config.h                         |  5 +++
 lib/librte_eal/common/include/rte_version.h | 36 +----------------
 ---- meson.build                                 | 14 +-------

mk/rte.sdkconfig.mk | 18 +++-------- 7 files
changed, 52 insertions(+), 62 deletions(-) create mode 100644 DPDK_VERSION

Quoted 7 lines

This is a good change, thanks for that. Too bad there's not yet a meson --project-version option - it's been discussed but not implemented:

https://github.com/mesonbuild/meson/issues/3535

Yes, I saw that request, and considered looking into doing it. However, even when it is implemented, we wouldn't be able to base anything on it till our next meson version bump at the earliest. Therefore I felt the most effective solution is one based in DPDK itself.

#12 lore raw

v2 cover One versionfile to rule them all...

In reply to Bruce Richardson

Right now with DPDK we have two sources of version information - the rte_version.h header file containing macros for C use, and the project version number in the project definition in meson.build. This is not optimal, so this patchset aims to provide a single source for the DPDK version. The options considered are:

* Keep version info in rte_version.h only. The two reasons this was not chosen were:
1) parsing the version number from the header is awkward, as seen in the rte.sdkconfig.mk file, and a script to do so would be needed to integrate that into the meson build project definition.
2) rte_version.h is not in an obvious location inside the project when a user clones from git. It's hidden away in the "lib/librte_eal/common/include" folder. Ideally the version number should be evident at the top level of the DPDK tree.

* Keep version info in meson.build file only. This seemed a better option than keeping the info in rte_version.h, but it still had disadvantages:
1) For make, using grep on meson.build to extract the version seemed a bit awkward, though doable. Splitting the version was tricky too, but managable with a small amount of scripting.
2) There was no easy way to have users access the version number when "make showversion" was deprecated with the make build system.

* Store the version number in a new version file at the root level of the repo.
* This did have the advantage of being easily discoverable on clone
* Still had the disadvantage of needing some parsing to generate the defines from rte_version.h

Since the last option seemed best, that is what is implemented in this set. The file DPDK_VERSION is added to store the version number, and make and meson both use that as their source of version info. For C code, the rte_version.h header remains, except that the basic definitions of the release YEAR, MONTH, MINOR etc. are moved to be automatically generated as part of rte_config.h. For make builds, this is done via using the preprocessor to insert the values when it generates the config. For meson builds, this is done by just adding the values to the dpdk_conf configuration object.

---
V2: Updated following review from David Marchand.

Bruce Richardson (4):
build: add single source of DPDK version number
build: use version number from config file
build: move meson version handling to config directory
eal: remove unneeded version logic

 DPDK_VERSION                                |  1 +
 config/common_base                          | 14 ++++++++
 config/meson.build                          | 26 +++++++++++++++
 config/rte_config.h                         |  5 +++
 lib/librte_eal/common/include/rte_version.h | 36 +--------------------
 meson.build                                 | 16 ++-------
 mk/rte.sdkconfig.mk                         | 18 +++--------
 7 files changed, 54 insertions(+), 62 deletions(-)
 create mode 100644 DPDK_VERSION
Signature · 1 line
2.20.1
#13 lore raw

PATCH v2 1/4 build: add single source of DPDK version number

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".

---
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
DPDK_VERSION new file +1 -0
new file mode 100644
index 000000000..c4a4cd00b
@@ -0,0 +1 @@
+19.05.0-rc0
meson.build +3 -1
index 69833de82..aaa6002ae 100644
@@ -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'
mk/rte.sdkconfig.mk +2 -14
index fa77331cb..d9c8d53d2 100644
@@ -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_%,%,\
Signature · 1 line
2.20.1
#14 lore raw

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

07/03/2019 14:34, Bruce Richardson:

Quoted 6 lines

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".

[...]

DPDK_VERSION

Quoted 2 lines
DPDK_VERSION new file +0 -0

Why not VERSION ?

[...]

Quoted 4 lines
mk/rte.sdkconfig.mk +0 -1
 showversion:
-	@set -- \

mk/rte.sdkconfig.mk line 6

Quoted 10 lines
mk/rte.sdkconfig.mk +1 -9
-		$$(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 ;)

#15 lore raw

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

Quoted 5 lines · Thomas Monjalon

07/03/2019 14:34, Bruce Richardson:

Quoted 4 lines

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".

Quoted 8 lines
Quoted 2 lines

[...]

DPDK_VERSION

Quoted 2 lines
DPDK_VERSION new file +0 -0

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.

Quoted 18 lines

[...]

Quoted 4 lines
mk/rte.sdkconfig.mk +0 -1
 showversion:
-	@set -- \

mk/rte.sdkconfig.mk line 6

Quoted 10 lines
mk/rte.sdkconfig.mk +1 -9
-		$$(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. :-)

#16 lore raw

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

13/03/2019 12:17, Bruce Richardson:

Quoted 15 lines · Thomas Monjalon
Quoted 5 lines

07/03/2019 14:34, Bruce Richardson:

Quoted 4 lines

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".

Quoted 8 lines
Quoted 2 lines

[...]

DPDK_VERSION

Quoted 2 lines
DPDK_VERSION new file +0 -0

Why not VERSION ?

Quoted 6 lines

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.

Quoted 18 lines
Quoted 18 lines

[...]

Quoted 4 lines
mk/rte.sdkconfig.mk +0 -1
 showversion:
-	@set -- \

mk/rte.sdkconfig.mk line 6

Quoted 10 lines
mk/rte.sdkconfig.mk +1 -9
-		$$(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 ;)

Quoted 3 lines

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 :)

#17 lore raw

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

Quoted 16 lines · Thomas Monjalon

13/03/2019 12:17, Bruce Richardson:

Quoted 15 lines · Thomas Monjalon
Quoted 13 lines

07/03/2019 14:34, Bruce Richardson:

Quoted 6 lines

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".

[...]

DPDK_VERSION

Quoted 2 lines
DPDK_VERSION new file +0 -0

Why not VERSION ?

Quoted 9 lines
Quoted 6 lines

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! :-)

Quoted 2 lines

I think I prefer just VERSION.

Ok, will change in V2.

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines

[...]

Quoted 4 lines
mk/rte.sdkconfig.mk +0 -1
 showversion:
-	@set -- \

mk/rte.sdkconfig.mk line 6

Quoted 10 lines
mk/rte.sdkconfig.mk +1 -9
-		$$(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 ;)

Quoted 6 lines
Quoted 3 lines

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! :-)

#18 lore raw

PATCH v2 2/4 build: use version number from config file

In reply to Bruce Richardson

Since we have the version number in a separate file at the root level, we should not need to duplicate this in rte_version.h too. Best approach here is to move the macros for specifying the year/month/etc. parts from the version header file to the build config file - leaving the other utility macros for e.g. printing the version string, where they are.

For make this is done by having a little bit of awk parse the version file and pass the results through to the preprocessor for the config generation stage.

For meson, this is done by parsing the version and adding it to the standard dpdk_conf object.

---
V2: removed extra change to DPDK_VERSION that crept into patch. Added ack

---
 config/common_base                          | 14 +++++++++
 config/rte_config.h                         |  5 ++++
 lib/librte_eal/common/include/rte_version.h | 32 ---------------------
 meson.build                                 | 14 +++++++++
 mk/rte.sdkconfig.mk                         |  2 ++
 5 files changed, 35 insertions(+), 32 deletions(-)
config/common_base +14 -0
index 0b09a9348..6292bc4af 100644
@@ -1,6 +1,20 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2010-2017 Intel Corporation
 
+#
+# String that appears before the version number
+#
+CONFIG_RTE_VER_PREFIX="DPDK"
+
+#
+# Version information completed when this file is processed for a build
+#
+CONFIG_RTE_VER_YEAR=__YEAR
+CONFIG_RTE_VER_MONTH=__MONTH
+CONFIG_RTE_VER_MINOR=__MINOR
+CONFIG_RTE_VER_SUFFIX=__SUFFIX
+CONFIG_RTE_VER_RELEASE=__RELEASE
+
 #
 # define executive environment
 # RTE_EXEC_ENV values are the directories in mk/exec-env/
config/rte_config.h +5 -0
index 7606f5d7b..5f1749dbb 100644
@@ -18,6 +18,11 @@
 
 #include <rte_build_config.h>
 
+/**
+ * String that appears before the version number
+ */
+#define RTE_VER_PREFIX "DPDK"
+
 /****** library defines ********/
 
 /* compat defines */
lib/librte_eal/common/include/rte_version.h +0 -32
index a7eed7ab7..50867ea81 100644
@@ -19,38 +19,6 @@ extern "C" {
 #include <stdio.h>
 #include <rte_common.h>
 
-/**
- * String that appears before the version number
- */
-#define RTE_VER_PREFIX "DPDK"
-
-/**
- * Major version/year number i.e. the yy in yy.mm.z
- */
-#define RTE_VER_YEAR 19
-
-/**
- * Minor version/month number i.e. the mm in yy.mm.z
- */
-#define RTE_VER_MONTH 5
-
-/**
- * Patch level number i.e. the z in yy.mm.z
- */
-#define RTE_VER_MINOR 0
-
-/**
- * Extra string to be appended to version number
- */
-#define RTE_VER_SUFFIX "-rc"
-
-/**
- * Patch release number
- *   0-15 = release candidates
- *   16   = release
- */
-#define RTE_VER_RELEASE 0
-
 /**
  * Macro to compute a version number usable for comparisons
  */
meson.build +14 -0
index aaa6002ae..9fefa1b75 100644
@@ -24,6 +24,20 @@ dpdk_app_link_libraries = []
 pver = meson.project_version().split('.')
 major_version = '@0@.@1@'.format(pver.get(0), pver.get(1))
 
+# extract all version information into the build configuration
+dpdk_conf.set('RTE_VER_YEAR', pver.get(0))
+dpdk_conf.set('RTE_VER_MONTH', pver.get(1))
+if pver.get(2).contains('-rc')
+	rc_ver = pver.get(2).split('-rc')
+	dpdk_conf.set('RTE_VER_MINOR', rc_ver.get(0))
+	dpdk_conf.set_quoted('RTE_VER_SUFFIX', '-rc')
+	dpdk_conf.set('RTE_VER_RELEASE', rc_ver.get(1))
+else
+	dpdk_conf.set('RTE_VER_MINOR', pver.get(2))
+	dpdk_conf.set_quoted('RTE_VER_SUFFIX', '')
+	dpdk_conf.set('RTE_VER_RELEASE', 0)
+endif
+
 pmd_subdir_opt = get_option('drivers_install_subdir')
 if pmd_subdir_opt.contains('<VERSION>')
 	pmd_subdir_opt = major_version.join(pmd_subdir_opt.split('<VERSION>'))
mk/rte.sdkconfig.mk +2 -0
index d9c8d53d2..007022adf 100644
@@ -76,6 +76,8 @@ else
 $(RTE_OUTPUT)/.config: $(RTE_CONFIG_TEMPLATE) FORCE | $(RTE_OUTPUT)
 	$(Q)if [ "$(RTE_CONFIG_TEMPLATE)" != "" -a -f "$(RTE_CONFIG_TEMPLATE)" ]; then \
 		$(CPP) -undef -P -x assembler-with-cpp \
+		`cat $(RTE_SRCDIR)/DPDK_VERSION | sed -e 's/-rc/.-rc./' | \
+		awk -F '.' '{print "-D__YEAR="$$1, "-D__MONTH="$$2, "-D__MINOR="$$3, "-D__SUFFIX=\""$$4"\"", "-D__RELEASE="int($$5)}'` \
 		-ffreestanding \
 		-o $(RTE_OUTPUT)/.config_tmp $(RTE_CONFIG_TEMPLATE) ; \
 		config=$$(cat $(RTE_OUTPUT)/.config_tmp) ; \
Signature · 1 line
2.20.1
#19 lore raw

Re: [PATCH v2 2/4] build: use version number from config file

07/03/2019 14:35, Bruce Richardson:

Quoted 8 lines
config/common_base +8 -0
+#
+# Version information completed when this file is processed for a build
+#
+CONFIG_RTE_VER_YEAR=__YEAR
+CONFIG_RTE_VER_MONTH=__MONTH
+CONFIG_RTE_VER_MINOR=__MINOR
+CONFIG_RTE_VER_SUFFIX=__SUFFIX
+CONFIG_RTE_VER_RELEASE=__RELEASE

[...]

lib/librte_eal/common/include/rte_version.h extern "C" { · line 52

Quoted 6 lines
lib/librte_eal/common/include/rte_version.h +0 -6
-/**
- * Patch release number
- *   0-15 = release candidates
- *   16   = release
- */
-#define RTE_VER_RELEASE 0

So you are removing the special value 16.
Is it replaced by an empty value?

I think it is an issue for version comparison with RTE_VERSION_NUM() macro. The -rc3 must be lower than the final release (which had number 16 for this reason).

#20 lore raw

Re: [PATCH v2 2/4] build: use version number from config file

Quoted 20 lines · Thomas Monjalon

07/03/2019 14:35, Bruce Richardson:

Quoted 8 lines
config/common_base +8 -0
+#
+# Version information completed when this file is processed for a build
+#
+CONFIG_RTE_VER_YEAR=__YEAR
+CONFIG_RTE_VER_MONTH=__MONTH
+CONFIG_RTE_VER_MINOR=__MINOR
+CONFIG_RTE_VER_SUFFIX=__SUFFIX
+CONFIG_RTE_VER_RELEASE=__RELEASE

[...]

lib/librte_eal/common/include/rte_version.h extern "C" { · line 52

Quoted 6 lines
lib/librte_eal/common/include/rte_version.h +0 -6
-/**
- * Patch release number
- *   0-15 = release candidates
- *   16   = release
- */
-#define RTE_VER_RELEASE 0

So you are removing the special value 16.
Is it replaced by an empty value?

Quoted 4 lines

I think it is an issue for version comparison with RTE_VERSION_NUM() macro. The -rc3 must be lower than the final release (which had number 16 for this reason).

Aha, that explains the reason for the 16 value. I did wonder why we bothered with it when it wasn't actually used in printing etc. Let me go back and look into this set again, armed with this new info. [We also need to document this reason in the code comments for future information]

#21 lore raw

Re: [PATCH v2 2/4] build: use version number from config file

13/03/2019 12:20, Bruce Richardson:

Quoted 21 lines · Thomas Monjalon
Quoted 20 lines

07/03/2019 14:35, Bruce Richardson:

Quoted 8 lines
config/common_base +8 -0
+#
+# Version information completed when this file is processed for a build
+#
+CONFIG_RTE_VER_YEAR=__YEAR
+CONFIG_RTE_VER_MONTH=__MONTH
+CONFIG_RTE_VER_MINOR=__MINOR
+CONFIG_RTE_VER_SUFFIX=__SUFFIX
+CONFIG_RTE_VER_RELEASE=__RELEASE

[...]

lib/librte_eal/common/include/rte_version.h extern "C" { · line 52

Quoted 6 lines
lib/librte_eal/common/include/rte_version.h +0 -6
-/**
- * Patch release number
- *   0-15 = release candidates
- *   16   = release
- */
-#define RTE_VER_RELEASE 0

So you are removing the special value 16.
Is it replaced by an empty value?

Quoted 8 lines
Quoted 4 lines

I think it is an issue for version comparison with RTE_VERSION_NUM() macro. The -rc3 must be lower than the final release (which had number 16 for this reason).

Aha, that explains the reason for the 16 value. I did wonder why we bothered with it when it wasn't actually used in printing etc. Let me go back and look into this set again, armed with this new info. [We also need to document this reason in the code comments for future information]

Yes it was not documented, sorry.
Thanks for working on it.

#22 lore raw

PATCH v2 3/4 build: move meson version handling to config directory

In reply to Bruce Richardson

To keep the top-level meson.build file as clean and clear as possible, we move the version handling - which was originally short but now is a lot longer - to the config/meson.build file, where the rest of the build configuration is already being set up.

---
V2: No changes, added Luca's ack

---
 config/meson.build | 26 ++++++++++++++++++++++++++
 meson.build        | 26 --------------------------
 2 files changed, 26 insertions(+), 26 deletions(-)
config/meson.build +26 -0
index 0419607d3..bbe17c786 100644
@@ -1,6 +1,32 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
+# set the major version, which might be used by drivers and libraries
+# depending on the configuration options
+pver = meson.project_version().split('.')
+major_version = '@0@.@1@'.format(pver.get(0), pver.get(1))
+
+# extract all version information into the build configuration
+dpdk_conf.set('RTE_VER_YEAR', pver.get(0))
+dpdk_conf.set('RTE_VER_MONTH', pver.get(1))
+if pver.get(2).contains('-rc')
+	rc_ver = pver.get(2).split('-rc')
+	dpdk_conf.set('RTE_VER_MINOR', rc_ver.get(0))
+	dpdk_conf.set_quoted('RTE_VER_SUFFIX', '-rc')
+	dpdk_conf.set('RTE_VER_RELEASE', rc_ver.get(1))
+else
+	dpdk_conf.set('RTE_VER_MINOR', pver.get(2))
+	dpdk_conf.set_quoted('RTE_VER_SUFFIX', '')
+	dpdk_conf.set('RTE_VER_RELEASE', 0)
+endif
+
+pmd_subdir_opt = get_option('drivers_install_subdir')
+if pmd_subdir_opt.contains('<VERSION>')
+	pmd_subdir_opt = major_version.join(pmd_subdir_opt.split('<VERSION>'))
+endif
+driver_install_path = join_paths(get_option('libdir'), pmd_subdir_opt)
+eal_pmd_path = join_paths(get_option('prefix'), driver_install_path)
+
 # set the machine type and cflags for it
 if meson.is_cross_build()
 	machine = host_machine.cpu()
meson.build +0 -26
index 9fefa1b75..9fba06767 100644
@@ -19,32 +19,6 @@ dpdk_drivers = []
 dpdk_extra_ldflags = []
 dpdk_app_link_libraries = []
 
-# set the major version, which might be used by drivers and libraries
-# depending on the configuration options
-pver = meson.project_version().split('.')
-major_version = '@0@.@1@'.format(pver.get(0), pver.get(1))
-
-# extract all version information into the build configuration
-dpdk_conf.set('RTE_VER_YEAR', pver.get(0))
-dpdk_conf.set('RTE_VER_MONTH', pver.get(1))
-if pver.get(2).contains('-rc')
-	rc_ver = pver.get(2).split('-rc')
-	dpdk_conf.set('RTE_VER_MINOR', rc_ver.get(0))
-	dpdk_conf.set_quoted('RTE_VER_SUFFIX', '-rc')
-	dpdk_conf.set('RTE_VER_RELEASE', rc_ver.get(1))
-else
-	dpdk_conf.set('RTE_VER_MINOR', pver.get(2))
-	dpdk_conf.set_quoted('RTE_VER_SUFFIX', '')
-	dpdk_conf.set('RTE_VER_RELEASE', 0)
-endif
-
-pmd_subdir_opt = get_option('drivers_install_subdir')
-if pmd_subdir_opt.contains('<VERSION>')
-	pmd_subdir_opt = major_version.join(pmd_subdir_opt.split('<VERSION>'))
-endif
-driver_install_path = join_paths(get_option('libdir'), pmd_subdir_opt)
-eal_pmd_path = join_paths(get_option('prefix'), driver_install_path)
-
 # configure the build, and make sure configs here and in config folder are
 # able to be included in any file. We also store a global array of include dirs
 # for passing to pmdinfogen scripts
Signature · 1 line
2.20.1
#23 lore raw

PATCH v2 4/4 eal: remove unneeded version logic

In reply to Bruce Richardson

The version number in the DPDK_VERSION file will never have an offset that needs to be subtracted, so remove that logic from the version string generation.

---
V2: No changes - added Luca's ack

---
 lib/librte_eal/common/include/rte_version.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
lib/librte_eal/common/include/rte_version.h +1 -3
index 50867ea81..f7a3a1ebc 100644
@@ -57,9 +57,7 @@ rte_version(void)
 			RTE_VER_MONTH,
 			RTE_VER_MINOR,
 			RTE_VER_SUFFIX,
-			RTE_VER_RELEASE < 16 ?
-				RTE_VER_RELEASE :
-				RTE_VER_RELEASE - 16);
+			RTE_VER_RELEASE);
 	return version;
 }
 
Signature · 1 line
2.20.1
#24 lore raw

v3 cover One versionfile to rule them all...

In reply to Bruce Richardson

Right now with DPDK we have two sources of version information - the rte_version.h header file containing macros for C use, and the project version number in the project definition in meson.build. This is not optimal, so this patchset aims to provide a single source for the DPDK version. The options considered are:

* Keep version info in rte_version.h only. The two reasons this was not chosen were:
1) parsing the version number from the header is awkward, as seen in the rte.sdkconfig.mk file, and a script to do so would be needed to integrate that into the meson build project definition.
2) rte_version.h is not in an obvious location inside the project when a user clones from git. It's hidden away in the "lib/librte_eal/common/include" folder. Ideally the version number should be evident at the top level of the DPDK tree.

* Keep version info in meson.build file only. This seemed a better option than keeping the info in rte_version.h, but it still had disadvantages:
1) For make, using grep on meson.build to extract the version seemed a bit awkward, though doable. Splitting the version was tricky too, but manageable with a small amount of scripting.
2) There was no easy way to have users access the version number when "make showversion" was deprecated with the make build system.

* Store the version number in a new version file at the root level of the repo.
* This did have the advantage of being easily discoverable on clone
* Still had the disadvantage of needing some parsing to generate the defines from rte_version.h

Since the last option seemed best, that is what is implemented in this set. The file DPDK_VERSION is added to store the version number, and make and meson both use that as their source of version info. For C code, the rte_version.h header remains, except that the basic definitions of the release YEAR, MONTH, MINOR etc. are moved to be automatically generated as part of rte_config.h. For make builds, this is done via using the preprocessor to insert the values when it generates the config. For meson builds, this is done by just adding the values to the dpdk_conf configuration object.

---
V3: Reworked following review from Thomas Monjalon. Main change is to how
the RTE_VER_RELEASE value is computed for non-release candidates. Also added int() conversion to each version value to remove leading zeros
V2: Updated following review from David Marchand.

Bruce Richardson (4):
build: add single source of DPDK version number
build: move meson version handling to config directory
build: use version number from config file
eal: remove unneeded version logic

 VERSION                                     |  1 +
 config/common_base                          | 14 ++++++++
 config/meson.build                          | 26 +++++++++++++++
 config/rte_config.h                         |  3 ++
 lib/librte_eal/common/include/rte_version.h | 36 +--------------------
 meson.build                                 | 21 +++++-------
 mk/rte.sdkconfig.mk                         | 23 ++++++-------
 7 files changed, 62 insertions(+), 62 deletions(-)
 create mode 100644 VERSION
Signature · 1 line
2.20.1
#25 lore raw

PATCH v3 1/4 build: add single source of DPDK version number

Add a new file 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".

---
v3: rename file from DPDK_VERSION to VERSION
v2: fix typos and include Luca's ack.

---
 VERSION             |  1 +
 meson.build         |  4 +++-
 mk/rte.sdkconfig.mk | 16 ++--------------
 3 files changed, 6 insertions(+), 15 deletions(-)
 create mode 100644 VERSION
VERSION new file +1 -0
new file mode 100644
index 000000000..c4a4cd00b
@@ -0,0 +1 @@
+19.05.0-rc0
meson.build +3 -1
index 69833de82..1b31e0da5 100644
@@ -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('VERSION')).stdout().strip(),
 	license: 'BSD',
 	default_options: ['buildtype=release', 'default_library=static'],
 	meson_version: '>= 0.47.1'
mk/rte.sdkconfig.mk +2 -14
index c79bec179..46ec9e76d 100644
@@ -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)/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)/VERSION | awk -F '.' '{print $$1$$2}'
 
 INSTALL_CONFIGS := $(sort $(filter-out %app-icc,$(filter-out %app-clang,\
 	$(filter-out %app-gcc,$(filter-out %~,\
Signature · 1 line
2.20.1
Reviewed-by on v3 1/4
#26 lore raw

Re: [PATCH v3 1/4] build: add single source of DPDK version number

Bruce Richardson ‏<[email protected]>:

Quoted 7 lines

Add a new file 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".

Quoted 1 line
#27 lore raw

PATCH v3 2/4 build: move meson version handling to config directory

In reply to Bruce Richardson

To keep the top-level meson.build file as clean and clear as possible, we move the version handling to the config/meson.build file, where the rest of the build configuration is already being set up.

---
V3: Reordered patch in set
V2: No changes, added Luca's ack

---
 config/meson.build | 12 ++++++++++++
 meson.build        | 12 ------------
 2 files changed, 12 insertions(+), 12 deletions(-)
config/meson.build +12 -0
index 0419607d3..999dea91e 100644
@@ -1,6 +1,18 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
+# set the major version, which might be used by drivers and libraries
+# depending on the configuration options
+pver = meson.project_version().split('.')
+major_version = '@0@.@1@'.format(pver.get(0), pver.get(1))
+
+pmd_subdir_opt = get_option('drivers_install_subdir')
+if pmd_subdir_opt.contains('<VERSION>')
+	pmd_subdir_opt = major_version.join(pmd_subdir_opt.split('<VERSION>'))
+endif
+driver_install_path = join_paths(get_option('libdir'), pmd_subdir_opt)
+eal_pmd_path = join_paths(get_option('prefix'), driver_install_path)
+
 # set the machine type and cflags for it
 if meson.is_cross_build()
 	machine = host_machine.cpu()
meson.build +0 -12
index 1b31e0da5..6a83c827e 100644
@@ -19,18 +19,6 @@ dpdk_drivers = []
 dpdk_extra_ldflags = []
 dpdk_app_link_libraries = []
 
-# set the major version, which might be used by drivers and libraries
-# depending on the configuration options
-pver = meson.project_version().split('.')
-major_version = '@0@.@1@'.format(pver.get(0), pver.get(1))
-
-pmd_subdir_opt = get_option('drivers_install_subdir')
-if pmd_subdir_opt.contains('<VERSION>')
-	pmd_subdir_opt = major_version.join(pmd_subdir_opt.split('<VERSION>'))
-endif
-driver_install_path = join_paths(get_option('libdir'), pmd_subdir_opt)
-eal_pmd_path = join_paths(get_option('prefix'), driver_install_path)
-
 # configure the build, and make sure configs here and in config folder are
 # able to be included in any file. We also store a global array of include dirs
 # for passing to pmdinfogen scripts
Signature · 1 line
2.20.1
#28 lore raw

PATCH v3 3/4 build: use version number from config file

In reply to Bruce Richardson

Since we have the version number in a separate file at the root level, we should not need to duplicate this in rte_version.h too. Best approach here is to move the macros for specifying the year/month/etc. parts from the version header file to the build config file - leaving the other utility macros for e.g. printing the version string, where they are.

For "make", this is done by having a little bit of awk parse the version file and pass the results through to the preprocessor for the config generation stage.

For "meson", this is done by parsing the version and adding it to the standard dpdk_conf object.

In both cases, we need to append a large number - in this case "99", previously 16 in original code - to the version number when we want to do version number comparisons. Without this, the release version e.g. 19.05.0 will compare as less than it's RC's e.g. 19.05.0-rc4. With it, the comparison is correct as "19.05.0.99 > 19.05.0-rc4.99".

---
V3: following Thomas review, include appending .99 to version numbers to
ensure correct comparison. Make sure the reason for this is properly documented in the code for future reference. Add in "int" casts for numeric values to strip leading zeros e.g. in "05" month.
V2: removed extra change to DPDK_VERSION that crept into patch. Added ack

---
 config/common_base                          | 14 +++++++++
 config/meson.build                          | 16 +++++++++++
 config/rte_config.h                         |  3 ++
 lib/librte_eal/common/include/rte_version.h | 32 ---------------------
 mk/rte.sdkconfig.mk                         |  7 +++++
 5 files changed, 40 insertions(+), 32 deletions(-)
config/common_base +14 -0
index 0b09a9348..6292bc4af 100644
@@ -1,6 +1,20 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2010-2017 Intel Corporation
 
+#
+# String that appears before the version number
+#
+CONFIG_RTE_VER_PREFIX="DPDK"
+
+#
+# Version information completed when this file is processed for a build
+#
+CONFIG_RTE_VER_YEAR=__YEAR
+CONFIG_RTE_VER_MONTH=__MONTH
+CONFIG_RTE_VER_MINOR=__MINOR
+CONFIG_RTE_VER_SUFFIX=__SUFFIX
+CONFIG_RTE_VER_RELEASE=__RELEASE
+
 #
 # define executive environment
 # RTE_EXEC_ENV values are the directories in mk/exec-env/
config/meson.build +16 -0
index 999dea91e..30a7261a5 100644
@@ -6,6 +6,22 @@
 pver = meson.project_version().split('.')
 major_version = '@0@.@1@'.format(pver.get(0), pver.get(1))
 
+# extract all version information into the build configuration
+dpdk_conf.set('RTE_VER_YEAR', pver.get(0).to_int())
+dpdk_conf.set('RTE_VER_MONTH', pver.get(1).to_int())
+if pver.get(2).contains('-rc')
+	rc_ver = pver.get(2).split('-rc')
+	dpdk_conf.set('RTE_VER_MINOR', rc_ver.get(0).to_int())
+	dpdk_conf.set_quoted('RTE_VER_SUFFIX', '-rc')
+	dpdk_conf.set('RTE_VER_RELEASE', rc_ver.get(1).to_int())
+else
+	dpdk_conf.set('RTE_VER_MINOR', pver.get(2).to_int())
+	dpdk_conf.set_quoted('RTE_VER_SUFFIX', '')
+# for actual, non-rc releases, set the release value to 99 to ensure releases
+# have higher version numbers than their respective release candidates
+	dpdk_conf.set('RTE_VER_RELEASE', 99)
+endif
+
 pmd_subdir_opt = get_option('drivers_install_subdir')
 if pmd_subdir_opt.contains('<VERSION>')
 	pmd_subdir_opt = major_version.join(pmd_subdir_opt.split('<VERSION>'))
config/rte_config.h +3 -0
index 1690f4d98..cda51af47 100644
@@ -26,6 +26,9 @@
 #define RTE_EXEC_ENV_BSDAPP 1
 #endif
 
+/* String that appears before the version number */
+#define RTE_VER_PREFIX "DPDK"
+
 /****** library defines ********/
 
 /* compat defines */
lib/librte_eal/common/include/rte_version.h +0 -32
index a7eed7ab7..50867ea81 100644
@@ -19,38 +19,6 @@ extern "C" {
 #include <stdio.h>
 #include <rte_common.h>
 
-/**
- * String that appears before the version number
- */
-#define RTE_VER_PREFIX "DPDK"
-
-/**
- * Major version/year number i.e. the yy in yy.mm.z
- */
-#define RTE_VER_YEAR 19
-
-/**
- * Minor version/month number i.e. the mm in yy.mm.z
- */
-#define RTE_VER_MONTH 5
-
-/**
- * Patch level number i.e. the z in yy.mm.z
- */
-#define RTE_VER_MINOR 0
-
-/**
- * Extra string to be appended to version number
- */
-#define RTE_VER_SUFFIX "-rc"
-
-/**
- * Patch release number
- *   0-15 = release candidates
- *   16   = release
- */
-#define RTE_VER_RELEASE 0
-
 /**
  * Macro to compute a version number usable for comparisons
  */
mk/rte.sdkconfig.mk +7 -0
index 46ec9e76d..f538649f2 100644
@@ -74,9 +74,16 @@ else
 # To do so the temp config is checked for duplicate keys with cut/sort/uniq
 # Then for each of those identified duplicates as long as there are more than
 # just one left the last match is removed.
+# Part of the config includes the version information taken from "VERSION"
+# in the repo. This needs to be split into the various parts using sed and awk.
+# To ensure correct version comparison, we append ".99" to the version number
+# so that the version of a release is higher than that of its rc's.
 $(RTE_OUTPUT)/.config: $(RTE_CONFIG_TEMPLATE) FORCE | $(RTE_OUTPUT)
 	$(Q)if [ "$(RTE_CONFIG_TEMPLATE)" != "" -a -f "$(RTE_CONFIG_TEMPLATE)" ]; then \
 		$(CPP) -undef -P -x assembler-with-cpp \
+		`cat $(RTE_SRCDIR)/VERSION | \
+		sed -e 's/-rc/.-rc./' -e 's/$$/..99/' | \
+		awk -F '.' '{print "-D__YEAR="int($$1), "-D__MONTH="int($$2), "-D__MINOR="int($$3), "-D__SUFFIX=\""$$4"\"", "-D__RELEASE="int($$5)}'` \
 		-ffreestanding \
 		-o $(RTE_OUTPUT)/.config_tmp $(RTE_CONFIG_TEMPLATE) ; \
 		config=$$(cat $(RTE_OUTPUT)/.config_tmp) ; \
Signature · 1 line
2.20.1
Acked-by on v3 3/4
#29 lore raw

Re: [PATCH v3 3/4] build: use version number from config file

15/03/2019 19:20, Bruce Richardson:

Quoted 20 lines

Since we have the version number in a separate file at the root level, we should not need to duplicate this in rte_version.h too. Best approach here is to move the macros for specifying the year/month/etc. parts from the version header file to the build config file - leaving the other utility macros for e.g. printing the version string, where they are.

For "make", this is done by having a little bit of awk parse the version file and pass the results through to the preprocessor for the config generation stage.

For "meson", this is done by parsing the version and adding it to the standard dpdk_conf object.

In both cases, we need to append a large number - in this case "99", previously 16 in original code - to the version number when we want to do version number comparisons. Without this, the release version e.g. 19.05.0 will compare as less than it's RC's e.g. 19.05.0-rc4. With it, the comparison is correct as "19.05.0.99 > 19.05.0-rc4.99".

Quoted 7 lines

---
V3: following Thomas review, include appending .99 to version numbers to
ensure correct comparison. Make sure the reason for this is properly documented in the code for future reference. Add in "int" casts for numeric values to strip leading zeros e.g. in "05" month.

#30 lore raw

PATCH v3 4/4 eal: remove unneeded version logic

In reply to Bruce Richardson

The version number in the DPDK_VERSION file will never have an offset that needs to be subtracted, so remove that logic from the version string generation.

---
V2,V3: No changes, added Luca's ack

 lib/librte_eal/common/include/rte_version.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
lib/librte_eal/common/include/rte_version.h +1 -3
index 50867ea81..f7a3a1ebc 100644
@@ -57,9 +57,7 @@ rte_version(void)
 			RTE_VER_MONTH,
 			RTE_VER_MINOR,
 			RTE_VER_SUFFIX,
-			RTE_VER_RELEASE < 16 ?
-				RTE_VER_RELEASE :
-				RTE_VER_RELEASE - 16);
+			RTE_VER_RELEASE);
 	return version;
 }
 
Signature · 1 line
2.20.1
#31 lore raw
In reply to Bruce Richardson

15/03/2019 19:20, Bruce Richardson:

Quoted 47 lines

Right now with DPDK we have two sources of version information - the rte_version.h header file containing macros for C use, and the project version number in the project definition in meson.build. This is not optimal, so this patchset aims to provide a single source for the DPDK version. The options considered are:

* Keep version info in rte_version.h only. The two reasons this was not chosen were:
1) parsing the version number from the header is awkward, as seen in the rte.sdkconfig.mk file, and a script to do so would be needed to integrate that into the meson build project definition.
2) rte_version.h is not in an obvious location inside the project when a user clones from git. It's hidden away in the "lib/librte_eal/common/include" folder. Ideally the version number should be evident at the top level of the DPDK tree.

* Keep version info in meson.build file only. This seemed a better option than keeping the info in rte_version.h, but it still had disadvantages:
1) For make, using grep on meson.build to extract the version seemed a bit awkward, though doable. Splitting the version was tricky too, but manageable with a small amount of scripting.
2) There was no easy way to have users access the version number when "make showversion" was deprecated with the make build system.

* Store the version number in a new version file at the root level of the repo.
* This did have the advantage of being easily discoverable on clone
* Still had the disadvantage of needing some parsing to generate the defines from rte_version.h

Since the last option seemed best, that is what is implemented in this set. The file DPDK_VERSION is added to store the version number, and make and meson both use that as their source of version info. For C code, the rte_version.h header remains, except that the basic definitions of the release YEAR, MONTH, MINOR etc. are moved to be automatically generated as part of rte_config.h. For make builds, this is done via using the preprocessor to insert the values when it generates the config. For meson builds, this is done by just adding the values to the dpdk_conf configuration object.

---
V3: Reworked following review from Thomas Monjalon. Main change is to how
the RTE_VER_RELEASE value is computed for non-release candidates. Also added int() conversion to each version value to remove leading zeros
V2: Updated following review from David Marchand.

Quoted 5 lines

Bruce Richardson (4):
build: add single source of DPDK version number
build: move meson version handling to config directory
build: use version number from config file
eal: remove unneeded version logic

Applied, thanks