diff options
author | Piotr Krysik <ptrkrysik@gmail.com> | 2017-08-24 15:35:42 +0200 |
---|---|---|
committer | Piotr Krysik <ptrkrysik@gmail.com> | 2017-08-24 15:35:42 +0200 |
commit | bb961c17fabea1c3c796131e5c4317cdfb21c9fa (patch) | |
tree | e3ae9a4929d3da8be7fd5d7eedc7ba847030eadc | |
parent | 77868e4fa677c1b7964a4e948104de2b50d1570d (diff) |
Added versioning borrowed fron GNU Radio to gr-gsm
-rw-r--r-- | CMakeLists.txt | 24 | ||||
-rw-r--r-- | cmake/Modules/GrVersion.cmake | 82 | ||||
-rw-r--r-- | include/grgsm/CMakeLists.txt | 4 | ||||
-rw-r--r-- | include/grgsm/constants.h | 58 | ||||
-rw-r--r-- | lib/CMakeLists.txt | 24 | ||||
-rw-r--r-- | lib/constants.cc.in | 63 | ||||
-rw-r--r-- | swig/CMakeLists.txt | 1 | ||||
-rw-r--r-- | swig/constants.i | 36 | ||||
-rw-r--r-- | swig/grgsm_swig.i | 4 |
9 files changed, 291 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e85472..13e1201 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,17 @@ set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) ######################################################################## +# Set version variables ( +######################################################################## + +# Set the version information here +set(VERSION_INFO_MAJOR_VERSION 1) +set(VERSION_INFO_API_COMPAT 0) +set(VERSION_INFO_MINOR_VERSION 0) +set(VERSION_INFO_MAINT_VERSION git) +include(GrVersion) #setup version info + +######################################################################## # Compiler specific setup ######################################################################## if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) @@ -122,10 +133,9 @@ endif() if(NOT LIBOSMOCORE_FOUND) message(FATAL_ERROR "Libosmocore required to compile gr-gsm") endif() -message( dupa 2!!! ) -#if(NOT LIBOSMOCODEC_FOUND) -# message(FATAL_ERROR "Libosmocodec required to compile gr-gsm") -#endif() +if(NOT LIBOSMOCODEC_FOUND) + message(FATAL_ERROR "Libosmocodec required to compile gr-gsm") +endif() #if(NOT LIBOSMOCODING_FOUND) # message(FATAL_ERROR "Libosmocoding required to compile gr-gsm") #endif() @@ -218,3 +228,9 @@ set(CPACK_PACKAGE_MAINTAINER ptrkrysik@gmail.com) set(CPACK_PACKAGE_DESCRIPTION "GSM functionality for Gnuradio") set(CPACK_PACKAGE_CONTACT ptrkrysik@gmail.com) include(CPack) + +######################################################################## +# Print summary +######################################################################## +message(STATUS "Using install prefix: ${CMAKE_INSTALL_PREFIX}") +message(STATUS "Building for version: ${VERSION} / ${LIBVER} / ${BUILD_DATE}") diff --git a/cmake/Modules/GrVersion.cmake b/cmake/Modules/GrVersion.cmake new file mode 100644 index 0000000..bafd0a7 --- /dev/null +++ b/cmake/Modules/GrVersion.cmake @@ -0,0 +1,82 @@ +# Copyright 2011,2013 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +if(DEFINED __INCLUDED_GR_VERSION_CMAKE) + return() +endif() +set(__INCLUDED_GR_VERSION_CMAKE TRUE) + +#eventually, replace version.sh and fill in the variables below +set(MAJOR_VERSION ${VERSION_INFO_MAJOR_VERSION}) +set(API_COMPAT ${VERSION_INFO_API_COMPAT}) +set(MINOR_VERSION ${VERSION_INFO_MINOR_VERSION}) +set(MAINT_VERSION ${VERSION_INFO_MAINT_VERSION}) + +######################################################################## +# Extract the version string from git describe. +######################################################################## +find_package(Git) + +if(GIT_FOUND AND EXISTS ${CMAKE_SOURCE_DIR}/.git) + message(STATUS "Extracting version information from git describe...") + execute_process( + COMMAND ${GIT_EXECUTABLE} describe --always --abbrev=8 --long + OUTPUT_VARIABLE GIT_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) +else() + set(GIT_DESCRIBE "v${MAJOR_VERSION}.${API_COMPAT}.x-xxx-xunknown") +endif() + +######################################################################## +# Use the logic below to set the version constants +######################################################################## +if("${MINOR_VERSION}" STREQUAL "git") + # VERSION: 3.3git-xxx-gxxxxxxxx + # DOCVER: 3.3git + # LIBVER: 3.3git + set(VERSION "${GIT_DESCRIBE}") + set(DOCVER "${MAJOR_VERSION}.${API_COMPAT}${MINOR_VERSION}") + set(LIBVER "${MAJOR_VERSION}.${API_COMPAT}${MINOR_VERSION}") + set(RC_MINOR_VERSION "0") + set(RC_MAINT_VERSION "0") +elseif("${MAINT_VERSION}" STREQUAL "git") + # VERSION: 3.3.1git-xxx-gxxxxxxxx + # DOCVER: 3.3.1git + # LIBVER: 3.3.1git + set(VERSION "${GIT_DESCRIBE}") + set(DOCVER "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}${MAINT_VERSION}") + set(LIBVER "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}${MAINT_VERSION}") + math(EXPR RC_MINOR_VERSION "${MINOR_VERSION} - 1") + set(RC_MAINT_VERSION "0") +else() + # This is a numbered release. + # VERSION: 3.3.1{.x} + # DOCVER: 3.3.1{.x} + # LIBVER: 3.3.1{.x} + if("${MAINT_VERSION}" STREQUAL "0") + set(VERSION "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}") + else() + set(VERSION "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}.${MAINT_VERSION}") + endif() + set(DOCVER "${VERSION}") + set(LIBVER "${VERSION}") + set(RC_MINOR_VERSION ${MINOR_VERSION}) + set(RC_MAINT_VERSION ${MAINT_VERSION}) +endif() diff --git a/include/grgsm/CMakeLists.txt b/include/grgsm/CMakeLists.txt index dc9b191..d9b032d 100644 --- a/include/grgsm/CMakeLists.txt +++ b/include/grgsm/CMakeLists.txt @@ -23,7 +23,9 @@ install(FILES plotting.hpp api.h - gsmtap.h DESTINATION include/grgsm + gsmtap.h + constants.h + DESTINATION include/grgsm ) add_subdirectory(decoding) diff --git a/include/grgsm/constants.h b/include/grgsm/constants.h new file mode 100644 index 0000000..a96424e --- /dev/null +++ b/include/grgsm/constants.h @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2009,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GRGSM_CONSTANTS_H +#define INCLUDED_GRGSM_CONSTANTS_H + +#include <grgsm/api.h> +#include <string> + +namespace gr { + namespace gsm{ + /*! + * \brief return date/time of build, as set when 'cmake' is run + */ + GRGSM_API const std::string build_date(); + + /*! + * \brief return version string defined by cmake (GrVersion.cmake) + */ + GRGSM_API const std::string version(); + + /*! + * \brief return just the major version defined by cmake + */ + GRGSM_API const std::string major_version(); + + /*! + * \brief return just the api version defined by cmake + */ + GRGSM_API const std::string api_version(); + + /*! + * \brief returnjust the minor version defined by cmake + */ + GRGSM_API const std::string minor_version(); + } /* namespace gsm */ +} /* namespace gr */ + +#endif /* INCLUDED_GRGSM_CONSTANTS_H */ diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 1686de5..9880e58 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -21,6 +21,29 @@ # Setup library ######################################################################## include(GrPlatform) #define LIB_SUFFIX +include(GrMiscUtils) + +######################################################################## +# Handle the generated constants +######################################################################## +execute_process(COMMAND ${PYTHON_EXECUTABLE} -c + "import time;print time.strftime('%a, %d %b %Y %H:%M:%S', time.gmtime())" + OUTPUT_VARIABLE BUILD_DATE OUTPUT_STRIP_TRAILING_WHITESPACE +) +message(STATUS "Loading build date ${BUILD_DATE} into constants...") +message(STATUS "Loading version ${VERSION} into constants...") + +#double escape for windows backslash path separators +string(REPLACE "\\" "\\\\" prefix "${prefix}") + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/constants.cc.in + ${CMAKE_CURRENT_BINARY_DIR}/constants.cc + ESCAPE_QUOTES +@ONLY) + +list(APPEND grgsm_sources ${CMAKE_CURRENT_BINARY_DIR}/constants.cc) +######################################################################### include_directories(${Boost_INCLUDE_DIR} receiver) link_directories(${Boost_LIBRARY_DIRS}) @@ -85,6 +108,7 @@ target_link_libraries(grgsm ${Boost_LIBRARIES} ${GNURADIO_ALL_LIBRARIES} ${VOLK_ # boost_filesystem ) set_target_properties(grgsm PROPERTIES DEFINE_SYMBOL "grgsm_EXPORTS") +GR_LIBRARY_FOO(grgsm) ######################################################################## # Install built library files diff --git a/lib/constants.cc.in b/lib/constants.cc.in new file mode 100644 index 0000000..d56f45e --- /dev/null +++ b/lib/constants.cc.in @@ -0,0 +1,63 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2009,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#if HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdlib.h> +#include <grgsm/constants.h> + +namespace gr { + namespace gsm{ + const std::string + build_date() + { + return "@BUILD_DATE@"; + } + + const std::string + version() + { + return "@VERSION@"; + } + + // Return individual parts of the version + const std::string + major_version() + { + return "@MAJOR_VERSION@"; + } + + const std::string + api_version() + { + return "@API_COMPAT@"; + } + + const std::string + minor_version() + { + return "@MINOR_VERSION@"; + } + } /* namespace gsm */ +} /* namespace gr */ diff --git a/swig/CMakeLists.txt b/swig/CMakeLists.txt index 1c237c8..4766220 100644 --- a/swig/CMakeLists.txt +++ b/swig/CMakeLists.txt @@ -59,6 +59,7 @@ GR_SWIG_INSTALL(TARGETS grgsm_swig DESTINATION ${GR_PYTHON_DIR}/grgsm) install( FILES grgsm_swig.i + constants.i ${CMAKE_CURRENT_BINARY_DIR}/grgsm_swig_doc.i DESTINATION ${GR_INCLUDE_DIR}/grgsm/swig ) diff --git a/swig/constants.i b/swig/constants.i new file mode 100644 index 0000000..1efca59 --- /dev/null +++ b/swig/constants.i @@ -0,0 +1,36 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2009,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + + +namespace gr { + namespace gsm{ + %rename(build_date) build_date; + %rename(version) version; + %rename(version_info) version_info; + + const std::string build_date(); + const std::string version(); + const std::string major_version(); + const std::string api_version(); + const std::string minor_version(); + } /* namespace gsm */ +} /* namespace gr */ diff --git a/swig/grgsm_swig.i b/swig/grgsm_swig.i index 9d6636a..66615e6 100644 --- a/swig/grgsm_swig.i +++ b/swig/grgsm_swig.i @@ -29,6 +29,7 @@ %include "grgsm_swig_doc.i" %{ +#include "grgsm/constants.h" #include "grgsm/receiver/receiver.h" #include "grgsm/receiver/clock_offset_control.h" #include "grgsm/receiver/cx_channel_hopper.h" @@ -65,6 +66,8 @@ #include "grgsm/misc_utils/controlled_fractional_resampler_cc.h" %} +%include "constants.i" + %include "grgsm/receiver/receiver.h" GR_SWIG_BLOCK_MAGIC2(gsm, receiver); %include "grgsm/receiver/clock_offset_control.h" @@ -140,3 +143,4 @@ GR_SWIG_BLOCK_MAGIC2(gsm, burst_source); GR_SWIG_BLOCK_MAGIC2(gsm, message_source); %include "grgsm/qa_utils/message_sink.h" GR_SWIG_BLOCK_MAGIC2(gsm, message_sink); + |