diff options
author | Toni Jones <toni.jones@ni.com> | 2019-02-21 15:05:34 -0600 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2021-03-01 15:57:01 -0600 |
commit | 902f4581372d08fa8f4ec9b2391648606d1c8c8e (patch) | |
tree | 26e443e5cf39a0245290f5782aa253a916b1ca2a | |
parent | 394530777b3ac656609cf98b3c9e35238e3fc296 (diff) | |
download | uhd-902f4581372d08fa8f4ec9b2391648606d1c8c8e.tar.gz uhd-902f4581372d08fa8f4ec9b2391648606d1c8c8e.tar.bz2 uhd-902f4581372d08fa8f4ec9b2391648606d1c8c8e.zip |
cmake: Add RegMaps build component to MPM
Add RegMaps build component to MPM. The PYTHON_CHECK_MODULE is
included from UHDPython in order to look up the presence of Mako.
Mako is required for generating the regmaps and RegMap will be
disabled without it. The RegMaps component creates custom commands for
generating all regmaps, creates a Python submodule "ic_reg_maps" with a
custom __init__.py file, and creates a target "ic_reg_maps" which gets
installed with usrp_mpm.
-rw-r--r-- | mpm/CMakeLists.txt | 10 | ||||
-rwxr-xr-x | mpm/python/setup.py.in | 1 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/chips/CMakeLists.txt | 1 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/chips/__init__.py | 1 | ||||
-rwxr-xr-x | mpm/python/usrp_mpm/chips/ic_reg_maps/CMakeLists.txt | 53 | ||||
-rwxr-xr-x | mpm/python/usrp_mpm/chips/ic_reg_maps/__init__.py.in | 9 |
6 files changed, 75 insertions, 0 deletions
diff --git a/mpm/CMakeLists.txt b/mpm/CMakeLists.txt index e426716a6..8dfd7da6c 100644 --- a/mpm/CMakeLists.txt +++ b/mpm/CMakeLists.txt @@ -33,6 +33,15 @@ set(PYTHON_MIN_VERSION 3.5) include(UHDPython) ######################################################################## +# Find Python Modules +######################################################################## +PYTHON_CHECK_MODULE( + "Mako templates 0.4.2 or greater" + "mako" "mako.__version__ >= '0.4.2'" + HAVE_PYTHON_MODULE_MAKO +) + +######################################################################## # Version Information ######################################################################## include(MPMVersion) @@ -143,6 +152,7 @@ elseif(MPM_DEVICE STREQUAL "sim") endif() MPM_REGISTER_COMPONENT("LibMPM" ENABLE_LIBMPM ON "Boost_FOUND" OFF ON) +MPM_REGISTER_COMPONENT("RegMaps" ENABLE_REGMAPS ON "HAVE_PYTHON_MODULE_MAKO" OFF OFF) MPM_REGISTER_COMPONENT("Mykonos" ENABLE_MYKONOS OFF "ENABLE_LIBMPM" OFF OFF) MPM_REGISTER_COMPONENT("Magnesium" ENABLE_MAGNESIUM OFF "ENABLE_MYKONOS" OFF OFF) MPM_REGISTER_COMPONENT("E320" ENABLE_E320 OFF "ENABLE_LIBMPM" OFF OFF) diff --git a/mpm/python/setup.py.in b/mpm/python/setup.py.in index 226cf0270..31313c9e7 100755 --- a/mpm/python/setup.py.in +++ b/mpm/python/setup.py.in @@ -33,6 +33,7 @@ setup(name='usrp_mpm', 'usrp_mpm.periph_manager', 'usrp_mpm.dboard_manager', 'usrp_mpm.chips', + 'usrp_mpm.chips.ic_reg_maps', 'usrp_mpm.cores', 'usrp_mpm.sys_utils', 'usrp_mpm.xports', diff --git a/mpm/python/usrp_mpm/chips/CMakeLists.txt b/mpm/python/usrp_mpm/chips/CMakeLists.txt index 1f64d8e2d..484df8572 100644 --- a/mpm/python/usrp_mpm/chips/CMakeLists.txt +++ b/mpm/python/usrp_mpm/chips/CMakeLists.txt @@ -14,4 +14,5 @@ set(USRP_MPM_CHIP_FILES ${CMAKE_CURRENT_SOURCE_DIR}/ds125df410.py ) list(APPEND USRP_MPM_FILES ${USRP_MPM_CHIP_FILES}) +add_subdirectory(ic_reg_maps) set(USRP_MPM_FILES ${USRP_MPM_FILES} PARENT_SCOPE) diff --git a/mpm/python/usrp_mpm/chips/__init__.py b/mpm/python/usrp_mpm/chips/__init__.py index 453ab5c2a..1b43ede6a 100644 --- a/mpm/python/usrp_mpm/chips/__init__.py +++ b/mpm/python/usrp_mpm/chips/__init__.py @@ -11,3 +11,4 @@ from .adf400x import ADF400x from .lmk04828 import LMK04828 from .lmk04832 import LMK04832 from .lmk03328 import LMK03328 +from . import ic_reg_maps diff --git a/mpm/python/usrp_mpm/chips/ic_reg_maps/CMakeLists.txt b/mpm/python/usrp_mpm/chips/ic_reg_maps/CMakeLists.txt new file mode 100755 index 000000000..631f30264 --- /dev/null +++ b/mpm/python/usrp_mpm/chips/ic_reg_maps/CMakeLists.txt @@ -0,0 +1,53 @@ +# +# Copyright 2019 Ettus Research, a National Instruments Brand +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +# macro for creating ic_reg_map files from a given generation file +macro(REG_MAPS_GEN_SOURCE pyfile outfile) + # ensure that the directory exists for outfile + get_filename_component(outfile_dir ${outfile} PATH) + file(MAKE_DIRECTORY ${outfile_dir}) + + # get name of outfile for the Python submodule __init__ file + get_filename_component(outfile_name ${outfile} NAME_WE) + string(APPEND REG_MAP_IMPORT "\nfrom ." ${outfile_name} " import " ${outfile_name} "_t") + + # make the outfile depend on the python script + add_custom_command( + OUTPUT ${outfile} DEPENDS ${pyfile} ${REG_MAPS_GEN_SOURCE_DEPS} + COMMAND ${PYTHON_EXECUTABLE} -B ${pyfile} ${outfile} + COMMENT "Generating ${outfile}" + ) + + # store all reg maps to be generated + set(IC_REG_MAPS ${IC_REG_MAPS} ${outfile}) +endmacro(REG_MAPS_GEN_SOURCE) + +if(ENABLE_REGMAPS) + # designate the file which will be used to generate all reg maps + set(REG_MAPS_GEN_SOURCE_DEPS ${UHD_HOST_ROOT}/lib/ic_reg_maps/common.py) + + # specify all reg maps you wish to generate + REG_MAPS_GEN_SOURCE( + ${UHD_HOST_ROOT}/lib/ic_reg_maps/gen_lmk04816_regs.py + ${CMAKE_CURRENT_BINARY_DIR}/lmk04816_regs.py + ) + + # add an ic_reg_maps target which can be referenced outside of this subdirectory + add_custom_target(ic_reg_maps DEPENDS ${IC_REG_MAPS}) + + # add new ic_reg_maps target to the list of usrp_mpm dependencies + set(USRP_MPM_FILES ${USRP_MPM_FILES}) + list(APPEND USRP_MPM_FILES ic_reg_maps) + set(USRP_MPM_FILES ${USRP_MPM_FILES} PARENT_SCOPE) +endif(ENABLE_REGMAPS) + +# write the Python submodule __init__.py by appending all generated reg map file +# names to be imported. This is not within "if(ENABLE_REGMAPS)" because MPM +# depends on the ic_reg_maps submodule regardless of whether any regmaps are +# generated. +set(REG_MAP_INIT_IN "${CMAKE_CURRENT_SOURCE_DIR}/__init__.py.in") +set(REG_MAP_INIT "${CMAKE_CURRENT_BINARY_DIR}/__init__.py") +configure_file(${REG_MAP_INIT_IN} ${REG_MAP_INIT}) diff --git a/mpm/python/usrp_mpm/chips/ic_reg_maps/__init__.py.in b/mpm/python/usrp_mpm/chips/ic_reg_maps/__init__.py.in new file mode 100755 index 000000000..ce4110769 --- /dev/null +++ b/mpm/python/usrp_mpm/chips/ic_reg_maps/__init__.py.in @@ -0,0 +1,9 @@ +# +# Copyright 2019 Ettus Research, a National Instruments Brand +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +""" +ic_reg_maps submodule +""" +${REG_MAP_IMPORT} |