-
Notifications
You must be signed in to change notification settings - Fork 1.3k
tools: add a convert tool to help migrate from make to cmake #9782
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
base: master
Are you sure you want to change the base?
Conversation
@raiden00pl that is a great idea! In fact working on two build systems at same time it not easy, at least this script will help to simplify the process! |
@acassis That's right, using two build systems is a pain. I personally migrate all my NuttX based code to CMake now. I was a bit skeptical about CMake as I don't know it at all, but once it's upstream it's a good motivation to learn. After a few days of using it, I can confidently say that it is a positive change. Faster build and out-of-source builds convince me. The CMake syntax isn't even that disgusting once you get used to it for a while ;) |
I agree @raiden00pl !!! It will make NuttX integration easier! |
Thank you a lot for your contribution! Please let me share a few comments and minor concerns:
I am not sure if there any systems out there still mapping Of course, the latter syntax would not be acceptable for non-POSIX environments e.g.: MS Windows, although I am not sure whether these a supported target within this project. |
Coincidentally, the example provided above nuttx/arch/arm/src/stm32f0l0g0/Make.defs Line 21 in f43c7e9
The file referred to above seems to define another bunch of source files. However, |
Nit: similar tools, such as |
The included Makefile is handled elsewhere (https://github.com/apache/nuttx/blob/f43c7e99bedd8ea0cc2e3e6c2c796c38dbb8f354/arch/arm/src/cmake/armv7-m.cmake), so we can just ignore it.
I see that all .py files in |
content = content.replace("ifeq ($", "if") | ||
content = content.replace("ifneq ($(", "if(NOT ") | ||
content = content.replace("else", "else()") | ||
content = content.replace("endif", "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.
content = content.replace("else ifeq ($", "elseif")
content = content.replace("ifeq ($", "if")
content = content.replace("ifneq ($(", "if(NOT ")
added “else ifeq”
content = content.replace("else\n", "else()\n")
content = content.replace("endif\n", "endif()\n")
Need to add \n to not replace “else ifeq”
content = "" | ||
with open(mpath, "r") as fm: | ||
content = fm.read() | ||
content = content.replace(mpath, cpath) |
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.
On Windows, it does not replace the filename (Windows paths are different from Unix)
simple change
content = content.replace(mpath, cpath)
with
content = content.replace("src/Make.defs", "src/CMakeLists.txt")
content = "" | ||
with open(mdpath, "r") as fm: | ||
content = fm.read() | ||
content = content.replace(mdpath, cpath) |
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.
On Windows, it does not replace the filename (Windows paths are different from Unix)
simple change
content = content.replace(mpath, cpath)
with
content = content.replace("src/Make.defs", "src/CMakeLists.txt")
Summary
A simple tool that convert arch/board makefiles to cmake files. Tested with stm32, don't know if it'll work with other architectures.
It's a really dumb not finished tool that is not ready for upstream so I keep it as a draft.
Maybe someone will find it useful. The results usually require minor manual adjustments, but this makes the job much easier.
Usage:
python tools/nxmake2cmake.py arch/arm/src/stm32f0l0g0
python tools/nxmake2cmake.py boards/arm/stm32/nucleo-f302r8
Impact
Testing