Skip to content

Commit b4f9008

Browse files
Add find program for python scripts
1 parent 5944eaf commit b4f9008

File tree

5 files changed

+42
-16
lines changed

5 files changed

+42
-16
lines changed

tools/cmake/mbed-run-greentea-test.in.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ set(MBEDHTRUN_ARGS --skip-flashing @MBED_HTRUN_ARGUMENTS@) # filled in by config
1414

1515
# Print out command
1616
string(REPLACE ";" " " MBEDHTRUN_ARGS_FOR_DISPLAY "${MBEDHTRUN_ARGS}")
17-
message("Executing: mbedhtrun ${MBEDHTRUN_ARGS_FOR_DISPLAY}")
17+
message("Executing: @mbedhtrun@ ${MBEDHTRUN_ARGS_FOR_DISPLAY}")
1818

1919
execute_process(
20-
COMMAND mbedhtrun ${MBEDHTRUN_ARGS}
20+
COMMAND @mbedhtrun@ ${MBEDHTRUN_ARGS}
2121
COMMAND_ERROR_IS_FATAL ANY)

tools/cmake/mbed_generate_configuration.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ if(MBED_NEED_TO_RECONFIGURE)
8282
# Make sure an old config file doesn't stick around
8383
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/mbed_config.cmake)
8484

85-
set(MBEDTOOLS_CONFIGURE_COMMAND mbed-tools
85+
set(MBEDTOOLS_CONFIGURE_COMMAND ${mbed_tools}
8686
-v -v # without at least -v, warnings (e.g. "you have tried to override a nonexistent parameter") do not get printed
8787
configure
8888
-t GCC_ARM # GCC_ARM is currently the only supported toolchain
@@ -104,7 +104,7 @@ if(MBED_NEED_TO_RECONFIGURE)
104104

105105
if((NOT MBEDTOOLS_CONFIGURE_RESULT EQUAL 0) OR (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/mbed_config.cmake))
106106
string(JOIN " " MBEDTOOLS_COMMAND_SPC_SEP ${MBEDTOOLS_CONFIGURE_COMMAND})
107-
message(FATAL_ERROR "mbedtools configure failed! Cannot build this project. Command was ${MBEDTOOLS_COMMAND_SPC_SEP} [note that you need to activate the Mbed OS virtualenv to run this command]")
107+
message(FATAL_ERROR "mbedtools configure failed! Cannot build this project. Command was ${MBEDTOOLS_COMMAND_SPC_SEP}")
108108
endif()
109109

110110
endif()

tools/cmake/mbed_python_interpreter.cmake

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ if(MBED_CREATE_PYTHON_VENV)
4141
unset(_Python3_INTERPRETER_PROPERTIES CACHE)
4242
unset(_Python3_INTERPRETER_SIGNATURE CACHE)
4343
set (Python3_FIND_VIRTUALENV STANDARD)
44+
unset(ENV{VIRTUAL_ENV})
4445
find_package(Python3 REQUIRED COMPONENTS Interpreter)
4546

47+
# Reset venv configuration as above
48+
set(Python3_FIND_VIRTUALENV FIRST)
49+
set(ENV{VIRTUAL_ENV} ${MBED_VENV_LOCATION})
50+
4651
set(NEED_TO_CREATE_VENV TRUE)
4752
set(NEED_TO_INSTALL_PACKAGES TRUE)
4853
elseif(NOT EXISTS "${VENV_STAMP_FILE}")
@@ -102,10 +107,31 @@ else()
102107

103108
# The cmsis_mcu_descr module was written from scratch by Mbed CE.
104109
# So, this check will ensure that the user has installed the Mbed CE version of mbed_tools
105-
# and not the PyPI version (which we cannot do anything with because it's owned by ARM)
110+
# and not the PyPI version (which we cannot update because it's owned by ARM)
106111
check_python_package(mbed_tools.cli.cmsis_mcu_descr HAVE_MBED_CE_TOOLS)
107112

108113
if(NOT HAVE_MBED_CE_TOOLS)
109114
message(FATAL_ERROR "Did not detect the Mbed CE Python tools installed into the python interpreter ${Python3_EXECUTABLE}. Install them with a command like: ${Python3_EXECUTABLE} -m pip install -e ${MBED_CE_TOOLS_BASE_DIR}")
110115
endif()
111116
endif()
117+
118+
get_filename_component(PYTHON3_INTERP_DIR ${Python3_EXECUTABLE} DIRECTORY)
119+
120+
# Find scripts provided by the Python package
121+
find_program(mbed_tools
122+
NAMES mbed-tools
123+
HINTS ${PYTHON3_INTERP_DIR}
124+
DOC "Path to mbed-tools Python script."
125+
REQUIRED)
126+
127+
find_program(mbedhtrun
128+
NAMES mbedhtrun
129+
HINTS ${PYTHON3_INTERP_DIR}
130+
DOC "Path to mbedhtrun Python script."
131+
REQUIRED)
132+
133+
find_program(memap
134+
NAMES memap
135+
HINTS ${PYTHON3_INTERP_DIR}
136+
DOC "Path to memap Python script."
137+
REQUIRED)

tools/cmake/mbed_target_functions.cmake

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ function(mbed_generate_map_file target)
6565
TARGET
6666
${target}
6767
POST_BUILD
68-
COMMAND ${Python3_EXECUTABLE} -m memap.memap
69-
-t ${MBED_TOOLCHAIN} ${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map
68+
COMMAND ${memap}
69+
-t ${MBED_TOOLCHAIN} ${target}${CMAKE_EXECUTABLE_SUFFIX}.map
7070
--depth ${MBED_MEMAP_DEPTH}
7171
${MEMORY_BANKS_ARG}
7272
WORKING_DIRECTORY
73-
${mbed-os_SOURCE_DIR}/tools/python
73+
${CMAKE_CURRENT_BINARY_DIR}
7474
)
7575

7676
# generate json file
@@ -79,14 +79,14 @@ function(mbed_generate_map_file target)
7979
TARGET
8080
${target}
8181
POST_BUILD
82-
COMMAND ${Python3_EXECUTABLE} -m memap.memap
83-
-t ${MBED_TOOLCHAIN} ${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map
82+
COMMAND ${memap}
83+
-t ${MBED_TOOLCHAIN} ${target}${CMAKE_EXECUTABLE_SUFFIX}.map
8484
--depth ${MBED_MEMAP_DEPTH}
8585
-e json
86-
-o ${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.memmap.json
86+
-o ${target}${CMAKE_EXECUTABLE_SUFFIX}.memmap.json
8787
${MEMORY_BANKS_ARG}
8888
WORKING_DIRECTORY
89-
${mbed-os_SOURCE_DIR}/tools/python
89+
${CMAKE_CURRENT_BINARY_DIR}
9090
)
9191
endif()
9292

@@ -96,14 +96,14 @@ function(mbed_generate_map_file target)
9696
TARGET
9797
${target}
9898
POST_BUILD
99-
COMMAND ${Python3_EXECUTABLE} -m memap.memap
100-
-t ${MBED_TOOLCHAIN} ${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map
99+
COMMAND ${memap}
100+
-t ${MBED_TOOLCHAIN} ${target}${CMAKE_EXECUTABLE_SUFFIX}.map
101101
--depth ${MBED_MEMAP_DEPTH}
102102
-e html
103-
-o ${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.memmap.html
103+
-o ${target}${CMAKE_EXECUTABLE_SUFFIX}.memmap.html
104104
${MEMORY_BANKS_ARG}
105105
WORKING_DIRECTORY
106-
${mbed-os_SOURCE_DIR}/tools/python
106+
${CMAKE_CURRENT_BINARY_DIR}
107107
)
108108
endif()
109109
endfunction()

tools/run_python_tests.sh

100644100755
File mode changed.

0 commit comments

Comments
 (0)