aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2018-03-30 14:19:35 -0700
committerMartin Braun <martin.braun@ettus.com>2018-04-02 15:27:05 -0700
commita5b87ab7c4a6834acc7587ffc4a769854b9d48b4 (patch)
treea9c16e82b6556bb5653052f8681e7d267c33085d
parentc7f52870805c9d9f79f15c80e9a4ad53ed88c857 (diff)
downloaduhd-a5b87ab7c4a6834acc7587ffc4a769854b9d48b4.tar.gz
uhd-a5b87ab7c4a6834acc7587ffc4a769854b9d48b4.tar.bz2
uhd-a5b87ab7c4a6834acc7587ffc4a769854b9d48b4.zip
mpm: cmake: Add git hash and version info to Python module
Reviewed-by: Brent Stapleton <brent.stapleton@ettus.com>
-rw-r--r--mpm/CMakeLists.txt53
-rw-r--r--mpm/cmake/Modules/MPMVersion.cmake31
-rwxr-xr-xmpm/python/usrp_hwd.py4
-rw-r--r--mpm/python/usrp_mpm/__init__.py3
-rw-r--r--mpm/python/usrp_mpm/periph_manager/__init__.py.in3
5 files changed, 79 insertions, 15 deletions
diff --git a/mpm/CMakeLists.txt b/mpm/CMakeLists.txt
index 72d72bcfc..85f1dd49b 100644
--- a/mpm/CMakeLists.txt
+++ b/mpm/CMakeLists.txt
@@ -16,6 +16,17 @@ IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
)
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+LIST(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules)
+SET(UHD_HOST_ROOT ${CMAKE_SOURCE_DIR}/../host)
+# Now, we can also include CMake modules from UHD:
+LIST(INSERT CMAKE_MODULE_PATH 0 ${UHD_HOST_ROOT}/cmake/Modules)
+
+
+########################################################################
+# Version Information
+########################################################################
+INCLUDE(MPMVersion)
+
########################################################################
# useful macros
########################################################################
@@ -109,8 +120,6 @@ ENDIF()
SET(PKG_DOC_DIR share/doc/mpm)
SET(PKG_MAN_DIR share/man/man1)
-
-
########################################################################
# Setup library configuration
########################################################################
@@ -118,14 +127,12 @@ SET(CMAKE_CXX_STANDARD 11)
SET(MPM_DEVICE "n3xx" CACHE STRING "Choose an MPM device to build")
SET_PROPERTY(CACHE MPM_DEVICE PROPERTY STRINGS n3xx tests)
-SET(UHD_HOST_ROOT ${CMAKE_SOURCE_DIR}/../host)
-
ADD_SUBDIRECTORY(include)
INCLUDE_DIRECTORIES(
- ${CMAKE_CURRENT_SOURCE_DIR}/include
- ${CMAKE_BINARY_DIR}/include
- ${UHD_HOST_ROOT}/include
- )
+ ${CMAKE_CURRENT_SOURCE_DIR}/include
+ ${CMAKE_BINARY_DIR}/include
+ ${UHD_HOST_ROOT}/include
+)
ADD_SUBDIRECTORY(lib)
@@ -143,14 +150,30 @@ ELSE()
ENDIF()
INSTALL(TARGETS usrp-periphs ${DESTINATION_KEYWORD} DESTINATION ${LIBRARY_DIR} COMPONENT libraries)
-SET(USRP_PERIPHS_MAJOR 0)
-SET(USRP_PERIPHS_MINOR 1)
-SET(USRP_PERIPHS_PATCH 0)
-SET(USRP_PERIPHS_VERSION ${USRP_PERIPHS_MAJOR}.${USRP_PERIPHS_MINOR}.${USRP_PERIPHS_PATCH})
-
-SET_TARGET_PROPERTIES(usrp-periphs PROPERTIES VERSION ${USRP_PERIPHS_VERSION})
-SET_TARGET_PROPERTIES(usrp-periphs PROPERTIES SOVERSION ${USRP_PERIPHS_MAJOR})
+# TODO: Come up with a versioning scheme for the MPM ABI. Not high priority
+# though... we're the only ones linking against that.
+SET_TARGET_PROPERTIES(usrp-periphs PROPERTIES VERSION "${MPM_VERSION_MAJOR}.${MPM_VERSION_API}.${MPM_VERSION_ABI}")
+SET_TARGET_PROPERTIES(usrp-periphs PROPERTIES SOVERSION ${MPM_VERSION_MAJOR})
ADD_SUBDIRECTORY(python)
ADD_SUBDIRECTORY(tools)
ADD_SUBDIRECTORY(systemd)
+
+########################################################################
+# Print Summary
+########################################################################
+IF(MPM_VERSION_DEVEL AND NOT MPM_GIT_BRANCH STREQUAL "maint")
+ MESSAGE(STATUS "******************************************************")
+ IF(MPM_GIT_BRANCH STREQUAL "master")
+ MESSAGE(STATUS "* You are building the UHD development master branch.")
+ MESSAGE(STATUS "* For production code, we recommend our stable,")
+ MESSAGE(STATUS "* releases or using the release branch (maint).")
+ ELSE()
+ MESSAGE(STATUS "* You are building a development branch of UHD.")
+ MESSAGE(STATUS "* These branches are designed to provide early access")
+ MESSAGE(STATUS "* to UHD and USRP features, but should be considered")
+ MESSAGE(STATUS "* unstable and/or experimental!")
+ ENDIF(MPM_GIT_BRANCH STREQUAL "master")
+ MESSAGE(STATUS "******************************************************")
+ENDIF(MPM_VERSION_DEVEL AND NOT MPM_GIT_BRANCH STREQUAL "maint")
+MESSAGE(STATUS "Building version: ${MPM_VERSION}")
diff --git a/mpm/cmake/Modules/MPMVersion.cmake b/mpm/cmake/Modules/MPMVersion.cmake
new file mode 100644
index 000000000..dfe22efb2
--- /dev/null
+++ b/mpm/cmake/Modules/MPMVersion.cmake
@@ -0,0 +1,31 @@
+#
+# Copyright 2010-2014,2016 Ettus Research LLC
+# Copyright 2018 Ettus Research, a National Instruments Company
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+
+
+INCLUDE(UHDVersion)
+
+###############################################################################
+# Set all version info equivalent to UHD versions
+###############################################################################
+SET(MPM_VERSION_MAJOR ${UHD_VERSION_MAJOR})
+SET(MPM_VERSION_API ${UHD_VERSION_API})
+SET(MPM_VERSION_ABI ${UHD_VERSION_ABI})
+SET(MPM_VERSION_PATCH ${UHD_VERSION_PATCH})
+SET(MPM_VERSION_DEVEL ${UHD_VERSION_DEVEL})
+SET(MPM_GIT_BRANCH ${UHD_GIT_BRANCH})
+SET(MPM_GIT_COUNT ${UHD_GIT_COUNT})
+SET(MPM_GIT_HASH ${UHD_GIT_HASH})
+STRING(REPLACE "g" "" MPM_GIT_HASH_RAW ${UHD_GIT_HASH})
+
+IF(DEFINED MPM_VERSION)
+ SET(MPM_VERSION "${MPM_VERSION}" CACHE STRING "Set MPM_VERSION to a custom value")
+ELSEIF(TRIM_UHD_VERSION STREQUAL "True")
+ SET(MPM_VERSION "${MPM_VERSION_MAJOR}.${MPM_VERSION_API}.${MPM_VERSION_ABI}.${MPM_VERSION_PATCH}-${MPM_GIT_HASH}")
+ELSE()
+ SET(MPM_VERSION "${MPM_VERSION_MAJOR}.${MPM_VERSION_API}.${MPM_VERSION_ABI}.${MPM_VERSION_PATCH}-${MPM_GIT_COUNT}-${MPM_GIT_HASH}")
+ENDIF()
+
diff --git a/mpm/python/usrp_hwd.py b/mpm/python/usrp_hwd.py
index 0b2cd1ecb..d04d04927 100755
--- a/mpm/python/usrp_hwd.py
+++ b/mpm/python/usrp_hwd.py
@@ -170,6 +170,10 @@ def main():
log = mpm.get_main_logger(
log_default_delta=args.verbose-args.quiet
).getChild('main')
+ version_string = mpm.__version__
+ if len(mpm.__githash__):
+ version_string += "-g" + mpm.__githash__
+ log.info("Launching USRP/MPM, version: %s", version_string)
if args.override_db_pids is not None:
log.warning('Overriding daughterboard PIDs!')
args.default_args['override_db_pids'] = args.override_db_pids
diff --git a/mpm/python/usrp_mpm/__init__.py b/mpm/python/usrp_mpm/__init__.py
index 00cbcc987..6b6b86d08 100644
--- a/mpm/python/usrp_mpm/__init__.py
+++ b/mpm/python/usrp_mpm/__init__.py
@@ -18,3 +18,6 @@ from . import cores
from . import chips
from . import gpsd_iface
from .mpmlog import get_main_logger
+
+__version__ = periph_manager.__version__
+__githash__ = periph_manager.__githash__
diff --git a/mpm/python/usrp_mpm/periph_manager/__init__.py.in b/mpm/python/usrp_mpm/periph_manager/__init__.py.in
index f507a6808..1a84ca3a4 100644
--- a/mpm/python/usrp_mpm/periph_manager/__init__.py.in
+++ b/mpm/python/usrp_mpm/periph_manager/__init__.py.in
@@ -7,6 +7,9 @@
periph_manager __init__.py
"""
+__version__ = "${MPM_VERSION_MAJOR}.${MPM_VERSION_API}.${MPM_VERSION_ABI}.${MPM_VERSION_PATCH}"
+__githash__ = "${MPM_GIT_HASH_RAW}"
+
from .base import PeriphManagerBase
# This is where the import magic happens