Skip to content

Commit

Permalink
Add version-sync script to update all places with versions.
Browse files Browse the repository at this point in the history
This will update tox.in.h only. Currently, you will still need to
manually update tox.h. An upcoming PR (#154) will update tox.h as
part of the build.
  • Loading branch information
iphydf committed Sep 28, 2016
1 parent 51139a0 commit 36f40f1
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
27 changes: 24 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ include(CTest)

# This version is for the entire project. All libraries (core, av, ...) move in
# versions in a synchronised way.
set(PROJECT_VERSION "0.0.1")
set(PROJECT_VERSION_MAJOR "0")
set(PROJECT_VERSION_MINOR "0")
set(PROJECT_VERSION_PATCH "1")
set(PROJECT_VERSION
"${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

Expand Down Expand Up @@ -379,6 +383,23 @@ if(BUILD_TOXAV)
DESTINATION "include/tox")
endif()

################################################################################
#
# :: Update versions in various places
#
################################################################################

find_program(SH NAMES sh dash bash zsh)

if(SH)
execute_process(
COMMAND ${SH} ${CMAKE_SOURCE_DIR}/other/version-sync
${CMAKE_SOURCE_DIR}
${PROJECT_VERSION_MAJOR}
${PROJECT_VERSION_MINOR}
${PROJECT_VERSION_PATCH})
endif()

################################################################################
#
# :: Strict ABI
Expand All @@ -387,7 +408,7 @@ endif()

function(make_version_script header ns lib)
execute_process(
COMMAND sh -c "egrep '^\\w' ${header} | grep '${ns}_[a-z0-9_]*(' | grep -v '^typedef' | grep -o '${ns}_[a-z0-9_]*(' | egrep -o '\\w+' | sort -u"
COMMAND ${SH} -c "egrep '^\\w' ${header} | grep '${ns}_[a-z0-9_]*(' | grep -v '^typedef' | grep -o '${ns}_[a-z0-9_]*(' | egrep -o '\\w+' | sort -u"
OUTPUT_VARIABLE ${lib}_SYMS
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REPLACE "\n" ";" ${lib}_SYMS ${${lib}_SYMS})
Expand All @@ -413,7 +434,7 @@ if(WIN32 OR APPLE)
set(STRICT_ABI OFF)
endif()

if(STRICT_ABI)
if(STRICT_ABI AND SH)
if(BUILD_TOXAV)
make_version_script(${CMAKE_SOURCE_DIR}/toxav/toxav.h toxav toxav)
endif()
Expand Down
28 changes: 28 additions & 0 deletions other/version-sync
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

set -eu

SOURCE_DIR=$1
MAJOR=$2
MINOR=$3
PATCH=$4

VER="$MAJOR.$MINOR.$PATCH"

update() {
file="$SOURCE_DIR/$1"
expr="$2"

sed -e "$expr" "$file" > "$file.updated-version"
if diff "$file" "$file.updated-version"; then
rm "$file.updated-version"
else
mv "$file.updated-version" "$file"
fi
}

update "configure.ac" 's/AC_INIT(\[tox\], \[.*\])/AC_INIT([tox], ['$VER'])/'

update "other/apidsl/tox.in.h" 's/\(const VERSION_MAJOR *= \).*;/\1'$MAJOR';/'
update "other/apidsl/tox.in.h" 's/\(const VERSION_MINOR *= \).*;/\1'$MINOR';/'
update "other/apidsl/tox.in.h" 's/\(const VERSION_PATCH *= \).*;/\1'$PATCH';/'

0 comments on commit 36f40f1

Please sign in to comment.