From f54a22c60a0cbe990c9d3892f4c565d64226196b Mon Sep 17 00:00:00 2001 From: Samuel O'Brien Date: Mon, 3 Aug 2020 12:10:53 -0500 Subject: sim: Embed MPM into libpyuhd When ENABLE_SIM and ENABLE_PYTHON_API are set, this commit embeds MPM (Built with -DMPM_DEVICE=sim) into the pyuhd package. Signed-off-by: Samuel O'Brien --- host/python/CMakeLists.txt | 57 +++++++++++++++++++++++++++++++++++++++++ mpm/python/setup.py.in | 1 + mpm/python/tests/CMakeLists.txt | 4 ++- 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/host/python/CMakeLists.txt b/host/python/CMakeLists.txt index dfe049b87..a8d974936 100644 --- a/host/python/CMakeLists.txt +++ b/host/python/CMakeLists.txt @@ -84,6 +84,63 @@ set(TIMESTAMP_FILE "${CMAKE_CURRENT_BINARY_DIR}/build/timestamp") file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR} NATIVE_CURRENT_BINARY_DIR) configure_file(${SETUP_PY_IN} ${SETUP_PY}) +if(ENABLE_SIM) + set(MPM_DEVICE "sim") + add_subdirectory(${CMAKE_SOURCE_DIR}/../mpm/python simulator) + # simulator/usrp_mpm needs to be copied to usrp_mpm because setuptools only detects import packages in the working directory + add_custom_target(copy_mpm_packages ALL DEPENDS usrp_mpm) + add_custom_command(TARGET copy_mpm_packages + PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/usrp_mpm + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/usrp_mpm/dboard_manager + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/usrp_mpm/periph_manager + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/usrp_mpm/simulator + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/usrp_mpm/sys_utils + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/usrp_mpm/xports + + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/simulator/usrp_mpm/dboard_manager/base.py + ${CMAKE_CURRENT_BINARY_DIR}/simulator/usrp_mpm/dboard_manager/__init__.py + ${CMAKE_CURRENT_BINARY_DIR}/usrp_mpm/dboard_manager + + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/simulator/usrp_mpm/periph_manager/base.py + ${CMAKE_CURRENT_BINARY_DIR}/simulator/usrp_mpm/periph_manager/common.py + ${CMAKE_CURRENT_BINARY_DIR}/simulator/usrp_mpm/periph_manager/sim.py + ${CMAKE_CURRENT_BINARY_DIR}/simulator/usrp_mpm/periph_manager/__init__.py + ${CMAKE_CURRENT_BINARY_DIR}/usrp_mpm/periph_manager + + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_CURRENT_BINARY_DIR}/simulator/usrp_mpm/simulator + ${CMAKE_CURRENT_BINARY_DIR}/usrp_mpm/simulator + + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_CURRENT_BINARY_DIR}/simulator/usrp_mpm/sys_utils + ${CMAKE_CURRENT_BINARY_DIR}/usrp_mpm/sys_utils + + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/simulator/usrp_mpm/xports/xportmgr_udp.py + ${CMAKE_CURRENT_BINARY_DIR}/simulator/usrp_mpm/xports/__init__.py + ${CMAKE_CURRENT_BINARY_DIR}/usrp_mpm/xports + + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/simulator/usrp_mpm/discovery.py + ${CMAKE_CURRENT_BINARY_DIR}/simulator/usrp_mpm/eeprom.py + ${CMAKE_CURRENT_BINARY_DIR}/simulator/usrp_mpm/ethdispatch.py + ${CMAKE_CURRENT_BINARY_DIR}/simulator/usrp_mpm/gpsd_iface.py + ${CMAKE_CURRENT_BINARY_DIR}/simulator/usrp_mpm/mpmlog.py + ${CMAKE_CURRENT_BINARY_DIR}/simulator/usrp_mpm/mpmtypes.py + ${CMAKE_CURRENT_BINARY_DIR}/simulator/usrp_mpm/mpmutils.py + ${CMAKE_CURRENT_BINARY_DIR}/simulator/usrp_mpm/prefs.py + ${CMAKE_CURRENT_BINARY_DIR}/simulator/usrp_mpm/rpc_server.py + ${CMAKE_CURRENT_BINARY_DIR}/simulator/usrp_mpm/__init__.py + ${CMAKE_CURRENT_BINARY_DIR}/usrp_mpm) + # Move usrp_hwd.py into usrp_mpm so that it is included in the package + configure_file(${CMAKE_SOURCE_DIR}/../mpm/python/usrp_hwd.py + ${CMAKE_CURRENT_BINARY_DIR}/usrp_mpm/usrp_hwd.py COPYONLY) + set(PYUHD_FILES ${PYUHD_FILES} copy_mpm_packages) +endif(ENABLE_SIM) + add_custom_command(OUTPUT ${TIMESTAMP_FILE} COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/uhd ${CMAKE_CURRENT_BINARY_DIR}/uhd COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} -q build diff --git a/mpm/python/setup.py.in b/mpm/python/setup.py.in index e131f02f1..226cf0270 100755 --- a/mpm/python/setup.py.in +++ b/mpm/python/setup.py.in @@ -36,6 +36,7 @@ setup(name='usrp_mpm', 'usrp_mpm.cores', 'usrp_mpm.sys_utils', 'usrp_mpm.xports', + 'usrp_mpm.simulator', ], install_requires=[ 'mprpc', diff --git a/mpm/python/tests/CMakeLists.txt b/mpm/python/tests/CMakeLists.txt index 26dcad40a..36bff9d3a 100755 --- a/mpm/python/tests/CMakeLists.txt +++ b/mpm/python/tests/CMakeLists.txt @@ -10,5 +10,7 @@ add_test( NAME mpm_unit_tests - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/run_unit_tests.py ${MPM_DEVICE} + COMMAND ${CMAKE_COMMAND} -E env + PYTHONPATH=${CMAKE_BINARY_DIR}/python + ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/run_unit_tests.py ${MPM_DEVICE} ) -- cgit v1.2.3