Added versioning borrowed fron GNU Radio to gr-gsm

This commit is contained in:
Piotr Krysik 2017-08-24 15:35:42 +02:00
parent 77868e4fa6
commit bb961c17fa
9 changed files with 291 additions and 5 deletions

View File

@ -35,6 +35,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
########################################################################
@ -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}")

View File

@ -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()

View File

@ -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)

58
include/grgsm/constants.h Normal file
View File

@ -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 */

View File

@ -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

63
lib/constants.cc.in Normal file
View File

@ -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 */

View File

@ -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
)

36
swig/constants.i Normal file
View File

@ -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 */

View File

@ -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);