From e62ceb5618c40cbc900d9ad4f664d658b2bd83b0 Mon Sep 17 00:00:00 2001 From: "Alexandru N. Onea" Date: Mon, 8 Apr 2019 12:20:28 +0300 Subject: Generate final version string and number based on major, minor and patch --- include/tinyalsa/version.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/include/tinyalsa/version.h b/include/tinyalsa/version.h index ae3fb5e..608511d 100644 --- a/include/tinyalsa/version.h +++ b/include/tinyalsa/version.h @@ -29,15 +29,30 @@ #ifndef TINYALSA_VERSION_H #define TINYALSA_VERSION_H +/* Macros for expanding the version numbers into string literals */ +#define TINYALSA_VERSION_STR_EX(number) #number +#define TINYALSA_VERSION_STR(number) TINYALSA_VERSION_STR_EX (number) + #define TINYALSA_VERSION_MAJOR 1 #define TINYALSA_VERSION_MINOR 1 #define TINYALSA_VERSION_PATCH 1 -#define TINYALSA_VERSION 0x010101UL - -#define TINYALSA_VERSION_STRING "1.1.1" +/* The final version number is constructed based on minor, major and patch */ +#define TINYALSA_VERSION \ + ((unsigned long) \ + ((TINYALSA_VERSION_MAJOR << 16) | \ + (TINYALSA_VERSION_MINOR << 8 ) | \ + (TINYALSA_VERSION_PATCH ))) + +/* The version string is constructed by concatenating individual ver. strings */ +#define TINYALSA_VERSION_STRING \ + TINYALSA_VERSION_STR (TINYALSA_VERSION_MAJOR) \ + "." \ + TINYALSA_VERSION_STR (TINYALSA_VERSION_MINOR) \ + "." \ + TINYALSA_VERSION_STR (TINYALSA_VERSION_PATCH) #endif /* TINYALSA_VERSION_H */ -- cgit v1.2.3 From 3a6abfad30dafcb1f39a12e6ee74f197cb776abf Mon Sep 17 00:00:00 2001 From: "Alexandru N. Onea" Date: Tue, 9 Apr 2019 01:23:10 +0300 Subject: Initial version-bump.sh --- Makefile | 3 + meson.build | 2 +- scripts/version-bump.sh | 160 ++++++++++++++++++++++++++++++++++++++++++++++++ src/Makefile | 23 ++++--- 4 files changed, 177 insertions(+), 11 deletions(-) create mode 100755 scripts/version-bump.sh diff --git a/Makefile b/Makefile index e3ed0ef..4de58df 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,9 @@ export LIBDIR ?= $(PREFIX)/lib export BINDIR ?= $(PREFIX)/bin export MANDIR ?= $(PREFIX)/share/man +export TINYALSA_VERSION_MAJOR = $(shell scripts/version-bump.sh -s print major) +export TINYALSA_VERSION = $(shell scripts/version-bump.sh -s print ) + .PHONY: all all: $(MAKE) -C src diff --git a/meson.build b/meson.build index d7e3a99..dda722d 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project ('tinyalsa', 'c', - version : run_command(find_program('scripts/version.py')).stdout().strip(), + version : run_command(find_program('scripts/version-bump.sh'), 'print', '-s').stdout().strip(), meson_version : '>= 0.48.0') tinyalsa_includes = include_directories('.', 'include') diff --git a/scripts/version-bump.sh b/scripts/version-bump.sh new file mode 100755 index 0000000..6378801 --- /dev/null +++ b/scripts/version-bump.sh @@ -0,0 +1,160 @@ +#!/bin/bash + +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# +# Project configuration variables +# +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +VERSION_FILE="include/tinyalsa/version.h" + +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# +# Scripts internal variables +# +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +LF="\n" +PARAMS="" + +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# +# Helper functions +# +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +die() +{ + echo "Error: $@" 1>&2 + exit 1 +} + +print_usage() +{ + echo "Usage: $0 [OPTIONS] ACTION" + echo + echo "Available options:" + echo " -s,--script Format output in \"script\" mode (no trailing newline)." + echo + echo "Available actions:" + echo " print [minor|major|patch] Print the current version." + echo + echo "Please run this script from the project root folder." +} + + +# Gets a part of the version from the project version file (version.h). +# Takes one argument: the matching version identifier in the version file. +get_version_part() +{ + local V=$(grep -m 1 "^#define\([ \t]*\)${1}" ${VERSION_FILE} | sed 's/[^0-9]*//g') + + [ ! -z ${V} ] || die "Could not get ${1} from ${VERSION_FILE}" + + echo ${V} +} + + +# Gets the complete version from the version file. +get_version() +{ + [ -f ${VERSION_FILE} ] || die "No ${VERSION_FILE} found! Is this the project root?"; + + VERSION_MAJOR=$(get_version_part "TINYALSA_VERSION_MAJOR") + VERSION_MINOR=$(get_version_part "TINYALSA_VERSION_MINOR") + VERSION_PATCH=$(get_version_part "TINYALSA_VERSION_PATCH") +} + +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# +# Actions implementations / functions +# +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +print_version() +{ + get_version + + if [ -z $1 ]; then + printf "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${LF}" + else + case "$1" in + major) + printf "${VERSION_MAJOR}${LF}" + ;; + minor) + printf "${VERSION_MINOR}${LF}" + ;; + patch) + printf "${VERSION_PATCH}${LF}" + ;; + *) + die "Unknown part \"$1\" (must be one of minor, major and patch)." + ;; + esac + fi + + return 0 +} + +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# +# Command Line parsing +# +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +parse_command() +{ + if [ "$#" -eq "0" ]; then + print_usage + exit 1 + fi + + case "$1" in + print) + print_version "$2" + exit $? + ;; + *) + die "Unsupported action \"$1\"." + ;; + esac +} + +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# +# Main +# +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +set -e +trap "set +e" 0 + +# Checking parameters +if [ "$#" -eq "0" ]; then + print_usage + exit 0 +fi + +while [ "$#" -ne "0" ]; do + case "$1" in + -s|--script) + unset LF + shift + ;; + --) + shift + break + ;; + -*|--*=) + die "Unsupported flag \"$1\"." + ;; + *) + PARAMS="$PARAMS ${1}" + shift + ;; + esac +done + +# set positional arguments in their proper place +set -- "${PARAMS}" + +parse_command ${PARAMS} + +# The script should never reach this place. +die "Internal error. Please report this." diff --git a/src/Makefile b/src/Makefile index d33c9f1..fde31e4 100644 --- a/src/Makefile +++ b/src/Makefile @@ -18,6 +18,9 @@ override CFLAGS := $(WARNINGS) $(INCLUDE_DIRS) -fPIC $(CFLAGS) VPATH = ../include/tinyalsa OBJECTS = limits.o mixer.o pcm.o +LIBVERSION_MAJOR = $(TINYALSA_VERSION_MAJOR) +LIBVERSION = $(TINYALSA_VERSION) + .PHONY: all all: libtinyalsa.a libtinyalsa.so @@ -30,28 +33,28 @@ mixer.o: mixer.c mixer.h libtinyalsa.a: $(OBJECTS) $(AR) $(ARFLAGS) $@ $^ -libtinyalsa.so: libtinyalsa.so.1 +libtinyalsa.so: libtinyalsa.so.$(LIBVERSION_MAJOR) ln -sf $< $@ -libtinyalsa.so.1: libtinyalsa.so.1.1.1 +libtinyalsa.so.$(LIBVERSION_MAJOR): libtinyalsa.so.$(LIBVERSION) ln -sf $< $@ -libtinyalsa.so.1.1.1: $(OBJECTS) - $(LD) $(LDFLAGS) -shared -Wl,-soname,libtinyalsa.so.1 $^ -o $@ +libtinyalsa.so.$(LIBVERSION): $(OBJECTS) + $(LD) $(LDFLAGS) -shared -Wl,-soname,libtinyalsa.so.$(LIBVERSION_MAJOR) $^ -o $@ .PHONY: clean clean: rm -f libtinyalsa.a rm -f libtinyalsa.so - rm -f libtinyalsa.so.1 - rm -f libtinyalsa.so.1.1.1 + rm -f libtinyalsa.so.$(LIBVERSION_MAJOR) + rm -f libtinyalsa.so.$(LIBVERSION) rm -f $(OBJECTS) .PHONY: install -install: libtinyalsa.a libtinyalsa.so.1 +install: libtinyalsa.a libtinyalsa.so.$(LIBVERSION_MAJOR) install -d $(DESTDIR)$(LIBDIR)/ install libtinyalsa.a $(DESTDIR)$(LIBDIR)/ - install libtinyalsa.so.1.1.1 $(DESTDIR)$(LIBDIR)/ - ln -sf libtinyalsa.so.1.1.1 $(DESTDIR)$(LIBDIR)/libtinyalsa.so.1 - ln -sf libtinyalsa.so.1 $(DESTDIR)$(LIBDIR)/libtinyalsa.so + install libtinyalsa.so.$(LIBVERSION) $(DESTDIR)$(LIBDIR)/ + ln -sf libtinyalsa.so.$(LIBVERSION) $(DESTDIR)$(LIBDIR)/libtinyalsa.so.$(LIBVERSION_MAJOR) + ln -sf libtinyalsa.so.$(LIBVERSION_MAJOR) $(DESTDIR)$(LIBDIR)/libtinyalsa.so -- cgit v1.2.3 From 891c04d70b30ed4533785469b8bd2f5d6c17a68c Mon Sep 17 00:00:00 2001 From: "Alexandru N. Onea" Date: Tue, 9 Apr 2019 21:16:34 +0300 Subject: Add release action to version-bump.sh --- scripts/version-bump.sh | 73 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 4 deletions(-) diff --git a/scripts/version-bump.sh b/scripts/version-bump.sh index 6378801..287580b 100755 --- a/scripts/version-bump.sh +++ b/scripts/version-bump.sh @@ -31,10 +31,11 @@ print_usage() echo "Usage: $0 [OPTIONS] ACTION" echo echo "Available options:" - echo " -s,--script Format output in \"script\" mode (no trailing newline)." + echo " -s,--script Format output in \"script\" mode (no trailing newline)." echo echo "Available actions:" - echo " print [minor|major|patch] Print the current version." + echo " print [minor|major|patch] Print the current version." + echo " release [minor|major|patch] Bump the specified version part" echo echo "Please run this script from the project root folder." } @@ -44,9 +45,9 @@ print_usage() # Takes one argument: the matching version identifier in the version file. get_version_part() { - local V=$(grep -m 1 "^#define\([ \t]*\)${1}" ${VERSION_FILE} | sed 's/[^0-9]*//g') + local V=$(grep -m 1 "^#define\([ \t]*\)$1" ${VERSION_FILE} | sed 's/[^0-9]*//g') - [ ! -z ${V} ] || die "Could not get ${1} from ${VERSION_FILE}" + [ ! -z ${V} ] || die "Could not get $1 from ${VERSION_FILE}" echo ${V} } @@ -62,6 +63,32 @@ get_version() VERSION_PATCH=$(get_version_part "TINYALSA_VERSION_PATCH") } +# Commits the new version part to the version file. +# Takes two arguments: the version part identifier in the version file and the +# new version number. +commit_version_part() +{ + if [ -z $1 ] || [ -z $2 ]; then + return 0 + fi + + sed -i "s/\(^#define[ \t]*$1\)[ \t]*\([0-9]*\)/\1 $2/g" ${VERSION_FILE} \ + || die "Could not commit version"; + + return 0 +} + +# Commits the new version to the version file. +# Takes three arguments, the new version numbers for major, minor and patch +commit_version() +{ + commit_version_part "TINYALSA_VERSION_PATCH" $1 + commit_version_part "TINYALSA_VERSION_MINOR" $2 + commit_version_part "TINYALSA_VERSION_MAJOR" $3 + + return 0 +} + # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # # Actions implementations / functions @@ -93,6 +120,40 @@ print_version() return 0 } +bump_version() +{ + get_version + + local PART="patch" + + if [ ! -z $1 ]; then + PART="$1" + fi + + case "$PART" in + major) + VERSION_MAJOR=$((VERSION_MAJOR+1)) + VERSION_MINOR=0 + VERSION_PATCH=0 + ;; + minor) + VERSION_MINOR=$((VERSION_MINOR+1)) + VERSION_PATCH=0 + ;; + patch) + VERSION_PATCH=$((VERSION_PATCH+1)) + ;; + *) + die "Unknown part \"$1\" (must be one of minor, major and patch)." + ;; + esac + + commit_version ${VERSION_PATCH} ${VERSION_MINOR} ${VERSION_MAJOR} + print_version + + return 0 +} + # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # # Command Line parsing @@ -110,6 +171,10 @@ parse_command() print_version "$2" exit $? ;; + release) + bump_version "$2" + exit $? + ;; *) die "Unsupported action \"$1\"." ;; -- cgit v1.2.3 From 52a7957cabc961d25b2eb765c34ca4e06844e197 Mon Sep 17 00:00:00 2001 From: "Alexandru N. Onea" Date: Tue, 9 Apr 2019 21:51:27 +0300 Subject: Add check action to version-bump.sh; Activate checks --- CMakeLists.txt | 6 ++++++ Makefile | 7 +++++-- meson.build | 7 +++++++ scripts/version-bump.sh | 20 ++++++++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb31c58..c927706 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,12 @@ add_library("tinyalsa" ${HDRS} ${SRCS}) target_compile_options("tinyalsa" PRIVATE -Wall -Wextra -Werror -Wfatal-errors) target_include_directories("tinyalsa" PRIVATE "include") +add_custom_command(TARGET "tinyalsa" + POST_BUILD + COMMENT "Checking version against the changelog" + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + COMMAND ${PROJECT_SOURCE_DIR}/scripts/version-bump.sh check) + macro(ADD_EXAMPLE EXAMPLE) add_executable(${EXAMPLE} ${ARGN}) target_link_libraries(${EXAMPLE} "tinyalsa") diff --git a/Makefile b/Makefile index 4de58df..ea9bfef 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,10 @@ export LIBDIR ?= $(PREFIX)/lib export BINDIR ?= $(PREFIX)/bin export MANDIR ?= $(PREFIX)/share/man -export TINYALSA_VERSION_MAJOR = $(shell scripts/version-bump.sh -s print major) -export TINYALSA_VERSION = $(shell scripts/version-bump.sh -s print ) +export VERSIONSCRIPT = $(shell pwd)/scripts/version-bump.sh + +export TINYALSA_VERSION_MAJOR = $(shell $(VERSIONSCRIPT) -s print major) +export TINYALSA_VERSION = $(shell $(VERSIONSCRIPT) -s print ) .PHONY: all all: @@ -16,6 +18,7 @@ all: $(MAKE) -C utils $(MAKE) -C doxygen $(MAKE) -C examples + $(VERSIONSCRIPT) check .PHONY: clean clean: diff --git a/meson.build b/meson.build index dda722d..04edda5 100644 --- a/meson.build +++ b/meson.build @@ -10,6 +10,13 @@ tinyalsa = library('tinyalsa', version: meson.project_version(), install: true) +log_version = run_command(find_program('scripts/version-bump.sh'), 'check') +if log_version.returncode() != 0 + error(log_version.stderr()) +endif + +message(log_version.stdout()) + # For use as a Meson subproject tinyalsa_dep = declare_dependency(link_with: tinyalsa, include_directories: include_directories('include')) diff --git a/scripts/version-bump.sh b/scripts/version-bump.sh index 287580b..05fbf37 100755 --- a/scripts/version-bump.sh +++ b/scripts/version-bump.sh @@ -6,6 +6,7 @@ # # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= VERSION_FILE="include/tinyalsa/version.h" +CHANGELOG_FILE="debian/changelog" # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # @@ -154,6 +155,21 @@ bump_version() return 0 } +check_version() +{ + get_version + + LOG_VERSION=$(grep -m 1 "^tinyalsa (" ${CHANGELOG_FILE}| sed "s/[^0-9.]*//g") + REF_VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" + + if [ "${LOG_VERSION}" != "${REF_VERSION}" ]; then + die "Changelog version (${LOG_VERSION}) does not match package version (${REF_VERSION})." + fi + + printf "Changelog version (${LOG_VERSION}) OK!${LF}" + return 0 +} + # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # # Command Line parsing @@ -175,6 +191,10 @@ parse_command() bump_version "$2" exit $? ;; + check) + check_version + exit $? + ;; *) die "Unsupported action \"$1\"." ;; -- cgit v1.2.3 From 8652557f6279a028ee6876283c6dba3d6e35ea0b Mon Sep 17 00:00:00 2001 From: "Alexandru N. Onea" Date: Wed, 10 Apr 2019 00:30:22 +0300 Subject: Minor improvements to version-bump.sh --- scripts/version-bump.sh | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/scripts/version-bump.sh b/scripts/version-bump.sh index 05fbf37..e9cc595 100755 --- a/scripts/version-bump.sh +++ b/scripts/version-bump.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # @@ -29,6 +29,7 @@ die() print_usage() { + echo echo "Usage: $0 [OPTIONS] ACTION" echo echo "Available options:" @@ -37,18 +38,29 @@ print_usage() echo "Available actions:" echo " print [minor|major|patch] Print the current version." echo " release [minor|major|patch] Bump the specified version part" + echo " check Check the changelog latest released" + echo " version against the version file." echo echo "Please run this script from the project root folder." + echo } +check_files() +{ + [ -f ${VERSION_FILE} ] || die "No ${VERSION_FILE} found!"; + [ -f ${CHANGELOG_FILE} ] || die "No ${CHANGELOG_FILE} found!" +} # Gets a part of the version from the project version file (version.h). -# Takes one argument: the matching version identifier in the version file. +# Takes one argument: the matching version identifier in the version file, e.g. +# TINYALSA_VERSION_MAJOR get_version_part() { local V=$(grep -m 1 "^#define\([ \t]*\)$1" ${VERSION_FILE} | sed 's/[^0-9]*//g') - [ ! -z ${V} ] || die "Could not get $1 from ${VERSION_FILE}" + if [ -z ${V} ]; then + die "Could not get $1 from ${VERSION_FILE}" + fi echo ${V} } @@ -57,8 +69,6 @@ get_version_part() # Gets the complete version from the version file. get_version() { - [ -f ${VERSION_FILE} ] || die "No ${VERSION_FILE} found! Is this the project root?"; - VERSION_MAJOR=$(get_version_part "TINYALSA_VERSION_MAJOR") VERSION_MINOR=$(get_version_part "TINYALSA_VERSION_MINOR") VERSION_PATCH=$(get_version_part "TINYALSA_VERSION_PATCH") @@ -66,7 +76,7 @@ get_version() # Commits the new version part to the version file. # Takes two arguments: the version part identifier in the version file and the -# new version number. +# new version number. If no arguments, do nothing. commit_version_part() { if [ -z $1 ] || [ -z $2 ]; then @@ -74,9 +84,11 @@ commit_version_part() fi sed -i "s/\(^#define[ \t]*$1\)[ \t]*\([0-9]*\)/\1 $2/g" ${VERSION_FILE} \ - || die "Could not commit version"; + || die "Could not commit version for $1"; - return 0 + [ $(get_version_part $1) = "$2" ] || die "Version check after commit failed for $1" + + return 0; } # Commits the new version to the version file. @@ -159,8 +171,8 @@ check_version() { get_version - LOG_VERSION=$(grep -m 1 "^tinyalsa (" ${CHANGELOG_FILE}| sed "s/[^0-9.]*//g") - REF_VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" + local LOG_VERSION=$(grep -m 1 "^tinyalsa (" ${CHANGELOG_FILE}| sed "s/[^0-9.]*//g") + local REF_VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" if [ "${LOG_VERSION}" != "${REF_VERSION}" ]; then die "Changelog version (${LOG_VERSION}) does not match package version (${REF_VERSION})." @@ -239,6 +251,7 @@ done # set positional arguments in their proper place set -- "${PARAMS}" +check_files parse_command ${PARAMS} # The script should never reach this place. -- cgit v1.2.3 From cbc69374fde7da9bac83fe70b99c5277f2b1bdbf Mon Sep 17 00:00:00 2001 From: "Alexandru N. Onea" Date: Wed, 10 Apr 2019 00:45:38 +0300 Subject: Add dry-run option to version-bump.sh --- scripts/version-bump.sh | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/scripts/version-bump.sh b/scripts/version-bump.sh index e9cc595..8876c40 100755 --- a/scripts/version-bump.sh +++ b/scripts/version-bump.sh @@ -15,6 +15,7 @@ CHANGELOG_FILE="debian/changelog" # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= LF="\n" PARAMS="" +DRYRUN=0 # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # @@ -33,7 +34,8 @@ print_usage() echo "Usage: $0 [OPTIONS] ACTION" echo echo "Available options:" - echo " -s,--script Format output in \"script\" mode (no trailing newline)." + echo " -s,--script Format output in \"script\" mode (no trailing newline)." + echo " -d,--dry-run Does not commit anything to any file, just prints." echo echo "Available actions:" echo " print [minor|major|patch] Print the current version." @@ -67,6 +69,7 @@ get_version_part() # Gets the complete version from the version file. +# Sets VERSION_MAJOR, VERSION_MINOR and VERSION_PATCH globals get_version() { VERSION_MAJOR=$(get_version_part "TINYALSA_VERSION_MAJOR") @@ -109,8 +112,6 @@ commit_version() # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= print_version() { - get_version - if [ -z $1 ]; then printf "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${LF}" else @@ -135,8 +136,6 @@ print_version() bump_version() { - get_version - local PART="patch" if [ ! -z $1 ]; then @@ -161,16 +160,16 @@ bump_version() ;; esac - commit_version ${VERSION_PATCH} ${VERSION_MINOR} ${VERSION_MAJOR} - print_version + if [ ${DRYRUN} -ne 1 ]; then + commit_version ${VERSION_PATCH} ${VERSION_MINOR} ${VERSION_MAJOR} + fi + print_version return 0 } check_version() { - get_version - local LOG_VERSION=$(grep -m 1 "^tinyalsa (" ${CHANGELOG_FILE}| sed "s/[^0-9.]*//g") local REF_VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" @@ -196,14 +195,17 @@ parse_command() case "$1" in print) + get_version print_version "$2" exit $? ;; release) + get_version bump_version "$2" exit $? ;; check) + get_version check_version exit $? ;; @@ -234,6 +236,10 @@ while [ "$#" -ne "0" ]; do unset LF shift ;; + -d|--dry-run) + DRYRUN=1 + shift + ;; --) shift break -- cgit v1.2.3 From a6838a0c6955a5803ca1b15338b971292c3e824b Mon Sep 17 00:00:00 2001 From: "Alexandru N. Onea" Date: Wed, 10 Apr 2019 01:00:58 +0300 Subject: Rename version-bump to just version --- CMakeLists.txt | 2 +- Makefile | 2 +- meson.build | 4 +- scripts/version-bump.sh | 264 ------------------------------------------------ scripts/version.sh | 264 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 268 insertions(+), 268 deletions(-) delete mode 100755 scripts/version-bump.sh create mode 100755 scripts/version.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index c927706..0bb0af5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ add_custom_command(TARGET "tinyalsa" POST_BUILD COMMENT "Checking version against the changelog" WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - COMMAND ${PROJECT_SOURCE_DIR}/scripts/version-bump.sh check) + COMMAND ${PROJECT_SOURCE_DIR}/scripts/version.sh check) macro(ADD_EXAMPLE EXAMPLE) add_executable(${EXAMPLE} ${ARGN}) diff --git a/Makefile b/Makefile index ea9bfef..f268487 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ export LIBDIR ?= $(PREFIX)/lib export BINDIR ?= $(PREFIX)/bin export MANDIR ?= $(PREFIX)/share/man -export VERSIONSCRIPT = $(shell pwd)/scripts/version-bump.sh +export VERSIONSCRIPT = $(shell pwd)/scripts/version.sh export TINYALSA_VERSION_MAJOR = $(shell $(VERSIONSCRIPT) -s print major) export TINYALSA_VERSION = $(shell $(VERSIONSCRIPT) -s print ) diff --git a/meson.build b/meson.build index 04edda5..7762706 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project ('tinyalsa', 'c', - version : run_command(find_program('scripts/version-bump.sh'), 'print', '-s').stdout().strip(), + version : run_command(find_program('scripts/version.sh'), 'print', '-s').stdout().strip(), meson_version : '>= 0.48.0') tinyalsa_includes = include_directories('.', 'include') @@ -10,7 +10,7 @@ tinyalsa = library('tinyalsa', version: meson.project_version(), install: true) -log_version = run_command(find_program('scripts/version-bump.sh'), 'check') +log_version = run_command(find_program('scripts/version.sh'), 'check') if log_version.returncode() != 0 error(log_version.stderr()) endif diff --git a/scripts/version-bump.sh b/scripts/version-bump.sh deleted file mode 100755 index 8876c40..0000000 --- a/scripts/version-bump.sh +++ /dev/null @@ -1,264 +0,0 @@ -#!/usr/bin/env bash - -# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -# -# Project configuration variables -# -# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -VERSION_FILE="include/tinyalsa/version.h" -CHANGELOG_FILE="debian/changelog" - -# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -# -# Scripts internal variables -# -# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -LF="\n" -PARAMS="" -DRYRUN=0 - -# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -# -# Helper functions -# -# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -die() -{ - echo "Error: $@" 1>&2 - exit 1 -} - -print_usage() -{ - echo - echo "Usage: $0 [OPTIONS] ACTION" - echo - echo "Available options:" - echo " -s,--script Format output in \"script\" mode (no trailing newline)." - echo " -d,--dry-run Does not commit anything to any file, just prints." - echo - echo "Available actions:" - echo " print [minor|major|patch] Print the current version." - echo " release [minor|major|patch] Bump the specified version part" - echo " check Check the changelog latest released" - echo " version against the version file." - echo - echo "Please run this script from the project root folder." - echo -} - -check_files() -{ - [ -f ${VERSION_FILE} ] || die "No ${VERSION_FILE} found!"; - [ -f ${CHANGELOG_FILE} ] || die "No ${CHANGELOG_FILE} found!" -} - -# Gets a part of the version from the project version file (version.h). -# Takes one argument: the matching version identifier in the version file, e.g. -# TINYALSA_VERSION_MAJOR -get_version_part() -{ - local V=$(grep -m 1 "^#define\([ \t]*\)$1" ${VERSION_FILE} | sed 's/[^0-9]*//g') - - if [ -z ${V} ]; then - die "Could not get $1 from ${VERSION_FILE}" - fi - - echo ${V} -} - - -# Gets the complete version from the version file. -# Sets VERSION_MAJOR, VERSION_MINOR and VERSION_PATCH globals -get_version() -{ - VERSION_MAJOR=$(get_version_part "TINYALSA_VERSION_MAJOR") - VERSION_MINOR=$(get_version_part "TINYALSA_VERSION_MINOR") - VERSION_PATCH=$(get_version_part "TINYALSA_VERSION_PATCH") -} - -# Commits the new version part to the version file. -# Takes two arguments: the version part identifier in the version file and the -# new version number. If no arguments, do nothing. -commit_version_part() -{ - if [ -z $1 ] || [ -z $2 ]; then - return 0 - fi - - sed -i "s/\(^#define[ \t]*$1\)[ \t]*\([0-9]*\)/\1 $2/g" ${VERSION_FILE} \ - || die "Could not commit version for $1"; - - [ $(get_version_part $1) = "$2" ] || die "Version check after commit failed for $1" - - return 0; -} - -# Commits the new version to the version file. -# Takes three arguments, the new version numbers for major, minor and patch -commit_version() -{ - commit_version_part "TINYALSA_VERSION_PATCH" $1 - commit_version_part "TINYALSA_VERSION_MINOR" $2 - commit_version_part "TINYALSA_VERSION_MAJOR" $3 - - return 0 -} - -# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -# -# Actions implementations / functions -# -# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -print_version() -{ - if [ -z $1 ]; then - printf "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${LF}" - else - case "$1" in - major) - printf "${VERSION_MAJOR}${LF}" - ;; - minor) - printf "${VERSION_MINOR}${LF}" - ;; - patch) - printf "${VERSION_PATCH}${LF}" - ;; - *) - die "Unknown part \"$1\" (must be one of minor, major and patch)." - ;; - esac - fi - - return 0 -} - -bump_version() -{ - local PART="patch" - - if [ ! -z $1 ]; then - PART="$1" - fi - - case "$PART" in - major) - VERSION_MAJOR=$((VERSION_MAJOR+1)) - VERSION_MINOR=0 - VERSION_PATCH=0 - ;; - minor) - VERSION_MINOR=$((VERSION_MINOR+1)) - VERSION_PATCH=0 - ;; - patch) - VERSION_PATCH=$((VERSION_PATCH+1)) - ;; - *) - die "Unknown part \"$1\" (must be one of minor, major and patch)." - ;; - esac - - if [ ${DRYRUN} -ne 1 ]; then - commit_version ${VERSION_PATCH} ${VERSION_MINOR} ${VERSION_MAJOR} - fi - - print_version - return 0 -} - -check_version() -{ - local LOG_VERSION=$(grep -m 1 "^tinyalsa (" ${CHANGELOG_FILE}| sed "s/[^0-9.]*//g") - local REF_VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" - - if [ "${LOG_VERSION}" != "${REF_VERSION}" ]; then - die "Changelog version (${LOG_VERSION}) does not match package version (${REF_VERSION})." - fi - - printf "Changelog version (${LOG_VERSION}) OK!${LF}" - return 0 -} - -# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -# -# Command Line parsing -# -# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -parse_command() -{ - if [ "$#" -eq "0" ]; then - print_usage - exit 1 - fi - - case "$1" in - print) - get_version - print_version "$2" - exit $? - ;; - release) - get_version - bump_version "$2" - exit $? - ;; - check) - get_version - check_version - exit $? - ;; - *) - die "Unsupported action \"$1\"." - ;; - esac -} - -# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -# -# Main -# -# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -set -e -trap "set +e" 0 - -# Checking parameters -if [ "$#" -eq "0" ]; then - print_usage - exit 0 -fi - -while [ "$#" -ne "0" ]; do - case "$1" in - -s|--script) - unset LF - shift - ;; - -d|--dry-run) - DRYRUN=1 - shift - ;; - --) - shift - break - ;; - -*|--*=) - die "Unsupported flag \"$1\"." - ;; - *) - PARAMS="$PARAMS ${1}" - shift - ;; - esac -done - -# set positional arguments in their proper place -set -- "${PARAMS}" - -check_files -parse_command ${PARAMS} - -# The script should never reach this place. -die "Internal error. Please report this." diff --git a/scripts/version.sh b/scripts/version.sh new file mode 100755 index 0000000..8876c40 --- /dev/null +++ b/scripts/version.sh @@ -0,0 +1,264 @@ +#!/usr/bin/env bash + +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# +# Project configuration variables +# +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +VERSION_FILE="include/tinyalsa/version.h" +CHANGELOG_FILE="debian/changelog" + +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# +# Scripts internal variables +# +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +LF="\n" +PARAMS="" +DRYRUN=0 + +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# +# Helper functions +# +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +die() +{ + echo "Error: $@" 1>&2 + exit 1 +} + +print_usage() +{ + echo + echo "Usage: $0 [OPTIONS] ACTION" + echo + echo "Available options:" + echo " -s,--script Format output in \"script\" mode (no trailing newline)." + echo " -d,--dry-run Does not commit anything to any file, just prints." + echo + echo "Available actions:" + echo " print [minor|major|patch] Print the current version." + echo " release [minor|major|patch] Bump the specified version part" + echo " check Check the changelog latest released" + echo " version against the version file." + echo + echo "Please run this script from the project root folder." + echo +} + +check_files() +{ + [ -f ${VERSION_FILE} ] || die "No ${VERSION_FILE} found!"; + [ -f ${CHANGELOG_FILE} ] || die "No ${CHANGELOG_FILE} found!" +} + +# Gets a part of the version from the project version file (version.h). +# Takes one argument: the matching version identifier in the version file, e.g. +# TINYALSA_VERSION_MAJOR +get_version_part() +{ + local V=$(grep -m 1 "^#define\([ \t]*\)$1" ${VERSION_FILE} | sed 's/[^0-9]*//g') + + if [ -z ${V} ]; then + die "Could not get $1 from ${VERSION_FILE}" + fi + + echo ${V} +} + + +# Gets the complete version from the version file. +# Sets VERSION_MAJOR, VERSION_MINOR and VERSION_PATCH globals +get_version() +{ + VERSION_MAJOR=$(get_version_part "TINYALSA_VERSION_MAJOR") + VERSION_MINOR=$(get_version_part "TINYALSA_VERSION_MINOR") + VERSION_PATCH=$(get_version_part "TINYALSA_VERSION_PATCH") +} + +# Commits the new version part to the version file. +# Takes two arguments: the version part identifier in the version file and the +# new version number. If no arguments, do nothing. +commit_version_part() +{ + if [ -z $1 ] || [ -z $2 ]; then + return 0 + fi + + sed -i "s/\(^#define[ \t]*$1\)[ \t]*\([0-9]*\)/\1 $2/g" ${VERSION_FILE} \ + || die "Could not commit version for $1"; + + [ $(get_version_part $1) = "$2" ] || die "Version check after commit failed for $1" + + return 0; +} + +# Commits the new version to the version file. +# Takes three arguments, the new version numbers for major, minor and patch +commit_version() +{ + commit_version_part "TINYALSA_VERSION_PATCH" $1 + commit_version_part "TINYALSA_VERSION_MINOR" $2 + commit_version_part "TINYALSA_VERSION_MAJOR" $3 + + return 0 +} + +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# +# Actions implementations / functions +# +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +print_version() +{ + if [ -z $1 ]; then + printf "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${LF}" + else + case "$1" in + major) + printf "${VERSION_MAJOR}${LF}" + ;; + minor) + printf "${VERSION_MINOR}${LF}" + ;; + patch) + printf "${VERSION_PATCH}${LF}" + ;; + *) + die "Unknown part \"$1\" (must be one of minor, major and patch)." + ;; + esac + fi + + return 0 +} + +bump_version() +{ + local PART="patch" + + if [ ! -z $1 ]; then + PART="$1" + fi + + case "$PART" in + major) + VERSION_MAJOR=$((VERSION_MAJOR+1)) + VERSION_MINOR=0 + VERSION_PATCH=0 + ;; + minor) + VERSION_MINOR=$((VERSION_MINOR+1)) + VERSION_PATCH=0 + ;; + patch) + VERSION_PATCH=$((VERSION_PATCH+1)) + ;; + *) + die "Unknown part \"$1\" (must be one of minor, major and patch)." + ;; + esac + + if [ ${DRYRUN} -ne 1 ]; then + commit_version ${VERSION_PATCH} ${VERSION_MINOR} ${VERSION_MAJOR} + fi + + print_version + return 0 +} + +check_version() +{ + local LOG_VERSION=$(grep -m 1 "^tinyalsa (" ${CHANGELOG_FILE}| sed "s/[^0-9.]*//g") + local REF_VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" + + if [ "${LOG_VERSION}" != "${REF_VERSION}" ]; then + die "Changelog version (${LOG_VERSION}) does not match package version (${REF_VERSION})." + fi + + printf "Changelog version (${LOG_VERSION}) OK!${LF}" + return 0 +} + +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# +# Command Line parsing +# +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +parse_command() +{ + if [ "$#" -eq "0" ]; then + print_usage + exit 1 + fi + + case "$1" in + print) + get_version + print_version "$2" + exit $? + ;; + release) + get_version + bump_version "$2" + exit $? + ;; + check) + get_version + check_version + exit $? + ;; + *) + die "Unsupported action \"$1\"." + ;; + esac +} + +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# +# Main +# +# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +set -e +trap "set +e" 0 + +# Checking parameters +if [ "$#" -eq "0" ]; then + print_usage + exit 0 +fi + +while [ "$#" -ne "0" ]; do + case "$1" in + -s|--script) + unset LF + shift + ;; + -d|--dry-run) + DRYRUN=1 + shift + ;; + --) + shift + break + ;; + -*|--*=) + die "Unsupported flag \"$1\"." + ;; + *) + PARAMS="$PARAMS ${1}" + shift + ;; + esac +done + +# set positional arguments in their proper place +set -- "${PARAMS}" + +check_files +parse_command ${PARAMS} + +# The script should never reach this place. +die "Internal error. Please report this." -- cgit v1.2.3 From 1830893d7b0c43e53da0e4c50449cf7826101614 Mon Sep 17 00:00:00 2001 From: "Alexandru N. Onea" Date: Thu, 11 Apr 2019 12:56:54 +0300 Subject: Move changelog check ver. from build systems to CI This commit moves the changelog version check to the CI instead of the build systems. Rationale is: the failure to update the changelog is not a build failure / issue but rather an integration failure and it should be detected at integration testing. The closest to integration testing is the CI testing which is mandatory before pull requests and new features integration. Additionally, the old version.py script is removed because it is relying on the old version of include/tinyalsa/version.h where the TINYALSA_VERSION_STRING macro is defiend as an explicit string literal. Since now the version string is defined piece-wise and based on the individual version numbers, and since the introduction of version.sh and its use within meson build system to get the version from the version file, the old version.py script is obsolete. --- CMakeLists.txt | 6 ------ Makefile | 1 - meson.build | 7 ------- scripts/travis-build.sh | 4 ++++ scripts/version.py | 25 ------------------------- 5 files changed, 4 insertions(+), 39 deletions(-) delete mode 100755 scripts/version.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 0bb0af5..cb31c58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,12 +17,6 @@ add_library("tinyalsa" ${HDRS} ${SRCS}) target_compile_options("tinyalsa" PRIVATE -Wall -Wextra -Werror -Wfatal-errors) target_include_directories("tinyalsa" PRIVATE "include") -add_custom_command(TARGET "tinyalsa" - POST_BUILD - COMMENT "Checking version against the changelog" - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - COMMAND ${PROJECT_SOURCE_DIR}/scripts/version.sh check) - macro(ADD_EXAMPLE EXAMPLE) add_executable(${EXAMPLE} ${ARGN}) target_link_libraries(${EXAMPLE} "tinyalsa") diff --git a/Makefile b/Makefile index f268487..9c3dcb1 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,6 @@ all: $(MAKE) -C utils $(MAKE) -C doxygen $(MAKE) -C examples - $(VERSIONSCRIPT) check .PHONY: clean clean: diff --git a/meson.build b/meson.build index 7762706..abbca8e 100644 --- a/meson.build +++ b/meson.build @@ -10,13 +10,6 @@ tinyalsa = library('tinyalsa', version: meson.project_version(), install: true) -log_version = run_command(find_program('scripts/version.sh'), 'check') -if log_version.returncode() != 0 - error(log_version.stderr()) -endif - -message(log_version.stdout()) - # For use as a Meson subproject tinyalsa_dep = declare_dependency(link_with: tinyalsa, include_directories: include_directories('include')) diff --git a/scripts/travis-build.sh b/scripts/travis-build.sh index 9639d88..2bfc4d2 100755 --- a/scripts/travis-build.sh +++ b/scripts/travis-build.sh @@ -3,6 +3,8 @@ set -e set -u +ROOT=$(pwd) + make make clean @@ -16,3 +18,5 @@ $HOME/.local/bin/meson . meson-build cd meson-build ninja cd .. + +${ROOT}/scripts/version.sh check diff --git a/scripts/version.py b/scripts/version.py deleted file mode 100755 index 892dbdb..0000000 --- a/scripts/version.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python3 -# -# tinyalsa version.py: Extracts versions from TINYALSA_VERSION_STRING in -# include/tinyalsa/version.h header file for Meson build. -import os -import sys - -if __name__ == '__main__': - try: - srcroot = os.environ['MESON_SOURCE_ROOT'] - except: - srcroot = os.getcwd() - print('Warning: MESON_SOURCE_ROOT env var not set, assuming source code is in', srcroot, file=sys.stderr) - - # API version - api_version = None - f = open(os.path.join(srcroot, 'include', 'tinyalsa', 'version.h'), 'r') - for line in f: - if line.startswith('#define TINYALSA_VERSION_STRING '): - api_version = line[32:].strip().replace('"', '') - print(api_version) - sys.exit(0) - - print('Warning: Could not extract API version from TINYALSA_VERSION_STRING in include/tinyalsa/version.h in', srcroot, file=sys.stderr) - sys.exit(-1) -- cgit v1.2.3