Skip to content

Commit fbc6fe7

Browse files
committed
Put OpenCoarrays version info in .VERSION file
This makes parsing it from scripts easier, and allows additional information to be included in the file.
1 parent 195f250 commit fbc6fe7

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

.VERSION

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# OpenCoarrays version file. Odd patch levels indicate inter-release
2+
# version, i.e., code is from SCM/git. This project uses semantic
3+
# versioning. For details see http://semver.org
4+
5+
1.8.3

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,15 @@ script:
165165
fi
166166
set +o errexit
167167
168+
after_script:
169+
- |
170+
if [ "$TRAVIS_TAG" ]; then
171+
if [[ "v$TRAVIS_TAG" != "v$(sed -n 's/\([0-9]\{1,\}\(\.[0-9]\{1,\}\)\{1,\}\)/\1/p' .VERSION)" ]]; then
172+
echo "ERROR: You are trying to tag a new release but have a version missmatch in \`.VERSION\`"
173+
false # throw an error
174+
fi
175+
fi
176+
168177
after_success:
169178
- find . -name '*.gcno' -print
170179
- gcov-6 --version

CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ set ( CMAKE_BUILD_TYPE "Release"
66
CACHE STRING "Select which configuration to build." )
77
set_property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES} )
88

9-
#Name project and specify source languages
10-
project(opencoarrays VERSION 1.8.3 LANGUAGES C Fortran)
9+
# Name project and specify source languages
10+
# Parse version from .VERSION file so that more info can be added and easier to get from scripts
11+
file( STRINGS ".VERSION" OpenCoarraysVersion
12+
REGEX "[0-9]+\\.[0-9]+\\.[0-9]+"
13+
)
14+
project(opencoarrays VERSION "${OpenCoarraysVersion}" LANGUAGES C Fortran)
15+
message( STATUS "Building OpenCoarrays version: ${OpenCoarraysVersion}" )
1116

1217
#Print an error message on an attempt to build inside the source directory tree:
1318
if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")

install.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,7 @@ source $opencoarrays_src_dir/prerequisites/install-functions/report_results.sh
240240
if [[ "${arg_v}" == "${__flag_present}" || "${arg_V}" == "opencoarrays" ]]; then
241241

242242
# Print script copyright if invoked with -v, -V, or --version argument
243-
cmake_project_line="$(grep project "${opencoarrays_src_dir}/CMakeLists.txt" | grep VERSION)"
244-
text_after_version_keyword="${cmake_project_line##*VERSION}"
245-
text_before_language_keyword="${text_after_version_keyword%%LANGUAGES*}"
246-
opencoarrays_version=$text_before_language_keyword
243+
opencoarrays_version=$(sed -n 's/\([0-9]\{1,\}\(\.[0-9]\{1,\}\)\{1,\}\)/\1/p' "${opencoarrays_src_dir%/}/.VERSION")
247244
if [[ "${arg_v}" == "${__flag_present}" ]]; then
248245
echo "OpenCoarrays ${opencoarrays_version}"
249246
echo ""

prerequisites/check_version.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,7 @@ elif [[ $1 == '--list' || $1 == '-l' ]]; then
8282

8383
elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
8484
# Print script copyright if invoked with -v, -V, or --version argument
85-
cmake_project_line=$(grep project ../CMakeLists.txt | grep VERSION)
86-
text_after_version_keyword="${cmake_project_line##*VERSION}"
87-
text_before_language_keyword="${text_after_version_keyword%%LANGUAGES*}"
88-
opencoarrays_version=$text_before_language_keyword
85+
opencoarrays_version=$(sed -n 's/\([0-9]\{1,\}\(\.[0-9]\{1,\}\)\{1,\}\)/\1/p' ../.VERSION)
8986
echo "opencoarrays $opencoarrays_version"
9087
echo ""
9188
echo "OpenCoarrays prerequisite version verifier"

0 commit comments

Comments
 (0)