diff mbox

[1/2] configure: the version cannot use a script

Message ID 1476804254-20341-1-git-send-email-mike.holmes@linaro.org
State Superseded
Headers show

Commit Message

Mike Holmes Oct. 18, 2016, 3:24 p.m. UTC
Use of a script in the autotools breaks github CI
Define the API version in configure and reuse it in the code

Benefits:
removes dependence on scripts to build
removes scripts and the make file from odp/scripts
removes generated .scmversion file
places api versioning right next to lib versioning in the configure.ac
allows github to auto build odp repos

Signed-off-by: Mike Holmes <mike.holmes@linaro.org>

---
 .gitignore                                       |  1 -
 Makefile.am                                      |  5 ++--
 configure.ac                                     | 21 +++++++++++++++--
 include/odp/api/spec/.gitignore                  |  1 +
 include/odp/api/spec/{version.h => version.h.in} |  6 ++---
 platform/Makefile.inc                            |  3 +--
 scripts/Makefile.am                              |  1 -
 scripts/get_impl_str.sh                          | 11 ---------
 scripts/git_hash.sh                              | 29 ------------------------
 9 files changed, 26 insertions(+), 52 deletions(-)
 create mode 100644 include/odp/api/spec/.gitignore
 rename include/odp/api/spec/{version.h => version.h.in} (93%)
 delete mode 100644 scripts/Makefile.am
 delete mode 100755 scripts/get_impl_str.sh
 delete mode 100755 scripts/git_hash.sh

-- 
2.7.4

Comments

Brian Brooks Oct. 13, 2016, 12:11 a.m. UTC | #1
On 10/18 11:24:13, Mike Holmes wrote:
> Use of a script in the autotools breaks github CI

> Define the API version in configure and reuse it in the code

> 

> Benefits:

> removes dependence on scripts to build

> removes scripts and the make file from odp/scripts

> removes generated .scmversion file

> places api versioning right next to lib versioning in the configure.ac

> allows github to auto build odp repos

> 

> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>


Reviewed-by: Brian Brooks <brian.brooks@linaro.org>


> ---

>  .gitignore                                       |  1 -

>  Makefile.am                                      |  5 ++--

>  configure.ac                                     | 21 +++++++++++++++--

>  include/odp/api/spec/.gitignore                  |  1 +

>  include/odp/api/spec/{version.h => version.h.in} |  6 ++---

>  platform/Makefile.inc                            |  3 +--

>  scripts/Makefile.am                              |  1 -

>  scripts/get_impl_str.sh                          | 11 ---------

>  scripts/git_hash.sh                              | 29 ------------------------

>  9 files changed, 26 insertions(+), 52 deletions(-)

>  create mode 100644 include/odp/api/spec/.gitignore

>  rename include/odp/api/spec/{version.h => version.h.in} (93%)

>  delete mode 100644 scripts/Makefile.am

>  delete mode 100755 scripts/get_impl_str.sh

>  delete mode 100755 scripts/git_hash.sh

> 

> diff --git a/.gitignore b/.gitignore

> index d4e7d02..fbc0eab 100644

> --- a/.gitignore

> +++ b/.gitignore

> @@ -12,7 +12,6 @@

>  .deps/

>  .dirstamp

>  .libs/

> -.scmversion

>  CUnit-Memory-Dump.xml

>  ID

>  Makefile

> diff --git a/Makefile.am b/Makefile.am

> index 625748a..2a9a658 100644

> --- a/Makefile.am

> +++ b/Makefile.am

> @@ -11,9 +11,8 @@ SUBDIRS = @platform_with_platform@ \

>  	  test \

>  	  helper/test \

>  	  doc \

> -	  example \

> -	  scripts

> +	  example

>  

>  @DX_RULES@

>  

> -EXTRA_DIST = bootstrap $(DX_CONFIG) CHANGELOG config/README .scmversion

> +EXTRA_DIST = bootstrap $(DX_CONFIG) CHANGELOG config/README

> diff --git a/configure.ac b/configure.ac

> index f081c51..ab19084 100644

> --- a/configure.ac

> +++ b/configure.ac

> @@ -1,5 +1,23 @@

>  AC_PREREQ([2.5])

> -AC_INIT([OpenDataPlane], m4_esyscmd(./scripts/git_hash.sh .), [lng-odp@lists.linaro.org])

> +##########################################################################

> +# Set correct API version

> +##########################################################################

> +m4_define([odpapi_generation_version], [1])

> +m4_define([odpapi_major_version], [11])

> +m4_define([odpapi_minor_version], [0])

> +m4_define([odpapi_point_version], [0])

> +m4_define([odpapi_version],

> +    [odpapi_generation_version.odpapi_major_version.odpapi_minor_version.odpapi_point_version])

> +AC_INIT([OpenDataPlane],[odpapi_version],[lng-odp@lists.linaro.org])

> +

> +ODP_VERSION_API_GENERATION=odpapi_generation_version

> +AC_SUBST(ODP_VERSION_API_GENERATION)

> +ODP_VERSION_API_MAJOR=odpapi_major_version

> +AC_SUBST(ODP_VERSION_API_MAJOR)

> +ODP_VERSION_API_MINOR=odpapi_minor_version

> +AC_SUBST(ODP_VERSION_API_MINOR)

> +AC_CONFIG_FILES([include/odp/api/spec/version.h])

> +

>  AM_INIT_AUTOMAKE([1.9 tar-pax subdir-objects])

>  AC_CONFIG_SRCDIR([helper/config.h.in])

>  AM_CONFIG_HEADER([helper/config.h])

> @@ -271,7 +289,6 @@ AC_CONFIG_FILES([Makefile

>  		 helper/test/Makefile

>  		 pkgconfig/libodp-linux.pc

>  		 pkgconfig/libodphelper-linux.pc

> -		 scripts/Makefile

>  		 ])

>  

>  AC_SEARCH_LIBS([timer_create],[rt posix4])

> diff --git a/include/odp/api/spec/.gitignore b/include/odp/api/spec/.gitignore

> new file mode 100644

> index 0000000..6702033

> --- /dev/null

> +++ b/include/odp/api/spec/.gitignore

> @@ -0,0 +1 @@

> +version.h

> diff --git a/include/odp/api/spec/version.h b/include/odp/api/spec/version.h.in

> similarity index 93%

> rename from include/odp/api/spec/version.h

> rename to include/odp/api/spec/version.h.in

> index aa3f3ab..4b16dcc 100644

> --- a/include/odp/api/spec/version.h

> +++ b/include/odp/api/spec/version.h.in

> @@ -37,7 +37,7 @@ extern "C" {

>   * very significant changes to the API. APIs with different

>   * versions are likely not backward compatible.

>   */

> -#define ODP_VERSION_API_GENERATION 1

> +#define ODP_VERSION_API_GENERATION @ODP_VERSION_API_GENERATION@

>  

>  /**

>   * ODP API major version

> @@ -45,7 +45,7 @@ extern "C" {

>   * Introduction of major new features or changes. APIs with different major

>   * versions are likely not backward compatible.

>   */

> -#define ODP_VERSION_API_MAJOR 10

> +#define  ODP_VERSION_API_MAJOR @ODP_VERSION_API_MAJOR@

>  

>  /**

>   * ODP API minor version

> @@ -54,7 +54,7 @@ extern "C" {

>   * to the API. For an API with common generation and major version, but with

>   * different minor numbers the two versions are backward compatible.

>   */

> -#define ODP_VERSION_API_MINOR 1

> +#define ODP_VERSION_API_MINOR @ODP_VERSION_API_MINOR@

>  

>  /**

>   * ODP API version string

> diff --git a/platform/Makefile.inc b/platform/Makefile.inc

> index a44f88f..432d1fd 100644

> --- a/platform/Makefile.inc

> +++ b/platform/Makefile.inc

> @@ -10,8 +10,7 @@ lib_LTLIBRARIES = $(LIB)/libodp-linux.la

>  

>  AM_LDFLAGS += -version-number '$(ODP_LIBSO_VERSION)'

>  

> -GIT_DESC = `$(top_srcdir)/scripts/get_impl_str.sh $(top_srcdir)`

> -AM_CFLAGS += "-DGIT_HASH=$(GIT_DESC)"

> +AM_CFLAGS += "-DGIT_HASH=$(VERSION)"

>  AM_CFLAGS += $(VISIBILITY_CFLAGS)

>  

>  #The implementation will need to retain the deprecated implementation

> diff --git a/scripts/Makefile.am b/scripts/Makefile.am

> deleted file mode 100644

> index 189b3ef..0000000

> --- a/scripts/Makefile.am

> +++ /dev/null

> @@ -1 +0,0 @@

> -EXTRA_DIST = get_impl_str.sh git_hash.sh

> diff --git a/scripts/get_impl_str.sh b/scripts/get_impl_str.sh

> deleted file mode 100755

> index d765a53..0000000

> --- a/scripts/get_impl_str.sh

> +++ /dev/null

> @@ -1,11 +0,0 @@

> -#!/bin/bash

> -

> -if [ -z ${1} ]; then

> -	echo "should be called with a path"

> -	exit

> -fi

> -ROOTDIR=${1}

> -

> -CUSTOM_STR=${CUSTOM_STR:-https://git.linaro.org/lng/odp.git}

> -

> -echo -n "'${CUSTOM_STR}' ($(cat ${ROOTDIR}/.scmversion))"

> diff --git a/scripts/git_hash.sh b/scripts/git_hash.sh

> deleted file mode 100755

> index 336eb01..0000000

> --- a/scripts/git_hash.sh

> +++ /dev/null

> @@ -1,29 +0,0 @@

> -#!/bin/bash

> -

> -if [ -z ${1} ]; then

> -	echo "should be called with a path"

> -	exit

> -fi

> -ROOTDIR=${1}

> -

> -if [ -d ${ROOTDIR}/.git ]; then

> -	hash=$(git --git-dir=${ROOTDIR}/.git describe --match 'v[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'\

> -	       | tr -d "\n")

> -	if [[ $(git --git-dir=${ROOTDIR}/.git diff --shortstat 2> /dev/null \

> -		| tail -n1) != "" ]]; then

> -		dirty=.dirty

> -	fi

> -

> -	echo -n "${hash}${dirty}">${ROOTDIR}/.scmversion

> -

> -	sed -i "s|-|.git|" ${ROOTDIR}/.scmversion

> -	sed -i "s|-|.|g" ${ROOTDIR}/.scmversion

> -	sed -i "s|^v||g" ${ROOTDIR}/.scmversion

> -elif [ ! -d ${ROOTDIR}/.git -a ! -f ${ROOTDIR}/.scmversion ]; then

> -	echo -n "File ROOTDIR/.scmversion not found, "

> -	echo "and not inside a git repository"

> -	echo "Bailing out! Not recoverable!"

> -	exit 1

> -fi

> -

> -cat ${ROOTDIR}/.scmversion

> -- 

> 2.7.4

>
diff mbox

Patch

diff --git a/.gitignore b/.gitignore
index d4e7d02..fbc0eab 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,7 +12,6 @@ 
 .deps/
 .dirstamp
 .libs/
-.scmversion
 CUnit-Memory-Dump.xml
 ID
 Makefile
diff --git a/Makefile.am b/Makefile.am
index 625748a..2a9a658 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,9 +11,8 @@  SUBDIRS = @platform_with_platform@ \
 	  test \
 	  helper/test \
 	  doc \
-	  example \
-	  scripts
+	  example
 
 @DX_RULES@
 
-EXTRA_DIST = bootstrap $(DX_CONFIG) CHANGELOG config/README .scmversion
+EXTRA_DIST = bootstrap $(DX_CONFIG) CHANGELOG config/README
diff --git a/configure.ac b/configure.ac
index f081c51..ab19084 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,23 @@ 
 AC_PREREQ([2.5])
-AC_INIT([OpenDataPlane], m4_esyscmd(./scripts/git_hash.sh .), [lng-odp@lists.linaro.org])
+##########################################################################
+# Set correct API version
+##########################################################################
+m4_define([odpapi_generation_version], [1])
+m4_define([odpapi_major_version], [11])
+m4_define([odpapi_minor_version], [0])
+m4_define([odpapi_point_version], [0])
+m4_define([odpapi_version],
+    [odpapi_generation_version.odpapi_major_version.odpapi_minor_version.odpapi_point_version])
+AC_INIT([OpenDataPlane],[odpapi_version],[lng-odp@lists.linaro.org])
+
+ODP_VERSION_API_GENERATION=odpapi_generation_version
+AC_SUBST(ODP_VERSION_API_GENERATION)
+ODP_VERSION_API_MAJOR=odpapi_major_version
+AC_SUBST(ODP_VERSION_API_MAJOR)
+ODP_VERSION_API_MINOR=odpapi_minor_version
+AC_SUBST(ODP_VERSION_API_MINOR)
+AC_CONFIG_FILES([include/odp/api/spec/version.h])
+
 AM_INIT_AUTOMAKE([1.9 tar-pax subdir-objects])
 AC_CONFIG_SRCDIR([helper/config.h.in])
 AM_CONFIG_HEADER([helper/config.h])
@@ -271,7 +289,6 @@  AC_CONFIG_FILES([Makefile
 		 helper/test/Makefile
 		 pkgconfig/libodp-linux.pc
 		 pkgconfig/libodphelper-linux.pc
-		 scripts/Makefile
 		 ])
 
 AC_SEARCH_LIBS([timer_create],[rt posix4])
diff --git a/include/odp/api/spec/.gitignore b/include/odp/api/spec/.gitignore
new file mode 100644
index 0000000..6702033
--- /dev/null
+++ b/include/odp/api/spec/.gitignore
@@ -0,0 +1 @@ 
+version.h
diff --git a/include/odp/api/spec/version.h b/include/odp/api/spec/version.h.in
similarity index 93%
rename from include/odp/api/spec/version.h
rename to include/odp/api/spec/version.h.in
index aa3f3ab..4b16dcc 100644
--- a/include/odp/api/spec/version.h
+++ b/include/odp/api/spec/version.h.in
@@ -37,7 +37,7 @@  extern "C" {
  * very significant changes to the API. APIs with different
  * versions are likely not backward compatible.
  */
-#define ODP_VERSION_API_GENERATION 1
+#define ODP_VERSION_API_GENERATION @ODP_VERSION_API_GENERATION@
 
 /**
  * ODP API major version
@@ -45,7 +45,7 @@  extern "C" {
  * Introduction of major new features or changes. APIs with different major
  * versions are likely not backward compatible.
  */
-#define ODP_VERSION_API_MAJOR 10
+#define  ODP_VERSION_API_MAJOR @ODP_VERSION_API_MAJOR@
 
 /**
  * ODP API minor version
@@ -54,7 +54,7 @@  extern "C" {
  * to the API. For an API with common generation and major version, but with
  * different minor numbers the two versions are backward compatible.
  */
-#define ODP_VERSION_API_MINOR 1
+#define ODP_VERSION_API_MINOR @ODP_VERSION_API_MINOR@
 
 /**
  * ODP API version string
diff --git a/platform/Makefile.inc b/platform/Makefile.inc
index a44f88f..432d1fd 100644
--- a/platform/Makefile.inc
+++ b/platform/Makefile.inc
@@ -10,8 +10,7 @@  lib_LTLIBRARIES = $(LIB)/libodp-linux.la
 
 AM_LDFLAGS += -version-number '$(ODP_LIBSO_VERSION)'
 
-GIT_DESC = `$(top_srcdir)/scripts/get_impl_str.sh $(top_srcdir)`
-AM_CFLAGS += "-DGIT_HASH=$(GIT_DESC)"
+AM_CFLAGS += "-DGIT_HASH=$(VERSION)"
 AM_CFLAGS += $(VISIBILITY_CFLAGS)
 
 #The implementation will need to retain the deprecated implementation
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
deleted file mode 100644
index 189b3ef..0000000
--- a/scripts/Makefile.am
+++ /dev/null
@@ -1 +0,0 @@ 
-EXTRA_DIST = get_impl_str.sh git_hash.sh
diff --git a/scripts/get_impl_str.sh b/scripts/get_impl_str.sh
deleted file mode 100755
index d765a53..0000000
--- a/scripts/get_impl_str.sh
+++ /dev/null
@@ -1,11 +0,0 @@ 
-#!/bin/bash
-
-if [ -z ${1} ]; then
-	echo "should be called with a path"
-	exit
-fi
-ROOTDIR=${1}
-
-CUSTOM_STR=${CUSTOM_STR:-https://git.linaro.org/lng/odp.git}
-
-echo -n "'${CUSTOM_STR}' ($(cat ${ROOTDIR}/.scmversion))"
diff --git a/scripts/git_hash.sh b/scripts/git_hash.sh
deleted file mode 100755
index 336eb01..0000000
--- a/scripts/git_hash.sh
+++ /dev/null
@@ -1,29 +0,0 @@ 
-#!/bin/bash
-
-if [ -z ${1} ]; then
-	echo "should be called with a path"
-	exit
-fi
-ROOTDIR=${1}
-
-if [ -d ${ROOTDIR}/.git ]; then
-	hash=$(git --git-dir=${ROOTDIR}/.git describe --match 'v[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'\
-	       | tr -d "\n")
-	if [[ $(git --git-dir=${ROOTDIR}/.git diff --shortstat 2> /dev/null \
-		| tail -n1) != "" ]]; then
-		dirty=.dirty
-	fi
-
-	echo -n "${hash}${dirty}">${ROOTDIR}/.scmversion
-
-	sed -i "s|-|.git|" ${ROOTDIR}/.scmversion
-	sed -i "s|-|.|g" ${ROOTDIR}/.scmversion
-	sed -i "s|^v||g" ${ROOTDIR}/.scmversion
-elif [ ! -d ${ROOTDIR}/.git -a ! -f ${ROOTDIR}/.scmversion ]; then
-	echo -n "File ROOTDIR/.scmversion not found, "
-	echo "and not inside a git repository"
-	echo "Bailing out! Not recoverable!"
-	exit 1
-fi
-
-cat ${ROOTDIR}/.scmversion