diff --git a/CMakeLists.txt b/CMakeLists.txt index 91a04230..1977f231 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,14 +13,14 @@ set(FASTSCAPELIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) include(GetGitRevisionAddons) -get_git_version_pieces(GIT_VERSION_PIECES) +get_version_pieces(VERSION_PIECES) -format_version_pep440(VERSION_STR GIT_VERSION_PIECES) +format_version_pep440(VERSION_STR VERSION_PIECES) get_version_numbers(VERSION_MAJOR VERSION_MINOR VERSION_PATCH - GIT_VERSION_PIECES) + VERSION_PIECES) -list(GET GIT_VERSION_PIECES 0 GIT_HASH_FULL) +list(GET VERSION_PIECES 0 GIT_HASH_FULL) message(STATUS "Building ${PROJECT_NAME} version ${VERSION_STR}") diff --git a/cmake/modules/GetGitRevisionAddons.cmake b/cmake/modules/GetGitRevisionAddons.cmake index cd10162e..3e62ea99 100644 --- a/cmake/modules/GetGitRevisionAddons.cmake +++ b/cmake/modules/GetGitRevisionAddons.cmake @@ -4,9 +4,8 @@ include(GetGitRevisionDescription) function(get_git_version_pieces _version_pieces) - get_git_head_revision(_ hash_full_) - git_describe(GIT_REV_DESCRIPTION --tags --always --dirty) + git_describe(GIT_REV_DESCRIPTION --tags --always --dirty --long) if(${GIT_REV_DESCRIPTION} MATCHES "^[v]*([0-9\\.]+)\\-([0-9]+)\\-g([A-Za-z0-9]+)\\-*([dirty]*).*") @@ -18,7 +17,7 @@ function(get_git_version_pieces _version_pieces) elseif(${GIT_REV_DESCRIPTION} MATCHES "^[v]*([0-9]+\\.[0-9]+\\.[0-9]+)\\-*([dirty]*).*") - # HEAD is a tag + # HEAD is a tag (normally not needed if --long is used for git describe) set(_closest_tag ${CMAKE_MATCH_1}) set(_commit_count "") set(_hash_short "") @@ -44,6 +43,41 @@ function(get_git_version_pieces _version_pieces) PARENT_SCOPE) endfunction() + +function(get_source_dir_version_pieces _version_pieces) + set(hash_full_ "NOTFOUND") + set(_commit_count "0") + set(_hash_short "") + set(_local_changes "") + + get_filename_component(_dirname ${CMAKE_CURRENT_SOURCE_DIR} NAME) + + if(${_dirname} MATCHES "^.*\\-[v]*([0-9\\.]+)") + set(_closest_tag ${CMAKE_MATCH_1}) + else() + set(_closest_tag "VERSION-NOTFOUND") + endif() + + set(${_version_pieces} + "${hash_full_};${_hash_short};${_closest_tag};${_commit_count};${_local_changes}" + PARENT_SCOPE) +endfunction() + + +function(get_version_pieces _version_pieces) + # TODO: proper version/error handling when git is not installed + get_git_head_revision(_ hash_full_) + + if(hash_full_ STREQUAL "GITDIR-NOTFOUND") + get_source_dir_version_pieces(_pieces) + else() + get_git_version_pieces(_pieces) + endif() + + set(${_version_pieces} "${_pieces}" PARENT_SCOPE) +endfunction() + + function(format_version_pep440 _version_str _version_pieces) list(GET ${_version_pieces} 1 _hash_short) list(GET ${_version_pieces} 2 _closest_tag) @@ -57,9 +91,9 @@ function(format_version_pep440 _version_str _version_pieces) endif() if(_commit_count) list(APPEND _local_version_items ${_commit_count}) - endif() - if(_hash_short) - list(APPEND _local_version_items "g${_hash_short}") + if(_hash_short) + list(APPEND _local_version_items "g${_hash_short}") + endif() endif() if(_local_changes) list(APPEND _local_version_items ${_local_changes}) @@ -75,6 +109,7 @@ function(format_version_pep440 _version_str _version_pieces) set(${_version_str} ${_closest_tag}${_local_version_label} PARENT_SCOPE) endfunction() + function(get_version_numbers _version_major _version_minor _version_patch _version_pieces) diff --git a/cmake/modules/GetGitRevisionDescription.cmake b/cmake/modules/GetGitRevisionDescription.cmake index b54ada49..7ecf0afd 100644 --- a/cmake/modules/GetGitRevisionDescription.cmake +++ b/cmake/modules/GetGitRevisionDescription.cmake @@ -118,7 +118,6 @@ function(git_describe _var) execute_process(COMMAND "${GIT_EXECUTABLE}" describe - --match ${hash} ${ARGN} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" diff --git a/cmake/modules/print_version.cmake b/cmake/modules/print_version.cmake index ae53528e..369180d7 100644 --- a/cmake/modules/print_version.cmake +++ b/cmake/modules/print_version.cmake @@ -4,8 +4,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH}) include(GetGitRevisionAddons) -get_git_version_pieces(GIT_VERSION_PIECES) - -format_version_pep440(VERSION_STR GIT_VERSION_PIECES) +get_version_pieces(VERSION_PIECES) +format_version_pep440(VERSION_STR VERSION_PIECES) message(${VERSION_STR}) diff --git a/include/fastscapelib/hillslope.hpp b/include/fastscapelib/hillslope.hpp index ba29ce9d..b68397c9 100644 --- a/include/fastscapelib/hillslope.hpp +++ b/include/fastscapelib/hillslope.hpp @@ -175,8 +175,11 @@ auto solve_diffusion_adi_row(Ei&& elevation, diag_bounds = 1; auto upper_bounds = xt::view(upper, xt::keep(0, -1)); upper_bounds = 0; - auto vec_bounds = xt::view(vec, xt::keep(0, -1)); - vec_bounds = xt::view(elevation, r, xt::keep(0, -1)); + vec(0) = elevation(r, 0); + vec(ncols - 1) = elevation(r, ncols - 1); + // TODO: the code below works with xtensor 0.17.1 but not with 0.17.2 + // auto vec_bounds = xt::view(vec, xt::keep(0, -1)); + // vec_bounds = xt::view(elevation, r, xt::keep(0, -1)); auto elevation_out_r = xt::view(elevation_out, r, xt::all()); diff --git a/python/setup.py b/python/setup.py index c4bb9b49..9210438d 100644 --- a/python/setup.py +++ b/python/setup.py @@ -30,9 +30,9 @@ def get_version(): """ check_cmake_version() - cmake_script = os.path.join(os.pardir, 'cmake', 'modules', - 'print_version.cmake') + cmake_script = os.path.join('cmake', 'modules', 'print_version.cmake') out = subprocess.check_output(['cmake', '-P', cmake_script], + cwd=os.pardir, stderr=subprocess.STDOUT) version_str = out.decode().strip() return version_str