-
Notifications
You must be signed in to change notification settings - Fork 3k
CMake: better detection of memap dependencies #14205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@multiplemonomials, thank you for your changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hugueskamba as we are porting post build hooks, this comes handy. please review
tools/cmake/app.cmake
Outdated
# Find Python and needed packages | ||
find_package(Python3) | ||
include(${CMAKE_CURRENT_LIST_DIR}/CheckPythonPackage.cmake) | ||
check_python_package(intelhex HAVE_INTELHEX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should read requirement.txt in tools/cmake as we might need few packages more (we are adding post build hooks that rely on some security modules).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The below could check if any of req. are not installed, print a warning otherwise we got all we need
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The requirements.txt
in the root directory should also be checked as it is the one that has the required packages for post build operations..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is possible but it's a bit harder because it means CMake needs to parse the "platform_system==XXXX" declarations that are used in that file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The requirements.txt in the root directory should also be checked as it is the one that has the required packages for post build operations..
Let's keep Cmake reqs separate and do proper clean up of deps (drop in replacement once the old tools are removed).
tools/cmake/app.cmake
Outdated
# Find Python and needed packages | ||
find_package(Python3) | ||
include(${CMAKE_CURRENT_LIST_DIR}/CheckPythonPackage.cmake) | ||
check_python_package(intelhex HAVE_INTELHEX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The requirements.txt
in the root directory should also be checked as it is the one that has the required packages for post build operations..
@0xc0170 I just added a requirements.txt parser based on your request. I will warn though, it's a bit fragile and could break if weird package names are used. |
Also, what specifically is your policy about extra lines, could you please explain? I seem to have run afoul of it pretty badly. |
Oh one other thing. While you guys are here, do you know why the requirements.txt has so many pinned versions and "must be older than X" versions? This really causes problems trying to set up an environment, and in my experience it seems to run just fine with the latest/default versions of all packages. |
We should start fixing this. Therefore we create own req file for CMake, so we can add only what we use and test the latest packages. For some historic reasons older versions were used, it's not true anymore in many cases.
Can you illustrate ?
I don't follow, can you reference the lines ? We got one extra line at end of every file (I noticed Github showed in some files here there is no empty line at the end of the files). |
Added it to this PR: 5d77b3e
Hugues asked me to add some extra blank lines, which I did. I'm just wondering since I'm required to add them, what is the formal policy on where blank lines are needed? |
Oh wait, you meant illustrate about the weird package names. I made the following assumptions:
|
I asked to add a new line at the end of the file. |
This pull request has automatically been marked as stale because it has had no recent activity. @ARMmbed/mbed-os-maintainers, please start CI to get the PR merged. |
CI restarted |
tools/cmake/CheckPythonPackage.cmake
Outdated
|
||
# set OUTPUT_VAR to whether PACKAGENAME was found | ||
function(check_python_package PACKAGENAME OUTPUT_VAR) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@multiplemonomials In Mbed OS CMake code we are not using newline after function starts, Could you please remove the new line?
tools/cmake/CheckPythonPackage.cmake
Outdated
|
||
if(DEFINED ${OUTPUT_VAR}) | ||
if(${OUTPUT_VAR}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@multiplemonomials In Mbed OS CMake code we are not using newline after if condition, Could you please remove the new line?
tools/cmake/CheckPythonPackage.cmake
Outdated
if("${PY_INTERP_FOR_${OUTPUT_VAR}}" STREQUAL "${Python3_EXECUTABLE}") | ||
set(NEED_TO_RUN_CHECK FALSE) | ||
endif() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@multiplemonomials, Same comment as before, could you please remove the new line?
tools/cmake/CheckPythonPackage.cmake
Outdated
|
||
set(${OUTPUT_VAR} ${HAVE_PACKAGE} CACHE BOOL "Whether the Python package ${PACKAGENAME} was found" FORCE) | ||
mark_as_advanced(${OUTPUT_VAR}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@multiplemonomials, Same comment as before, could you please remove the new line?
tools/cmake/app.cmake
Outdated
# Check python packages from requirements.txt | ||
file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/requirements.txt PYTHON_REQUIREMENTS) | ||
foreach(REQUIREMENT ${PYTHON_REQUIREMENTS}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@multiplemonomials, Same comment as before, could you please remove the new line?
tools/cmake/app.cmake
Outdated
|
||
# Look for a string from the start of each line that does not contain "<", ">", "=", or " ". | ||
if(REQUIREMENT MATCHES "^([^<>= ]+)") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@multiplemonomials, Same comment as before, could you please remove the new line?
tools/cmake/app.cmake
Outdated
if(NOT HAVE_PYTHON_${PACKAGE_NAME_UCASE}) | ||
message(WARNING "Missing Python dependency ${PACKAGE_NAME}") | ||
endif() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@multiplemonomials, Same comment as before, could you please remove the new line?
tools/cmake/app.cmake
Outdated
|
||
message(FATAL_ERROR "Cannot parse line \"${REQUIREMENT}\" in requirements.txt") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@multiplemonomials, Same comment as before, could you please remove the new line?
tools/cmake/app.cmake
Outdated
set(HAVE_MEMAP_DEPS TRUE) | ||
else() | ||
set(HAVE_MEMAP_DEPS FALSE) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@multiplemonomials, Same comment as before, could you please remove the new line?
Co-authored-by: Hugues Kamba <[email protected]>
Co-authored-by: Hugues Kamba <[email protected]>
Co-authored-by: Hugues Kamba <[email protected]>
…can be replaced with command line
f60f0a4
to
7b03aea
Compare
OK just rebased |
CI restarted |
Jenkins CI Test : ❌ FAILEDBuild Number: 4 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
CI was aborted. We had some issue with it, I'll restart today. |
CI started |
Jenkins CI Test : ✔️ SUCCESSBuild Number: 5 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
Summary of changes
The current CMake build system is a bit naive about executing memap. It just assumes that Python was found and that memap's dependencies (prettytable and intelhex) are installed. If this is not true, you'll get errors.
This PR adds a module I wrote a while ago, CheckPythonPackage.cmake, and uses it to verify that the correct python dependencies are installed. If they aren't, a warning will be printed and memap won't be run.
Broken out from #14010
Impact of changes
CMake will now work if the python dependencies are not installed instead of erroring.
Migration actions required
None needed.
Documentation
None needed.
Pull request type
Test results
Reviewers
@0xc0170