Merge pull request #2584 from martin-frbg/issue2583
[WIP] Have CMAKE parse conditional lines in KERNEL files
This commit is contained in:
commit
141998dce2
|
@ -15,10 +15,33 @@ endfunction ()
|
||||||
# Reads a Makefile into CMake vars.
|
# Reads a Makefile into CMake vars.
|
||||||
macro(ParseMakefileVars MAKEFILE_IN)
|
macro(ParseMakefileVars MAKEFILE_IN)
|
||||||
message(STATUS "Reading vars from ${MAKEFILE_IN}...")
|
message(STATUS "Reading vars from ${MAKEFILE_IN}...")
|
||||||
|
set (IfElse 0)
|
||||||
|
set (ElseSeen 0)
|
||||||
file(STRINGS ${MAKEFILE_IN} makefile_contents)
|
file(STRINGS ${MAKEFILE_IN} makefile_contents)
|
||||||
foreach (makefile_line ${makefile_contents})
|
foreach (makefile_line ${makefile_contents})
|
||||||
|
#message(STATUS "parsing ${makefile_line}")
|
||||||
|
if (${IfElse} GREATER 0)
|
||||||
|
string(REGEX MATCH "endif[ \t]*" line_match "${makefile_line}")
|
||||||
|
if (NOT "${line_match}" STREQUAL "")
|
||||||
|
# message(STATUS "ENDIF ${makefile_line}")
|
||||||
|
set (IfElse 0)
|
||||||
|
set (ElseSeen 0)
|
||||||
|
continue ()
|
||||||
|
endif ()
|
||||||
|
string(REGEX MATCH "else[ \t]*" line_match "${makefile_line}")
|
||||||
|
if (NOT "${line_match}" STREQUAL "")
|
||||||
|
# message(STATUS "ELSE ${makefile_line}")
|
||||||
|
set (ElseSeen 1)
|
||||||
|
continue ()
|
||||||
|
endif()
|
||||||
|
if ( (${IfElse} EQUAL 2 AND ${ElseSeen} EQUAL 0) OR ( ${IfElse} EQUAL 1 AND ${ElseSeen} EQUAL 1))
|
||||||
|
# message(STATUS "skipping ${makefile_line}")
|
||||||
|
continue ()
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
string(REGEX MATCH "([0-9_a-zA-Z]+)[ \t]*=[ \t]*(.+)$" line_match "${makefile_line}")
|
string(REGEX MATCH "([0-9_a-zA-Z]+)[ \t]*=[ \t]*(.+)$" line_match "${makefile_line}")
|
||||||
if (NOT "${line_match}" STREQUAL "")
|
if (NOT "${line_match}" STREQUAL "")
|
||||||
|
#message(STATUS "match on ${line_match}")
|
||||||
set(var_name ${CMAKE_MATCH_1})
|
set(var_name ${CMAKE_MATCH_1})
|
||||||
set(var_value ${CMAKE_MATCH_2})
|
set(var_value ${CMAKE_MATCH_2})
|
||||||
# check for Makefile variables in the string, e.g. $(TSUFFIX)
|
# check for Makefile variables in the string, e.g. $(TSUFFIX)
|
||||||
|
@ -33,7 +56,31 @@ macro(ParseMakefileVars MAKEFILE_IN)
|
||||||
else ()
|
else ()
|
||||||
string(REGEX MATCH "include \\$\\(KERNELDIR\\)/(.+)$" line_match "${makefile_line}")
|
string(REGEX MATCH "include \\$\\(KERNELDIR\\)/(.+)$" line_match "${makefile_line}")
|
||||||
if (NOT "${line_match}" STREQUAL "")
|
if (NOT "${line_match}" STREQUAL "")
|
||||||
|
#message(STATUS "match on include ${line_match}")
|
||||||
ParseMakefileVars(${KERNELDIR}/${CMAKE_MATCH_1})
|
ParseMakefileVars(${KERNELDIR}/${CMAKE_MATCH_1})
|
||||||
|
else ()
|
||||||
|
# message(STATUS "unmatched line ${line_match}")
|
||||||
|
string(REGEX MATCH "ifeq \\(\\$\\(([_A-Z]+)\\),[ \t]*([0-9_A-Z]+)\\)" line_match "${makefile_line}")
|
||||||
|
if (NOT "${line_match}" STREQUAL "")
|
||||||
|
# message(STATUS "IFEQ: ${line_match} first: ${CMAKE_MATCH_1} second: ${CMAKE_MATCH_2}")
|
||||||
|
if (${${CMAKE_MATCH_1}} STREQUAL ${CMAKE_MATCH_2})
|
||||||
|
# message (STATUS "condition is true")
|
||||||
|
set (IfElse 1)
|
||||||
|
else ()
|
||||||
|
set (IfElse 2)
|
||||||
|
endif ()
|
||||||
|
else ()
|
||||||
|
string(REGEX MATCH "ifneq \\(\\$\\(([_A-Z]+)\\),[ \t]*([0-9_A-Z]+)\\)" line_match "${makefile_line}")
|
||||||
|
if (NOT "${line_match}" STREQUAL "")
|
||||||
|
# message(STATUS "IFNEQ: ${line_match} first: ${CMAKE_MATCH_1} second: ${CMAKE_MATCH_2}")
|
||||||
|
if (NOT ( ${${CMAKE_MATCH_1}} STREQUAL ${CMAKE_MATCH_2}))
|
||||||
|
# message (STATUS "condition is true")
|
||||||
|
set (IfElse 1)
|
||||||
|
else ()
|
||||||
|
set (IfElse 2)
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
endforeach ()
|
endforeach ()
|
||||||
|
|
Loading…
Reference in New Issue